Browse Source

提交代码

JX.Li 1 year ago
parent
commit
6b2bfd0b23
1 changed files with 12 additions and 8 deletions
  1. 12 8
      src/views/gas/area/index.vue

+ 12 - 8
src/views/gas/area/index.vue

@@ -151,9 +151,9 @@
           <el-input v-model="form.name" placeholder="请输入小区名"/>
         </el-form-item>
         <el-form-item label="负责工长" prop="userIds">
-          <el-select v-model="form.userIds" filterable multiple placeholder="请选择负责工长" style="width: 100%">
-            <el-option v-for="item in workerList"
-                       :key="item.id"
+          <el-select v-model="userIds" multiple filterable placeholder="请选择负责工长" style="width: 100%">
+            <el-option v-for="(item,index) in workerList"
+                       :key="index"
                        :label="item.name"
                        :value="item.id"/>
           </el-select>
@@ -201,6 +201,7 @@ export default {
       exportLoading: false,
       // 选中数组
       ids: [],
+      userIds: [],
       // 非单个禁用
       single: true,
       // 非多个禁用
@@ -231,7 +232,7 @@ export default {
           {required: true, message: "小区名不能为空", trigger: "blur"}
         ],
         userIds: [
-          {required: true, message: "负责工长不能为空", trigger: "change"}
+          {required: false, message: "负责工长不能为空", trigger: "change"}
         ],
         releaseIs: [
           {required: true, message: "是否释放不能为空", trigger: "change"}
@@ -264,8 +265,7 @@ export default {
     },
     getUserName(userId) {
       let name = ''
-      console.log(userId)
-      if (userId == undefined || userId == null|| userId == '') {
+      if (userId == undefined || userId == null || userId == '') {
         return ''
       }
       for (let i = 0; i < userId.split(",").length; i++) {
@@ -282,6 +282,9 @@ export default {
     /** 查询小区列表 */
     getList() {
       this.loading = true;
+      if (this.queryParams.userId == '') {
+        this.queryParams.userId = undefined
+      }
       if (this.queryParams.userId != undefined)
         this.queryParams.userId = this.queryParams.userId + ""
       listArea(this.queryParams).then(response => {
@@ -299,6 +302,7 @@ export default {
     },
     // 表单重置
     reset() {
+      this.userIds = []
       this.form = {
         id: undefined,
         name: undefined,
@@ -349,7 +353,7 @@ export default {
       getArea(id).then(response => {
         this.loading = false;
         this.form = response.data;
-        this.form.userIds = response.data.userId.split(",").map(Number);
+        this.userIds = response.data.userId == '' || response.data.userId == null ? [] : response.data.userId.split(",").map(Number);
         this.form.userId = response.data.userId;
         this.open = true;
         this.title = "修改小区";
@@ -360,7 +364,7 @@ export default {
       this.$refs["form"].validate(valid => {
         if (valid) {
           this.buttonLoading = true;
-          this.form.userId = this.form.userIds.join(",")
+          this.form.userId = this.userIds.join(",")
           if (this.form.releaseIs === 'Y') {
             this.form.releaseBy = this.$store.state.user.userId
           }