From 9ce29c536ba2a636416c618761985e2b9a711ee6 Mon Sep 17 00:00:00 2001 From: lxl <lixuliang_hd@126.com> Date: 星期四, 27 十月 2022 14:17:45 +0800 Subject: [PATCH] user --- src/views/userManage/orgManage.vue | 155 ++++++++++++++++++++++++++++++--------------------- 1 files changed, 92 insertions(+), 63 deletions(-) diff --git a/src/views/userManage/orgManage.vue b/src/views/userManage/orgManage.vue index cb25cb4..ff052ca 100644 --- a/src/views/userManage/orgManage.vue +++ b/src/views/userManage/orgManage.vue @@ -23,6 +23,7 @@ <span>{{ node.label }}</span> <span class="btnBox"> <el-button + v-if="menuStatus.insert" type="text" size="mini" @click="() => append(node, data)" @@ -30,6 +31,7 @@ <i class="el-icon-circle-plus"></i> </el-button> <el-button + v-if="menuStatus.delete" type="text" size="mini" @click="() => remove(node, data)" @@ -86,7 +88,7 @@ <el-form-item label="澶囨敞" :label-width="formLabelWidth"> <el-input v-model="itemdetail.bak" autocomplete="off"></el-input> </el-form-item> - <div class="btnBox"> + <div class="btnBox" v-if="menuStatus.update"> <el-button type="primary" @click="updDep('itemdetail')" >淇濆瓨</el-button > @@ -152,7 +154,7 @@ </template> <script> -import MyBread from "../../components/MyBread.vue"; +import MyBread from '../../components/MyBread.vue'; import { queryDepTree, updateDepTree, @@ -160,7 +162,7 @@ queryMaxId, insertDep, deleteDep, -} from "../../api/api"; +} from '../../api/api'; export default { //import寮曞叆鐨勭粍浠堕渶瑕佹敞鍏ュ埌瀵硅薄涓墠鑳戒娇鐢� components: { @@ -168,16 +170,21 @@ }, data() { let validName = (rule, value, callback) => { - if (value === "" || value === null || value === undefined) { - return callback(new Error("鍚嶇О涓嶈兘涓虹┖")); + if (value === '' || value === null || value === undefined) { + return callback(new Error('鍚嶇О涓嶈兘涓虹┖')); } else { callback(); } }; return { + menuStatus: { + delete: false, + insert: false, + update: false, + }, defaultProps: { - children: "children", - label: "name", + children: 'children', + label: 'name', }, fullscreenLoading: false, oriData: [], //鍘熷鏍戞暟鎹� @@ -185,41 +192,41 @@ old_depData: [], //el鏍戞暟鎹�(鎷栧姩鍓�) newData: [], //鎷栧姩鍚庡師濮嬫暟鎹� itemdetail: { - addr: "", - bak: "", - code: "", - contact: "", - email: "", - fax: "", - name: "", - post: "", - sname: "", - uncode: "", - website: "", + addr: '', + bak: '', + code: '', + contact: '', + email: '', + fax: '', + name: '', + post: '', + sname: '', + uncode: '', + website: '', }, - backUpData: "", - formLabelWidth: "130px", - delChildID: "", + backUpData: '', + formLabelWidth: '130px', + delChildID: '', delChildIDs: [], dialogFormVisible: false, ruleForm: { level: null, orderNum: null, pid: null, - addr: "", - bak: "", - code: "", - contact: "", - email: "", - fax: "", - name: "", - post: "", - sname: "", - uncode: "", - website: "", + addr: '', + bak: '', + code: '', + contact: '', + email: '', + fax: '', + name: '', + post: '', + sname: '', + uncode: '', + website: '', }, rules: { - name: [{ required: true, validator: validName, trigger: "blur" }], + name: [{ required: true, validator: validName, trigger: 'blur' }], }, }; }, @@ -237,7 +244,7 @@ } else { this.$notify.error({ title: res.code, - message: "鏃犳硶鑾峰彇鍗曚綅鍒楄〃", + message: '鏃犳硶鑾峰彇鍗曚綅鍒楄〃', }); } }); @@ -247,7 +254,7 @@ return cloneData.filter((father) => { // 寰幆鎵�鏈夐」 let branchArr = cloneData.filter((child) => father.id == child.pid); // 瀵规瘮ID锛屽垎鍒笂涓嬬骇鑿滃崟锛屽苟杩斿洖鏁版嵁 - branchArr.length > 0 ? (father.children = branchArr) : ""; // 缁欑埗绾ф坊鍔犱竴涓猚hildren灞炴�э紝骞惰祴鍊� + branchArr.length > 0 ? (father.children = branchArr) : ''; // 缁欑埗绾ф坊鍔犱竴涓猚hildren灞炴�э紝骞惰祴鍊� return father.pid == 0; // 杩斿洖涓�绾ц彍鍗� }); }, @@ -277,8 +284,8 @@ this.fullscreenLoading = false; if (res.code == 200) { this.$message({ - message: "娣诲姞鎴愬姛", - type: "success", + message: '娣诲姞鎴愬姛', + type: 'success', }); this.getMenuTree(); this.itemdetail = {}; @@ -290,7 +297,7 @@ }) .catch((res) => { this.itemdetail = {}; - this.$message.error("娣诲姞澶辫触"); + this.$message.error('娣诲姞澶辫触'); this.fullscreenLoading = false; console.log(res); }); @@ -301,10 +308,10 @@ }); }, remove(node, data) { - this.$confirm("姝ゆ搷浣滃皢鍒犻櫎璇ヨ妭鐐�, 鏄惁缁х画?", "鎻愮ず", { - confirmButtonText: "纭畾", - cancelButtonText: "鍙栨秷", - type: "warning", + this.$confirm('姝ゆ搷浣滃皢鍒犻櫎璇ヨ妭鐐�, 鏄惁缁х画?', '鎻愮ず', { + confirmButtonText: '纭畾', + cancelButtonText: '鍙栨秷', + type: 'warning', }) .then(() => { //鍏勫紵閲嶆柊鎺掑簭 @@ -326,24 +333,24 @@ console.log(res); if (res[0].code == 200 && res[1].code == 200) { this.$message({ - type: "success", - message: "鍒犻櫎鎴愬姛!", + type: 'success', + message: '鍒犻櫎鎴愬姛!', }); this.getMenuTree(); this.itemdetail = {}; } else if (res[0].code == 200) { this.getMenuTree(); - this.$message.error("鍒犻櫎鎴愬姛锛屼綅缃皟鏁村け璐�"); + this.$message.error('鍒犻櫎鎴愬姛锛屼綅缃皟鏁村け璐�'); } else if (res[1].code == 200) { this.getMenuTree(); - this.$message.error("鍒犻櫎澶辫触,浣嶇疆璋冩暣鎴愬姛"); + this.$message.error('鍒犻櫎澶辫触,浣嶇疆璋冩暣鎴愬姛'); } else { this.getMenuTree(); - this.$message.error("鍒犻櫎澶辫触"); + this.$message.error('鍒犻櫎澶辫触'); } }) .catch(() => { - this.$message.error("鍒犻櫎澶辫触"); + this.$message.error('鍒犻櫎澶辫触'); this.itemdetail = {}; }); @@ -351,7 +358,7 @@ this.delChildIDs = []; }) .catch(() => { - this.$message("宸插彇娑堝垹闄�"); + this.$message('宸插彇娑堝垹闄�'); }); // this.dialogMessage="鏄惁鍒犻櫎" // this.dialogFlag = 1; @@ -393,21 +400,21 @@ this.old_depData = JSON.parse(JSON.stringify(this.depList)); //灏嗗浠界殑dir閲嶆柊璧嬪�� }, handleDrop(draggingNode, dropNode, dropType, ev) { - this.$confirm("姝ゆ搷浣滃皢淇濆瓨鐩綍鏇存敼, 鏄惁缁х画?", "鎻愮ず", { - confirmButtonText: "纭畾", - cancelButtonText: "鍙栨秷", - type: "warning", + this.$confirm('姝ゆ搷浣滃皢淇濆瓨鐩綍鏇存敼, 鏄惁缁х画?', '鎻愮ず', { + confirmButtonText: '纭畾', + cancelButtonText: '鍙栨秷', + type: 'warning', }) .then(() => { //鐖惰妭鐐� - let data = dropType != "inner" ? dropNode.parent.data : dropNode.data; + let data = dropType != 'inner' ? dropNode.parent.data : dropNode.data; // 鐖惰妭鐐逛腑鍏ㄩ儴瀛愯妭鐐� let nodeData = - dropNode.level == 1 && dropType != "inner" ? data : data.children; + dropNode.level == 1 && dropType != 'inner' ? data : data.children; //鍙樻洿鑺傜偣 // console.log(nodeData); nodeData.forEach((item, i) => { - if (dropType != "inner") { + if (dropType != 'inner') { if (draggingNode.data.pid === dropNode.data.pid) { item.pid = item.pid; } else { @@ -432,8 +439,8 @@ }) .catch(() => { this.$message({ - type: "info", - message: "宸插彇娑堟洿鏀�", + type: 'info', + message: '宸插彇娑堟洿鏀�', }); this.depList = this.old_depData; //灏嗗浠界殑dir閲嶆柊璧嬪�� }); @@ -445,11 +452,11 @@ this.getMenuTree(); return; } else { - alert("璋冩暣澶辫触锛岃閲嶈瘯锛�"); + alert('璋冩暣澶辫触锛岃閲嶈瘯锛�'); } }) .catch(() => { - alert("淇敼澶辫触锛岃閲嶈瘯锛�"); + alert('淇敼澶辫触锛岃閲嶈瘯锛�'); }); }, handleNodeClick(data) { @@ -467,14 +474,14 @@ setTimeout(() => { this.fullscreenLoading = false; if (res.code == 200) { - this.getMenuTree() + this.getMenuTree(); this.itemdetail = {}; this.dialogFormVisible = false; } }, 500); }) .catch((res) => { - alert("淇敼澶辫触锛岃閲嶈瘯锛�"); + alert('淇敼澶辫触锛岃閲嶈瘯锛�'); this.fullscreenLoading = false; }); } else { @@ -485,14 +492,36 @@ }, reset() { this.$refs[formName].resetFields(); - if (this.backUpData != "") { + if (this.backUpData != '') { this.itemdetail = JSON.parse(this.backUpData); + } + }, + showPermsMenu(res) { + switch (res.tag) { + case '/delete': + this.menuStatus.delete = true; + break; + case '/insert': + this.menuStatus.insert = true; + break; + case '/update': + this.menuStatus.update = true; + break; } }, }, mounted() { this.getDepTree(); }, + created() { + var val = this.$store.state.currentPerms; + var permsEntity = this.$store.state.permsEntity; + for (var i = 0; i < permsEntity.length; i++) { + if (permsEntity[i].perms == val) { + this.showPermsMenu(permsEntity[i]); + } + } + }, }; </script> <style lang="less" scoped> -- Gitblit v1.9.3