From e4714d079331ffd42b411695d27389a6887f8260 Mon Sep 17 00:00:00 2001 From: lyh <925863403@qq.com> Date: 星期五, 17 一月 2025 09:07:37 +0800 Subject: [PATCH] DNC部门管理页面 --- src/views/system/DncDepartmentList.vue | 2 src/views/system/modules/DepartMentAuthModal.vue | 200 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 201 insertions(+), 1 deletions(-) diff --git a/src/views/system/DncDepartmentList.vue b/src/views/system/DncDepartmentList.vue index 8d36317..e9cc243 100644 --- a/src/views/system/DncDepartmentList.vue +++ b/src/views/system/DncDepartmentList.vue @@ -7,7 +7,7 @@ <a-row style="margin-left: 14px"> <a-button @click="handleAdd(1)" type="primary">娣诲姞閮ㄩ棬</a-button> <a-button @click="handleAdd(2)" type="primary">娣诲姞涓嬬骇</a-button> - <a-button title="鍒犻櫎澶氭潯鏁版嵁" @click="batchDel" type="default">鎵归噺鍒犻櫎</a-button> +<!-- <a-button title="鍒犻櫎澶氭潯鏁版嵁" @click="batchDel" type="default">鎵归噺鍒犻櫎</a-button>--> <!--<a-button @click="refresh" type="default" icon="reload" :loading="loading">鍒锋柊</a-button>--> </a-row> <div style="background: #fff;padding-left:16px;height: 100%; margin-top: 5px"> diff --git a/src/views/system/modules/DepartMentAuthModal.vue b/src/views/system/modules/DepartMentAuthModal.vue new file mode 100644 index 0000000..d629a37 --- /dev/null +++ b/src/views/system/modules/DepartMentAuthModal.vue @@ -0,0 +1,200 @@ +<template> + <a-card :bordered="false"> + <template v-if="this.departId"> + <a-spin :spinning="loading"> + <a-form> + <a-form-item label='鎵�鎷ユ湁鐨勬潈闄�'> + <a-tree + checkable + @check="onCheck" + :checkedKeys="checkedKeys" + :treeData="treeData" + @expand="onExpand" + @select="onTreeNodeSelect" + :selectedKeys="selectedKeys" + :expandedKeys="expandedKeysss" + :checkStrictly="checkStrictly" + style="height:500px;overflow: auto;"> + <span slot="hasDatarule" slot-scope="{slotTitle,ruleFlag}"> + {{ slotTitle }} + <a-icon v-if="ruleFlag" type="align-left" style="margin-left:5px;color: red;"></a-icon> + </span> + </a-tree> + </a-form-item> + </a-form> + </a-spin> + <div class="anty-form-btn"> + <a-dropdown style="float: left" :trigger="['click']" placement="topCenter"> + <a-menu slot="overlay"> + <!-- 绠�鍖朤ree閫昏緫锛屼娇鐢ㄩ粯璁heckStrictly涓篺alse鐨勮涓猴紝鍗抽粯璁ょ埗瀛愬叧鑱� + <a-menu-item key="1" @click="switchCheckStrictly(1)">鐖跺瓙鍏宠仈</a-menu-item> + <a-menu-item key="2" @click="switchCheckStrictly(2)">鍙栨秷鍏宠仈</a-menu-item> + --> + <a-menu-item key="3" @click="checkALL">鍏ㄩ儴鍕鹃��</a-menu-item> + <a-menu-item key="4" @click="cancelCheckALL">鍙栨秷鍏ㄩ��</a-menu-item> + <a-menu-item key="5" @click="expandAll">灞曞紑鎵�鏈�</a-menu-item> + <a-menu-item key="6" @click="closeAll">鍚堝苟鎵�鏈�</a-menu-item> + </a-menu> + <a-button> + 鏍戞搷浣� <a-icon type="up" /> + </a-button> + </a-dropdown> + <a-button style="float: right" @click="handleSubmit" type="primary" htmlType="button" icon="form">淇濆瓨</a-button> + </div> + </template> + <a-card v-else :bordered="false" style="height:200px"> + <a-empty> + <span slot="description"> 璇峰厛閫夋嫨涓�涓儴闂�! </span> + </a-empty> + </a-card> + <depart-datarule-modal ref="datarule"/> + </a-card> +</template> + +<script> + import {queryTreeListForRole,queryDepartPermission,saveDepartPermission} from '@/api/api' + import DepartDataruleModal from './DepartDataruleModal' + + export default { + name: 'DepartAuthModal', + components: { DepartDataruleModal }, + data(){ + return { + departId:"", + treeData: [], + defaultCheckedKeys:[], + checkedKeys:[], + halfCheckedKeys:[], + expandedKeysss:[], + allTreeKeys:[], + autoExpandParent: true, + checkStrictly: false, + title:"閮ㄩ棬鏉冮檺閰嶇疆", + visible: false, + loading: false, + selectedKeys:[] + } + }, + methods: { + onTreeNodeSelect(id){ + if(id && id.length>0){ + this.selectedKeys = id + } + this.$refs.datarule.show(this.selectedKeys[0],this.departId) + }, + onCheck (checkedKeys, { halfCheckedKeys }) { + // 淇濆瓨閫変腑鐨勫拰鍗婇�変腑鐨勶紝鍚庨潰淇濆瓨鐨勬椂鍊欏悎骞舵彁浜� + this.checkedKeys = checkedKeys + this.halfCheckedKeys = halfCheckedKeys + }, + show(departId){ + this.departId=departId + this.loadData(); + }, + close () { + this.reset() + this.$emit('close'); + this.visible = false; + }, + onExpand(expandedKeys){ + this.expandedKeysss = expandedKeys; + this.autoExpandParent = false + }, + reset () { + this.expandedKeysss = [] + this.checkedKeys = [] + this.defaultCheckedKeys = [] + this.loading = false + }, + expandAll () { + this.expandedKeysss = this.allTreeKeys + }, + closeAll () { + this.expandedKeysss = [] + }, + checkALL () { + this.checkedKeys = this.allTreeKeys + }, + cancelCheckALL () { + this.checkedKeys = [] + }, + handleCancel () { + this.close() + }, + handleSubmit() { + let that = this; + if(!that.departId){ + this.$message.warning('璇风偣鍑婚�夋嫨涓�涓儴闂�!') + } + let checkedKeys = [...that.checkedKeys, ...that.halfCheckedKeys] + const permissionIds = checkedKeys.join(",") + let params = { + departId:that.departId, + permissionIds, + lastpermissionIds:that.defaultCheckedKeys.join(","), + }; + that.loading = true; + saveDepartPermission(params).then((res)=>{ + if(res.success){ + // that.$message.success(res.message); + that.$notification.warning({ + message:'娑堟伅', + description:res.message + }); + that.loading = false; + that.loadData(); + }else { + // that.$message.error(res.message); + that.$notification.warning({ + message:'娑堟伅', + description:res.message + }); + that.loading = false; + } + }) + }, + convertTreeListToKeyLeafPairs(treeList, keyLeafPair = []) { + for(const {key, isLeaf, children} of treeList) { + keyLeafPair.push({key, isLeaf}) + if(children && children.length > 0) { + this.convertTreeListToKeyLeafPairs(children, keyLeafPair) + } + } + return keyLeafPair; + }, + emptyCurrForm() { + this.form.resetFields() + }, + loadData(){ + this.loading = true; + queryTreeListForRole().then((res) => { + this.treeData = res.result.treeList + this.allTreeKeys = res.result.ids + const keyLeafPairs = this.convertTreeListToKeyLeafPairs(this.treeData) + queryDepartPermission({departId:this.departId}).then((res)=>{ + // 杩囨护鍑� leaf node 鍗冲彲锛屽嵆閫変腑鐨� + // Tree缁勪欢涓璫heckStrictly榛樿涓篺alse鐨勬椂鍊欙紝閫変腑瀛愯妭鐐癸紝鐖惰妭鐐逛細鑷姩璁剧疆閫変腑鎴栧崐閫変腑 + // 淇濆瓨 checkedKeys 浠ュ強 halfCheckedKeys 浠ヤ究浜庢湭鍋氫换浣曟搷浣滄椂鎻愪氦琛ㄥ崟鏁版嵁 + const checkedKeys = [...res.result].filter(key => { + const keyLeafPair = keyLeafPairs.filter(item => item.key === key)[0] + return keyLeafPair && keyLeafPair.isLeaf + }) + const halfCheckedKeys = [...res.result].filter(key => { + const keyLeafPair = keyLeafPairs.filter(item => item.key === key)[0] + return keyLeafPair && !keyLeafPair.isLeaf + }) + this.checkedKeys = [...checkedKeys]; + this.halfCheckedKeys = [...halfCheckedKeys] + this.defaultCheckedKeys = [...halfCheckedKeys, ...checkedKeys]; + this.expandedKeysss = this.allTreeKeys; + this.loading = false; + }) + }) + } + }, + } +</script> + +<style scoped> + +</style> \ No newline at end of file -- Gitblit v1.9.3