Jelajahi Sumber

feat: cargo.子表部分列增加排序功能.

peter 3 minggu lalu
induk
melakukan
96992931af
1 mengubah file dengan 86 tambahan dan 6 penghapusan
  1. 86 6
      src/pages/cargo-consolidation-request/index.vue

+ 86 - 6
src/pages/cargo-consolidation-request/index.vue

@@ -293,6 +293,8 @@
           width="50"
         ></el-table-column>
         <el-table-column
+          :sortable="currentTab === 'Arrangement'"
+          :sort-method="batchRecordSort"
           fixed
           label="CRM批次记录"
           width="220"
@@ -346,6 +348,8 @@
         <el-table-column
           label="箱数"
           width="80"
+          :sortable="currentTab === 'Arrangement'"
+          :sort-method="customSort1"
         >
           <template #default="scope">
             <el-input
@@ -406,6 +410,8 @@
         <el-table-column
           label="数量"
           width="100"
+          :sortable="currentTab === 'Arrangement'"
+          :sort-method="customSort2"
         >
           <template #default="scope">
             <el-input
@@ -418,7 +424,9 @@
         </el-table-column>
         <el-table-column
           label="单价(澳币/AUD)"
-          width="120"
+          :sortable="currentTab === 'Arrangement'"
+          :sort-method="customSort3"
+          width="145"
         >
           <template #default="scope">
             <el-input
@@ -430,6 +438,8 @@
           </template>
         </el-table-column>
         <el-table-column
+          :sortable="currentTab === 'Arrangement'"
+          :sort-method="requesterSort"
           label="负责人"
           fixed="right"
           width="120"
@@ -443,6 +453,8 @@
           </template>
         </el-table-column>
         <el-table-column
+          :sortable="currentTab === 'Arrangement'"
+          :sort-method="salesPersonSort"
           label="申请人"
           fixed="right"
           width="120"
@@ -510,7 +522,9 @@
         <el-table-column
           fixed="right"
           label="重量 (KG)"
-          width="70"
+          :sortable="currentTab === 'Arrangement'"
+          :sort-method="customSort4"
+          width="95"
         >
           <template #default="scope">
             <el-input
@@ -522,9 +536,11 @@
           </template>
         </el-table-column>
         <el-table-column
+          :sortable="currentTab === 'Arrangement'"
+          :sort-method="customSort5"
           fixed="right"
           label="体积 m&sup3;"
-          width="70"
+          width="95"
         >
           <template #default="scope">
             <el-button
@@ -539,9 +555,11 @@
           </template>
         </el-table-column>
         <el-table-column
+          :sortable="currentTab === 'Arrangement'"
+          :sort-method="customSort6"
           fixed="right"
           label="总离岸价 (澳币/AUD)"
-          width="140"
+          width="165"
         >
           <template #default="scope">
             <el-input
@@ -552,9 +570,11 @@
           </template>
         </el-table-column>
         <el-table-column
+          :sortable="currentTab === 'Arrangement'"
+          :sort-method="refSort"
           label="Reference"
           fixed="right"
-          width="90"
+          width="115"
         >
           <template #default="scope">
             <div class="">{{ scope.row.Reference || scope.row.PO_Number }}</div>
@@ -1015,7 +1035,7 @@ const onBatchRecordChange = ($e: string, line = -1) => {
       !subList.value[line].Marks_Nos ||
       subList.value[line].Marks_Nos.length < 1
     ) {
-      subList.value[line].Marks_Nos = result.Job_Name	 || ''
+      subList.value[line].Marks_Nos = result.Job_Name || ''
     }
     if (!subList.value[line].Quantity) {
       subList.value[line].Quantity = result.Quantity || ''
@@ -1496,6 +1516,66 @@ let closeCubeDialog = () => {
   cubeForm.value.h = ''
   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
+}
 </script>
 <style lang="scss">
 .page-cargo-consolidation {