zs 1 năm trước cách đây
mục cha
commit
07c76aec6a
1 tập tin đã thay đổi với 24 bổ sung5 xóa
  1. 24 5
      src/views/system/money/index.vue

+ 24 - 5
src/views/system/money/index.vue

@@ -29,19 +29,20 @@
         <el-col :span="24" class="dialog_one" v-if="dialog.type == '1'">
           <cForm :span="24" :fields="formFields" :form="form" :rules="rules" @save="toSave">
             <template #office>
-              <el-option @click="toChange(i)" v-for="i in officeList" :key="i._id" :label="i.name" :value="i._id"></el-option>
+              <el-option @click="toChange(i)" v-for="i in officeList" :key="i._id" :label="i.name"
+                :value="i._id"></el-option>
             </template>
             <template #is_use>
               <el-radio v-for="(i, index) in is_useList" :key="index" :label="i.value">{{ i.label }}</el-radio>
             </template>
             <template #leader>
               <el-select v-model="form.leader" multiple placeholder="请选择审批领导" style="width: 100%">
-                <el-option v-for="item in ldList" :key="item" :label="item.name" :value="item._id" />
+                <el-option v-for="item in ldList" :key="item._id" :label="item.name" :value="item._id" />
               </el-select>
             </template>
             <template #accounting>
               <el-select v-model="form.accounting" multiple placeholder="请选择审批会计" style="width: 100%">
-                <el-option v-for="item in kjList" :key="item" :label="item.name" :value="item._id" />
+                <el-option v-for="item in kjList" :key="item._id" :label="item.name" :value="item._id" />
               </el-select>
             </template>
           </cForm>
@@ -165,12 +166,12 @@ const getProps = (data: any, prop: any) => {
   let res;
   if (prop == 'leader') {
     for (const val of data[prop]) {
-      res = ldList.value.find((i) => i._id == val);
+      res = ldList.value.find((i) => i._id == val._id);
       if (res) list.push(res.name);
     }
   } else {
     for (const val of data[prop]) {
-      res = kjList.value.find((i) => i._id == val);
+      res = kjList.value.find((i) => i._id == val._id);
       if (res) list.push(res.name);
     }
   }
@@ -187,6 +188,24 @@ const toEdit = async (data: any) => {
 };
 // 提交保存
 const toSave = async (data: any) => {
+  if (data.accounting) {
+    if (!data.accounting[0]._id) {
+      data.accounting = data.accounting.map((i) => {
+        let arrObj = { _id: '' };
+        arrObj._id = i;
+        return arrObj;
+      });
+    }
+  }
+  if (data.leader) {
+    if (!data.leader[0]._id) {
+      data.leader = data.leader.map((i) => {
+        let arrObj = { _id: '' };
+        arrObj._id = i;
+        return arrObj;
+      });
+    }
+  }
   let res: IQueryResult;
   if (data._id) res = await collectionAxios.update(data);
   else res = await collectionAxios.create(data);