| | |
| | | <el-container> |
| | | <el-aside> |
| | | <basic-container> |
| | | <div style="max-height: calc(100vh - 170px);overflow: auto"> |
| | | <avue-tree :key="refresh" ref="tree" :data="treeData" :option="treeOption" @node-click="nodeClick"> |
| | | <div style="max-height: calc(100vh - 150px);overflow: auto"> |
| | | <avue-tree :key="refresh" ref="tree" :data="treeData" :option="treeOption" node-key="id" |
| | | @node-click="nodeClick"> |
| | | <span slot-scope="{ node, data }" class="el-tree-node__label"> |
| | | <span style="font-size: 15px"> |
| | | <i class="el-icon-s-promotion"></i> |
| | | <span style="display: flex"> |
| | | <icon-show :name="data.icon"></icon-show> |
| | | {{ (node || {}).label }} |
| | | </span> |
| | | </span> |
| | |
| | | |
| | | <el-main> |
| | | <basic-container> |
| | | <el-form ref="form" :model="form" label-width="85px" style="height: 79vh"> |
| | | <el-form-item label="名称:"> |
| | | <el-input v-model="form.name" placeholder="请输入名称"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="标识:"> |
| | | <el-input v-model="form.code" placeholder="请输入标识"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="别名:"> |
| | | <el-input v-model="form.alias" placeholder="请输入别名"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="顺序:"> |
| | | <el-input-number v-model="form.sort" :min="0" :max="9999" label="顺序"></el-input-number> |
| | | </el-form-item> |
| | | <el-form-item label="描述:"> |
| | | <el-input v-model="form.remark" placeholder="请输入描述"></el-input> |
| | | </el-form-item> |
| | | </el-form> |
| | | <div v-if="nodeRow.childType === 0 || nodeRow.childType === -1" class="btnBox"> |
| | | <el-button v-if="!addStatus" :disabled="nodeRow.childType === 0" icon="el-icon-plus" plain |
| | | <el-button v-if="!addStatus && !editStatus" :disabled="nodeRow.childType === 0" icon="el-icon-plus" plain |
| | | size="small" |
| | | type="primary" @click="addClickHandler">增加 |
| | | </el-button> |
| | | <el-button v-if="addStatus" icon="el-icon-check" plain size="small" |
| | | type="success" @click="addSaveClickHandler">保存 |
| | | </el-button> |
| | | <el-button v-if="!editStatus" :disabled="nodeRow.childType === -1" icon="el-icon-edit" plain size="small" type="primary" |
| | | <el-button v-if="!addStatus && !editStatus" :disabled="nodeRow.childType === -1" icon="el-icon-edit" plain |
| | | size="small" type="primary" |
| | | @click="editClickHandler">修改 |
| | | </el-button> |
| | | <el-button v-if="editStatus" icon="el-icon-check" plain size="small" |
| | | type="success" @click="editSaveClickHandler">保存 |
| | | </el-button> |
| | | <el-button :disabled="nodeRow.childType === -1" icon="el-icon-close" plain size="small" type="danger" |
| | | <el-button v-if="addStatus || editStatus" icon="el-icon-close" plain size="small" |
| | | type="danger" @click="addStatus=false;editStatus=false;">取消 |
| | | </el-button> |
| | | <el-button v-if="!addStatus && !editStatus" :disabled="nodeRow.childType === -1" icon="el-icon-close" plain |
| | | size="small" type="danger" |
| | | @click="delClickHandler">删除 |
| | | </el-button> |
| | | <el-button icon="el-icon-upload2" plain size="small" type="primary" @click="sqlClickExportClick">导出sql |
| | | <el-button v-if="!addStatus && !editStatus" icon="el-icon-upload2" plain size="small" type="primary" |
| | | @click="sqlClickExportClick">导出sql |
| | | </el-button> |
| | | </div> |
| | | <el-form ref="form" :model="form" label-width="85px" style="max-height: calc(100vh - 180px);overflow: auto;"> |
| | | <el-form-item label="名称:"> |
| | | <el-input v-model="form.name" :disabled="!editStatus && !addStatus" placeholder="请输入名称"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="标识:"> |
| | | <el-input v-model.trim="form.code" :disabled="!editStatus && !addStatus" placeholder="请输入标识"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="别名:"> |
| | | <el-input v-model="form.alias" :disabled="!editStatus && !addStatus" placeholder="请输入别名"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="图标:"> |
| | | <input-icon v-model="form.source" :disabled="!editStatus && !addStatus" placeholder="请选择图标"> |
| | | </input-icon> |
| | | </el-form-item> |
| | | <el-form-item label="顺序:"> |
| | | <el-input-number v-model="form.sort" :disabled="!editStatus && !addStatus" :max="9999" :min="0" |
| | | label="顺序"></el-input-number> |
| | | </el-form-item> |
| | | <el-form-item label="描述:"> |
| | | <el-input v-model="form.remark" :disabled="!editStatus && !addStatus" placeholder="请输入描述"></el-input> |
| | | </el-form-item> |
| | | </el-form> |
| | | </basic-container> |
| | | </el-main> |
| | | </el-container> |
| | |
| | | <script> |
| | | //管理功能模块 |
| | | import {exportFunctionSql, getSysModelTreeMenuByPID} from "@/api/systemModel/mangeModel/api" |
| | | import {addOperationType,updateOperationType,delOperationType} from "@/api/systemModel/operateType/api" |
| | | import {addOperationType, updateOperationType, delOperationType} from "@/api/systemModel/operateType/api" |
| | | import func from "@/util/func"; |
| | | |
| | | export default { |
| | | name: "index", |
| | | data() { |
| | | return { |
| | | refresh:Math.random(), |
| | | editStatus:false, |
| | | refresh: Math.random(), |
| | | editStatus: false, |
| | | addStatus: false, |
| | | nodeRow: {}, |
| | | currentClickNode: {}, |
| | | form: {}, |
| | | treeData: [], |
| | | treeOption: { |
| | |
| | | ...item, |
| | | id: item.id, |
| | | name: item.name, |
| | | leaf: !item.hasChildren |
| | | leaf: !item.hasChildren, |
| | | icon: item.source || 'iconoir:home' |
| | | } |
| | | })) |
| | | }) |
| | |
| | | }, |
| | | created() { |
| | | }, |
| | | computed: { |
| | | }, |
| | | computed: {}, |
| | | methods: { |
| | | // 树行点击 |
| | | nodeClick(row) { |
| | | console.log(row); |
| | | nodeClick(row, node) { |
| | | this.form = {...row}; |
| | | this.nodeRow = {...row}; |
| | | this.currentClickNode = node; |
| | | this.addStatus = false; |
| | | this.editStatus = false; |
| | | }, |
| | |
| | | } |
| | | this.form.parentId = this.nodeRow.id; |
| | | const params = { |
| | | name:this.form.name, |
| | | identify:this.form.code, |
| | | alias:this.form.alias, |
| | | desc:this.form.remark, |
| | | seq:this.form.sort |
| | | name: this.form.name, |
| | | identify: this.form.code, |
| | | alias: this.form.alias, |
| | | desc: this.form.remark, |
| | | seq: this.form.sort, |
| | | source: this.form.source, |
| | | } |
| | | addOperationType(params).then(res => { |
| | | if(res.data.code === 200){ |
| | | if (res.data.code === 200) { |
| | | this.$message.success(res.data.msg); |
| | | this.refresh = Math.random(); // 刷新左侧树 |
| | | this.handleRefreshTree('add'); |
| | | this.addStatus = false; |
| | | } |
| | | }) |
| | | }, |
| | | |
| | | // 修改按钮 |
| | | editClickHandler(){ |
| | | editClickHandler() { |
| | | this.addStatus = false; |
| | | this.editStatus = true; |
| | | }, |
| | | |
| | | // 修改保存 |
| | | editSaveClickHandler(){ |
| | | editSaveClickHandler() { |
| | | console.log(this.form); |
| | | if (!this.form.name) { |
| | | this.$message.error('名称不能为空'); |
| | |
| | | this.$message.error('别名不能为空'); |
| | | return |
| | | } |
| | | if (!this.form.sort) { |
| | | if (this.form.sort == null || this.form.sort === '' || this.form.sort === undefined) { |
| | | this.$message.error('顺序不能为空'); |
| | | return |
| | | return; |
| | | } |
| | | if (this.form.name.length > 128) { |
| | | this.$message.error('名称长度不能超过128!'); |
| | |
| | | if (this.form.alias && this.form.alias.length > 255) { |
| | | this.$message.error('别名长度不能超过255!'); |
| | | return |
| | | }; |
| | | } |
| | | |
| | | const params = { |
| | | id:this.form.id, |
| | | name:this.form.name, |
| | | identify:this.form.code, |
| | | alias:this.form.alias, |
| | | desc:this.form.remark, |
| | | seq:this.form.sort |
| | | id: this.form.id, |
| | | name: this.form.name, |
| | | identify: this.form.code, |
| | | alias: this.form.alias, |
| | | desc: this.form.remark, |
| | | seq: this.form.sort, |
| | | source: this.form.source, |
| | | } |
| | | updateOperationType(params).then(res => { |
| | | if(res.data.code === 200){ |
| | | if (res.data.code === 200) { |
| | | this.$message.success(res.data.msg); |
| | | this.refresh = Math.random(); // 刷新左侧树 |
| | | this.handleRefreshTree('edit'); |
| | | this.editStatus = false; |
| | | } |
| | | }) |
| | | }, |
| | | |
| | | // 删除 |
| | | delClickHandler(){ |
| | | delClickHandler() { |
| | | this.$confirm('您确定要删除所选择的数据吗?', '提示', { |
| | | confirmButtonText: '确定', |
| | | cancelButtonText: '取消', |
| | |
| | | delOperationType(this.form).then(res => { |
| | | if (res.data.code === 200) { |
| | | this.$message.success(res.data.msg); |
| | | this.resetFormValue(); |
| | | this.handleRefreshTree('del') |
| | | this.addStatus = false; |
| | | this.editStatus = false; |
| | | this.nodeRow = {}; |
| | |
| | | exportFunctionSql({isFunction: false}).then(res => { |
| | | func.downloadFileByBlobHandler(res); |
| | | this.$message.success('导出成功'); |
| | | }).catch(err => { |
| | | this.$message.error(err); |
| | | }); |
| | | }, |
| | | handleRefreshTree(type) { |
| | | //type:add\edit\del |
| | | if (type == "del") { |
| | | this.$refs.tree.remove(this.currentClickNode); |
| | | this.currentClickNode = null; |
| | | this.form = {}; |
| | | } else { |
| | | if (this.currentClickNode) { |
| | | let node = this.currentClickNode.parent; |
| | | node.loaded = false; |
| | | node.expand(); |
| | | if (type === 'edit') { |
| | | this.$refs.tree.setCurrentKey(null); |
| | | } else { |
| | | this.$refs.tree.setCurrentNode(this.nodeRow); |
| | | } |
| | | } else { |
| | | this.refresh = Math.random(); // 刷新左侧树 |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | |
| | | |
| | | .btnBox { |
| | | display: flex; |
| | | justify-content: center; |
| | | justify-content: left; |
| | | margin-bottom: 15px; |
| | | } |
| | | </style> |