|
@@ -0,0 +1,276 @@
|
|
|
+<template>
|
|
|
+ <div>
|
|
|
+ <div class="spacing">
|
|
|
+ <el-button size="small" type="primary" icon="el-icon-plus" @click="handlerModule('add')"> 新增一级模块 </el-button>
|
|
|
+ </div>
|
|
|
+ <el-table
|
|
|
+ ref="moduleTable"
|
|
|
+ :data="moduleData"
|
|
|
+ style="width: 100%;margin-bottom: 20px;"
|
|
|
+ row-key="id"
|
|
|
+ border
|
|
|
+ :tree-props="{children: 'childModules', hasChildren: 'hasChildren'}"
|
|
|
+ header-align="center"
|
|
|
+ size="mini"
|
|
|
+ :header-cell-style="{ background: '#F2F3F6' }"
|
|
|
+ fit
|
|
|
+ >
|
|
|
+ <el-table-column v-if="false" prop="id" label="ID" width="180" align="center" />
|
|
|
+ <el-table-column prop="moduleName" label="模块名称" />
|
|
|
+ <el-table-column prop="creator" label="创建人" width="150" align="center" />
|
|
|
+ <el-table-column prop="createTime" label="创建时间" width="150" align="center" />
|
|
|
+ <el-table-column label="操作" width="240" align="center">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-button size="mini" plain @click="handlerModule('add', scope.row, scope.$index)">添加</el-button>
|
|
|
+ <el-button size="mini" plain type="primary" @click="handlerModule('edit', scope.row, scope.$index)">编辑</el-button>
|
|
|
+ <el-button size="mini" plain type="danger" @click="handlerModule('delete', scope.row, scope.$index)">删除</el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ <normal-dialog :show-dialog="moduleDialog" :title="moduleTitle" :width="'30%'" @confirm="confirmModule('moduleForm')" @cancel="moduleDialog=false">
|
|
|
+ <el-form ref="moduleForm" :model="moduleForm">
|
|
|
+ <template v-if="curcentModule === 'add'">
|
|
|
+ <el-form-item label="父模块:" :label-width="formLabelWidth">
|
|
|
+ <el-col :span="11">{{ curcentParent }}</el-col>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item
|
|
|
+ v-for="(moduleName, index) in moduleForm.moduleNames"
|
|
|
+ :key="index"
|
|
|
+ label="模块名称:"
|
|
|
+ :label-width="formLabelWidth"
|
|
|
+ :prop="'moduleNames.' + index"
|
|
|
+ :rules="[
|
|
|
+ { required: true, message: '请输入模块名称', trigger: 'blur' },
|
|
|
+ { min: 1, max: 20, message: '模块名称过长', trigger: 'blur' }
|
|
|
+ ]"
|
|
|
+ >
|
|
|
+ <el-col :span="20">
|
|
|
+ <el-input v-model="moduleForm.moduleNames[index]" autocomplete="off" placeholder="不超过20个字符" />
|
|
|
+ </el-col>
|
|
|
+ <el-col v-show="index === moduleForm.moduleNames.length-1" :span="2" :offset="1">
|
|
|
+ <i class="el-icon-circle-plus-outline" @click="addModuleForm()" />
|
|
|
+ </el-col>
|
|
|
+ </el-form-item>
|
|
|
+ </template>
|
|
|
+ <template v-if="curcentModule === 'edit'">
|
|
|
+ <el-form-item label="父模块:" :label-width="formLabelWidth">
|
|
|
+ <el-col :span="11">{{ curcentParent }}</el-col>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="模块名称:" :label-width="formLabelWidth">
|
|
|
+ <el-col :span="20">
|
|
|
+ <el-input v-model="moduleForm.moduleNames[0]" autocomplete="off" placeholder="不超过20个字符" />
|
|
|
+ </el-col>
|
|
|
+ </el-form-item>
|
|
|
+ </template>
|
|
|
+ <el-col v-if="curcentModule === 'delete'" :span="11">
|
|
|
+ 是否要删除模块:<span style="color: #E6A23C">{{ moduleForm.moduleNames[0] }}</span>
|
|
|
+ </el-col>
|
|
|
+ </el-form>
|
|
|
+ </normal-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { mapGetters } from 'vuex'
|
|
|
+import { queryBizModuleList, updateBizModule, deleteBizModule, addModule } from '@/api/configure'
|
|
|
+import normalDialog from '@/components/dialog/normalDialog'
|
|
|
+export default {
|
|
|
+ components: {
|
|
|
+ normalDialog
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ userInformation: localStorage.getItem('username'),
|
|
|
+ dialogFormVisible: false,
|
|
|
+ dialogFormVisibleQuery: false,
|
|
|
+ activeName: 'second',
|
|
|
+ title_name: '',
|
|
|
+ currentPage1: 1,
|
|
|
+ gridData: [],
|
|
|
+ arr_team: [],
|
|
|
+ rules: {
|
|
|
+ teamName: [{ required: true, message: '团队名称不能为空', trigger: 'change' }, { max: 20, message: '团队名称,不得超过20个汉字', trigger: 'blur' }],
|
|
|
+ teamAttribute: [{ required: true, message: '团队属性不能为空', trigger: 'change' }],
|
|
|
+ dates: [{ required: true, message: '团队成员不能为空', trigger: ['blur', 'change'] }]
|
|
|
+ },
|
|
|
+ teamRoleEnum: [],
|
|
|
+ teamMemberRelateInfos: [],
|
|
|
+ form: {},
|
|
|
+ tableData: [],
|
|
|
+ table_Data: [],
|
|
|
+ options: [],
|
|
|
+ lerader: [],
|
|
|
+ tates: [],
|
|
|
+ depid: [],
|
|
|
+ loading: false,
|
|
|
+ test: {},
|
|
|
+ arry: [],
|
|
|
+ arr: [],
|
|
|
+ total: 0,
|
|
|
+ total1: 0,
|
|
|
+ curIndex: 1,
|
|
|
+ pageSize: 15,
|
|
|
+ activeIndex: '0',
|
|
|
+ businessCode: '0',
|
|
|
+ isAdmin: false, // 是否管理员
|
|
|
+ treeData: [],
|
|
|
+ curcentTreeData: { id: null, label: null },
|
|
|
+ showDialog: false,
|
|
|
+ dialogTitle: '', // 对话框title
|
|
|
+ curcentDialog: '', // 当前业务线窗口的类型
|
|
|
+ nodeForm: { id: null, name: null }, // 添加节点form
|
|
|
+ formLabelWidth: '120px',
|
|
|
+ nodeRules: {
|
|
|
+ name: [
|
|
|
+ { required: true, message: '请输入业务线名称', trigger: 'blur' },
|
|
|
+ { min: 1, max: 10, message: '业务线名称过长', trigger: 'blur' }
|
|
|
+ ],
|
|
|
+ id: [
|
|
|
+ { required: true, message: 'id不能为空' },
|
|
|
+ { type: 'number', message: 'id必须为数字值' }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ moduleData: [], // 模块数据
|
|
|
+ moduleDialog: false, // 模块操作对话框
|
|
|
+ moduleTitle: '', // 模块对话框title
|
|
|
+ curcentModule: '', // 当前模块类型
|
|
|
+ curcentParent: '', // 当前模块父模块
|
|
|
+ curcentParentId: '', // 当前模块父模块ID
|
|
|
+ moduleForm: { bizId: null, moduleNames: [null], parentId: null, id: null }, // 添加模块form
|
|
|
+ teamType: 0 // 0 我的 1 团队
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ ...mapGetters(['bizId'])
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ bizId: {
|
|
|
+ handler(newV) {
|
|
|
+ if (newV === -1) return
|
|
|
+ this.getQueryBizModuleList()
|
|
|
+ },
|
|
|
+ immediate: true
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ async getQueryBizModuleList() { // 获取结构化模块列表
|
|
|
+ const res = await queryBizModuleList(this.bizId)
|
|
|
+ this.moduleData = this.handleData(res.data)
|
|
|
+ },
|
|
|
+ handleData(arr) {
|
|
|
+ if (arr.length === 0) return
|
|
|
+ const newArr = arr.filter(item => {
|
|
|
+ return item.isDelete !== 1
|
|
|
+ })
|
|
|
+ for (let i = 0; i < newArr.length; i++) {
|
|
|
+ newArr[i].childModules = this.handleData(newArr[i].childModules)
|
|
|
+ }
|
|
|
+ return newArr
|
|
|
+ },
|
|
|
+ addModuleForm() {
|
|
|
+ if (this.moduleForm.moduleNames.length <= 4) {
|
|
|
+ this.moduleForm.moduleNames.push(null)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ handlerModule(type, data, index) { // 模块处理
|
|
|
+ this.curcentModule = type
|
|
|
+ this.moduleForm = { bizId: null, moduleNames: [null], parentId: -1, id: null }// 初始化
|
|
|
+ this.curcentParent = '无'
|
|
|
+ this.moduleTitle = '新增模块'
|
|
|
+ if (data && type === 'add') {
|
|
|
+ this.moduleDialog = true
|
|
|
+ this.moduleTitle = '新增模块'
|
|
|
+ this.curcentParent = data.moduleName
|
|
|
+ this.moduleForm.parentId = data.id
|
|
|
+ } else if (data && type === 'edit') {
|
|
|
+ this.moduleDialog = true
|
|
|
+ this.moduleTitle = '编辑模块'
|
|
|
+ this.moduleForm.id = data.id
|
|
|
+ this.curcentParent = data.parentId === -1 ? '无' : data.parentModuleName
|
|
|
+ this.moduleForm.parentId = data.parentId
|
|
|
+ this.moduleForm.moduleNames[0] = data.moduleName
|
|
|
+ } else if (data && type === 'delete') {
|
|
|
+ if (data.childModules && data.childModules.length > 0) {
|
|
|
+ this.$message({ message: '该模块下存在子模块,不允许删除', type: 'error' })
|
|
|
+ } else {
|
|
|
+ this.moduleDialog = true
|
|
|
+ this.moduleTitle = '删除确认'
|
|
|
+ this.moduleForm.id = data.id
|
|
|
+ this.moduleForm.moduleNames[0] = data.moduleName
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.moduleDialog = true
|
|
|
+ }
|
|
|
+ },
|
|
|
+ confirmModule(formName) { // 模块操作确认
|
|
|
+ if (this.curcentModule === 'add') {
|
|
|
+ this.$refs[formName].validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ this.addModule(this.moduleForm)
|
|
|
+ } else {
|
|
|
+ this.$message({ message: '填写格式不正确', type: 'error' })
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else if (this.curcentModule === 'edit') {
|
|
|
+ this.$refs[formName].validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ this.updataModule(this.moduleForm)
|
|
|
+ } else {
|
|
|
+ this.$message({ message: '填写格式不正确', type: 'error' })
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else if (this.curcentModule === 'delete') {
|
|
|
+ this.deleteModule(this.moduleForm)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async addModule(moduleForm) { // 添加模块
|
|
|
+ const form = {
|
|
|
+ bizId: this.bizId,
|
|
|
+ moduleNames: moduleForm.moduleNames,
|
|
|
+ parentId: moduleForm.parentId || -1
|
|
|
+ }
|
|
|
+ const res = await addModule(form)
|
|
|
+ if (res.code === 200) {
|
|
|
+ this.$message({ message: '添加成功', type: 'success' })
|
|
|
+ this.getQueryBizModuleList(this.bizId)// 重新获取模块列表
|
|
|
+ this.moduleDialog = false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async updataModule(moduleForm) { // 更新模块
|
|
|
+ const form = {
|
|
|
+ id: moduleForm.id,
|
|
|
+ bizId: this.bizId,
|
|
|
+ moduleName: moduleForm.moduleNames[0],
|
|
|
+ parentId: moduleForm.parentId || -1
|
|
|
+ }
|
|
|
+ const res = await updateBizModule(form)
|
|
|
+ if (res.code === 200) {
|
|
|
+ this.$message({ message: '更新成功', type: 'success' })
|
|
|
+ this.getQueryBizModuleList(this.bizId)// 重新获取模块列表
|
|
|
+ this.moduleDialog = false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async deleteModule(moduleForm) { // 删除模块
|
|
|
+ const form = {
|
|
|
+ id: moduleForm.id
|
|
|
+ }
|
|
|
+ const res = await deleteBizModule(form)
|
|
|
+ if (res.code === 200) {
|
|
|
+ this.$message({ message: '删除成功', type: 'success' })
|
|
|
+ this.moduleData = []// 初始化
|
|
|
+ this.getQueryBizModuleList(this.bizId)// 重新获取模块列表
|
|
|
+ this.moduleDialog = false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+.spacing {
|
|
|
+ margin: 0 0 20px;
|
|
|
+ text-align: right;
|
|
|
+}
|
|
|
+</style>
|