Przeglądaj źródła

Merge branch 'master' of http://116.63.33.55/git/read_opc

FinalYu 2 lat temu
rodzic
commit
7f4c9ee297

+ 4 - 4
chuanyi-admin/src/App.vue

@@ -18,10 +18,10 @@ export default {
   float: right;
   margin-left: 10px !important;
 }
-.el-icon-delete{
-  color:red
+.el-icon-delete {
+  color: red;
 }
-.el-icon-delete+span{
-  color:red
+.el-icon-delete + span {
+  color: red;
 }
 </style>

+ 2 - 0
chuanyi-admin/src/views/system/role/index.vue

@@ -127,6 +127,8 @@
                 size="mini"
                 type="text"
                 icon="el-icon-delete"
+                :disabled="!multiple"
+
                 @click="handleDelete(scope.row)"
               >删除</el-button>
               <el-button

+ 6 - 4
chuanyi-admin/src/views/system/role/user-auth.vue

@@ -121,6 +121,7 @@
             size="mini"
             type="text"
             icon="el-icon-circle-close"
+            :disabled="!multiple"
             @click="cancelAuthUser(scope.row)"
           >取消授权
           </el-button>
@@ -223,16 +224,17 @@ export default {
       this.$router.push('/system/role')
     },
     /** 搜索按钮操作 */
-    handleQuery() {
+    handleQuery(event) {
+      this.$resetBtn(event)
       this.queryParams.page = 1
       this.getList()
     },
     /** 重置按钮操作 */
-    resetQuery() {
+    resetQuery(event) {
       if (this.$refs['queryForm']) {
         this.$refs['queryForm'].resetFields()
       }
-      this.handleQuery()
+      this.handleQuery(event)
     },
     /** 多选框选中数据 */
     handleSelectionChange(selection) {
@@ -278,7 +280,7 @@ export default {
     },
     /** 批量取消授权按钮操作 */
     cancelAuthUserAll() {
-      this.$confirm('是否取消授权?', '提示', {
+      this.$confirm('是否批量取消授权?', '提示', {
         confirmButtonText: '确定',
         cancelButtonText: '取消',
         cancelButtonClass: 'btn_custom_cancel',

+ 74 - 6
chuanyi-admin/src/views/system/role/user-menu.vue

@@ -79,8 +79,7 @@
       >
         <template slot-scope="scope">
           <el-button
-            type="danger"
-            plain
+            type="text"
             icon="el-icon-circle-close"
             size="mini"
             :disabled="!celDistribution"
@@ -111,10 +110,13 @@
         </el-col>
       </el-row>
       <el-table
+        ref="distTable"
         v-loading="distLoading"
         :data="addMenuList"
         row-key="id"
         @selection-change="handelAddDist"
+        @select="select"
+        @select-all="selectAll"
       >
         <el-table-column
           type="selection"
@@ -187,7 +189,9 @@ export default {
       // 分配菜单表格
       addMenuList: [],
       // 禁用分配
-      distribution: true
+      distribution: true,
+      // 全选按钮选中所有节点
+      isSelectAll: false
     }
   },
   created() {
@@ -210,6 +214,9 @@ export default {
     getMenuListTree() {
       getMenuListTree().then(res => {
         const data = res.data
+        data.forEach(item => {
+          item.isSelect = false
+        })
         this.addMenuList = data
         this.distLoading = false
       })
@@ -270,7 +277,7 @@ export default {
     /** 取消分配按钮 */
     delMenu(id) {
       this.delDistObj.menuList = []
-      this.$confirm('是否分配菜单?', '提示', {
+      this.$confirm('是否取消分配菜单?', '提示', {
         confirmButtonText: '确定',
         cancelButtonText: '取消',
         cancelButtonClass: 'btn_custom_cancel',
@@ -278,7 +285,6 @@ export default {
       }).then(() => {
         this.delDistObj.menuList.push({ id })
         this.delDistributionMenu()
-        console.log(this.delDistObj.menuList)
       }).catch(() => {
         this.$message({
           type: 'info',
@@ -288,7 +294,7 @@ export default {
     },
     /** 批量取消分配菜单按钮 */
     handleDelMenus() {
-      this.$confirm('是否批量分配菜单?', '提示', {
+      this.$confirm('是否批量取消分配菜单?', '提示', {
         confirmButtonText: '确定',
         cancelButtonText: '取消',
         cancelButtonClass: 'btn_custom_cancel',
@@ -326,6 +332,68 @@ export default {
           this.getList()
         }
       })
+    },
+    // 选中父节点时,子节点一起选中取消
+    select(selection, row) {
+      if (
+        selection.some((el) => {
+          return row.id === el.id
+        })
+      ) {
+        if (row.children) {
+          // 解决子组件没有被勾选到
+          this.setChildren(row.children, true)
+        }
+      } else {
+        if (row.children) {
+          this.setChildren(row.children, false)
+        }
+      }
+    },
+    toggleSelection(row, select) {
+      if (row) {
+        this.$nextTick(() => {
+          this.$refs.distTable && this.$refs.distTable.toggleRowSelection(row, select)
+        })
+      }
+    },
+    // 选择全部
+    selectAll(selection) {
+      // tabledata第一层只要有在selection里面就是全选
+      const isSelect = selection.some((el) => {
+        const tableDataIds = this.addMenuList.map((j) => j.id)
+        return tableDataIds.includes(el.id)
+      })
+      // tableDate第一层只要有不在selection里面就是全不选
+      const isCancel = !this.addMenuList.every((el) => {
+        const selectIds = selection.map((j) => j.id)
+        return selectIds.includes(el.id)
+      })
+      if (isSelect) {
+        selection.map((el) => {
+          if (el.children) {
+            // 解决子组件没有被勾选到
+            this.setChildren(el.children, true)
+          }
+        })
+      }
+      if (isCancel) {
+        this.addMenuList.map((el) => {
+          if (el.children) {
+            // 解决子组件没有被勾选到
+            this.setChildren(el.children, false)
+          }
+        })
+      }
+    },
+    setChildren(children, type) {
+      // 编辑多个子层级
+      children.map((j) => {
+        this.toggleSelection(j, type)
+        if (j.children) {
+          this.setChildren(j.children, type)
+        }
+      })
     }
   }
 }

+ 96 - 17
chuanyi-admin/src/views/system/role/user-select.vue

@@ -1,48 +1,106 @@
 <template>
   <!-- 授权用户 -->
-  <el-dialog title="选择用户" :visible.sync="visible" width="800px" top="5vh" append-to-body :close-on-click-modal="false">
-    <el-form ref="queryForm" :model="queryParams" size="small" :inline="true">
-      <el-form-item label="用户名称" prop="userName">
-        <el-input v-model="queryParams.userName" placeholder="请输入用户名称" clearable @keyup.enter.native="handleQuery" />
+  <el-dialog
+    title="选择用户"
+    :visible.sync="visible"
+    width="800px"
+    top="5vh"
+    append-to-body
+    :close-on-click-modal="false"
+  >
+    <el-form
+      ref="queryForm"
+      :model="queryParams"
+      size="small"
+      :inline="true"
+    >
+      <el-form-item
+        label="用户名称"
+        prop="userName"
+      >
+        <el-input
+          v-model="queryParams.userName"
+          placeholder="请输入用户名称"
+          clearable
+          @keyup.enter.native="handleQuery"
+        />
       </el-form-item>
       <el-form-item>
-        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
-        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
+        <el-button
+          type="primary"
+          icon="el-icon-search"
+          size="mini"
+          @click="handleQuery"
+        >搜索</el-button>
+        <el-button
+          icon="el-icon-refresh"
+          size="mini"
+          @click="resetQuery"
+        >重置</el-button>
       </el-form-item>
     </el-form>
     <el-row>
       <el-table
         ref="table"
         :data="userList"
-        height="260px"
         @row-click="clickRow"
         @selection-change="handleSelectionChange"
       >
-        <el-table-column type="selection" width="55" />
-        <el-table-column label="用户名称" prop="userName" :show-overflow-tooltip="true" />
-        <el-table-column label="用户状态" prop="state" :show-overflow-tooltip="true">
+        <el-table-column
+          type="selection"
+          width="55"
+        />
+        <el-table-column
+          label="用户名称"
+          prop="userName"
+          :show-overflow-tooltip="true"
+        />
+        <el-table-column
+          label="用户状态"
+          prop="state"
+          :show-overflow-tooltip="true"
+        >
           <template slot-scope="scope">
             <span>{{ convertUserStatus(scope.row.state) }}</span>
           </template>
         </el-table-column>
-        <el-table-column label="用户类型" prop="userType" :show-overflow-tooltip="true">
+        <el-table-column
+          label="用户类型"
+          prop="userType"
+          :show-overflow-tooltip="true"
+        >
           <template slot-scope="scope">
             <span>{{ convertUserType(scope.row.userType) }}</span>
           </template>
         </el-table-column>
-        <el-table-column label="最后登录时间" prop="lastLoginTime" width="160" />
-        <el-table-column label="创建时间" prop="createTime" width="160" />
+        <el-table-column
+          label="最后登录时间"
+          prop="lastLoginTime"
+          width="160"
+        />
+        <el-table-column
+          label="创建时间"
+          prop="createTime"
+          width="160"
+        />
       </el-table>
       <pagination
         v-show="total > 0"
         :total="total"
+        align="right"
         :page.sync="queryParams.page"
         :limit.sync="queryParams.limit"
         @pagination="getList"
       />
     </el-row>
-    <div slot="footer" class="dialog-footer">
-      <el-button type="primary" @click="handleSelectUser">确 定</el-button>
+    <div
+      slot="footer"
+      class="dialog-footer"
+    >
+      <el-button
+        type="primary"
+        @click="handleSelectUser"
+      >确 定</el-button>
       <el-button @click="visible = false">取 消</el-button>
     </div>
   </el-dialog>
@@ -107,8 +165,8 @@ export default {
     /** 显示弹框 */
     show() {
       this.queryParams.roleId = this.roleId
-      this.getList()
       this.visible = true
+      this.resetQuery()
     },
     /** 行点击事件 */
     clickRow(row) {
@@ -159,14 +217,35 @@ export default {
         addUserToAuthRole(query).then(res => {
           if (res.code === 200) {
             this.$message({
-              message: res.data,
+              message: '分配用户成功',
               type: 'success'
             })
+            this.visible = false
             this.$emit('updateUserList')
           }
         })
       }
     }
   }
+  // watch: {
+  //   //弹出框表格数据刷新滚动条置顶
+  //   userList: {
+  //     handler () {
+  //       this.$nextTick(() => {
+  //         // 滚动到顶部
+  //         this.$refs.table.bodyWrapper.scrollTop = 0;
+  //       });
+  //     },
+  //     deep: true,
+  //     immediate: true,
+  //   }
+  // }
 }
 </script>
+
+<style lang="scss" scoped>
+.el-dialog {
+  height: 78vh;
+  overflow: auto;
+}
+</style>