From e9eb9ee7bec1dd64e3b9a494a2814a5bc3952709 Mon Sep 17 00:00:00 2001
From: yuxc <yuxc@vci-tech.com>
Date: 星期五, 27 十二月 2024 11:57:43 +0800
Subject: [PATCH] 1、主要优化业务类型加载过慢由于重复加载平台的属性、枚举数据,属性数据通过第一次加载全部进行传递解决,枚举数据通过新增枚举的本地线程工具类来进行实现。
---
Source/plt-web/plt-web-ui/src/views/authority/ui/dataAuthorization/dataView.vue | 352 +++++++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 273 insertions(+), 79 deletions(-)
diff --git a/Source/plt-web/plt-web-ui/src/views/authority/ui/dataAuthorization/dataView.vue b/Source/plt-web/plt-web-ui/src/views/authority/ui/dataAuthorization/dataView.vue
index fe69008..05c44a1 100644
--- a/Source/plt-web/plt-web-ui/src/views/authority/ui/dataAuthorization/dataView.vue
+++ b/Source/plt-web/plt-web-ui/src/views/authority/ui/dataAuthorization/dataView.vue
@@ -12,23 +12,26 @@
<fieldset style="width: 48%">
<legend> 涓讳綋 </legend>
<div>
- <avue-crud ref="mainCrud" :data="mainData" :option="mainOption">
+ <avue-crud ref="mainCrud" :data="mainData" :option="mainOption"
+ @current-row-change="mainCurrentRowHandler"
+ >
<template #type="{ row }">
<el-tag v-if="row.type=='鐢ㄦ埛'" :key="row.oid" effect="dark">{{ row.type }}</el-tag>
<el-tag v-else-if="row.type=='瑙掕壊'" type="info" :key="row.oid" effect="dark">{{ row.type }}</el-tag>
- <el-tag v-else="row.type=='閮ㄩ棬'" type="warning" :key="row.oid" effect="dark">{{ row.type }}</el-tag>
+ <el-tag v-else="row.type=='鐢ㄦ埛缁�'" type="warning" :key="row.oid" effect="dark">{{ row.type }}</el-tag>
</template>
</avue-crud>
</div>
</fieldset>
<div style="text-align: center;">
- <el-button icon="el-icon-arrow-right" size="mini" @click="rightHandler" style="margin-bottom: 50px;"></el-button><br/>
- <el-button icon="el-icon-arrow-left" size="mini" @click="leftHandler"></el-button>
+ <el-button icon="el-icon-arrow-right" type="primary" size="small" @click="rightHandler" style="margin-bottom: 50px;"></el-button><br/>
+ <el-button icon="el-icon-arrow-left" type="primary" size="small" @click="leftHandler"></el-button>
</div>
<fieldset style="width: 42%">
<legend> 鎺堟潈涓讳綋 </legend>
<div>
- <avue-crud ref="authCrud" :data="authData" :option="authOption" :table-loading="tableLoading">
+ <avue-crud ref="authCrud" :data="authData" :option="authOption" :table-loading="tableLoading"
+ @current-row-change="authCurrentRowHandler">
</avue-crud>
</div>
</fieldset>
@@ -112,9 +115,32 @@
</transfer>
<!-- 閫夋嫨鐢ㄦ埛绌挎妗� -->
<transfer ref="roletransfer" :left-role-data="leftRoleData" :right-role-data="rightRoleData"
- :transferTitle="['鐜版湁瑙掕壊','鎷ユ湁瑙掕壊']" title="娣诲姞瑙掕壊"
+ :transferTitle="['鐜版湁瑙掕壊','鎷ユ湁瑙掕壊']" title="鍒嗛厤瑙掕壊"
@transferSend="roleSendHandler">
</transfer>
+ <!-- 閫夋嫨閮ㄩ棬瀵硅瘽妗� -->
+ <el-dialog
+ v-dialogDrag
+ v-loading="departLoading"
+ :visible.sync="departVisible"
+ append-to-body="true"
+ class="avue-dialog"
+ title="閫夋嫨閮ㄩ棬"
+ width="50%"
+ >
+ <avue-crud
+ ref="departCrud"
+ :data="departData"
+ :option="departOption"
+ @selection-change="selectDepartChange"
+ @row-click="rowClickDeptHandler"
+ >
+ </avue-crud>
+ <div slot="footer" class="dialog-footer">
+ <el-button size="small" type="primary" @click="saveDepartHandler">纭� 瀹�</el-button>
+ <el-button size="small" @click="departVisible = false">鍙� 娑�</el-button>
+ </div>
+ </el-dialog>
</div>
</template>
@@ -123,8 +149,8 @@
import formQueryDialog from "@/views/modelingMenu/queryTemplate/linkTypeQuery/formQueryDialog.vue";
import {queryTemplateListByAttr} from "@/api/queryTemplate/queryDefine";
import {getCriteria} from "@/api/queryTemplate/linkTypeQuery";
-import {listUserByUserType} from "@/api/system/user/api";
-import {listUserByRoleOid, listUserUnInRoleOid, saveRight} from "@/api/system/role/api";
+import {listUserByUserType, gridRoles, departmentQueryController} from "@/api/system/user/api";
+import func from "@/util/func";
export default {
name: "dataView",
@@ -159,7 +185,40 @@
rightUserData: [], // 閫夋嫨鎴愬憳绌挎妗嗗彸渚у垵濮嬫暟鎹�
leftRoleData: [], // 閫夋嫨瑙掕壊绌挎妗嗗乏渚у垵濮嬫暟鎹�
rightRoleData: [], // 閫夋嫨瑙掕壊绌挎妗嗗彸渚у垵濮嬫暟鎹�
+ departCurrenRows: [],
+ departOption: {
+ ...basicOption,
+ addBtn: false,
+ rowKey: 'oid',
+ rowParentKey: 'parentId',
+ selection: true,
+ highlightCurrentRow: true,
+ stripe: false,
+ menu: false,
+ refreshBtn: false,
+ gridBtn: false,
+ header: false,
+ column: [
+ {
+ label: '鍚嶇О',
+ prop: 'name',
+ align: 'left'
+ },
+ {
+ label: '缂栧彿',
+ prop: 'id',
+ },
+ {
+ label: '鎻忚堪',
+ prop: 'description',
+ },
+ ]
+ },
+ departData: [],//閫夋嫨閮ㄩ棬鏁版嵁
+ departLoading: false,
+ departVisible: false,
mainData:[],
+ mainCurrentRow:{},
tableLoading: false,
mainOption: {
...basicOption,
@@ -178,7 +237,7 @@
label: ' 鍒嗙被',
prop: 'type',
sortable: true,
- width:110
+ width:90
},{
label: '缂栫爜',
prop: 'id'
@@ -188,6 +247,7 @@
}]
},
authData:[],
+ authCurrentRow:{},
authOption:{
...basicOption,
header:false,
@@ -242,7 +302,14 @@
value: '3',
disabled:true
}],
- value: '0'
+ value: '0',
+ change:function (column,value){
+ if(value=='1' || value=='3'){
+ this.form.btmName=this.btmNode.attributes.name;
+ this.form.levelFlag=0;
+ this.form.queryTemplate={};
+ }
+ }
}],
form:{
btmName:'',
@@ -254,14 +321,14 @@
"userGroups": "",//鏄剧ず鍒版巿鏉冧富浣撶晫闈紝閮ㄩ棬鍚嶇О锛屽涓娇鐢ㄩ�楀彿鍒嗛殧
"users": "",//鏄剧ず鍒版巿鏉冧富浣撶晫闈紝鐢ㄦ埛鍚嶇О锛屽涓娇鐢ㄩ�楀彿鍒嗛殧
"expToSQL": "",//姝ゅ涓哄厑璁告潈闄愭垨鎷掔粷鏉冮檺闇�濉厖鐨勬暟鎹紝鏆傛椂涓嶅仛澶勭悊锛屼负绌哄瓧绗︿覆鍗冲彲
- "identifier": "terminology_query",//涓氬姟绫诲瀷锛坱erminology锛�+涓嬪垝绾匡紙_锛�+鎿嶄綔鍖虹殑涓�鑸搷浣滅殑鎸夐挳鑻辨枃鍚嶇О锛坬uery锛�,澶氫釜鎸夐挳鐨勮瘽鏄鏉℃暟鎹笉鏄娇鐢ㄩ�楀彿鍒嗛殧
+ "identifier": "",//涓氬姟绫诲瀷锛坱erminology锛�+涓嬪垝绾匡紙_锛�+鎿嶄綔鍖虹殑涓�鑸搷浣滅殑鎸夐挳鑻辨枃鍚嶇О锛坬uery锛�,澶氫釜鎸夐挳鐨勮瘽鏄鏉℃暟鎹笉鏄娇鐢ㄩ�楀彿鍒嗛殧
"isGrand": 49, //姝ゅ涓烘搷浣滃尯鐨勪竴鑸搷浣滅殑鎸夐挳鏄惁涓洪�夋嫨鎯呭喌锛屾湭閫変腑鍊间负48锛岄�変腑涓�49锛岃繖閲屾槸灏�0鍜�1杞负浜哹yte鍊硷紝鎵�浠ヤ负48锛�49
"lexpToSQL": "",//姝ゅ涓哄厑璁告潈闄愭垨鎷掔粷鏉冮檺闇�濉厖鐨勬暟鎹紝鏆傛椂涓嶅仛澶勭悊锛屼负绌哄瓧绗︿覆鍗冲彲
"lruleText": "",//姝ゅ涓哄厑璁告潈闄愭垨鎷掔粷鏉冮檺闇�濉厖鐨勬暟鎹紝鏆傛椂涓嶅仛澶勭悊锛屼负绌哄瓧绗︿覆鍗冲彲
"lseniorRuleText": "",//姝ゅ涓哄厑璁告潈闄愭垨鎷掔粷鏉冮檺闇�濉厖鐨勬暟鎹紝鏆傛椂涓嶅仛澶勭悊锛屼负绌哄瓧绗︿覆鍗冲彲
- "ruleName": "assssss",//瑙勫垯鍚嶇О
+ "ruleName": "",//瑙勫垯鍚嶇О
"ruleText": "",//姝ゅ涓哄厑璁告潈闄愭垨鎷掔粷鏉冮檺闇�濉厖鐨勬暟鎹紝鏆傛椂涓嶅仛澶勭悊锛屼负绌哄瓧绗︿覆鍗冲彲
- "ruleType": "2",//0鍏ㄩ儴鍏佽锛�1鍏佽鏉冮檺锛�2鍏ㄩ儴鎷掔粷锛�3鎷掔粷鏉冮檺锛岀敱浜庢殏鏃跺彧鍋氬叏閮ㄥ厑璁镐笌鍏ㄩ儴鎷掔粷锛屾墍浠ユ殏鏃跺彲浠ヤ笉鐢ㄧ
+ "ruleType": "",//0鍏ㄩ儴鍏佽锛�1鍏佽鏉冮檺锛�2鍏ㄩ儴鎷掔粷锛�3鎷掔粷鏉冮檺锛岀敱浜庢殏鏃跺彧鍋氬叏閮ㄥ厑璁镐笌鍏ㄩ儴鎷掔粷锛屾墍浠ユ殏鏃跺彲浠ヤ笉鐢ㄧ
"seniorRuleText": "",//姝ゅ涓哄厑璁告潈闄愭垨鎷掔粷鏉冮檺闇�濉厖鐨勬暟鎹紝鏆傛椂涓嶅仛澶勭悊锛屼负绌哄瓧绗︿覆鍗冲彲
},
radioForm:0,
@@ -314,59 +381,33 @@
},
created() {
listUserByUserType().then(res => {
- if(typeof res.data == 'string'){
- res.data=eval('('+res.data +')')
- }
// 缁勮濂界┛姊鍙敤鏁版嵁
this.leftUserData = res.data.data.map(item => {
return {
+ ...item,
name: item.name + `(${item.id})`,
oid: item.oid
}
})
this.rightUserData = [];
})
+ gridRoles(1,-1).then(res => {
+ // 缁勮濂界┛姊鍙敤鏁版嵁
+ this.leftRoleData = res.data.data.map(item => {
+ return {
+ ...item,
+ name: item.name ,
+ oid: item.oid
+ }
+ })
+ this.rightRoleData = [];
+ })
+ departmentQueryController({queryAllLevel: true}).then(res => {
+ const data = res.data.treeData;
+ this.departData = this.departDtaFormAtter(data);
+ })
},
watch: {
- selectRow:{
- handler(val) {
- this.authData=[];
- if(val && val.rules){
- //this.getTemp(true);
- //this.getTemp(false)
- //鏋勫缓鎺堟潈涓讳綋鏁版嵁
- if(val.rules.users){
- val.rules.users.split(',').forEach((item,i)=>{
- if(item){
- this.authData.push({
- name:'{'+item+', '+item+', user}'
- })
- }
- })
- }
- if(val.rules.roles){
- val.rules.roles.split(',').forEach((item,i)=>{
- if(item){
- this.authData.push({
- name:'{'+item+', '+item+', role}'
- })
- }
- })
- }
- if(val.rules.userGroups){
- val.rules.userGroups.split(',').forEach((item,i)=>{
- if(item){
- this.authData.push({
- name:'{'+item+', '+item+', userGroup}'
- })
- }
- })
- }
- }
- },
- immediate: true,
- deep: true
- },
actionMap:{
handler(val) {
this.actionDic=[];
@@ -382,6 +423,67 @@
immediate: true,
deep: true
},
+ selectRow:{
+ handler(val,oldval) {
+ this.authData=[];
+ if(val && val.rules &&val.rules.length>0) {
+ this.form = JSON.parse(JSON.stringify(val.rules[0]));
+ //this.getTemp(true);
+ //this.getTemp(false)
+ //鏋勫缓鎺堟潈涓讳綋鏁版嵁
+ if (val.rules[0].users) {
+ val.rules[0].users.split(',').forEach((item, i) => {
+ if (item) {
+ this.authData.push({
+ name: '{' + item + ', ' + item + ', user}'
+ })
+ }
+ })
+ }
+ if (val.rules[0].roles) {
+ val.rules[0].roles.split(',').forEach((item, i) => {
+ if (item) {
+ this.authData.push({
+ name: '{' + item + ', ' + item + ', role}'
+ })
+ }
+ })
+ }
+ if (val.rules[0].userGroups) {
+ val.rules[0].userGroups.split(',').forEach((item, i) => {
+ if (item) {
+ this.authData.push({
+ name: '{' + item + ', ' + item + ', userGroup}'
+ })
+ }
+ })
+ }
+ //瑙f瀽鎿嶄綔鎸夐挳閫変腑鍊�
+ if (this.actionDic.length > 0) {
+ let actionDicStr = JSON.stringify(this.actionDic);
+ val.rules.forEach(item => {
+ if (item.isGrand == 49) {
+ let identifier = item.identifier.replace(this.btmNode.attributes.name + '_', '')
+ if (actionDicStr.indexOf('"value":"'+identifier+'"}') != -1) {
+ this.actionForm.push(identifier)
+ } else {
+ this.linkactionForm.push(identifier);
+ }
+ }
+ })
+ }
+ }else {
+ this.form={
+ ruleName:'',
+ ruleType:'0'
+ };
+ this.actionForm=[];
+ this.linkactionForm=[];
+ }
+ },
+ immediate: true,
+ deep: true
+ },
},
methods: {
//閫変腑鐢ㄦ埛
@@ -391,45 +493,135 @@
// 閫変腑鐢ㄦ埛绌挎妗嗗洖濉�
userSendHandler(row) {
+ this.mainData=this.mainData.filter(item=>{
+ return item.type!='鐢ㄦ埛'
+ })
row.forEach((item,index)=>{
- this.authData.push({
- type:'user',
- ...item
+ var addItem=this.leftUserData.find(leftitem=>leftitem.oid==item);
+ this.mainData.push({
+ type:'鐢ㄦ埛',
+ id:addItem.id,
+ name:addItem.name.split('(')[0],
+ oid:addItem.oid
})
})
+ this.rightUserData=row;
+ this.$refs.usertransfer.visible = false;
},
//閫夋嫨瑙掕壊
roleHandler(){
- Promise.all([
- listUserUnInRoleOid({pkRole: this.selectList.oid}),
- listUserByRoleOid({pkRole: this.selectList.oid})
- ]).then(([unInRoleRes, byRoleRes]) => {
- if (unInRoleRes.data.code === 200 && byRoleRes.data.code === 200) {
- const leftData = [...unInRoleRes.data.data, ...byRoleRes.data.data];
- // 缁勮濂界┛姊鍙敤鏁版嵁
- this.leftRoleData = leftData.map(item => {
- return {
- name: item.name + `(${item.id})`,
- oid: item.oid
- }
- })
- this.rightRoleData = byRoleRes.data.data.map(item => item.oid);
- this.$refs.transfer.visible = true;
- }
- });
+ this.$refs.roletransfer.visible = true;
},
// 閫夋嫨瑙掕壊绌挎妗嗗洖濉�
roleSendHandler(row) {
+ this.mainData=this.mainData.filter(item=>{
+ return item.type!='瑙掕壊'
+ })
row.forEach((item,index)=>{
- this.authData.push({
- type:'role',
- ...item
+ var addItem=this.leftRoleData.find(leftitem=>leftitem.oid==item);
+ this.mainData.push({
+ type:'瑙掕壊',
+ id:addItem.name,
+ name:addItem.name,
+ oid:addItem.oid
})
})
+ this.rightRoleData=row;
+ this.$refs.roletransfer.visible = false;
},
//閫夋嫨鐢ㄦ埛缁�
deptHandler(){
-
+ this.departVisible=true;
+ },
+ // 閫夋嫨閮ㄩ棬鏁版嵁杞崲
+ departDtaFormAtter(items) {
+ return items.map(item => {
+ // 杞崲褰撳墠鑺傜偣鐨勫睘鎬�
+ const formList = {
+ oid: item.oid,
+ id: item.attributes.id,
+ name: item.attributes.name,
+ description: item.attributes.description,
+ parentId: item.parentId,
+ parentName: item.parentName,
+ parentBtmName: item.parentBtmName,
+ // 濡傛灉children瀛樺湪涓斾笉涓虹┖锛屽垯閫掑綊杞崲children
+ children: item.children && item.children.length > 0 ? this.departDtaFormAtter(item.children) : undefined
+ };
+ return formList;
+ });
+ },
+ // 閫夋嫨閮ㄩ棬
+ selectDepartChange(row) {
+ this.departCurrenRows = row;
+ },
+ // 閫夋嫨閮ㄩ棬 琛屽崟閫�
+ rowClickDeptHandler(row) {
+ func.rowClickHandler(
+ row,
+ this.$refs.departCrud,
+ this.lastIndex,
+ (newIndex) => { this.lastIndex = newIndex; },
+ () => { this.departCurrenRows = [row]; }
+ );
+ },
+ // 閫夋嫨閮ㄩ棬 纭畾
+ saveDepartHandler() {
+ if (this.departCurrenRows.length==0) {
+ this.$message.warning('璇烽�夋嫨閮ㄩ棬鑺傜偣锛�')
+ return;
+ }
+ this.mainData=this.mainData.filter(item=>{
+ return item.type!='鐢ㄦ埛缁�'
+ })
+ this.departCurrenRows.forEach((addItem,index)=>{
+ this.mainData.push({
+ type:'鐢ㄦ埛缁�',
+ id:addItem.id,
+ name:addItem.name,
+ oid:addItem.oid
+ })
+ })
+ this.departVisible = false;
+ },
+ //涓讳綋鍒楄〃琛岀偣鍑�
+ mainCurrentRowHandler(row){
+ this.mainCurrentRow=row;
+ },
+ //鎺堟潈涓讳綋鍒楄〃琛岀偣鍑�
+ authCurrentRowHandler(row){
+ this.authCurrentRow=row;
+ },
+ rightHandler() {
+ if(func.isEmptyObject(this.mainCurrentRow)){
+ this.$message.warning('璇烽�夋嫨鐢ㄦ埛銆佺敤鎴风粍銆佽鑹蹭俊鎭紒')
+ return;
+ }
+ let name='{' + this.mainCurrentRow.id + ', ' + this.mainCurrentRow.name + ', ';
+ if (this.mainCurrentRow.type == '鐢ㄦ埛') {
+ name+='user}';
+ } else if (this.mainCurrentRow.type == '瑙掕壊') {
+ name+='role}';
+ } else if (this.mainCurrentRow.type == '鐢ㄦ埛缁�') {
+ name+='userGroup}';
+ }
+ let canAdd = !this.authData.some(item => {
+ return item.name == name
+ })
+ if(canAdd) {
+ this.authData.push({
+ name: name
+ })
+ this.$refs.mainCrud.setCurrentRow();
+ this.mainCurrentRow={}
+ }else {
+ this.$message.warning('鎺堟潈涓讳綋淇℃伅閫夋嫨閲嶅锛�')
+ }
+ },
+ leftHandler() {
+ this.authData = this.authData.filter(item => {
+ return item.name != this.authCurrentRow.name
+ })
},
initFormData() {
let formData = {
@@ -578,6 +770,7 @@
::v-deep {
.el-radio ,.el-checkbox{
margin-right: 30px;
+ margin-bottom: 10px;
}
}
div{
@@ -587,5 +780,6 @@
padding: 10px 6px;
margin: 0;
border: 1px solid #EBEEF5;
+ overflow: auto;
}
</style>
--
Gitblit v1.9.3