From 7528d44d20d12b0b3044fb19e58c2f68c1cebf94 Mon Sep 17 00:00:00 2001
From: 田源 <lastanimals@163.com>
Date: 星期三, 20 十一月 2024 15:40:25 +0800
Subject: [PATCH] 系统模块配置修改树节点图标
---
Source/plt-web/plt-web-ui/src/views/authority/ui/uiAuthorization/index.vue | 255 ++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 222 insertions(+), 33 deletions(-)
diff --git a/Source/plt-web/plt-web-ui/src/views/authority/ui/uiAuthorization/index.vue b/Source/plt-web/plt-web-ui/src/views/authority/ui/uiAuthorization/index.vue
index e29f4a0..a77bb26 100644
--- a/Source/plt-web/plt-web-ui/src/views/authority/ui/uiAuthorization/index.vue
+++ b/Source/plt-web/plt-web-ui/src/views/authority/ui/uiAuthorization/index.vue
@@ -4,7 +4,7 @@
<basic-container>
<div ref="TreeBox" style="height: calc(100vh - 154px);!important;">
<!-- 宸︿晶鏍� -->
- <div style="height: calc(100vh - 200px);">
+ <div style="height: calc(100vh - 195px);">
<avue-tree :data="treeData" :option="treeOption" @node-click="nodeClick">
<span slot-scope="{ node, data }" class="el-tree-node__label">
<span style="font-size: 15px">
@@ -19,7 +19,45 @@
</el-aside>
<el-main>
- <basic-container>
+ <basic-container v-loading="treeLoading">
+ <h3 style="margin: 0 0 10px 0">UI鏉冮檺閰嶇疆</h3>
+ <div>
+ <el-button icon="el-icon-place" plain size="small" type="primary" @click="saveHandler">鎺堟潈</el-button>
+ <el-button icon="el-icon-close" plain size="small" style="margin-right: 40px;" type="primary"
+ @click="clearValue">閲嶇疆
+ </el-button>
+ 涓氬姟绫诲瀷锛�
+ <el-select v-model="type" :clearable="true" placeholder="璇烽�夋嫨" size="small"
+ style="width: 300px;margin-right: 20px;"
+ @change="typeChange">
+ <el-option
+ v-for="item in typeData"
+ :key="item.oid"
+ :label="item.text"
+ :value="item.attributes.name">
+ </el-option>
+ </el-select>
+ UI涓婁笅鏂囷細
+ <el-select v-model="context" :clearable="true" placeholder="璇烽�夋嫨" size="small" style="width: 350px;"
+ @change="contextChange">
+ <el-option
+ v-for="item in contextData"
+ :key="item.oid"
+ :label="item.plCode+' '+item.plName"
+ :value="item.plCode">
+ </el-option>
+ </el-select>
+ </div>
+ <div style="height: calc(100vh - 232px);margin-top: 10px;">
+ <avue-tree ref="uiTree" :data="uiTreeData" :node-key="oid" :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>
@@ -27,16 +65,18 @@
</template>
<script>
-import {gridRoles} from "@/api/system/role/api";
-import {getUIAuthor,authorizedUI} from "@/api/authority/ui/uiAuthor";
+import {gridRoles, getRightListByRoleId} from "@/api/system/role/api";
+import {getUIAuthor, authorizedUI} from "@/api/authority/ui/uiAuthor";
+import {getBizTree, gridUIContextData} from "@/api/UI/uiDefine";
export default {
name: "index",
data() {
return {
- type:'',//涓氬姟绫诲瀷
+ treeLoading: false,
+ type: '',//涓氬姟绫诲瀷
+ context: '',//UI涓婁笅鏂嘽ode
treeOption: {
- height: '500px',
menu: false,
addBtn: false,
props: {
@@ -47,61 +87,209 @@
},
nodeRow: {},
treeData: [],
+ defaultExpandKeys: [],
uiTreeOption: {
- height: '500px',
+ defaultExpandedKeys: this.defaultExpandKeys,
+ multiple: true,
menu: false,
addBtn: false,
- filter:false,
+ filter: false,
props: {
- label: 'name',
+ label: 'label',
value: 'oid',
children: 'children'
}
},
uiTreeData: [],
+ typeData: [],
+ contextData: []
}
},
created() {
- this.getTreeList()
+ this.getTreeList();
+ // this.getUITree();
+ this.getTypeList();
},
- methods:{
+ methods: {
getTreeList() {
const loading = this.$loading({});
gridRoles().then(res => {
this.treeData = res.data.data;
loading.close();
- }).catch(error=>{
+ }).catch(error => {
loading.close();
})
},
+
// 瑙掕壊鐐瑰嚮
nodeClick(row) {
this.nodeRow = row;
- const loading = this.$loading({});
- getUIAuthor().then(res => {
- this.uiTreeData = res.data.data;
- loading.close();
- }).catch(error=>{
- loading.close();
+ this.getUITree();
+ // const params = {
+ // roleId: row.oid
+ // }
+ // getRightListByRoleId(params).then(res => {
+ // const data = res.data.data.map(item => item.funcId);
+ // console.log(data);
+ // this.$refs.uiTree.setCheckedKeys(data);
+ // })
+ },
+
+ getUITree() {
+ this.treeLoading = true;
+ const params = {
+ 'conditionMap[roleId]': this.nodeRow.oid,
+ 'conditionMap[type]': this.type,
+ 'conditionMap[context]': this.context,
+ 'conditionMap[showCheckbox]': true
+ }
+ 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
+ }];
+ const checkedData = this.findCheckedOids(res.data.data[0]);
+ this.$refs.uiTree.setCheckedKeys(checkedData);
+
+ this.treeLoading = false;
+ }).catch(error => {
+ this.treeLoading = false;
})
},
+
+ // 鏌ユ壘宸查�夋嫨鑺傜偣
+ findCheckedOids(obj, result = []) {
+ if (obj.checked === true) {
+ result.push(obj.oid);
+ }
+ // 濡傛灉鏈� children锛屽垯缁х画閬嶅巻
+ if (obj.children && obj.children.length > 0) {
+ obj.children.forEach(child => {
+ this.findCheckedOids(child, result);
+ });
+ }
+ return result;
+ },
+
+ //澶勭悊鏍�
+ processChildren(item) {
+ if (item.children && item.children.length > 0) {
+ item.children = item.children.map(child => {
+ if (child.level < 3) {
+ // 榛樿鏍戣妭鐐瑰睍寮�涓ゅ眰鏁堟灉
+ 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
+ });
+ }
+ },
+
+ getTypeList() {
+ getBizTree().then(res => {
+ this.typeData = res.data.obj.children;
+ })
+ },
+
+ typeChange(data) {
+ this.contextData = [];
+ this.type = data;
+ if (data) {
+ const params = {
+ 'conditionMap[btmName]': data,
+ }
+ gridUIContextData(1, 500, params).then(res => {
+ this.contextData = res.data.data;
+ })
+ } else {
+ this.contextData = [];
+ }
+ this.getUITree();
+ },
+
+ contextChange(data) {
+ this.context = data;
+ this.getUITree();
+ },
+
saveHandler() {
- this.$refs.form.validate((valid) => {
- if (valid) {
- const formData={}
- authorizedUI(formData).then(res => {
- if (res.data.success) {
- this.$message.success("淇濆瓨鎴愬姛");
- this.cancelDialog();
- }
- });
- } else {
- return false;
+ const selectTreeList = this.$refs.uiTree.getCheckedNodes();
+ const selectParentList = this.$refs.uiTree.getHalfCheckedNodes();
+ if (selectTreeList.length == 0) {
+ this.$message.error("璇烽�夋嫨鍔熻兘妯″潡");
+ return;
+ }
+ const selectTreeData = selectTreeList.map(item => {
+ return {
+ checked: true,
+ expanded: true,
+ data:item.data,
+ parentId:item.parentId,
+ level: item.level,
+ leaf:item.leaf,
+ oid: item.oid,
+ text: item.text
+ }
+ })
+
+ const parentData = selectParentList.map(item => {
+ return {
+ checked: false,
+ expanded: true,
+ data:item.data,
+ parentId:item.parentId,
+ level: item.level,
+ leaf:item.leaf,
+ oid: item.oid,
+ text: item.text
+ }
+ })
+ // 鍦ㄥ崐閫夌姸鎬佷腑杩囨护鎺夐《绾ц妭鐐� oid 涓� root
+ const filterSelectTreeData = parentData.filter(item => item.oid !== 'root');
+
+ const data = [...selectTreeData,...filterSelectTreeData];
+ const formData = {
+ roleId: this.nodeRow.oid,
+ type: this.type,
+ context: this.context,
+ selectTreeList: data
+ }
+ authorizedUI(formData).then(res => {
+ if (res.data.success) {
+ this.$message.success("鎺堟潈鎴愬姛");
+ this.cancelDialog();
}
});
},
- clearValue(){
- this.$refs.uiTree.setCheckedNodes([])
+
+ clearValue() {
+ this.$refs.uiTree.setCheckedNodes([]);
}
}
}
@@ -112,8 +300,9 @@
.el-scrollbar__wrap {
overflow: auto !important;
}
- .headerCon{
- .el-button{
+
+ .headerCon {
+ .el-button {
width: 82px;
}
}
--
Gitblit v1.9.3