peter 2 сар өмнө
parent
commit
31937ab9e2

+ 2 - 0
src/interface.ts

@@ -78,6 +78,8 @@ export interface IForm {
   Reference?: string // 用在 表单项:订单号 显示
   Warehouse?: string
   CF_Product_Type?: string
+  Special_QC_Requirement?: string
+  Special_Package_Requirement?: string
 }
 
 export interface IVendorItem {

+ 88 - 10
src/pages/purchase-order/edit.vue

@@ -1403,6 +1403,35 @@
         </div>
       </div>
     </div>
+    <el-dialog
+      v-model="specialReminderVisible"
+      width="700px"
+      style="margin-top: 30vh"
+      :title="`${soData.Order_Reminder}`"
+    >
+      <div class="flex items-center">
+        <span class="mr-2">将此特殊提醒添加到</span>
+        <div class="py-2">
+          <el-checkbox-group v-model="selectReminderType">
+            <el-checkbox
+              v-for="item in reminderTypeList"
+              :key="item"
+              :value="item"
+              :label="item"
+            ></el-checkbox>
+          </el-checkbox-group>
+        </div>
+      </div>
+      <div class="flex justify-center pt-2">
+        <el-button
+          type="primary"
+          @click="onReminderSelect"
+        >
+          OK
+        </el-button>
+        <el-button @click="specialReminderVisible = false">Cancel</el-button>
+      </div>
+    </el-dialog>
   </div>
 </template>
 
@@ -1425,6 +1454,9 @@ import {
   ElRadio,
   ElMessageBox,
   ElTooltip,
+  ElDialog,
+  ElCheckboxGroup,
+  ElCheckbox,
 } from 'element-plus'
 import type { FormInstance } from 'element-plus'
 import { ShoppingCart, FolderAdd, Switch } from '@element-plus/icons-vue'
@@ -1434,6 +1466,7 @@ import jspdf from 'jspdf'
 import html2canvas from 'html2canvas'
 import utils from '@/utils/index'
 import variables from '@/assets/css/var.module.scss'
+import cloneDeep from 'lodash/cloneDeep'
 import {
   ServiceTypeKeyEnum,
   ISelectItem,
@@ -1857,6 +1890,8 @@ const form = ref<IForm>({
   field5: '供应商承担',
   currentVendor: '',
   Delivery_Details: '',
+  Special_QC_Requirement: '',
+  Special_Package_Requirement: '',
 })
 
 const addRow = function () {
@@ -2178,12 +2213,12 @@ const soOwner = ref('')
 const p2 = request.post('/common/getSalesOrdersDatV7', { id: route.params.id })
 
 // 获取对 该so对应客户的标注 并弹窗提醒
-const getAccountsData = async (id: string) =>
+const getAccountsData = async (id: string, Order_Reminder = '') =>
   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.confirm(res.result.User_Notes, '', {
+    const accountData = response.data
+    if (accountData.code !== 1) return
+    if (accountData.result.User_Notes && accountData.result.User_Notes.length) {
+      ElMessageBox.confirm(accountData.result.User_Notes, '', {
         confirmButtonText: '将此备注添加到合同',
         cancelButtonText: '已知悉',
         type: 'warning',
@@ -2196,7 +2231,7 @@ const getAccountsData = async (id: string) =>
           // 迭代3 需求. 固定填充一行.
           form.value.productList.push(
             Object.assign({}, emptyProductItem, {
-              requirement: res.result.User_Notes || '',
+              requirement: accountData.result.User_Notes || '',
               quantity: 1,
               rate: 0,
               id: '4791186000172849436',
@@ -2212,8 +2247,14 @@ const getAccountsData = async (id: string) =>
           )
         })
         .catch(() => {})
+        .finally(() => {
+          if (Order_Reminder) {
+            specialReminderVisible.value = true
+          }
+        })
     }
   })
+
 const getProductData = async (id: string) =>
   request.post('/common/getProductsData', { id }).then((response) => {
     const res = response.data
@@ -2228,7 +2269,7 @@ const getProductData = async (id: string) =>
           item.Supplier?.id &&
           !computedRecommandVendorID.value.includes(item.Supplier.id)
         ) {
-          console.log(item, 'item')
+          // console.log(item, 'item')
           recommandVendor.value.push({
             id: item.Supplier.id,
             name: item.Supplier.name,
@@ -2272,14 +2313,51 @@ const p3 = request
     }
   })
 const preferSupplier = ref([] as any[])
-Promise.all([p1, p2, p3, getAccountsData])
+const specialReminderVisible = ref(false)
+let selectReminderType = ref([] as string[])
+const reminderTypeList = ref(['QC Item', 'Package Notes', 'Purchase Order'])
+const onReminderSelect = () => {
+  if (selectReminderType.value.length === 0) {
+    ElMessage.error('请选择至少一个选项')
+    return
+  }
+  if (selectReminderType.value.includes('QC Item')) {
+    form.value.Special_QC_Requirement = soData.value.Order_Reminder || ''
+  }
+  if (selectReminderType.value.includes('Package Notes')) {
+    form.value.Special_Package_Requirement = soData.value.Order_Reminder || ''
+  }
+  if (selectReminderType.value.includes('Purchase Order')) {
+    form.value.productList.push(
+      Object.assign({}, emptyProductItem, {
+        requirement: soData.value.Order_Reminder || '',
+        quantity: 1,
+        rate: 0,
+        id: '4791186000172849436',
+        name: 'User Notes',
+        CF_Product_Type: '',
+        candidate: [
+          {
+            label: 'User Notes',
+            value: '4791186000172849436',
+          },
+        ],
+      }),
+    )
+  }
+  specialReminderVisible.value = false
+}
+const soData = ref({ Order_Reminder: '' } as any)
+Promise.all([p1, p2, p3])
   .then((array: any[]) => {
+    console.log(222, '222')
     // p2的数据处理逻辑从原本的p2then移动到这里处理.
     // 因为要根据p3用户数据的Organization 来填充产品列表里面的 requirement, 这步处理必须放在p3后面, 而p2 p3是并发操作.
     if (array[1].data.code !== 1) return
     const res = array[1].data.result
+    soData.value = Object.assign({ Order_Reminder: '' }, cloneDeep(res))
     if (res.Account_Name && res.Account_Name.id) {
-      getAccountsData(res.Account_Name.id)
+      getAccountsData(res.Account_Name.id, res.Order_Reminder)
     }
     form.value.field7 = res.Owner_name || res.Owner.name || ''
     soOwner.value = res.Owner_name || res.Owner.name || ''
@@ -2301,7 +2379,7 @@ Promise.all([p1, p2, p3, getAccountsData])
     recommandVendor.value = []
     temp.forEach((item: any) => {
       getProductData(item.Product_Name.id).then((ctx) => {
-        console.log(ctx, 'product ctx')
+        // console.log(ctx, 'product ctx')
         form.value.productList.push(
           Object.assign({}, emptyProductItem, {
             candidate: [