Forráskód Böngészése

0713若干零碎调整, 涉及跨模块异步取数.

peter 1 éve
szülő
commit
46c686aa78
2 módosított fájl, 65 hozzáadás és 24 törlés
  1. 1 0
      src/interface.ts
  2. 64 24
      src/pages/purchase-order/edit.vue

+ 1 - 0
src/interface.ts

@@ -74,6 +74,7 @@ export interface IVendorItem {
   Primary_Contact_name: string
   PDF_display: string
   PDF_display2: string
+  Payment_Terms: string
   [x: string]: string | null
 }
 export interface ICompanyItem {

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

@@ -273,7 +273,7 @@
                   <th class="product">Product</th>
                   <th class="quantity">Quantity</th>
                   <th class="rate">Rate</th>
-                  <th class="requirement">Requirement</th>
+                  <th class="requirement">Chinese Catalogue & Requirement</th>
                   <th class="amount">Amount</th>
                   <th class="discount">Discount</th>
                   <th class="action">Action</th>
@@ -655,7 +655,7 @@
               <tr>
                 <th class="row-index">#</th>
                 <th>品目</th>
-                <th>要求</th>
+                <th>中文品目|要求</th>
                 <th>数量</th>
                 <th>价钱</th>
                 <th>金额</th>
@@ -1006,7 +1006,7 @@ export default defineComponent({
 })
 </script>
 <script lang="ts" setup>
-import { computed, defineComponent, ref, unref } from 'vue'
+import { computed, defineComponent, ref, unref, watch } from 'vue'
 import { useRoute } from 'vue-router'
 import {
   ElButton,
@@ -1022,6 +1022,7 @@ import {
   ElNotification,
   ElRadioGroup,
   ElRadio,
+  ElMessageBox,
 } from 'element-plus'
 import type { FormInstance, FormRules } from 'element-plus'
 import { ShoppingCart, FolderAdd, Switch } from '@element-plus/icons-vue'
@@ -1080,7 +1081,7 @@ const submit = () => {
                 duration: 0,
                 type: 'success',
                 title: '任务已成功处理',
-                message: '本页面将在数秒后自动跳转',
+                message: '本页面将自动跳转',
               })
               const url =
                 import.meta.env.VITE_PO_PATH +
@@ -1088,7 +1089,7 @@ const submit = () => {
                 import.meta.env.VITE_PO_APPEND
               setTimeout(() => {
                 window.location.replace(url)
-              }, 5000)
+              }, 1000)
             })
             .finally(() => {
               loading.value = false
@@ -1580,6 +1581,9 @@ const onProductSelect = function (e: any, product: IProductItem) {
       product.name = temp[0].label
       product.Product_Code = temp[0].Product_Code
     }
+    getProductData(product.id).then((ctx) => {
+      product.requirement = ctx || ''
+    })
   } else {
     product.name = ''
   }
@@ -1657,8 +1661,19 @@ const computedVendor = computed(() => {
         PDF_display2: '',
         label: '',
         value: '',
+        Payment_Terms: '',
       }
 })
+
+watch(computedVendor, () => {
+  if (
+    computedVendor.value.Payment_Terms &&
+    computedVendor.value.Payment_Terms.length
+  ) {
+    form.value.Supplier_Payment_Terms = computedVendor.value.Payment_Terms
+  }
+})
+
 const vendorLoading = ref(false)
 const getSupplierLists = utils.debounce(function (string: string) {
   const data = {
@@ -1898,6 +1913,9 @@ const p2 = request
   .then((response) => {
     if (response.data.code !== 1) return
     const res = response.data.result
+    if (res.Account_Name && res.Account_Name.id) {
+      getAccountsData(res.Account_Name.id)
+    }
     form.value.field7 = res.Owner_name || res.Owner.name || ''
     soOwner.value = res.Owner_name || res.Owner.name || ''
     form.value.Title =
@@ -1920,27 +1938,49 @@ const p2 = request
     if (!temp.length) return
     form.value.productList = []
     temp.forEach((item: any) => {
-      form.value.productList.push(
-        Object.assign({}, emptyProductItem, {
-          candidate: [
-            {
-              Product_Code: item.product_Product_Code,
-              label: item.product.name,
-              value: item.product.id,
-            },
-          ],
-          Product_Code: item.product.Product_Code,
-          id: item.product.id,
-          name: item.product.name,
-          label: item.product.name,
-          value: item.product.id,
-          desc: item.product_description || '',
-          quantity: Number(item.quantity),
-        }),
-      )
+      getProductData(item.product.id).then((ctx) => {
+        form.value.productList.push(
+          Object.assign({}, emptyProductItem, {
+            candidate: [
+              {
+                Product_Code: item.product_Product_Code,
+                label: item.product.name,
+                value: item.product.id,
+              },
+            ],
+            Product_Code: item.product.Product_Code,
+            id: item.product.id,
+            name: item.product.name,
+            label: item.product.name,
+            value: item.product.id,
+            desc: item.product_description || '',
+            quantity: Number(item.quantity),
+            requirement: ctx || '',
+          }),
+        )
+      })
     })
   })
 
+// 获取对 该so对应客户的标注 并弹窗提醒
+const getAccountsData = async (id: string) =>
+  request.post('/common/getAccountsData', { id }).then((response) => {
+    const res = response.data
+    if (res.code !== 1) return
+    if (res.result.User_Notes && res.result.User_Notes.length) {
+      ElMessageBox.alert(res.result.User_Notes, '', {
+        showClose: false,
+      })
+    }
+  })
+const getProductData = async (id: string) =>
+  request.post('/common/getProductsData', { id }).then((response) => {
+    const res = response.data
+    if (res.code !== 1) return
+    console.log(res.result)
+    return res.result?.CF3 || ''
+  })
+
 // 根据url传递过来的用户ID获取的用户身份信息
 const userInfo = ref({} as IUser)
 const p3 = request
@@ -1960,7 +2000,7 @@ const p3 = request
     }
   })
 
-Promise.all([p1, p2, p3]).finally(() => {
+Promise.all([p1, p2, p3, getAccountsData]).finally(() => {
   loading.value = false
 })
 </script>