Browse Source

修改发布会议的传参

Sanmu8 1 year ago
parent
commit
bf0d0c7684
1 changed files with 24 additions and 17 deletions
  1. 24 17
      src/views/JOINTCONFERENCE/add.vue

+ 24 - 17
src/views/JOINTCONFERENCE/add.vue

@@ -17,9 +17,9 @@
         ></el-input>
       </el-form-item>
 
-      <el-form-item label="协作单位" prop="deptId">
+      <el-form-item label="协作单位" prop="dept">
         <el-select
-          v-model="form.deptId"
+          v-model="deptId"
           multiple
           placeholder="请选择协作单位"
           @change="selectChange"
@@ -62,7 +62,15 @@ export default {
     },
   },
   data() {
+    var checkDeptId = (rule, value, callback) => {
+      if (this.deptId.length == 0) {
+        return callback(new Error("协作单位不能为空"));
+      } else {
+        callback();
+      }
+    };
     return {
+      deptId: [],
       deptList: [],
       form: {},
       rules: {
@@ -72,9 +80,7 @@ export default {
         conferenceContent: [
           { required: true, message: "会议内容不能为空", trigger: "blur" },
         ],
-        deptId: [
-          { required: true, message: "协作单位不能为空", trigger: "blur" },
-        ],
+        dept: [{ validator: checkDeptId, trigger: "blur" }],
       },
     };
   },
@@ -98,18 +104,19 @@ export default {
               this.getList();
             });
           } else {
-            this.form.deptName = [];
-            for (const index in this.form.deptId) {
-              for (const i in this.deptList) {
-                if (this.form.deptId[index] == this.deptList[i].deptId) {
-                  console.log(
-                    this.form.deptId[index],
-                    this.deptList[i].deptName
-                  );
-                  this.form.deptName[index] = this.deptList[i].deptName;
-                }
-              }
-            }
+            // this.form.deptName = [];
+            // for (const index in this.form.deptId) {
+            //   for (const i in this.deptList) {
+            //     if (this.form.deptId[index] == this.deptList[i].deptId) {
+            //       console.log(
+            //         this.form.deptId[index],
+            //         this.deptList[i].deptName
+            //       );
+            //       this.form.deptName[index] = this.deptList[i].deptName;
+            //     }
+            //   }
+            // }
+            this.form.deptId = this.deptId.toString();
             addJOINTCONFERENCE(this.form).then((response) => {
               this.$modal.msgSuccess("发布成功");
               this.open = false;