Browse Source

change: SO详情数据字段名调整. 兼容从CRM主动取回的数据格式

peter 1 year ago
parent
commit
bd287fd545
1 changed files with 24 additions and 17 deletions
  1. 24 17
      src/pages/purchase-order/edit.vue

+ 24 - 17
src/pages/purchase-order/edit.vue

@@ -1853,17 +1853,24 @@ const soOwner = ref('')
 axios
   .post('/api/common/getSalesOrdersData', { id: route.params.id })
   .then((response) => {
-    const res = response.data
-    if (res.code !== 1) return
-    form.value.field7 = res.result.Owner_name || ''
-    soOwner.value = res.result.Owner_name || ''
-    form.value.Title = res.result.Sales_Order_Title_Job_Name || ''
-    form.value.saleOrderId = res.result.sales_orders_id || ''
+    if (response.data.code !== 1) return
+    const res = response.data.result
+    form.value.field7 = res.Owner_name || res.Owner.name || ''
+    soOwner.value = res.Owner_name || res.Owner.name || ''
+    form.value.Title = res.Sales_Order_Title_Job_Name || ''
+    form.value.saleOrderId = res.sales_orders_id || res.id || ''
     form.value.PO_Date = dayjs(new Date()).format('YYYY-MM-DD')
-
-    let temp = res.result.details.filter(
-      (item: any) => !productBlackList.includes(item.product_id),
-    )
+    let temp = []
+    if (res.details) {
+      temp = res.details.filter(
+        (item: any) => !productBlackList.includes(item.product_id),
+      )
+    } else if (res.Product_Details) {
+      temp = res.Product_Details.filter(
+        (item: any) => !productBlackList.includes(item.product.id),
+      )
+    }
+    console.log(temp)
 
     if (import.meta.env.MODE !== 'production' && temp.length < 1) {
       temp.unshift({
@@ -1881,16 +1888,16 @@ axios
           candidate: [
             {
               Product_Code: item.product_Product_Code,
-              label: item.product_name,
-              value: item.product_id,
+              label: item.product.name,
+              value: item.product.id,
             },
           ],
-          Product_Code: item.product_Product_Code,
-          id: item.product_id,
-          name: item.product_name,
+          Product_Code: item.product.Product_Code,
+          id: item.product.id,
+          name: item.product.name,
           // label: `(${item.product_Product_Code})${item.product_name}`,
-          label: item.product_name,
-          value: item.product_id,
+          label: item.product.name,
+          value: item.product.id,
           desc: item.product_description || '',
           quantity: Number(item.quantity),
         }),