From 4659799564fd6b85a7e59372c1827b1d1484c73c Mon Sep 17 00:00:00 2001 From: ludc Date: 星期二, 08 十月 2024 10:23:16 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- Source/plt-web/plt-web-ui/src/views/authority/ui/uiAuthorization/UIDialog.vue | 201 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 201 insertions(+), 0 deletions(-) diff --git a/Source/plt-web/plt-web-ui/src/views/authority/ui/uiAuthorization/UIDialog.vue b/Source/plt-web/plt-web-ui/src/views/authority/ui/uiAuthorization/UIDialog.vue new file mode 100644 index 0000000..4b92d8d --- /dev/null +++ b/Source/plt-web/plt-web-ui/src/views/authority/ui/uiAuthorization/UIDialog.vue @@ -0,0 +1,201 @@ +<template> + <el-dialog v-dialogDrag + :title="dialog.title" + :visible.sync="dialog.showDialog" + width="1000px" + :append-to-body="true" + class="avue-dialog" + :destroy-on-close="true" + :close-on-click-modal="false" + @close="cancelDialog"> + <el-container style="height: 550px"> + <el-aside> + <basic-container style="height: 500px"> + <avue-tree ref="tree" :data="treeData" :option="treeOption" @node-click="nodeClick"> + <span slot-scope="{ node, data }" class="el-tree-node__label"> + <span style="font-size: 15px"> + <i class="el-icon-user-solid"></i> + {{ (node || {}).label }} + </span> + </span> + </avue-tree> + </basic-container> + </el-aside> + + <el-main> + <basic-container style="height: 500px"> + <h3 style="margin: 0">妯″潡鏉冮檺閰嶇疆</h3> + <div style="height: 445px;"> + <avue-tree ref="uiTree" :data="uiTreeData" :option="uiTreeOption"> + <span slot-scope="{ node, data }" class="el-tree-node__label"> + <span style="font-size: 15px"> + <i :class="data.icon"></i> + {{ (node || {}).label }} + </span> + </span> + </avue-tree> + </div> + </basic-container> + </el-main> + </el-container> + <div class="dialog-footer avue-dialog__footer"> + <el-button type="primary" plain size="small" @click="submitDialog" >鎺堟潈</el-button> + <el-button type="primary" plain size="small" @click="clearValue" >閲嶇疆</el-button> + <el-button size="small" @click="cancelDialog">鍙� 娑�</el-button> + </div> + </el-dialog> +</template> + +<script> +import {gridRoles} from '@/api/system/role/api' +import {getUIAuthor,authorizedUI} from "@/api/authority/ui/uiAuthor"; + +export default { +name: "UIDialog", + data() { + return { + dialog: { + showDialog: false, + title: "UI鎺堟潈", + loading: false, + type: "add", + }, + type:'',//涓氬姟绫诲瀷 + context:'',//UI涓婁笅鏂嘽ode + treeOption: { + menu: false, + addBtn: false, + props: { + label: 'name', + value: 'oid', + children: 'children' + } + }, + nodeRow: {}, + treeData: [], + defaultExpandKeys:[], + uiTreeOption: { + nodeKey:'oid', + checkOnClickNode:true, + defaultExpandedKeys:this.defaultExpandKeys, + multiple: true, + menu: false, + addBtn: false, + filter:false, + props: { + label: 'label', + value: 'oid', + children: 'children' + } + }, + uiTreeData: [], + } + }, + methods:{ + openDialog(type,context) { + this.type=type; + this.context=context; + this.dialog.showDialog = true; + this.getTreeList() + this.uiTreeData=[]; + }, + cancelDialog() { + this.dialog.loading = false; + this.dialog.showDialog = false; + }, + getTreeList() { + const loading = this.$loading({}); + gridRoles().then(res => { + this.treeData = res.data.data; + loading.close(); + }).catch(error=>{ + loading.close(); + }) + }, + // 瑙掕壊鐐瑰嚮 + nodeClick(row,node) { + this.nodeRow = row; + const loading = this.$loading({}); + const params = { + 'conditionMap[roleId]': this.nodeRow.oid, + 'conditionMap[type]': this.type, + 'conditionMap[context]': this.context + } + this.defaultExpandKeys=['root']; + getUIAuthor(params).then(res => { + this.processChildren(res.data.data[0]); // 澶勭悊姣忎釜鑺傜偣 + this.uiTreeOption.defaultExpandedKeys=this.defaultExpandKeys; + this.uiTreeData = [{ + attributes: {}, + checked: false, + expanded: true, + data: "root", + level: 0, + icon: 'el-icon-s-home', + oid: res.data.data[0].oid, + label: res.data.data[0].text, + children: res.data.data[0].children + }]; + loading.close(); + }).catch(error => { + loading.close(); + }) + }, + //澶勭悊鏍� + processChildren(item) { + if (item.children && item.children.length > 0) { + item.children = item.children.map(child => { + if(child.level<4){ + this.defaultExpandKeys.push(child.oid) + } + if(child.level==1){ + child.icon='el-icon-s-promotion'; + child.label=child.data.label+'('+child.data.name+')' + }else if(child.level==2){ + child.icon='el-icon-s-order'; + child.label=child.text + }else if(child.level==3){ + child.icon='el-icon-office-building'; + child.label=child.text + }else if(child.level==4){ + child.icon='el-icon-document'; + child.label=child.text + }else if(child.level==5){ + child.icon='el-icon-s-tools'; + child.label=child.text + } + this.processChildren(child); // 閫掑綊澶勭悊姣忎釜瀛愯妭鐐� + return child; // 鍙繑鍥炲瓙鑺傜偣鐨� attributes + }); + } + }, + submitDialog() { + const selectTreeList = this.$refs.uiTree.getCheckedNodes(); + if (selectTreeList.length == 0) { + this.$message.error("璇烽�夋嫨鍔熻兘妯″潡"); + return; + } + const formData = { + roleId: this.nodeRow.oid, + type: this.type, + context: this.context, + selectTreeList: selectTreeList + } + authorizedUI(formData).then(res => { + if (res.data.success) { + this.$message.success("鎺堟潈鎴愬姛"); + this.cancelDialog(); + } + }); + + }, + clearValue(){ + this.$refs.uiTree.setCheckedNodes([]) + } + } +} +</script> + +<style scoped> + +</style> -- Gitblit v1.9.3