From 1de239fd89d33d074d0031f2d1363a211dce98f4 Mon Sep 17 00:00:00 2001 From: wangting <675591594@qq.com> Date: 星期四, 05 十二月 2024 18:04:07 +0800 Subject: [PATCH] 表单增加参数,数据授权 --- Source/plt-web/plt-web-ui/src/api/system/user/api.js | 10 + Source/plt-web/plt-web-ui/src/components/dynamic-components/dynamic-form.vue | 4 Source/plt-web/plt-web-ui/src/views/authority/ui/dataAuthorization/dataView.vue | 105 ++++++++++------- Source/plt-web/plt-web-ui/src/views/authority/ui/dataAuthorization/index.vue | 225 +++++++++++++++++++++++++------------ Source/plt-web/plt-web-ui/src/api/authority/ui/dataAuthor.js | 13 + 5 files changed, 237 insertions(+), 120 deletions(-) diff --git a/Source/plt-web/plt-web-ui/src/api/authority/ui/dataAuthor.js b/Source/plt-web/plt-web-ui/src/api/authority/ui/dataAuthor.js index a6b5b23..b0bea7e 100644 --- a/Source/plt-web/plt-web-ui/src/api/authority/ui/dataAuthor.js +++ b/Source/plt-web/plt-web-ui/src/api/authority/ui/dataAuthor.js @@ -15,14 +15,23 @@ return request({ url: '/api/dataAuthController/saveGrand', method: 'post', - params: params + data: params }) } // 鍒犻櫎 export function delGrand(params) { return request({ - url: "/api/dataAuthController/delGrand", + url: "/api/dataAuthController/deleteTypeRuleGrand", method: "delete", params }) } + +// 鏌ョ湅鎺堟潈缁撴灉 +export function authResult(params) { + return request({ + url: "/api/dataAuthController/authResult", + method: "get", + params + }); +} diff --git a/Source/plt-web/plt-web-ui/src/api/system/user/api.js b/Source/plt-web/plt-web-ui/src/api/system/user/api.js index 47b476b..8f40f96 100644 --- a/Source/plt-web/plt-web-ui/src/api/system/user/api.js +++ b/Source/plt-web/plt-web-ui/src/api/system/user/api.js @@ -43,6 +43,16 @@ } }); } +// 鏌ヨ褰撳墠鐢ㄦ埛鎵�鍦ㄩ儴闂� +export function listDeptByUserOid(userOid) { + return request({ + url: "/api/departmentQueryController/listDeptByUserOid", + method: "get", + params:{ + userOid + } + }); +} // 淇濆瓨瑙掕壊 export function saveRights(params) { diff --git a/Source/plt-web/plt-web-ui/src/components/dynamic-components/dynamic-form.vue b/Source/plt-web/plt-web-ui/src/components/dynamic-components/dynamic-form.vue index 81f8707..19a7c3b 100644 --- a/Source/plt-web/plt-web-ui/src/components/dynamic-components/dynamic-form.vue +++ b/Source/plt-web/plt-web-ui/src/components/dynamic-components/dynamic-form.vue @@ -164,7 +164,9 @@ btmName: this.currentDefineVO.btmType, btmType: this.currentDefineVO.btmType, formDefineId: this.currentDefineVO.id, - formDefineOid: this.currentDefineVO.oid + formDefineOid: this.currentDefineVO.oid, + componentOid: this.componentVO.oid, + uiDefineId: this.uiContext, }; if (this.dataStore[0] && this.dataStore[0].oid) { formParams.oid = this.dataStore[0].oid; 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 49865da..8a08f85 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 @@ -405,53 +405,9 @@ departmentQueryController({queryAllLevel: true}).then(res => { const data = res.data.treeData; this.departData = this.departDtaFormAtter(data); - }).catch(err => { - this.$message.error(err); }) }, watch: { - selectRow:{ - handler(val,oldval) { - this.authData=[]; - if(val && val.rules){ - this.form=JSON.parse(JSON.stringify(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}' - }) - } - }) - } - }else { - this.form={}; - } - }, - immediate: true, - deep: true - }, actionMap:{ handler(val) { this.actionDic=[]; @@ -467,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: { //閫変腑鐢ㄦ埛 diff --git a/Source/plt-web/plt-web-ui/src/views/authority/ui/dataAuthorization/index.vue b/Source/plt-web/plt-web-ui/src/views/authority/ui/dataAuthorization/index.vue index 2b0c6fa..54d9cd4 100644 --- a/Source/plt-web/plt-web-ui/src/views/authority/ui/dataAuthorization/index.vue +++ b/Source/plt-web/plt-web-ui/src/views/authority/ui/dataAuthorization/index.vue @@ -35,7 +35,7 @@ </template> </avue-crud> <div style="margin-top: 15px;"> - <data-view key="dataView" :btmNode="nodeRow" :selectRow="selectRow" :actionMap="actionMap" :readOnly="true" :height="clientHeight-260-220"></data-view> + <data-view key="dataView" :btmNode="nodeRow" :actionMap="actionMap" :selectRow="selectRow" :readOnly="true" :height="clientHeight-260-220"></data-view> </div> <!-- 鏂板 && 缂栬緫 --> <el-dialog @@ -47,7 +47,7 @@ width="70%" @close="addDialogClose"> <div> - <data-view ref="editView" key="editView" :btmNode="nodeRow" :selectRow="title === 'add'?{}:selectRow" :actionMap="actionMap" :readOnly="false" :height="clientHeight-260"></data-view> + <data-view ref="editView" key="editView" :btmNode="nodeRow" :actionMap="actionMap" :selectRow="title === 'add'?{}:selectRow" :readOnly="false" :height="clientHeight-260"></data-view> </div> <span slot="footer" class="dialog-footer"> <el-button size="small" type="primary" @click="addDialogSavaHandler">淇� 瀛�</el-button> @@ -57,22 +57,54 @@ <!-- 鏌ョ湅鎺堟潈缁撴灉 --> <el-dialog v-dialogDrag - v-loading="checkViewLoading" :visible.sync="checkViewVisible" append-to-body="true" class="avue-dialog" title="鏌ョ湅浣跨敤鑼冨洿" width="60%" > - <avue-crud - ref="checkViewCrud" - :data="checkViewData" - :option="checkViewOption" - @search-change="checkHandleSearch" - @search-reset="checkHandleReset" - > + <el-form ref="form" :inline="true" size="mini" :model="form" label-width="80px"> + <el-form-item label="涓氬姟瀵硅薄" prop="btmType"> + <el-input v-model="form.btmType"></el-input> + </el-form-item> + <el-form-item> + <el-button type="primary" size="mini" @click="onSubmit">鏌ヨ涓氬姟瀵硅薄</el-button> + </el-form-item> + <fieldset style="width: 99.5%"> + <legend> 鐢ㄦ埛淇℃伅 </legend> + <div> + <el-form-item label="鐢ㄦ埛"> + <el-select v-model="form.userOid"> + <el-option v-for="item in userDic" :label="item.name+'('+item.id+')'" :value="item.oid"></el-option> + </el-select> + </el-form-item> + <el-form-item label="瑙掕壊"> + <el-select v-model="form.roleOid"> + <el-option v-for="item in roleDic" :label="item.name" :value="item.oid"></el-option> + </el-select> + </el-form-item> + <el-form-item label="鐢ㄦ埛缁�"> + <el-select v-model="form.deptOid"> + <el-option v-for="item in deptDic" :label="item.name" :value="item.oid"></el-option> + </el-select> + </el-form-item> + </div> + </fieldset> - </avue-crud> + </el-form> + <fieldset style="width: 99.5%;margin-top: 10px;"> + <legend> 鎺堟潈缁撴灉锛� </legend> + <div> + <avue-crud + ref="checkViewCrud" + :data="checkViewData" + :option="checkViewOption" + > + + </avue-crud> + </div> + </fieldset> + </el-dialog> </basic-container> </el-main> @@ -84,9 +116,9 @@ import {getBizTree} from "@/api/UI/uiDefine"; import basicOption from "@/util/basic-option"; import dataView from "./dataView"; -import {getData,saveGrand,delGrand} from "@/api/authority/ui/dataAuthor"; +import {getData,saveGrand,delGrand,authResult} from "@/api/authority/ui/dataAuthor"; +import {listUserByUserType, listRoleByUserOid, listDeptByUserOid} from "@/api/system/user/api"; import func from "@/util/func"; -import {getUsedEnumList} from "@/api/modeling/enumType/api"; export default { name: "index", components:{dataView}, @@ -136,7 +168,15 @@ data: [], title: '', visible: false, - form:{}, + form:{ + btmType:'', + userOid:'', + roleOid:'', + deptOid:'' + }, + userDic:[], + roleDic:[], + deptDic:[], actionMap:{}, switchDic:[{ label:'', @@ -144,11 +184,45 @@ },{ label:'', value:true - }] + }], + checkViewVisible:false, + } }, created() { this.getTreeList(); + }, + watch:{ + 'form.userOid':{ + handler(val) { + if(val){ + listRoleByUserOid(val).then(res => { + // 缁勮濂界┛姊鍙敤鏁版嵁 + this.roleDic = res.data.data; + if(this.roleDic.length>0){ + this.form.roleOid=this.roleDic[0].oid + }else{ + this.form.roleOid='' + } + }) + listDeptByUserOid(val).then(res => { + this.deptDic = res.data.data; + if(this.deptDic.length>0){ + this.form.deptOid=this.deptDic[0].oid + }else { + this.form.deptOid=''; + } + }) + }else{ + this.roleDic=[]; + this.deptDic=[]; + this.form.roleOid='' + this.form.deptOid=''; + } + }, + immediate: true, + deep: true + } }, methods: { //鏍戣〃鏌ヨ @@ -199,10 +273,9 @@ }) } this.data = res.data.obj.rowList; - this.$refs.crud.clearSelection(); this.tableLoading = false; this.actionMap=res.data.obj.actionMap; - this.selectRow={} + this.$refs.crud.setCurrentRow( ); }) }, handleRefresh() { @@ -211,38 +284,6 @@ // 琛岀偣鍑� rowClickHandler(row) { this.selectRow=row - }, - // 鏌ョ湅鎺堟潈缁撴灉 - chekView() { - if (this.selectRow=={}) { - this.$message.warning('璇烽�夋嫨涓�鏉℃暟鎹�'); - return; - } - - getUsedEnumList({enumName: this.selectRow.id}).then(res => { - if (res.data.code === 200) { - this.checkViewVisible = true; - this.checkViewData = res.data.data; - this.checkViewDataSearch = res.data.data; - } - }) - }, - - // 鏌ョ湅鎺堟潈缁撴灉鏌ヨ - checkHandleSearch(params, done) { - const {source} = params; - - if (!params.source) { - this.checkViewData = this.checkViewDataSearch; - return done(); - } - - this.checkViewData = this.checkViewData.filter(item => { - return item.source && item.source.includes(source); - }); - - done(); - }, //鍒涘缓 addHandler(){ @@ -264,31 +305,45 @@ }, // 鏂板缂栬緫淇濆瓨 addDialogSavaHandler() { - let form=this.$refs.editView.form; - form.users='' - form.userGroups=''; - form.roles='' - this.$refs.editView.authData.forEach(item=>{ - let infos=item.name.split(', '); - infos[0]=infos[0].replace('{','') - if(infos[2]=='user}'){ - form.users+=infos[0]+',' + let form = this.$refs.editView.form; + if (form.ruleName == '') { + this.$message.error('瀹綋璇疯緭鍏ヨ鍒欏悕绉�'); + return; + } + form.users = '' + form.userGroups = ''; + form.roles = '' + this.$refs.editView.authData.forEach(item => { + let infos = item.name.split(', '); + infos[0] = infos[0].replace('{', '') + if (infos[2] == 'user}') { + form.users += infos[0] + ',' } - if(infos[2]=='userGroup}'){ - form.userGroups+=infos[0]+',' + if (infos[2] == 'userGroup}') { + form.userGroups += infos[0] + ',' } - if(infos[2]=='role}'){ - form.roles+=infos[0]+',' + if (infos[2] == 'role}') { + form.roles += infos[0] + ',' } }); - console.log(form) - //saveGrand(this.viewData).then(res => { - //if (res.data.code === 200) { - //this.$message.success(res.data.obj); + let data = []; + for (var i in this.actionMap) { + data.push({ + ...form, + identifier: this.nodeRow.attributes.name + '_' + this.actionMap[i], + isGrand: this.$refs.editView.actionForm.some(item => { + return item == this.actionMap[i] + }) ? 49 : 48 + }) + } + + saveGrand(data).then(res => { + if (res.data.code === 200) { + this.$message.success(res.data.obj); this.getTableList(); this.addDialogClose(); - //} - //}) + } + }) }, // 鏂板缂栬緫瀵硅瘽妗嗗彇娑� addDialogClose() { @@ -305,7 +360,7 @@ cancelButtonText: '鍙栨秷', type: 'warning' }).then(() => { - delGrand({name:this.templateForm}).then(res => { + delGrand({typeName:this.nodeRow.attributes.name,ruleName:this.selectRow.rules[0].ruleName}).then(res => { if (res.data.code === 200) { this.$message.success(res.data.obj); this.getTableList(); @@ -318,9 +373,29 @@ }); }); }, - // 鏌ョ湅浣跨敤鑼冨洿閲嶇疆 - checkHandleReset() { - this.checkViewData = this.checkViewDataSearch; + + // 鏌ョ湅鎺堟潈缁撴灉 + chekView() { + if (func.isEmptyObject(this.nodeRow)) { + this.$message.warning('璇烽�夋嫨绫诲瀷鏍戜俊鎭�'); + return; + } + this.checkViewVisible = true; + listUserByUserType({type:1}).then(res => { + // 缁勮濂界┛姊鍙敤鏁版嵁 + this.userDic = res.data.data; + if(this.userDic.length>0){ + this.form.userOid=this.userDic[0].oid + }else{ + this.form.userOid='' + } + }) + + authResult({biztype: this.nodeRow.attributes.name,objectoid:''}).then(res => { + if (res.data.code === 200) { + this.checkViewData = res.data.data; + } + }) }, } } @@ -332,5 +407,9 @@ overflow: auto !important; } } - +fieldset { + padding: 10px 6px; + margin: 0; + border: 1px solid #EBEEF5; +} </style> -- Gitblit v1.9.3