Browse Source

refactor: cargo集货. 冗余代码删除.功能类方法拆分至单独文件.

peter 1 month ago
parent
commit
2b0d5c70e7

+ 60 - 0
src/pages/cargo-consolidation-request/func.ts

@@ -0,0 +1,60 @@
+export const customSort1 = function(a: any, b: any) {
+  return parseFloat(a.Carton || 0) - parseFloat(b.Carton || 0)
+}
+export const customSort2 = function(a: any, b: any) {
+  return parseFloat(a.Quantity || 0) - parseFloat(b.Quantity || 0)
+}
+export const customSort3 = function(a: any, b: any) {
+  return parseFloat(a.Unit_Price || 0) - parseFloat(b.Unit_Price || 0)
+}
+export const customSort4 = function(a: any, b: any) {
+  return parseFloat(a.Weight || 0) - parseFloat(b.Weight || 0)
+}
+export const customSort5 = function(a: any, b: any) {
+  return parseFloat(a.Cube || 0) - parseFloat(b.Cube || 0)
+}
+export const customSort6 = function(a: any, b: any) {
+  return parseFloat(a.Total_FOB || 0) - parseFloat(b.Total_FOB || 0)
+}
+export const refSort = function(a: any, b: any) {
+  if (a.Reference && b.Reference) {
+    return a.Reference.localeCompare(b.Reference)
+  } else if (a.Reference) {
+    return -1
+  } else if (b.Reference) {
+    return 1
+  }
+  return 0
+}
+// 申请人/负责人 点击按 首字符A-Z排序
+export const requesterSort = function(a: any, b: any) {
+  if (a.Requester && b.Requester) {
+    return a.Requester.name.localeCompare(b.Requester.name)
+  } else if (a.Requester) {
+    return -1
+  } else if (b.Requester) {
+    return 1
+  }
+  return 0
+}
+export const salesPersonSort = function(a: any, b: any) {
+  if (a.Sales_Person && b.Sales_Person) {
+    return a.Sales_Person.localeCompare(b.Sales_Person)
+  } else if (a.Sales_Person) {
+    return -1
+  } else if (b.Sales_Person) {
+    return 1
+  }
+  return 0
+}
+// 批次记录batchRecord排序, 按 有值 无值 排序即可
+export const batchRecordSort = function(a: any, b: any) {
+  if (a.Batch_Record && b.Batch_Record) {
+    return a.Batch_Record.name.localeCompare(b.Batch_Record.name)
+  } else if (a.Batch_Record) {
+    return -1
+  } else if (b.Batch_Record) {
+    return 1
+  }
+  return 0
+}

+ 14 - 92
src/pages/cargo-consolidation-request/index.vue

@@ -699,6 +699,18 @@ import * as XLSX from 'xlsx'
 import debounce from 'lodash.debounce'
 import compPrint from '@/components/print.vue'
 import request from '@/utils/axios'
+import {
+  customSort1,
+  customSort2,
+  customSort3,
+  customSort4,
+  customSort5,
+  customSort6,
+  refSort,
+  requesterSort,
+  salesPersonSort,
+  batchRecordSort,
+} from './func'
 
 defineComponent({
   name: 'ComponentCargoConsolidationRequest',
@@ -961,31 +973,14 @@ let getSubList = (e: any = {}) => {
     .finally(() => (loading.value = false))
 }
 // 货物材质候选数据
-const goodMaterialOption = ref([
-  'Cotton 棉',
-  'Iron 铁',
-  'Neoprene 潜水料',
-  'Paper 纸质',
-  'Plastic 塑料',
-  'Polyester Fibre 聚酯纤维',
-  'PU 聚氨酯',
-  'PVC 聚氯乙烯',
-  'Velvet 天鹅绒',
-  'Zinc alloy 锌合金',
-  'Aluminum alloy 铝合金',
-  'Glass 玻璃',
-  'Rubber 橡胶',
-  'Stainless Steel 不锈钢',
-])
+const goodMaterialOption = ref([] as any[])
 // 动态获取货物材质候选数据
 let getGoodMaterialOption = () => {
   request
     .post('/common/getWebsiteSubform', { id: '4791186000359651051' })
     .then((resp: any) => {
-      // console.log(resp, 'res')
       const res = resp.data.result || {}
       if (Array.isArray(res.data) && res.data.length) {
-        // console.log(res.data, 'res.data')
         goodMaterialOption.value =
           res.data[0].Website_Subform.map(
             (i: any) => i.Website_Subform_Value,
@@ -1107,26 +1102,13 @@ const commit = () => {
       }
     }) as any[]
 
-  // const emptyBatchRecordList: number[] = []
   const emptyUserNotesList: number[] = []
   result.forEach((i, index) => {
-    // if (!i.Sample) {
-    //   if (!i.Batch_Record) {
-    //     emptyBatchRecordList.push(index)
-    //   }
-    // }
     if (!i.User_Notes) {
       emptyUserNotesList.push(index)
     }
   })
-  // if (emptyBatchRecordList.length) {
-  //   ElNotification({
-  //     title: '请检查表单',
-  //     message: `第 ${emptyBatchRecordList.map((i) => i + 1).join(', ')} 行的Batch Record数据`,
-  //     duration: 5000,
-  //   })
-  //   return
-  // }
+
   if (emptyUserNotesList.length) {
     ElNotification({
       title: '请检查表单, 备注是必填的',
@@ -1556,66 +1538,6 @@ let closeCubeDialog = () => {
   cubeForm.value.Carton = '1'
   cubeForm2.value.c = ''
 }
-let customSort1 = (a: any, b: any) => {
-  return parseFloat(a.Carton || 0) - parseFloat(b.Carton || 0)
-}
-let customSort2 = (a: any, b: any) => {
-  return parseFloat(a.Quantity || 0) - parseFloat(b.Quantity || 0)
-}
-let customSort3 = (a: any, b: any) => {
-  return parseFloat(a.Unit_Price || 0) - parseFloat(b.Unit_Price || 0)
-}
-let customSort4 = (a: any, b: any) => {
-  return parseFloat(a.Weight || 0) - parseFloat(b.Weight || 0)
-}
-let customSort5 = (a: any, b: any) => {
-  return parseFloat(a.Cube || 0) - parseFloat(b.Cube || 0)
-}
-let customSort6 = (a: any, b: any) => {
-  return parseFloat(a.Total_FOB || 0) - parseFloat(b.Total_FOB || 0)
-}
-let refSort = (a: any, b: any) => {
-  if (a.Reference && b.Reference) {
-    return a.Reference.localeCompare(b.Reference)
-  } else if (a.Reference) {
-    return -1
-  } else if (b.Reference) {
-    return 1
-  }
-  return 0
-}
-// 申请人/负责人 点击按 首字符A-Z排序
-let requesterSort = (a: any, b: any) => {
-  if (a.Requester && b.Requester) {
-    return a.Requester.name.localeCompare(b.Requester.name)
-  } else if (a.Requester) {
-    return -1
-  } else if (b.Requester) {
-    return 1
-  }
-  return 0
-}
-let salesPersonSort = (a: any, b: any) => {
-  if (a.Sales_Person && b.Sales_Person) {
-    return a.Sales_Person.localeCompare(b.Sales_Person)
-  } else if (a.Sales_Person) {
-    return -1
-  } else if (b.Sales_Person) {
-    return 1
-  }
-  return 0
-}
-// 批次记录batchRecord排序, 按 有值 无值 排序即可
-let batchRecordSort = (a: any, b: any) => {
-  if (a.Batch_Record && b.Batch_Record) {
-    return a.Batch_Record.name.localeCompare(b.Batch_Record.name)
-  } else if (a.Batch_Record) {
-    return -1
-  } else if (b.Batch_Record) {
-    return 1
-  }
-  return 0
-}
 
 let selectedRow = ref([] as any[])
 const handleSelectionChange = (val: any[]) => {