From a1d1a7e006081b716774be1688bba6ebbdde2fbb Mon Sep 17 00:00:00 2001
From: Surpriseplus <845948745@qq.com>
Date: 星期一, 17 十月 2022 11:02:52 +0800
Subject: [PATCH] 资源配置

---
 src/api/api.js                                              |   16 +
 src/assets/lang/zh.js                                       |    1 
 public/config/config.js                                     |    4 
 src/views/AuthorizationManagement/roleResAuthorization.vue  |    5 
 src/views/AuthorizationManagement/roleMenuAuthorization.vue |  576 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/assets/lang/en.js                                       |    3 
 src/router/index.js                                         |   10 
 7 files changed, 611 insertions(+), 4 deletions(-)

diff --git a/public/config/config.js b/public/config/config.js
index 1c4b53c..6be7033 100644
--- a/public/config/config.js
+++ b/public/config/config.js
@@ -1,5 +1,5 @@
-//const BASE_URL = 'http://192.168.20.55:12316';
-const BASE_URL = 'http://192.168.20.39:12316';
+const BASE_URL = 'http://192.168.20.55:12316';
+//const BASE_URL = 'http://192.168.20.39:12316';
 var gisUrl = 'http://183.162.245.49:3301';
 var ifreamUrl = 'http://192.168.20.39:12306/';
 
diff --git a/src/api/api.js b/src/api/api.js
index 709823c..53cca13 100644
--- a/src/api/api.js
+++ b/src/api/api.js
@@ -333,3 +333,19 @@
 export function resSelectCountForRole(params) {
   return request.get('/res/selectCountForRole', { params: params });
 }
+//瑙掕壊鑿滃崟-鏍规嵁瑙掕壊ID+鑿滃崟ID鍒嗛〉鏌ヨ骞惰繑鍥炶褰曟暟
+export function roleMenuAuthelectByPageForRole(params) {
+  return request.get('/roleMenuAuth/selectByPageForRole', { params: params });
+}
+//瑙掕壊鑿滃崟-鎻掑叆澶氭
+export function roleMenuAuthInserts(params) {
+  return request.post('/roleMenuAuth/inserts', params);
+}
+//瑙掕壊鑿滃崟-鍒犻櫎澶氭潯
+export function roleMenuAuthDeletes(params) {
+  return request.get('/roleMenuAuth/deletes', { params: params });
+}
+//鑿滃崟鏉冮檺-鏍规嵁瑙掕壊ID+鑿滃崟ID鍒嗛〉鏌ヨ骞惰繑鍥炶褰曟暟
+export function menuAuthSelectByPageForRole(params) {
+  return request.get('/menuAuth/selectByPageForRole', { params: params });
+}
diff --git a/src/assets/lang/en.js b/src/assets/lang/en.js
index 36b91ec..a3686ad 100644
--- a/src/assets/lang/en.js
+++ b/src/assets/lang/en.js
@@ -106,7 +106,8 @@
     ResourceLog: 'Resource Log',
     UserRoleAuthorization: 'User Role Authorization',
     MenuRoleAuthorization: 'Menu Permission Authorization',
-    RoleResAuthorization: 'Role resource authorization',
+    RoleResAuthorization: 'Role Resource Authorization',
+    RoleMenuAuthorization: 'Role Menu Authorization',
     UserRoleAuthorizationObj: {
       RoleTable: 'Role Table',
       userTable: 'user Table',
diff --git a/src/assets/lang/zh.js b/src/assets/lang/zh.js
index 2994468..7a3c5f5 100644
--- a/src/assets/lang/zh.js
+++ b/src/assets/lang/zh.js
@@ -108,6 +108,7 @@
     UserRoleAuthorization: '鐢ㄦ埛瑙掕壊鎺堟潈',
     MenuRoleAuthorization: '鑿滃崟鏉冮檺鎺堟潈',
     RoleResAuthorization: '瑙掕壊璧勬簮鎺堟潈',
+    RoleMenuAuthorization: '瑙掕壊鑿滃崟鎺堟潈',
     UserRoleAuthorizationObj: {
       RoleTable: '瑙掕壊琛�',
       userTable: '鐢ㄦ埛琛�',
diff --git a/src/router/index.js b/src/router/index.js
index c52e652..eeb2a3a 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -41,6 +41,7 @@
 
 import menuRoleAuthorization from '@/views/AuthorizationManagement/menuRoleAuthorization.vue'; //绯荤粺绠$悊-鑿滃崟鏉冮檺鎺堟潈
 import roleResAuthorization from '@/views/AuthorizationManagement/roleResAuthorization.vue'; //绯荤粺绠$悊-瑙掕壊璧勬簮鎺堟潈
+import roleMenuAuthorization from '@/views/AuthorizationManagement/roleMenuAuthorization.vue'; //绯荤粺绠$悊-瑙掕壊鑿滃崟鎺堟潈
 
 const originalPush = VueRouter.prototype.push;
 
@@ -375,6 +376,15 @@
           requireAuth: true, // 鏍囪瘑璇ヨ矾鐢辨槸鍚﹂渶瑕佺櫥褰�
         },
       },
+      {
+        path: '/roleMenuAuthorization',
+        component: roleMenuAuthorization,
+        name: 'roleMenuAuthorization',
+        meta: {
+          title: '鑿滃崟鏉冮檺鎺堟潈',
+          requireAuth: true, // 鏍囪瘑璇ヨ矾鐢辨槸鍚﹂渶瑕佺櫥褰�
+        },
+      },
     ],
   },
 ];
diff --git a/src/views/AuthorizationManagement/roleMenuAuthorization.vue b/src/views/AuthorizationManagement/roleMenuAuthorization.vue
new file mode 100644
index 0000000..6338f65
--- /dev/null
+++ b/src/views/AuthorizationManagement/roleMenuAuthorization.vue
@@ -0,0 +1,576 @@
+<template>
+  <div class="menuSettings_box">
+    <!-- 瑙掕壊锛屽崟浣� -->
+    <div
+      class="menuSettings_tree"
+      style="margin-left: 10px; width: calc(50% - 172px)"
+    >
+      <My-bread
+        :list="[
+          `${$t('operatManage.operatManage')}`,
+          `${$t('operatManage.RoleMenuAuthorization')}`,
+        ]"
+      ></My-bread>
+
+      <el-divider />
+      <el-form ref="form" :model="selFrom">
+        <el-form-item label="鍗曚綅">
+          <el-select
+            ref="multiSelect"
+            style="width: 300px"
+            v-model="selFrom.name"
+            placeholder="璇烽�夋嫨鍗曚綅鍚嶇О..."
+            @change="chooseCustom"
+          >
+            <el-option
+              :value="selectTree"
+              class="setstyle"
+              style="overflow: auto; height: 200px"
+              disabled
+            >
+              <el-tree
+                :data="depList"
+                :props="defaultProps"
+                :check-on-click-node="true"
+                :check-strictly="true"
+                node-key="id"
+                ref="treeForm"
+                @node-click="addAdminHandleNodeClick"
+              >
+              </el-tree>
+            </el-option>
+          </el-select>
+        </el-form-item>
+      </el-form>
+      <div style="height: 75%">
+        <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">
+              <!-- 鍙互鎵嬪姩鐨勪慨鏀筶abel鐨勫�硷紝浠庤�屾帶鍒堕�夋嫨鍝竴椤� -->
+              <el-radio
+                class="radio"
+                v-model="templateSelection"
+                :label="scope.row.id"
+                >&nbsp;</el-radio
+              >
+            </template>
+          </el-table-column>
+          <el-table-column
+            prop="id"
+            :label="$t('operatManage.UserRoleAuthorizationObj.serialNumber')"
+          >
+          </el-table-column>
+          <el-table-column
+            prop="name"
+            :label="$t('operatManage.UserRoleAuthorizationObj.name')"
+          >
+          </el-table-column>
+        </el-table>
+      </div>
+      <div style="margin-top: 20px; text-align: center" class="pagination_box">
+        <el-pagination
+          @size-change="dephandleSizeChange"
+          @current-change="dephandleCurrentChange"
+          :current-page="roleDepListData.pageIndex"
+          :page-sizes="[10, 20, 30, 40]"
+          :page-size="roleDepListData.pageSize"
+          layout="total, sizes, prev, pager, next, jumper"
+          :total="roleDepCount"
+        >
+        </el-pagination>
+      </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: 5px;
+          margin-left: 10px;
+          display: flex;
+          align-items: center;
+        "
+      >
+        <span>
+          {{
+            $t('operatManage.UserRoleAuthorizationObj.PermissionTable')
+          }}</span
+        >
+      </div>
+      <el-divider />
+      <div class="menuTreeBox">
+        <el-tree
+          :data="menuList"
+          :props="defaultMenuProps"
+          :show-checkbox="true"
+          :check-on-click-node="true"
+          :check-strictly="true"
+          node-key="id"
+          @check="menuTreeCheck"
+          ref="treeForm"
+        >
+        </el-tree>
+      </div>
+    </div>
+
+    <div class="menuSettings">
+      <!-- <div class="title_box">
+        <h4>璇︾粏淇℃伅</h4>
+      </div> -->
+      <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.PermissionTable')
+          }}</span
+        >
+        <div class="btn" style="margin-left: auto">
+          <el-button
+            type="primary"
+            icon="el-icon-circle-plus-outline"
+            size="small"
+            @click="adduser"
+            :disabled="menuid == null ? true : false"
+            >{{ $t('operatManage.UserRoleAuthorizationObj.Added') }}</el-button
+          >
+          <el-button
+            type="danger"
+            icon="el-icon-delete"
+            size="small"
+            @click="deletesUser"
+            :disabled="menuid == null ? true : false"
+            >{{ $t('operatManage.UserRoleAuthorizationObj.delete') }}</el-button
+          >
+        </div>
+      </div>
+      <el-divider class="divider" />
+
+      <el-table
+        :data="menuTableData"
+        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
+          prop="id"
+          :label="$t('operatManage.UserRoleAuthorizationObj.serialNumber')"
+        >
+        </el-table-column>
+        <el-table-column
+          prop="name"
+          :label="$t('operatManage.UserRoleAuthorizationObj.name')"
+        >
+        </el-table-column>
+      </el-table>
+
+      <div style="margin-top: 20px; text-align: center" class="pagination_box">
+        <el-pagination
+          @size-change="authhandleSizeChange"
+          @current-change="authhandleCurrentChange"
+          :current-page="rolMenuListData.pageIndex"
+          :page-sizes="[10, 20, 30, 40]"
+          :page-size="rolMenuListData.pageSize"
+          layout="total, sizes, prev, pager, next, jumper"
+          :total="roleMenuCount"
+        >
+        </el-pagination>
+      </div>
+    </div>
+    <el-dialog
+      :title="$t('operatManage.UserRoleAuthorizationObj.Added')"
+      :visible.sync="dialogTableVisible"
+    >
+      <el-table
+        :data="gridData"
+        height="40vh"
+        @selection-change="addhandleSelectionChange"
+      >
+        <el-table-column type="selection" width="55"> </el-table-column>
+        <el-table-column
+          prop="id"
+          :label="$t('operatManage.UserRoleAuthorizationObj.serialNumber')"
+        >
+        </el-table-column>
+        <el-table-column
+          prop="name"
+          :label="$t('operatManage.UserRoleAuthorizationObj.name')"
+        >
+        </el-table-column>
+      </el-table>
+      <div style="margin-top: 20px; text-align: center" class="pagination_box">
+        <el-pagination
+          @size-change="addhandleSizeChange"
+          @current-change="addhandleCurrentChange"
+          :current-page="addlistData.pageIndex"
+          :page-sizes="[10, 20, 30, 40]"
+          :page-size="addlistData.pageSize"
+          layout="total, sizes, prev, pager, next, jumper"
+          :total="addcount"
+        >
+        </el-pagination>
+      </div>
+      <div slot="footer" class="dialog-footer">
+        <el-button @click="dialogTableVisible = false">{{
+          $t('dataManage.dictionaryManageObj.cancel')
+        }}</el-button>
+        <el-button type="primary" @click="addConfirm">{{
+          $t('dataManage.dictionaryManageObj.confirm')
+        }}</el-button>
+      </div>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import MyBread from '../../components/MyBread.vue';
+import {
+  queryDepTree,
+  select_Role_ByPageAndCount,
+  selectMenuRecursive,
+  roleMenuAuthelectByPageForRole,
+  menuAuthSelectByPageForRole,
+  roleMenuAuthInserts,
+  roleMenuAuthDeletes,
+} from '../../api/api';
+export default {
+  //import寮曞叆鐨勭粍浠堕渶瑕佹敞鍏ュ埌瀵硅薄涓墠鑳戒娇鐢�
+  components: {
+    MyBread,
+  },
+
+  data() {
+    return {
+      dialogTableVisible: false,
+      selFrom: { name: '' },
+      selectTree: '',
+      depList: [], //el鏍戞暟鎹�
+      defaultProps: {
+        children: 'children',
+        label: 'name',
+      }, //鏍戠粦瀹氬璞�
+      defaultMenuProps: {
+        children: 'children',
+        label: 'cnName',
+      }, //鑿滃崟琛ㄧ粦瀹氭潈闄�
+      depid: null, //鍗曚綅ID
+      roleDepListData: {
+        pageIndex: 1,
+        pageSize: 10,
+      },
+      rolMenuListData: {
+        pageIndex: 1,
+        pageSize: 10,
+      },
+      addlistData: { pageIndex: 1, pageSize: 10 },
+      addcount: 0,
+      roleDepCount: 0,
+      roleMenuCount: 0,
+      roleDepCheckList: [],
+
+      tableData: [], //瑙掕壊鍒楄〃
+      templateSelection: '',
+      menuList: [],
+      roleid: null,
+      menuid: null,
+      menuTableData: [],
+      gridData: [],
+      addmultipleSelection: [],
+      usermultipleSelection: [],
+    };
+  },
+  methods: {
+    async getDepTree() {
+      //鑾峰彇鐩綍鏍戞渶澶D锛屾柊寤鸿妭鐐逛娇鐢�
+      const data = await queryDepTree();
+      if (data.code !== 200) {
+        return this.$message.error('璇锋眰鍗曚綅鎶ラ敊');
+      }
+      this.depList = this.treeData(data.result);
+    },
+    async getMenuTree() {
+      const data = await selectMenuRecursive({ name: '绠¢亾鍩虹澶ф暟鎹钩鍙�' });
+      if (data.code !== 200) {
+        return this.$message.error('璇锋眰鍗曚綅鎶ラ敊');
+      }
+
+      this.menuList = this.treeData(data.result);
+    },
+    treeData(source) {
+      let cloneData = JSON.parse(JSON.stringify(source)); // 瀵规簮鏁版嵁娣卞害鍏嬮殕
+      return cloneData.filter((father) => {
+        // 寰幆鎵�鏈夐」
+        let branchArr = cloneData.filter((child) => father.id == child.pid); // 瀵规瘮ID锛屽垎鍒笂涓嬬骇鑿滃崟锛屽苟杩斿洖鏁版嵁
+        branchArr.length > 0 ? (father.children = branchArr) : ''; // 缁欑埗绾ф坊鍔犱竴涓猚hildren灞炴�э紝骞惰祴鍊�
+        return father.pid == 0; // 杩斿洖涓�绾ц彍鍗�
+      });
+    },
+    //鏍戦�変腑鑺傜偣
+    addAdminHandleNodeClick(e) {
+      this.roleDepCheckList = [];
+      this.templateSelection = '';
+      this.depid = e.id;
+      this.selFrom.name = e.name;
+      this.selectTree = e.name;
+      this.getRoleDep();
+      this.getMenuTree();
+    },
+    menuTreeCheck(node, list) {
+      if (list.checkedNodes.length > 0) {
+        this.rolMenuListData.menuid = node.id;
+        this.menuid = node.id;
+        this.rolMenuListData.roleid = this.roleid;
+        this.getRoleMenu();
+      } else {
+        this.menuid = null;
+      }
+    },
+    async getRoleMenu() {
+      const data = await roleMenuAuthelectByPageForRole(this.rolMenuListData);
+      if (data.code !== 200) {
+        return this.$message.error('瑙掕壊鑿滃崟璇锋眰閿欒');
+      }
+      this.menuTableData = data.result;
+      this.roleMenuCount = data.count;
+    },
+    async getRoleDep() {
+      this.roleDepListData.depid = this.depid;
+      const data = await select_Role_ByPageAndCount(this.roleDepListData);
+      if (data.code !== 200) {
+        return this.$message.error('鐢ㄦ埛瑙掕壊璇锋眰閿欒');
+      }
+      this.tableData = data.result;
+      this.roleDepCount = data.count;
+    },
+    async getadduserList() {
+      this.addlistData.roleid = this.roleid;
+      this.addlistData.menuid = this.menuid;
+      const data = await menuAuthSelectByPageForRole(this.addlistData);
+      if (data.code !== 200) {
+        return this.$message.error('鑿滃崟鏉冮檺鍒楄〃璇锋眰閿欒');
+      }
+      this.gridData = data.result;
+      this.addcount = data.count;
+    },
+    singleElection(row) {
+      this.templateSelection = row.id;
+      this.roleid = row.id;
+      this.roleDepCheckList = this.tableData.filter(
+        (item) => item.id === row.id
+      );
+    },
+    //涓嬫媺妗嗛�変腑鍚庤嚜鍔ㄥ叧闂�
+    chooseCustom() {
+      setTimeout(() => {
+        this.$refs.multiSelect.blur();
+      }, 50);
+    },
+    dephandleSizeChange() {
+      this.roleDepListData.pageSize = val;
+      this.getDepTree();
+    },
+    dephandleCurrentChange() {
+      this.roleDepListData.pageIndex = val;
+      this.getDepTree();
+    },
+    authhandleSizeChange() {
+      this.roleDepListData.pageSize = val;
+      this.getRoleMenu();
+    },
+    authhandleCurrentChange() {
+      this.roleDepListData.pageIndex = val;
+      this.getRoleMenu();
+    },
+    // 鏂板鐢ㄦ埛琛ㄥ垎椤�
+    addhandleSizeChange(val) {
+      this.addlistData.pageSize = val;
+      this.getadduserList();
+    },
+    // 鏂板鐢ㄦ埛琛ㄥ垎椤�
+    addhandleCurrentChange(val) {
+      this.addlistData.pageIndex = val;
+      this.getadduserList();
+    },
+    addhandleSelectionChange(val) {
+      this.addmultipleSelection = val;
+    },
+    handleSelectionChange(val) {
+      this.usermultipleSelection = val;
+    },
+    adduser() {
+      this.dialogTableVisible = true;
+      this.getadduserList();
+    },
+    async deletesUser() {
+      let arr = [];
+      this.usermultipleSelection.forEach((e) => {
+        arr.push(e.id);
+      });
+      const data = await roleMenuAuthDeletes({ ids: arr.toString() });
+      if (data.code !== 200) {
+        return this.$message.error('鍒犻櫎澶辫触');
+      }
+      this.$message({
+        message: '鍒犻櫎鎴愬姛',
+        type: 'success',
+      });
+      this.getRoleMenu();
+    },
+    addConfirm() {
+      this.$confirm('纭畾鏄惁鏂板', '鎻愮ず', {
+        confirmButtonText: '纭畾',
+        cancelButtonText: '鍙栨秷',
+        type: 'warning',
+      })
+        .then(async () => {
+          let arr = [];
+          this.addmultipleSelection.forEach((e) => {
+            arr.push({ menuAuthId: e.id, roleid: this.roleid });
+          });
+          const data = await roleMenuAuthInserts(arr);
+          if (data.code !== 200) {
+            return this.$message.error('鏂板澶辫触');
+          }
+
+          this.$message({
+            type: 'success',
+            message: '鏂板鎴愬姛!',
+          });
+          this.dialogTableVisible = false;
+          this.getRoleMenu();
+        })
+        .catch(() => {});
+    },
+  },
+  created() {
+    this.getDepTree();
+    this.getMenuTree();
+  },
+};
+</script>
+<style lang="less" scoped>
+//@import url(); 寮曞叆鍏叡css绫�
+.menuSettings_box {
+  //   background: rgb(240, 242, 245);
+  border-radius: 10px;
+  height: 100%;
+  padding: 10px;
+  box-sizing: border-box;
+  display: flex;
+  .menuSettings_tree {
+    position: relative;
+    width: 344px;
+    height: 100%;
+    background: rgb(240, 242, 245);
+    padding: 20px;
+    border-radius: 10px;
+    box-sizing: border-box;
+    overflow: auto;
+    .saveBtn {
+      position: absolute;
+      left: 250px;
+      top: 23px;
+    }
+    .menuTreeBox {
+      height: 90%;
+      overflow: auto;
+      .el-tree {
+        background: transparent;
+        font-size: 15px;
+        font-family: Microsoft YaHei;
+        font-weight: 400;
+        color: #000000;
+        // /deep/ .el-tree-node__label {
+        //   font-size: 18px;
+        // }
+        /deep/ .el-tree-node {
+          padding-top: 10px;
+          // padding-bottom: 10px;
+        }
+        /deep/ .el-tree-node:focus > .el-tree-node__content {
+          background-color: #b9b9b9;
+        }
+        /deep/ .el-tree-node__content:hover {
+          background-color: rgb(153, 153, 153);
+        }
+        .btnBox {
+          margin-left: 5px;
+          .el-button + .el-button {
+            margin-left: 5px;
+          }
+        }
+      }
+    }
+  }
+  .menuSettings {
+    width: calc(50% - 172px);
+    border-radius: 10px;
+    background: rgb(240, 242, 245);
+    margin-left: 10px;
+    height: 100%;
+    padding: 20px;
+    box-sizing: border-box;
+    .title_box {
+      background: #fff;
+      padding: 10px;
+      margin-bottom: 24px;
+      display: flex;
+      border-radius: 10px;
+      border: 1px solid rgb(202, 201, 204);
+      box-sizing: border-box;
+    }
+  }
+  .table_box {
+    padding: 10px;
+    background: #fff;
+    border-radius: 5px;
+    border: 1px solid rgb(202, 201, 204);
+    overflow: auto;
+    height: 85%;
+  }
+  .divider {
+    margin-top: 8px;
+  }
+}
+.el-table,
+.el-table /deep/ .el-table__expanded-cell {
+  background-color: transparent;
+}
+
+.el-table /deep/ th,
+.el-table /deep/ tr {
+  background-color: transparent;
+}
+</style>
diff --git a/src/views/AuthorizationManagement/roleResAuthorization.vue b/src/views/AuthorizationManagement/roleResAuthorization.vue
index 734e1de..fdd1d71 100644
--- a/src/views/AuthorizationManagement/roleResAuthorization.vue
+++ b/src/views/AuthorizationManagement/roleResAuthorization.vue
@@ -103,7 +103,9 @@
           align-items: center;
         "
       >
-        <span> {{ $t('operatManage.UserRoleAuthorizationObj.ResTable') }}</span>
+        <span>
+          {{ $t('operatManage.UserRoleAuthorizationObj.userTable') }}</span
+        >
         <div class="btn" style="margin-left: auto">
           <el-button
             type="primary"
@@ -411,6 +413,7 @@
       if (data.code !== 200) {
         return this.$message.error('鏂板璧勬簮鍒楄〃璇锋眰閿欒');
       }
+      debugger;
       this.gridData = data.result;
       this.addcount = data.count;
     },

--
Gitblit v1.9.3