From 8bc25357d5742f07710baa7a6f1d6ac4023da3ac Mon Sep 17 00:00:00 2001 From: wangting <wangting@vci-tech.com> Date: 星期三, 25 十二月 2024 12:00:55 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- Source/plt-web/plt-web-ui/src/views/authority/ui/dataAuthorization/index.vue | 534 ++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 474 insertions(+), 60 deletions(-) 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 308c333..19075c8 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 @@ -1,33 +1,17 @@ <template> <el-container> - <el-aside> <basic-container> - <div ref="TreeBox" style="height: calc(100vh - 144px);!important;"> - <div class="headerCon"> - <el-button icon="el-icon-plus" plain size="small" type="primary" @click="addClickHandler">鍒涘缓 - </el-button> - <el-button icon="el-icon-edit" plain size="small" type="primary" @click="editClickHandler">淇敼 - </el-button> - <el-button icon="el-icon-delete" plain size="small" type="danger" @click="delClickHandler">鍒犻櫎 - </el-button> - <el-button icon="el-icon-download" plain size="small" type="primary" @click="exportClickHandler">瀵煎嚭 - </el-button> - <el-button icon="el-icon-upload2" plain size="small" type="primary" @click="uploadClickHandler">瀵煎叆 - </el-button> - <el-button class="smallBtn" plain size="small" type="primary" - @click="checkViewClickHandler">鏌ョ湅浣跨敤鑼冨洿 - </el-button> - </div> + <div ref="TreeBox" style="height: calc(100vh - 154px);!important;"> <!-- 宸︿晶鏍� --> - <div style="height: calc(100vh - 280px);"> + <div style="height: calc(100vh - 190px);"> <avue-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-s-promotion"></i> - {{ (node || {}).label }} - </span> - </span> + <span slot-scope="{ node, data }" class="el-tree-node__label"> + <span> + <i class="el-icon-s-promotion"></i> + {{ (node || {}).label }} + </span> + </span> </avue-tree> </div> </div> @@ -35,7 +19,107 @@ </el-aside> <el-main> - <basic-container> + <basic-container cardBodyStyle="padding-bottom:0;"> + <avue-crud + ref="crud" + :data="data" + :option="option" + :table-loading="tableLoading" + @refresh-change="handleRefresh" + @current-row-change="rowClickHandler"> + <template slot="menuLeft"> + <el-button v-if="permissionList.addBtn" icon="el-icon-plus" size="small" type="primary" @click="addHandler">娣诲姞</el-button> + <el-button v-if="permissionList.editBtn" icon="el-icon-plus" size="small" type="primary" @click="editHandler">淇敼</el-button> + <el-button v-if="permissionList.delBtn" icon="el-icon-delete" plain size="small" type="danger" @click="delHandler">鍒犻櫎</el-button> + <!--<el-button icon="el-icon-view" plain size="small" type="primary" @click="viewAuthHandler">鏌ョ湅鎺堟潈缁撴灉</el-button>--> + </template> + </avue-crud> + <div style="margin-top: 15px;"> + <data-view key="dataView" :btmNode="nodeRow" :actionMap="actionMap" :selectRow="selectRow" :readOnly="true" :height="clientHeight-260-220"></data-view> + </div> + <!-- 鏂板 && 缂栬緫 --> + <el-dialog + v-dialogDrag + :title="title === 'add' ? '鍒涘缓' : '淇敼'" + :visible.sync="visible" + append-to-body="true" + class="avue-dialog" + width="70%" + @close="addDialogClose"> + <div> + <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> + <el-button size="small" @click="addDialogClose">鍙� 娑�</el-button> + </span> + </el-dialog> + <!-- 鏌ョ湅鎺堟潈缁撴灉 --> + <el-dialog + v-dialogDrag + :visible.sync="authResultVisible" + append-to-body="true" + class="avue-dialog" + title="鏌ョ湅鎺堟潈缁撴灉" + width="60%" + > + <el-form ref="form" :inline="true" size="mini" :model="form" label-width="80px"> + <el-form-item label="涓氬姟瀵硅薄" prop="objectoid"> + <el-input v-model="form.objectoid" style="width:300px;"></el-input> + </el-form-item> + <el-form-item> + <el-button type="primary" @click="queryBtm" style="padding: 6px 15px;">鏌ヨ涓氬姟瀵硅薄</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> + <el-dialog + v-dialogDrag + :visible.sync="btmObjVisible" + append-to-body="true" + class="avue-dialog" + title="涓氬姟瀵硅薄鍒楄〃" + width="90%" + > + <avue-crud + ref="btmObjCrud" + :data="btmObjData" + :option="btmObjOption" + @current-row-change="btmObjClickHandler" + > + </avue-crud> + </el-dialog> + </el-form> + <fieldset style="width: 99.5%;margin-top: 10px;"> + <legend> 鎺堟潈缁撴灉锛� </legend> + <div> + <avue-crud + ref="authResultCrud" + :data="authResultData" + :option="authResultOption" + > + </avue-crud> + </div> + </fieldset> + + </el-dialog> </basic-container> </el-main> @@ -43,8 +127,368 @@ </template> <script> +import {getBizTree} from "@/api/UI/uiDefine"; +import basicOption from "@/util/basic-option"; +import dataView from "./dataView"; +import {getData,saveGrand,delGrand,authResult,queryBusiness} from "@/api/authority/ui/dataAuthor"; +import {listUserByUserType, listRoleByUserOid, listDeptByUserOid} from "@/api/system/user/api"; +import func from "@/util/func"; +import {mapGetters} from "vuex"; export default { - name: "index" + name: "index", + components:{dataView}, + data:function (){ + return{ + clientHeight:Math.max(document.body.clientHeight,700), + treeOption: { + height: 'auto', + defaultExpandAll: true, + menu: false, + addBtn: false, + props: { + label: 'text', + value: 'oid', + children: 'children' + } + }, + nodeRow: {}, + treeData: [], + tableLoading: false, + selectRow: {}, + option: { + ...basicOption, + height:280, + highlightCurrentRow:true, + addBtn: false, + editBtn: false, + delBtn: false, + filterBtn:false, + columnBtn:false, + gridBtn:false, + tip: false, + index:false, + selection:false, + menu:false, + align:'center', + column: [{ + label: '瑙勫垯鍚嶇О', + prop: 0, + overHidden: true + },{ + label: '瑙勫垯绫诲瀷', + prop: 1, + overHidden: true + }] + }, + data: [], + title: '', + visible: false, + form:{ + objectoid:'', + userOid:'', + roleOid:'', + deptOid:'' + }, + userDic:[], + roleDic:[], + deptDic:[], + actionMap:{}, + switchDic:[{ + label:'', + value:false + },{ + label:'', + value:true + }], + authResultVisible:false, + authResultData:[], + authResultOption:{ + ...basicOption, + height:300, + tip: false, + index:false, + selection:false, + menu:false, + header:false, + column: [{ + label: '鍚嶇О', + prop: 'name', + overHidden: true + }] + }, + //涓氬姟瀵硅薄鍒楄〃 + btmObjVisible:false, + btmObjData:[], + btmObjOption:{ + ...basicOption, + height:500, + tip: false, + selection:false, + menu:false, + header:false, + column: [] + } + } + }, + computed:{ + ...mapGetters(["permission"]), + permissionList() { + return { + addBtn: this.vaildData(this.permission[this.$route.query.id].ADD, false), + delBtn: this.vaildData(this.permission[this.$route.query.id].DELETE, false), + editBtn: this.vaildData(this.permission[this.$route.query.id].EDIT, 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: { + //鏍戣〃鏌ヨ + getTreeList() { + const loading = this.$loading({}); + getBizTree().then(res => { + this.treeData = [res.data.obj]; + loading.close(); + }).catch(error => { + loading.close(); + }) + }, + // 鏍戠偣鍑� + nodeClick(row) { + if (row.oid) { + this.nodeRow = row; + this.getTableList(); + } + }, + getTableList() { + getData(this.nodeRow.attributes.name).then(res => { + if(typeof res.data == 'string'){ + res.data=eval('('+res.data +')') + } + if(res.data.obj.tableHeader){ + this.option.column=[ { + label: '瑙勫垯鍚嶇О', + prop: 0, + overHidden: true + },{ + label: '瑙勫垯绫诲瀷', + prop: 1, + overHidden: true + }]; + res.data.obj.tableHeader.forEach((item,i)=>{ + if(i<=1) return; + if(i=='rules') return; + this.option.column.push({ + label: item, + prop: i, + overHidden: true, + width:(this.stringLength(item) *6+35)+'px', + html:true, + formatter:(val)=> { + return '<label class="el-checkbox is-disabled ' + (val[i] == true ? 'is-checked' : '') + '"><span class="el-checkbox__input is-disabled ' + (val[i] == true ? 'is-checked' : '') + '"><span class="el-checkbox__inner"></span><input type="checkbox" aria-hidden="false" class="el-checkbox__original" value="' + val[i] + '"></span></label>' + } + }) + }) + } + this.data = res.data.obj.rowList; + this.tableLoading = false; + this.actionMap=res.data.obj.actionMap; + this.$refs.crud.setCurrentRow( ); + + }) + }, + stringLength(str) { + let len = 0; + for (let i = 0; i < str.length; i++) { + let code = str.charCodeAt(i); + if (code >= 0 && code <= 127) { + len += 1; // 鑻辨枃瀛楃 + } else { + len += 2; // 涓枃瀛楃 + } + } + return len; + }, + handleRefresh() { + this.getTableList(); + }, + // 琛岀偣鍑� + rowClickHandler(row) { + this.selectRow=row + }, + //鍒涘缓 + addHandler(){ + if (func.isEmptyObject(this.nodeRow)) { + this.$message.error('璇烽�夋嫨瑕佹坊鍔犵殑鑺傜偣'); + return; + } + this.title = 'add'; + this.visible = true; + }, + //淇敼 + editHandler(){ + if (func.isEmptyObject(this.selectRow)) { + this.$message.error('璇烽�夋嫨涓�鏉℃暟鎹�'); + return; + } + this.title = 'edit'; + this.visible = true; + }, + // 鏂板缂栬緫淇濆瓨 + addDialogSavaHandler() { + 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] == 'role}') { + form.roles += infos[0] + ',' + } + }); + 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() { + this.visible = false; + }, + //鍒犻櫎 + delHandler(){ + if (func.isEmptyObject(this.selectRow)) { + this.$message.error('璇烽�夋嫨鏁版嵁'); + return; + } + this.$confirm('鎮ㄧ‘瀹氳鍒犻櫎鎵�閫夋嫨鐨勬暟鎹悧锛�', '鎻愮ず', { + confirmButtonText: '纭畾', + cancelButtonText: '鍙栨秷', + type: 'warning' + }).then(() => { + 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(); + } + }) + }).catch(() => { + this.$message({ + type: 'info', + message: '宸插彇娑堝垹闄�' + }); + }); + }, + + // 鏌ョ湅鎺堟潈缁撴灉 + viewAuthHandler() { + if (func.isEmptyObject(this.nodeRow)) { + this.$message.warning('璇烽�夋嫨绫诲瀷鏍戜俊鎭�'); + return; + } + this.authResultVisible = 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='' + } + }) + this.getAuthResultData() + }, + getAuthResultData(){ + authResult({biztype: this.nodeRow.attributes.name,objectoid:this.form.objectoid}).then(res => { + if (res.data.code === 200) { + this.authResultData = res.data.data; + } + }) + }, + //鏌ヨ涓氬姟瀵硅薄 + queryBtm(){ + queryBusiness({btmName: this.nodeRow.attributes.name,boFlag:true,btmType:'btm'}).then(res => { + if (res.data.code === 200) { + if(res.data.obj.tableHeader){ + this.btmObjOption.column=[]; + res.data.obj.tableHeader.forEach((item,i)=>{ + this.btmObjOption.column.push({ + label: item, + prop: i, + overHidden: true, + width:(this.stringLength(item) *8+30)+'px', + }) + }) + } + this.btmObjData = res.data.obj.tableValues; + } + }) + this.btmObjVisible=true; + }, + btmObjClickHandler(row){ + this.form.objectoid=row[0]; + this.getAuthResultData() + this.btmObjVisible=false; + } + } } </script> @@ -53,40 +497,10 @@ .el-scrollbar__wrap { overflow: auto !important; } - .headerCon{ - .el-button{ - width: 82px; - } - } } - -.headerCon { - display: flex; - flex-wrap: wrap; - margin-bottom: 5px; - - .el-button + .el-button { - margin-left: 5px; - } - - .el-button { - margin-top: 5px; - } +fieldset { + padding: 10px 6px; + margin: 0; + border: 1px solid #EBEEF5; } - -.headerCon > .el-button:nth-child(4) { - margin-left: 0; -} - -.headerCon > .el-button:nth-child(7) { - margin-left: 0; -} - - -.smallBtn { - width: 82px; - text-align: center; - padding-left: 4.5px; -} - </style> -- Gitblit v1.9.3