|
@@ -0,0 +1,127 @@
|
|
|
+<template>
|
|
|
+ <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="模块名称">
|
|
|
+ <template slot="header">
|
|
|
+ 模块名称<i class="el-icon-circle-plus" @click="handlerModule('add')" />
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <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>
|
|
|
+ <el-dialog :title="moduleTitle" :visible.sync="moduleDialog" width="30%" :before-close="() => {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="11">
|
|
|
+ <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="11">
|
|
|
+ <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>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+export default {
|
|
|
+ props: {
|
|
|
+ data: { type: Array, default: null }
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ moduleData: this.data,
|
|
|
+ moduleDialog: false,
|
|
|
+ formLabelWidth: '120px',
|
|
|
+ curcentModule: '', // 当前模块类型
|
|
|
+ moduleForm: { bizId: null, moduleNames: [null], parentId: null, id: null }, // 添加模块form
|
|
|
+ moduleTitle: ''
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ 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
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style>
|
|
|
+
|
|
|
+</style>
|