Просмотр исходного кода

fix: 添加获取编辑信息的接口,并在更新前拉取最新数据

xieyong 1 месяц назад
Родитель
Сommit
cd25aa054f

+ 10 - 0
src/api/purchasingManage/purchaseOrder.js

@@ -31,6 +31,16 @@ export async function getByIdCondition(id,productType) {
   }
   }
   return Promise.reject(new Error(res.data.message));
   return Promise.reject(new Error(res.data.message));
 }
 }
+/**
+ * 获取编辑信息(更新前获取最新数据)
+ */
+export async function getByIdForEdit(id) {
+  const res = await request.get(`/eom/purchaseorder/getByIdForEdit/${id}`, {});
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
 
 
 /**
 /**
  * 更新信息
  * 更新信息

+ 21 - 19
src/views/purchasingManage/purchaseOrder/components/addDialogNew.vue

@@ -793,7 +793,8 @@
     getpurchaseorderDetail,
     getpurchaseorderDetail,
     getPurchasePlanByContractIdAPI,
     getPurchasePlanByContractIdAPI,
     UpdateInformation,
     UpdateInformation,
-    getSupplierInfo
+    getSupplierInfo,
+    getByIdForEdit
   } from '@/api/purchasingManage/purchaseOrder';
   } from '@/api/purchasingManage/purchaseOrder';
   import { getplanDetail } from '@/api/purchasingManage/purchasePlanManage';
   import { getplanDetail } from '@/api/purchasingManage/purchasePlanManage';
   import { getpurchaseinquiry } from '@/api/purchasingManage/inquiryManage';
   import { getpurchaseinquiry } from '@/api/purchasingManage/inquiryManage';
@@ -2500,24 +2501,25 @@
           // console.log('提交数据', commitData);  
           // console.log('提交数据', commitData);  
 
 
           if (this.isUpdate) {
           if (this.isUpdate) {
-            UpdateInformation(commitData)
-              .then((res) => {
-                this.loading = false;
-                this.$message.success('修改成功');
-                updateRelationStatus([this.form.partbId]);
-                if (this.form.contractId) {
-                  updateContractStatus([this.form.contractId]);
-                }
-                if (type === 'sub') {
-                  this.sub(res);
-                  return;
-                }
-                this.cancel();
-                this.$emit('done');
-              })
-              .catch((e) => {
-                //this.loading = false;
-              });
+            try {
+              // 更新前先拉取最新编辑数据,确保基于最新版本提交
+              await getByIdForEdit(this.form.id || this.businessId);
+              const res = await UpdateInformation(commitData);
+              this.loading = false;
+              this.$message.success('修改成功');
+              updateRelationStatus([this.form.partbId]);
+              if (this.form.contractId) {
+                updateContractStatus([this.form.contractId]);
+              }
+              if (type === 'sub') {
+                this.sub(res);
+                return;
+              }
+              this.cancel();
+              this.$emit('done');
+            } catch (e) {
+              this.loading = false;
+            }
           } else {
           } else {
             addInformation(commitData)
             addInformation(commitData)
               .then((res) => {
               .then((res) => {