From aa82e3631a7571ce14f44ab5cb57401abd89692e Mon Sep 17 00:00:00 2001 From: WX <1377869194@qq.com> Date: 星期五, 21 七月 2023 16:24:17 +0800 Subject: [PATCH] Merge branch 'master' of http://192.168.20.39:8989/r/LunarMidplane --- src/views/AuthorizationManagement/roleResAuthorization.vue | 417 ++++++++++++++++++++++------------------------------------- 1 files changed, 155 insertions(+), 262 deletions(-) diff --git a/src/views/AuthorizationManagement/roleResAuthorization.vue b/src/views/AuthorizationManagement/roleResAuthorization.vue index 26b9547..447ceb2 100644 --- a/src/views/AuthorizationManagement/roleResAuthorization.vue +++ b/src/views/AuthorizationManagement/roleResAuthorization.vue @@ -41,7 +41,7 @@ border @row-click="singleElection" highlight-current-row - height="calc(100% - 80px)" + height="calc(100% - 80px)" > <el-table-column align="center" @@ -123,221 +123,18 @@ </div> </div> <el-divider class="divider" /> - - <el-table - :data="usertableData" - border - style="width: 100%" - height="calc(100% - 80px)" - @selection-change="handleSelectionChange" - > - <el-table-column - type="selection" - width="55" - > </el-table-column> - <el-table-column - align="center" - type="index" - :label="$t('dataManage.styleObj.index')" - /> - <el-table-column - prop="resName" - :label="$t('operatManage.UserRoleAuthorizationObj.name')" - > - </el-table-column> - <el-table-column - prop="server" - :label="$t('operatManage.UserRoleAuthorizationObj.server')" - > - </el-table-column> - </el-table> - - <div - style="margin-top: 10px; text-align: center" - class="pagination_box" - > - <el-pagination - @size-change="userhandleSizeChange" - @current-change="userhandleCurrentChange" - :current-page="userlistData.pageIndex" - :page-sizes="[10, 20, 50, 100]" - :page-size="userlistData.pageSize" - layout="prev, pager, next" - :total="usercount" - > - </el-pagination> - </div> - </div> - </div> - - <!-- <div class="menuSettings_tree"> - <My-bread - :list="[ - `${$t('operatManage.operatManage')}`, - `${$t('operatManage.RoleResAuthorization')}`, - ]" - ></My-bread> - - <el-divider /> - <div class="menuTreeBox"> <el-tree - :data="depList" - :props="defaultProps" - :show-checkbox="true" - :check-on-click-node="true" - :check-strictly="true" - node-key="id" - @check="treeCheck" - ref="treeForm" + ref="tree" + :props="defaultLayerrops" + node-key="resid" + :data="layerData" + show-checkbox :default-expanded-keys="[1]" > </el-tree> </div> </div> - <div - class="menuSettings_tree" - style="margin-left: 10px; width: calc(50% - 172px)" - > - <div - style=" - font-size: 14px; - color: #606266; - line-height: 1; - cursor: text; - position: relative; - top: 10px; - margin-left: 10px; - " - > - {{ $t('operatManage.UserRoleAuthorizationObj.RoleTable') }} - </div> - <el-divider /> - <el-table - :data="tableData" - style="width: 100%" - @row-click="singleElection" - highlight-current-row - height="85%" - :header-cell-style="{ - background: 'transparent', - }" - > - <el-table-column align="center" width="55"> - <template slot-scope="scope"> - <el-radio - class="radio" - v-model="templateSelection" - :label="scope.row.id" - > </el-radio - > - </template> - </el-table-column> - <el-table-column - align="center" - type="index" - :label="$t('dataManage.styleObj.index')" - /> - <el-table-column - prop="name" - :label="$t('operatManage.UserRoleAuthorizationObj.name')" - > - </el-table-column> - </el-table> - <div style="text-align: center; margin-top: 20px"> - <el-pagination - @size-change="handleSizeChange" - @current-change="handleCurrentChange" - :current-page="listData.pageIndex" - :page-sizes="[10, 20, 50, 100]" - :page-size="userlistData.pageSize" - layout="total, sizes, prev, pager, next, jumper" - :total="count" - > - </el-pagination> - </div> - </div> - <div class="menuSettings"> - <div - style=" - font-size: 14px; - color: #606266; - line-height: 1; - cursor: text; - position: relative; - top: 5px; - margin-left: 10px; - display: flex; - align-items: center; - " - > - <span> - {{ $t('operatManage.UserRoleAuthorizationObj.userTable') }}</span - > - <div class="btn" style="margin-left: auto"> - <el-button - v-if="menuStatus.insert" - type="primary" - icon="el-icon-circle-plus-outline" - size="small" - :disabled="roleid == null ? true : false" - @click="adduser" - >{{ $t('operatManage.UserRoleAuthorizationObj.Added') }}</el-button - > - <el-button - v-if="menuStatus.delete" - type="danger" - icon="el-icon-delete" - size="small" - @click="deletesUser" - :disabled="roleid == null ? true : false" - >{{ $t('operatManage.UserRoleAuthorizationObj.delete') }}</el-button - > - </div> - </div> - <el-divider class="divider" /> - - <el-table - :data="usertableData" - stripe - style="width: 100%" - height="85%" - @selection-change="handleSelectionChange" - :header-cell-style="{ - background: 'transparent', - }" - > - <el-table-column type="selection" width="55"> </el-table-column> - <el-table-column - align="center" - type="index" - :label="$t('dataManage.styleObj.index')" - /> - <el-table-column - prop="resName" - :label="$t('operatManage.UserRoleAuthorizationObj.name')" - > - </el-table-column> - <el-table-column - prop="server" - :label="$t('operatManage.UserRoleAuthorizationObj.server')" - > - </el-table-column> - </el-table> - - <div style="margin-top: 20px; text-align: center" class="pagination_box"> - <el-pagination - @size-change="userhandleSizeChange" - @current-change="userhandleCurrentChange" - :current-page="userlistData.pageIndex" - :page-sizes="[10, 20, 50, 100]" - :page-size="userlistData.pageSize" - layout="total, sizes, prev, pager, next, jumper" - :total="usercount" - > - </el-pagination> - </div> - </div> --> <el-dialog :title="$t('operatManage.UserRoleAuthorizationObj.Added')" :visible.sync="dialogTableVisible" @@ -411,6 +208,10 @@ roleResDeletes, resSelectCountForRole, roleResInserts, + res_selectAll, + roleRes_selectResByRole, + roleRes_inserts, + roleRes_deletes } from '../../api/api'; export default { //import寮曞叆鐨勭粍浠堕渶瑕佹敞鍏ュ埌瀵硅薄涓墠鑳戒娇鐢� @@ -443,7 +244,10 @@ templateSelection: '', // 褰撳墠閫夋嫨鐨勮鐨勬暟鎹� checkList: [], - + defaultLayerrops: { + children: "children", + label: "cnName", + }, defaultProps: { children: 'children', label: 'name', @@ -461,6 +265,9 @@ debid: null, roleid: null, addmultipleSelection: [], + layerData: [], + layeroption: [] + }; }, methods: { @@ -489,50 +296,91 @@ }) .catch(() => { }); }, - adduser() { - this.dialogTableVisible = true; - this.getadduserList(); + async adduser() { + var val = this.$refs.tree.getCheckedNodes(false, true); // 鍒╃敤杩欎釜鏂规硶灏卞彲浠ヨ幏鍙栧埌瀛愯妭鐐�+鐖惰妭鐐�) + + var std = []; + for (var i in val) { + if (val[i].id == 0) { + val[i].roleid = this.roleid + std.push(val[i]) + } + } + if (std.length == 0) { + return + } + const data = await roleRes_inserts(std) + if (data.code != 200) { + this.$message.error('鎺堟潈澶辫触'); + } else { + this.$message({ + type: 'success', + message: '鎺堟潈鎴愬姛!', + }); + } + this.getuserList(); + // this.dialogTableVisible = true; + // this.getadduserList(); }, //鐢ㄦ埛鍒犻櫎 async deletesUser() { - let arr = []; - this.usermultipleSelection.forEach((e) => { - arr.push(e.id); - }); - this.$confirm('姝ゆ搷浣滃皢姘镐箙鍒犻櫎璇ユ潈闄�, 鏄惁缁х画?', '鎻愮ず', { - confirmButtonText: '纭畾', - cancelButtonText: '鍙栨秷', - type: 'warning' - }).then(async () => { - const data = await roleResDeletes({ ids: arr.toString() }); - if (data.code == 200) { - this.InsertFormdialog = false; - this.$message({ - message: '鍒犻櫎鎴愬姛锛�', - type: 'success', - }); - this.getuserList(); - } else { - this.$message({ - message: '鍒犻櫎澶辫触锛�', - type: 'warning', - }); + var val = this.$refs.tree.getCheckedNodes(false, true); // 鍒╃敤杩欎釜鏂规硶灏卞彲浠ヨ幏鍙栧埌瀛愯妭鐐�+鐖惰妭鐐�) + var std = []; + for (var i in val) { + if (val[i].id > 0) { + std.push(val[i].id) } - }).catch(() => { + } + var res = this.layeroption; + var arr = []; + for (var i in res) { + if (res[i].id > 0 && std.indexOf(res[i].id) == -1) { + arr.push(res[i].id) + } + } + if (arr.length == 0) { + return + } + const data = await roleRes_deletes({ ids: arr.toString() }); + if (data.code != 200) { + this.$message.error('鎺堟潈澶辫触'); + } else { this.$message({ - type: 'info', - message: '宸插彇娑堝垹闄�' + type: 'success', + message: '鎺堟潈鎴愬姛!', }); - }); - // const data = await roleResDeletes({ ids: arr.toString() }); - // if (data.code !== 200) { - // return this.$message.error('鍒犻櫎澶辫触'); - // } - // this.$message({ - // message: '鍒犻櫎鎴愬姛', - // type: 'success', + } + this.getuserList() + // let arr = []; + // this.usermultipleSelection.forEach((e) => { + // arr.push(e.id); // }); - // this.getuserList(); + // this.$confirm('姝ゆ搷浣滃皢姘镐箙鍒犻櫎璇ユ潈闄�, 鏄惁缁х画?', '鎻愮ず', { + // confirmButtonText: '纭畾', + // cancelButtonText: '鍙栨秷', + // type: 'warning' + // }).then(async () => { + // const data = await roleResDeletes({ ids: arr.toString() }); + // if (data.code == 200) { + // this.InsertFormdialog = false; + // this.$message({ + // message: '鍒犻櫎鎴愬姛锛�', + // type: 'success', + // }); + // this.getuserList(); + // } else { + // this.$message({ + // message: '鍒犻櫎澶辫触锛�', + // type: 'warning', + // }); + // } + // }).catch(() => { + // this.$message({ + // type: 'info', + // message: '宸插彇娑堝垹闄�' + // }); + // }); + }, //鐢ㄦ埛琛ㄥ閫� handleSelectionChange(val) { @@ -571,6 +419,35 @@ handleCurrentChange(val) { this.listData.pageIndex = val; this.getRole(); + }, + //鑾峰彇璧勬簮鍒楄〃 + async getlayerTree() { + this.layerData = [] + const data = await res_selectAll(); + if (data.code != 200) { + return this.$message.error("鍥惧眰鍒楄〃鏌ヨ澶辫触"); + } + var val = this.setTreeData(data.result); + val.sort(function (a, b) { + return a.sort - b.sort + }) + this.layerData = val + }, + setTreeData(source) { + let cloneData = JSON.parse(JSON.stringify(source)); // 瀵规簮鏁版嵁娣卞害鍏嬮殕 + return cloneData.filter((father) => { + // 寰幆鎵�鏈夐」 + let branchArr = cloneData.filter((child) => father.resid == child.pid); + if (branchArr.length > 0) { + branchArr.sort(function (a, b) { + return a.sort - b.sort + }) + } + branchArr.length > 0 ? (father.children = branchArr) : ""; // 缁欑埗绾ф坊鍔犱竴涓猚hildren灞炴�э紝骞惰祴鍊� + // 灞炰簬鍚屼竴瀵硅薄闂锛屼緥濡傦細浠� a=b銆乧=1 锛岀劧鍚庡啀浠� b.c=c 锛� 閭d箞 a.c=b.c=c=1 锛涘悓鐞嗭紝鍚庣画浠� c.d=2 ,閭d箞 a.c.d 涔熸槸=2锛� + // 鐢辨寰幆澶氭鍚庯紝灏辫兘褰㈡垚鐩稿簲鐨勬爲褰㈡暟鎹粨鏋� + return father.pid == 0; // 杩斿洖涓�绾ц彍鍗� + }); }, // 瑙掕壊鍗曢�� singleElection(row) { @@ -620,25 +497,41 @@ } }, async getadduserList() { - this.addlistData.roleid = this.roleid; + // this.addlistData.roleid = this.roleid; - // this.addlistData.debid = this.debid; - const data = await resSelectCountForRole(this.addlistData); - if (data.code !== 200) { - return this.$message.error('鏂板璧勬簮鍒楄〃璇锋眰閿欒'); - } + // // this.addlistData.debid = this.debid; + // const data = await resSelectCountForRole(this.addlistData); + // if (data.code !== 200) { + // return this.$message.error('鏂板璧勬簮鍒楄〃璇锋眰閿欒'); + // } - this.gridData = data.result; - this.addcount = data.count; + // this.gridData = data.result; + // this.addcount = data.count; + + }, // 鐢ㄦ埛琛ㄨ姹� async getuserList() { - const data = await roleReselectByPageAndCount(this.userlistData); + this.layerData = []; + this.layeroption = []; + + const data = await roleRes_selectResByRole({ roleid: this.userlistData.roleid }); if (data.code !== 200) { - return this.$message.error('鐢ㄦ埛璧勬簮鍒楄〃璇锋眰閿欒'); + return this.$message.error('鏍规嵁ID鏌ヨ璧勬簮澶辫触'); } - this.usertableData = data.result; - this.usercount = data.count; + var std = []; + this.layeroption = data.result; + for (var i in data.result) { + if (data.result[i].id > 0 && data.result[i].type != 1) { + std.push(data.result[i].resid) + } + } + var val = this.setTreeData(data.result); + val.sort(function (a, b) { + return a.sort - b.sort + }) + this.layerData = val + this.$refs.tree.setCheckedKeys(std); }, // 瑙掕壊琛ㄨ姹� async getRole() { @@ -676,6 +569,7 @@ } } this.getMenuTree(); + // this.getlayerTree(); }, }; </script> @@ -685,14 +579,14 @@ height: calc(100% - 20px); //height: 98%; width: 98%; - padding:10px 1%; + padding: 10px 1%; .menuSettings_tree { width: 100%; height: 100%; display: flex; justify-content: space-around; - .content_left_box{ + .content_left_box { padding: 10px; width: 20%; height: calc(100% - 20px); @@ -717,5 +611,4 @@ .el-table /deep/ tr { background-color: transparent !important; } - </style> -- Gitblit v1.9.3