zs 1 year ago
parent
commit
f57b239cb4
1 changed files with 23 additions and 6 deletions
  1. 23 6
      src/views/system/buy/index.vue

+ 23 - 6
src/views/system/buy/index.vue

@@ -36,12 +36,12 @@
             </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 +165,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 +187,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 buyAxios.update(data);
   else res = await buyAxios.create(data);
@@ -232,5 +250,4 @@ const searchOther = async () => {
     margin: 0 0 10px 0;
   }
 }
-</style>
-@/stores/shopsetting/buy@/stores/setting/buy
+</style>