zhaoke 2 anni fa
parent
commit
908545eee2

+ 13 - 6
src/views/newRole/css/index.scss

@@ -26,7 +26,12 @@
         }
       }
       &-bottom {
-        height: calc(100% - 138px);
+        height: calc(100% - 128px);
+        .treeArr{
+          .customTxt{
+            font-size: 14px;
+          }
+        }
         .contents {
           padding: 0 24px;
           height: 42px;
@@ -146,15 +151,17 @@
           .newRole-content-left-bottom{
             padding: 0 24px;
             ::v-deep .multipleTable {
-              .DisabledSelection .cell .el-checkbox__inner {
-                display: none;
-                position: relative;
+              .DisabledSelection .cell {
+                text-align: left;
+                .el-checkbox{
+                  margin-left: 18px;
+                }
               }
               .DisabledSelection .cell:before {
-                content: "是否可用";
+                content: "全选";
                 position: absolute;
                 left: 50%;
-                margin-left: -28px;
+                // margin-left: -28px;
               }
               .cell{
                 text-align: center;

+ 135 - 88
src/views/newRole/index.vue

@@ -14,16 +14,13 @@
         </div>
         <div v-loading="loading" element-loading-text="拼命加载中" element-loading-spinner="el-icon-loading" element-loading-background="rgba(0, 0, 0, 0.8)" class="newRole-content-left-bottom">
           <el-scrollbar ref="scroll" style="height: 100%">
-            <div>
+            <div class="treeArr">
               <el-tree ref="treeArr" :data="arrs" :props="defaultArrProps" highlight-current :filter-node-method="filterArrNode" default-expand-all node-key="user_group_id" @node-click="handleClick" :expand-on-click-node="false">
-                <span class="custom-tree-node" slot-scope="{ node, data }">
+                <span class="custom-tree-node" slot-scope="{ node }">
                   <div class="flex">
                     <div>
                       <span class="customTxt">{{ node.label }}</span>
                     </div>
-                    <div v-show="activeIndex == data.user_group_id" class="right">
-                      <span @click.stop="handleError" class="error">删除</span>
-                    </div>
                   </div>
                 </span>
               </el-tree>
@@ -36,7 +33,7 @@
           <div class="newRole-content-right-bottom contents1 flex1">
             <div class="newRole-content-left-top">
               <div class="flex head">
-                <div class="title">权限列表</div>
+                <div class="title">功能授权</div>
               </div>
               <div class="search">
                 <el-input size="small" placeholder="请输入内容" clearable prefix-icon="el-icon-search" :filter-node-method="filterNode" v-model="filterText">
@@ -50,7 +47,7 @@
                     <span class="custom-tree-node" slot-scope="{ node, data }">
                       <span class="customTxt">{{ node.label }}</span>
                       <span v-show="treeCheckId == data.auth_id" class="customBtn">
-                        <span @click="setItem(node,data)" v-if="data.auth_id != 0 && data.auth_type == 4" class="ym">列授权</span>
+                        <span @click.stop="setItem(node,data)" v-if="data.auth_id != 0 && data.auth_type == 4" class="ym">列授权</span>
                       </span>
                     </span>
                   </el-tree>
@@ -61,19 +58,19 @@
           <div class="newRole-content-right-bottom contents2 flex1">
             <div class="newRole-content-left-top">
               <div class="flex head">
-                <div class="title">授权</div>
+                <div class="title">数据授权</div>
                 <el-button type="primary" @click="handleColSave" class="bcButton" size="small">保存</el-button>
               </div>
             </div>
             <div class="newRole-content-left-bottom">
-              <el-table ref="multipleTable" class="multipleTable" :data="checkArrs" border stripe :maxHeight="tableHeight" tooltip-effect="dark" style="width: 100%;" @selection-change="handleSelectionChange">
+              <el-table ref="multipleTable" class="multipleTable" :data="checkArrs" border max-height="700" stripe tooltip-effect="dark" style="width: 100%;" @selection-change="handleSelectionChange">
                 <el-table-column label-class-name="DisabledSelection" type="selection" width="100">
                 </el-table-column>
                 <el-table-column prop="columnLabel" label="列名">
                 </el-table-column>
                 <el-table-column label="行授权">
                   <template slot-scope="scope">
-                    <el-input size="small" placeholder="请输入内容" v-model="scope.row.rowauth" clearable>
+                    <el-input size="small" placeholder="请输入内容" v-model="scope.row.row_auth" clearable>
                     </el-input>
                   </template>
                 </el-table-column>
@@ -163,18 +160,8 @@ export default {
       checkDatas: [],
       checkGroups: [],
       multipleTable: [],
-      rmFlag: false
-    }
-  },
-  computed: {
-    tableHeight () {
-      const dom = document.querySelector('.contents2')
-      if (dom) {
-        const height = dom.clientHeight
-        return height
-      } else {
-        return 500
-      }
+      rmFlag: false,
+      msgUserId: ''
     }
   },
   watch: {
@@ -183,6 +170,9 @@ export default {
     },
     search (val) {
       this.$refs.treeArr.filter(val);
+    },
+    treeCheckId () {
+      this.checkArrs = []
     }
   },
   created () {
@@ -275,10 +265,16 @@ export default {
     //获取角色已有权限
     async getRoleQuth (item) {
       this.$refs.tree.setCheckedKeys([])
-      const { code, returnData } = await this.getQueryList(SERVICE_ID.authTreeId, { role_id: item.role_ID })
+      const newItem = _.cloneDeep(item)
+      const newObj = {}
+      if (newItem.hasOwnProperty('user_id')) {
+        newObj.user_id = newItem.user_id
+      } else {
+        newObj.user_group_id = newItem.user_group_id
+      }
+      const { code, returnData } = await this.getQueryList(SERVICE_ID.userAuthorizationId, newObj)
       if (code == 0) {
         const result = returnData
-        this.checkDatas.push(result)
         if (result && result.length) {
           const datas = []
           result.forEach(item => {
@@ -289,21 +285,33 @@ export default {
           const res = [...treeDatas, ...result].filter((item) => !(treeDatas.some((p) => item.auth_id == p.auth_id) && result.some((c) => item.auth_id == c.auth_id)))
           setTimeout(() => {
             res.forEach((item) => {
-              this.$refs.tree.setChecked(item.auth_id, false, false);
+              if (item.auth_id) {
+                this.$refs.tree.setChecked(item.auth_id, false, false);
+              }
             });
           }, 50);
+          setTimeout(() => {
+            const newTreeDatas = this.$refs.tree.getCheckedNodes().concat(this.$refs.tree.getHalfCheckedNodes())
+            const arrs = newTreeDatas.filter(item => item.auth_id != 0)
+            this.checkDatas.push(arrs)
+          }, 70);
         }
       }
     },
+    removeClass (elements) {
+      elements.className = '';
+    },
     //服务列表-点击
     handleClick (item) {
-      console.log(item)
       this.dataType = 'edit'
       this.dataObj = _.cloneDeep(item)
       this.formInline = _.cloneDeep(item)
       this.activeIndex = item.user_group_id
       this.flag = false
-      // this.getRoleQuth(item)
+      this.treeCheckId = null
+      this.$refs.tree.setCurrentKey(null)
+      this.msgUserId = null
+      this.getRoleQuth(item)
     },
     //服务列表-保存
     async handleSave () {
@@ -380,39 +388,64 @@ export default {
       this.rmFlag = true
     },
     handleNodeClick (data) {
+      this.msgUserId = null
       this.treeCheckId = data.auth_id
       this.treeCheckObj = data
+      // this.treeCheckId = null
+      // this.checkArrs = []
     },
-    checkChange () {
-      if (this.dataObj.role_ID) {
+    async checkChange () {
+      if (this.dataObj.user_group_id) {
         const datas = this.$refs.tree.getCheckedNodes().concat(this.$refs.tree.getHalfCheckedNodes());
         const arrs = datas.filter(item => item.auth_id != 0)
         this.checkDatas.push(arrs)
-        const data1 = this.checkDatas[this.checkDatas.length - 1]; //最后一条数据
-        const data2 = this.checkDatas[this.checkDatas.length - 2]; //倒数第二条数据
-        if (data1.length > data2.length) {
-          this.checksBoxTs(data1, data2, "add");
+        if (this.checkDatas.length == 1) {
+          const res = this.checkDatas[this.checkDatas.length - 1]; //最后一条数据
+          const addRes = []
+          const newItem = _.cloneDeep(this.dataObj)
+          res.forEach(item => {
+            if (newItem.hasOwnProperty('user_id')) {
+              item.user_id = newItem.user_id
+            } else {
+              item.user_group_id = newItem.user_group_id
+            }
+            addRes.push(item)
+          })
+          const { code } = await this.getChangeList(SERVICE_ID.userAuthorizationId, addRes, 1)
+          if (code == 0) {
+            setTimeout(() => {
+              this.getRoleQuth(this.dataObj)
+            }, 100);
+          }
+          this.tipMsg(code)
         } else {
-          this.checksBoxTs(data2, data1, "del");
+          const data1 = this.checkDatas[this.checkDatas.length - 1]; //最后一条数据
+          const data2 = this.checkDatas[this.checkDatas.length - 2]; //倒数第二条数据
+          if (data1.length > data2.length) {
+            this.checksBoxTs(data1, data2, "add");
+          } else {
+            this.checksBoxTs(data2, data1, "del");
+          }
         }
       } else {
-        this.$message.error('请选中角色后再操作');
+        this.$message.error('请选中账号后再操作');
         this.$refs.tree.setCheckedKeys([]);
       }
     },
     async checksBoxTs (datas, arr, type) {
       const res = [...datas, ...arr].filter((item) => !(datas.some((p) => item.auth_id == p.auth_id) && arr.some((c) => item.auth_id == c.auth_id)));
-      const msgs = []
+      const addRes = []
+      const newItem = _.cloneDeep(this.dataObj)
       res.forEach(item => {
-        msgs.push({
-          ID: item.ID
-        })
-        item.role_id = this.dataObj.role_ID
-        item.role_name = this.dataObj.role_name
-        item.role_status = this.dataObj.role_status
+        if (newItem.hasOwnProperty('user_id')) {
+          item.user_id = newItem.user_id
+        } else {
+          item.user_group_id = newItem.user_group_id
+        }
+        addRes.push(item)
       })
       if (type == 'add') {
-        const { code } = await this.getChangeList(SERVICE_ID.authTreeId, res, 1)
+        const { code } = await this.getChangeList(SERVICE_ID.userAuthorizationId, addRes, 1)
         if (code == 0) {
           setTimeout(() => {
             this.getRoleQuth(this.dataObj)
@@ -420,7 +453,7 @@ export default {
         }
         this.tipMsg(code)
       } else {
-        const { code } = await this.getChangeList(SERVICE_ID.authTreeId, msgs, 3)
+        const { code } = await this.getChangeList(SERVICE_ID.userAuthorizationId, addRes, 3)
         if (code == 0) {
           setTimeout(() => {
             this.getRoleQuth(this.dataObj)
@@ -431,21 +464,39 @@ export default {
       // this.checkArrs = []
     },
     async setItem (node, data) {
-      if (this.dataObj.role_ID) {
-        const { code, returnData } = await this.getQueryList(SERVICE_ID.getTableColumnId, { serviceOutPutId: data.auth_id })
+      if (this.dataObj.user_id || this.dataObj.user_group_id) {
+        this.msgUserId = data.auth_id
+        const newItem = _.cloneDeep(this.dataObj)
+        const addRes = []
+        const newObj = {}
+        if (newItem.hasOwnProperty('user_id')) {
+          newObj.user_id = newItem.user_id
+        } else {
+          newObj.user_group_id = newItem.user_group_id
+        }
+        addRes.push(newObj)
+        addRes.push({
+          auth_id: data.auth_id
+        })
+        const { code, returnData } = await this.getQueryList(SERVICE_ID.sysUserAuthId, [{ user_id: getToken('userid'), auth_id: data.auth_id }])
         if (code == 0) {
           const result = returnData
-          if (result && result) {
-            this.checkArrs = result
-            const { code, returnData } = await this.getQueryList(SERVICE_ID.authTreeId, [{ auth_id: data.auth_id }, { role_id: this.dataObj.role_ID }])
+          if (result && result.length) {
+            result.map(item => {
+              item.row_auth = null
+            })
+            this.checkArrs = [...result]
+            const { code, returnData } = await this.getQueryList(SERVICE_ID.userAuthorizationId, addRes)
             if (code == 0) {
-              const res = returnData
+              const res = returnData.filter(item => item.queryTemplateColumnSetID)
               if (res && res.length) {
+                // const caps = _.intersectionBy([result, res], 'queryTemplateColumnSetID')
+                // console.log(caps)
                 const resmsg = []
                 result.forEach((item) => {
                   res.forEach(p => {
                     if (item.queryTemplateColumnSetID == p.queryTemplateColumnSetID) {
-                      item.rowauth = p.rowauth
+                      item.row_auth = p.row_auth
                       resmsg.push(item)
                     }
                   })
@@ -455,59 +506,43 @@ export default {
                     this.$refs.multipleTable.toggleRowSelection(row);
                   });
                 }
-                this.checkGroups = resmsg
                 this.multipleTable = resmsg
               }
             }
           }
         }
       } else {
-        this.$message.error('请选中角色后再操作');
-      }
-    },
-    async groupChange (val) {
-      this.checkGroups.push(val)
-      if (this.checkGroups.length == 1) {
-        const res = this.getColName(val)
-        const result = this.sendCheckData(res)
-        const { code } = await this.getChangeList(SERVICE_ID.authTreeId, result, 1)
-        this.tipMsg(code)
-      } else if (this.checkGroups.length > 1) {
-        const data1 = this.checkGroups[this.checkGroups.length - 1]; //最后一条数据
-        const data2 = this.checkGroups[this.checkGroups.length - 2]; //倒数第二条数据
-        const msg = [...data1, ...data2].filter((item) => !(data1.some((p) => item == p) && data2.some((c) => item == c)));
-        const cap = this.getColName(msg)
-        const result = this.sendCheckData(cap)
-        if (data1.length > data2.length) {
-          const { code } = await this.getChangeList(SERVICE_ID.authTreeId, result, 1)
-          this.tipMsg(code)
-        } else {
-          const { code } = await this.getChangeList(SERVICE_ID.authTreeId, result, 3)
-          this.tipMsg(code)
-        }
+        this.$message.error('请选中账号后再操作');
       }
     },
     sendCheckData (arr, type = false) {
       const newData = []
+      const newItem = _.cloneDeep(this.dataObj)
       arr.forEach(item => {
         if (type) {
-          const obj = {
-            "role_id": this.dataObj.role_ID,
+          const newObj = {
             "auth_id": this.treeCheckObj.auth_id,
             "queryTemplateColumnSetID": item.queryTemplateColumnSetID,
           }
-          newData.push(obj)
+          if (newItem.hasOwnProperty('user_id')) {
+            newObj.user_id = newItem.user_id
+          } else {
+            newObj.user_group_id = newItem.user_group_id
+          }
+          newData.push(newObj)
         } else {
           const obj = {
-            "role_id": this.dataObj.role_ID,
-            "role_name": this.dataObj.role_name,
-            "role_status": this.dataObj.role_status,
             "auth_id": this.treeCheckObj.auth_id,
             "auth_type": this.treeCheckObj.auth_type,
             "queryTemplateColumnSetID": item.queryTemplateColumnSetID,
             "columnLabel": item.columnLabel,
             "columnname": item.columnName,
-            "rowauth": item.rowauth
+            "row_auth": item.row_auth
+          }
+          if (newItem.hasOwnProperty('user_id')) {
+            obj.user_id = newItem.user_id
+          } else {
+            obj.user_group_id = newItem.user_group_id
           }
           newData.push(obj)
         }
@@ -529,13 +564,25 @@ export default {
       this.multipleTable = val
     },
     async handleColSave () {
-      const result = this.sendCheckData(this.multipleTable)
-      const dis = this.sendCheckData(this.checkGroups, true)
-      if (dis && dis.length) {
-        await this.getChangeList(SERVICE_ID.authTreeId, dis, 3)
+      if (this.treeCheckObj.auth_id && this.dataObj.user_group_id && this.msgUserId) {
+        const newItem = _.cloneDeep(this.dataObj)
+        const newObj = {
+          "auth_id": this.treeCheckObj.auth_id,
+        }
+        if (newItem.hasOwnProperty('user_id')) {
+          newObj.user_id = newItem.user_id
+        } else {
+          newObj.user_group_id = newItem.user_group_id
+        }
+        const result = this.sendCheckData(this.multipleTable)
+        const tes = await this.getChangeList(SERVICE_ID.userAuthorizationId, [newObj], 3)
+        if (tes.code == 0) {
+          const { code } = await this.getChangeList(SERVICE_ID.userAuthorizationId, result, 1)
+          this.tipMsg(code)
+        }
+      } else {
+        this.$message.error('请先选中用户和权限后再操作列设置后保存数据')
       }
-      const { code } = await this.getChangeList(SERVICE_ID.authTreeId, result, 1)
-      this.tipMsg(code)
     }
   }
 }

+ 26 - 8
src/views/newUserManagement/index.vue

@@ -1,6 +1,5 @@
 <template>
   <div class="newUserManagement">
-    <div class="newUserManagement-head manageTitle">用户管理</div>
     <div class="flex-wrap newUserManagement-content">
       <div class="newUserManagement-content-left">
         <!-- <div class="head flex">
@@ -81,11 +80,11 @@
               </el-table-column> -->
               <el-table-column prop="user_comment" label="描述">
               </el-table-column>
-              <el-table-column label="操作" width="325">
+              <el-table-column label="操作" width="235">
                 <template slot-scope="scope">
                   <el-button @click="handleTablepaswod(scope.row)" type="primary" plain size="small">修改密码 </el-button>
                   <el-button @click="handleTableEdit(scope.row)" type="primary" plain size="small">编辑 </el-button>
-                  <el-button @click="handleTableAuth(scope.row)" type="primary" plain size="small">账号授权 </el-button>
+                  <!-- <el-button @click="handleTableAuth(scope.row)" type="primary" plain size="small">账号授权 </el-button> -->
                   <el-button @click="handleTableDel(scope.row)" type="danger" size="small">删除 </el-button>
                 </template>
               </el-table-column>
@@ -524,13 +523,12 @@ export default {
 </script>
 
 <style lang="scss" scoped>
-@import "../newRole/css/index.scss";
 .newUserManagement {
   padding: 24px;
   height: calc(100vh - 80px);
+
   &-content {
-    height: calc(100% - 58px);
-    margin-top: 30px;
+    height: 100%;
     .title {
       font-size: 20px;
       font-family: Microsoft YaHei;
@@ -544,10 +542,27 @@ export default {
       box-shadow: 0px 3px 3px 0px rgba(0, 0, 0, 0.1);
       border-radius: 4px;
       margin-right: 16px;
-      padding: 24px;
+      .newService-content-left-top {
+        padding: 24px 24px 18px 24px;
+        .search {
+          margin-top: 18px;
+        }
+      }
       .contents {
         // margin-top: 24px;
-        height: calc(100% - 56px);
+        padding: 0 24px;
+        height: 42px;
+        line-height: 42px;
+        .left {
+          font-size: 16px;
+          font-family: Microsoft YaHei;
+          font-weight: bold;
+          color: #101116;
+        }
+        .right {
+          color: #dd3838;
+          cursor: pointer;
+        }
         .custom-tree-node {
           flex: 1;
           display: flex;
@@ -561,6 +576,9 @@ export default {
           }
         }
       }
+      .active {
+        background: #e4f3f9;
+      }
     }
     &-right {
       &-top {

+ 14 - 5
src/views/systemSettings/views/newMachine/components/table.vue

@@ -81,8 +81,9 @@
 import { setTableFilters } from "@/utils/table";
 import Dialog from "@/layout/components/Dialog/index.vue";
 import NoData from "@/components/nodata";
-import { translateDataToTreeAllTreeMsg } from "@/utils/validate";
+import { translateDataToTreeAllTreeMsg, getAuthData } from "@/utils/validate";
 import { Query, newData, modifyData, moveData, start, stop } from "@/api/webApi";
+import { getToken } from '@/utils/auth';
 export default {
   name: "DataTable",
   props: {
@@ -265,6 +266,16 @@ export default {
       });
     },
   },
+  mounted () {
+    const { auth_id } = this.$route.meta
+    const { arrs } = getAuthData(auth_id)
+    const table = arrs.filter(item => item.auth_type == 4)
+    if (table && table.length) {
+      const obj = table[0]
+      this.datasource_id = obj.auth_id
+      // this.getColumnData();
+    }
+  },
   updated () {
     this.$refs["table"]?.doLayout();
   },
@@ -273,10 +284,8 @@ export default {
     async getColumnData (id) {
       try {
         const { code, returnData } = await Query({
-          serviceId: SERVICE_ID.getTableColumnId,
-          dataContent: {
-            "serviceOutPutId": `${SERVICE_ID.depTableId}`,
-          },
+          serviceId: SERVICE_ID.sysUserAuthId,
+          dataContent: [{ user_id: getToken('userid'), auth_id: this.datasource_id }],
           event: '0'
         });
         if (code == 0) {

+ 8 - 6
src/views/table/index.vue

@@ -131,6 +131,7 @@ import AdvanceQuery from './components/advanceQuery.vue';
 import AuthButton from './components/authButton.vue';
 import { translateDataToTreeAllTreeMsg, getAuthData } from "@/utils/validate";
 import { Query, newData, modifyData, moveData, abnormalDataRecovery } from "@/api/webApi";
+import { getToken } from '@/utils/auth';
 export default {
   name: "DataTable",
   props: {
@@ -293,9 +294,7 @@ export default {
   mounted () {
     const { query } = this.$route
     const { title, auth_id } = this.$route.meta
-    console.log(auth_id)
     const { arrs } = getAuthData(auth_id)
-    console.log(arrs)
     const table = arrs.filter(item => item.auth_type == 4)
     this.urlParams = query
     if (table && table.length) {
@@ -339,10 +338,13 @@ export default {
     async getColumnData (id) {
       try {
         const { code, returnData } = await Query({
-          serviceId: SERVICE_ID.getTableColumnId,
-          dataContent: {
-            serviceOutPutId: id
-          },
+          serviceId: SERVICE_ID.sysUserAuthId,
+          dataContent: [
+            {
+              user_id: getToken('userid'),
+              auth_id: id
+            }
+          ],
         });
         if (code == 0) {
           if (returnData && returnData.length) {