Эх сурвалжийг харах

修复重复修改用户mars岗位时出现的报错问题

pm 10 сар өмнө
parent
commit
7e72fdf2cc

+ 83 - 81
src/views/system/user/index.vue

@@ -297,9 +297,9 @@
         <el-row>
         <el-row>
           <el-col :span="12">
           <el-col :span="12">
             <el-form-item label="玛氏岗位" prop="workstationId">
             <el-form-item label="玛氏岗位" prop="workstationId">
-              <el-select size="small" v-model="form.workstationIds" placeholder="请选择" :popper-append-to-body="false" multiple
+              <el-select size="small" v-model="form.workstationIds" placeholder="请选择"   :popper-append-to-body="false" multiple
                          @remove-tag="removeTag" >
                          @remove-tag="removeTag" >
-                <el-option :value="selectTreeValue" class="setstyle" disabled>
+                <el-option :value="selectTreeValue"  class="setstyle" disabled>
                   <el-input class="setinput" size="mini" placeholder="输入关键字进行过滤" clearable v-model="filterText"></el-input>
                   <el-input class="setinput" size="mini" placeholder="输入关键字进行过滤" clearable v-model="filterText"></el-input>
                   <el-tree :data="treeData" check-strictly default-expand-all show-checkbox node-key="id" ref="treeRef" highlight-current
                   <el-tree :data="treeData" check-strictly default-expand-all show-checkbox node-key="id" ref="treeRef" highlight-current
                            :filter-node-method="MardfilterNode" :props="defaultProps" @check-change="handleCheckChange"></el-tree>
                            :filter-node-method="MardfilterNode" :props="defaultProps" @check-change="handleCheckChange"></el-tree>
@@ -507,6 +507,80 @@ export default {
         this.$set(this, 'treeData', this.transformDataToTree(response.data.records));
         this.$set(this, 'treeData', this.transformDataToTree(response.data.records));
       })
       })
     },
     },
+    // 筛选节点
+    filterNode(value, data) {
+      if (!value) return true;
+      return data.label.indexOf(value) !== -1;
+    },
+    // 节点单击事件
+    handleNodeClick(data) {
+      this.queryParams.deptId = data.id;
+      this.handleQuery();
+    },
+    // 用户状态修改
+    handleStatusChange(row) {
+      let text = row.status === "0" ? "启用" : "停用";
+      this.$modal.confirm('确认要"' + text + '""' + row.userName + '"用户吗?').then(function() {
+        return changeUserStatus(row.userId, row.status);
+      }).then(() => {
+        this.$modal.msgSuccess(text + "成功");
+      }).catch(function() {
+        row.status = row.status === "0" ? "1" : "0";
+      });
+    },
+    // 取消按钮
+    cancel() {
+      this.open = false;
+      this.reset();
+    },
+    // 表单重置
+    reset() {
+      this.form = {
+        userId: undefined,
+        deptId: undefined,
+        userName: undefined,
+        nickName: undefined,
+        password: undefined,
+        phonenumber: undefined,
+        email: undefined,
+        sex: undefined,
+        status: "0",
+        remark: undefined,
+        postIds: [],
+        roleIds: []
+      };
+      this.resetForm("form");
+    },
+    /** 搜索按钮操作 */
+    handleQuery() {
+      this.queryParams.pageNum = 1;
+      this.getList();
+    },
+    /** 重置按钮操作 */
+    resetQuery() {
+      this.dateRange = [];
+      this.resetForm("queryForm");
+      this.handleQuery();
+    },
+    // 多选框选中数据
+    handleSelectionChange(selection) {
+      this.ids = selection.map(item => item.userId);
+      this.single = selection.length != 1;
+      this.multiple = !selection.length;
+    },
+    // 更多操作触发
+    handleCommand(command, row) {
+      switch (command) {
+        case "handleResetPwd":
+          this.handleResetPwd(row);
+          break;
+        case "handleAuthRole":
+          this.handleAuthRole(row);
+          break;
+        default:
+          break;
+      }
+    },
     // 树形结构
     // 树形结构
     transformDataToTree(data) {
     transformDataToTree(data) {
       const map = {};
       const map = {};
@@ -567,7 +641,6 @@ export default {
         const record = this.MarsWordStationOptions.find(record => record.workstationId === workstationId);
         const record = this.MarsWordStationOptions.find(record => record.workstationId === workstationId);
         return record ? { id: record.workstationId, label: record.workstationName } : null;
         return record ? { id: record.workstationId, label: record.workstationName } : null;
       }).filter(node => node !== null);
       }).filter(node => node !== null);
-
       this.$nextTick(() => {
       this.$nextTick(() => {
         this.$refs.treeRef.setCheckedNodes(workstationNames);
         this.$refs.treeRef.setCheckedNodes(workstationNames);
       });
       });
@@ -577,7 +650,7 @@ export default {
     handleCheckChange(data, checked, indeterminate) {
     handleCheckChange(data, checked, indeterminate) {
       if (checked) {
       if (checked) {
         this.addTag(data); // 调用 addTag 方法
         this.addTag(data); // 调用 addTag 方法
-      
+
       } else {
       } else {
         this.removeTag(data.label); // 调用 removeTag 方法
         this.removeTag(data.label); // 调用 removeTag 方法
 
 
@@ -597,80 +670,7 @@ export default {
         this.deptOptions = response.data;
         this.deptOptions = response.data;
       });
       });
     },
     },
-    // 筛选节点
-    filterNode(value, data) {
-      if (!value) return true;
-      return data.label.indexOf(value) !== -1;
-    },
-    // 节点单击事件
-    handleNodeClick(data) {
-      this.queryParams.deptId = data.id;
-      this.handleQuery();
-    },
-    // 用户状态修改
-    handleStatusChange(row) {
-      let text = row.status === "0" ? "启用" : "停用";
-      this.$modal.confirm('确认要"' + text + '""' + row.userName + '"用户吗?').then(function() {
-        return changeUserStatus(row.userId, row.status);
-      }).then(() => {
-        this.$modal.msgSuccess(text + "成功");
-      }).catch(function() {
-        row.status = row.status === "0" ? "1" : "0";
-      });
-    },
-    // 取消按钮
-    cancel() {
-      this.open = false;
-      this.reset();
-    },
-    // 表单重置
-    reset() {
-      this.form = {
-        userId: undefined,
-        deptId: undefined,
-        userName: undefined,
-        nickName: undefined,
-        password: undefined,
-        phonenumber: undefined,
-        email: undefined,
-        sex: undefined,
-        status: "0",
-        remark: undefined,
-        postIds: [],
-        roleIds: []
-      };
-      this.resetForm("form");
-    },
-    /** 搜索按钮操作 */
-    handleQuery() {
-      this.queryParams.pageNum = 1;
-      this.getList();
-    },
-    /** 重置按钮操作 */
-    resetQuery() {
-      this.dateRange = [];
-      this.resetForm("queryForm");
-      this.handleQuery();
-    },
-    // 多选框选中数据
-    handleSelectionChange(selection) {
-      this.ids = selection.map(item => item.userId);
-      this.single = selection.length != 1;
-      this.multiple = !selection.length;
-    },
-    // 更多操作触发
-    handleCommand(command, row) {
-      switch (command) {
-        case "handleResetPwd":
-          this.handleResetPwd(row);
-          break;
-        case "handleAuthRole":
-          this.handleAuthRole(row);
-          break;
-        default:
-          break;
-      }
-    },
+
     /** 新增按钮操作 */
     /** 新增按钮操作 */
     handleAdd() {
     handleAdd() {
       this.reset();
       this.reset();
@@ -684,7 +684,6 @@ export default {
           console.error('treeRef is not defined');
           console.error('treeRef is not defined');
         }
         }
       });
       });
-
       getUser().then(response => {
       getUser().then(response => {
         this.postOptions = response.posts;
         this.postOptions = response.posts;
         this.roleOptions = response.roles;
         this.roleOptions = response.roles;
@@ -707,8 +706,11 @@ export default {
         this.form.postIds = response.postIds;
         this.form.postIds = response.postIds;
         this.form.roleIds = response.roleIds;
         this.form.roleIds = response.roleIds;
         //查找并转换
         //查找并转换
-        this.editTag(response.workstationIds)
-
+        if(response.workstationIds){
+          this.editTag(response.workstationIds)
+        }else {
+          this.form.workstationIds=[]
+        }
         this.title = "修改用户";
         this.title = "修改用户";
         this.form.password = "";
         this.form.password = "";
       });
       });