Эх сурвалжийг харах

Merge branch 'master' of http://120.26.64.82:10880/BFFE/SZYGM1.0

zhaoke 2 жил өмнө
parent
commit
cb99cf8379

+ 16 - 14
src/components/SimpleTable/index.vue

@@ -194,23 +194,25 @@ const props = withDefaults(
 )
 
 const defaultSummaryMethod = ({ columns, data }) => {
-  const sums: string[] = []
+  const sums: (string | number)[] = []
   columns.forEach((column, index) => {
     tableColumns.value.forEach(col => {
       if (column.property === col.columnName && col.needCount) {
-        const values = data.map(item => Number(item[column.property]))
-        if (!values.every(value => isNaN(value))) {
-          sums[index] = String(
-            values.reduce((prev, curr) => {
-              const value = Number(curr)
-              if (!isNaN(value)) {
-                return prev + curr
-              } else {
-                return prev
-              }
-            }, 0)
-          )
-        }
+        sums[index] = data.reduce((prev: number, curr: CommonData) => {
+          const cellData = curr[column.property]
+          if (col.countMode === 'all') {
+            return prev + 1
+          }
+          if (col.countMode === 'notNull') {
+            return cellData ? prev + 1 : prev
+          }
+          const value = Number(cellData)
+          if (!isNaN(value)) {
+            return prev + value
+          } else {
+            return prev
+          }
+        }, 0)
       }
     })
   })

+ 10 - 2
src/hooks/useTableFilterAndSort.ts

@@ -5,8 +5,9 @@ import { CommonData, CommonTableColumn, MaybeRef } from '~/common'
 interface Options {
   defaultFilterValueMap?: { [x: string]: string[] } // 默认筛选条件
   extraFilterValueMap?: MaybeRef<{ [x: string]: string[] }> // 表头之外的额外筛选条件
-  defaultSortRuleMap?: { [x: string]: string } // 默认排序
+  defaultSortRuleMap?: { [x: string]: string } // 默认排序条件
   extraSortRuleMap?: MaybeRef<{ [x: string]: string }> // 表头之外的额外排序条件
+  defaultSortFunction?: (a: CommonData, b: CommonData) => number // 默认排序函数
   sortMode?: 'single' | 'multiple'
 }
 
@@ -47,6 +48,7 @@ export function useTableFilterAndSort(
     extraFilterValueMap = {},
     defaultSortRuleMap = {},
     extraSortRuleMap = {},
+    defaultSortFunction,
   } = options
 
   const filterOptionMap = reactive<{
@@ -84,7 +86,13 @@ export function useTableFilterAndSort(
       },
       [[], []]
     )
-    return _.orderBy(filtered, sortRules[0], sortRules[1])
+    if (sortRules[1].length) {
+      return _.orderBy(filtered, sortRules[0], sortRules[1])
+    }
+    if (defaultSortFunction) {
+      return filtered.sort(defaultSortFunction)
+    }
+    return filtered
   })
 
   const sortChangeHandler = (currentKey: string) => {

+ 3 - 3
src/views/realTime/components/AirportView/index.scss

@@ -65,9 +65,9 @@
         .el-table-v2__row {
           &.bg-gray {
             background-color: #d2d6df;
-            // & + :not(.bg-gray) {
-            //   border-top: 2px solid #e83f82;
-            // }
+          }
+          &.bg-light {
+            background-color: #eef3d6;
           }
           &.underline-red {
             border-bottom: 2px solid #e83f82;

+ 90 - 18
src/views/realTime/components/AirportView/index.vue

@@ -3,15 +3,29 @@
     <div class="airport-header">
       <AirportForm :name="name" @form-data-change="formDataChangeHandler" />
       <div class="airport-count">
-        <CountBox
+        <!-- <CountBox
           :count-number="tableDataCount.waybillCount"
           :label="isDeparture ? '预计装载总运单数' : '预计卸载总运单数'"
         />
         <CountBox
-          v-show="countFlag"
-          :count-number="tableDataCount.goodsCount"
-          :label="isDeparture ? '预计装载总件数' : '预计卸载总件数'"
+        v-show="countFlag"
+        :count-number="tableDataCount.goodsCount"
+        :label="isDeparture ? '预计装载总件数' : '预计卸载总件数'"
+        /> -->
+        <CountBox
+          :count-number="tableDataCount.flightCount"
+          label="今日计划航班数"
+        />
+        <CountBox
+          :count-number="
+            isDeparture ? finishedCount : tableDataCount.tallyCount
+          "
+          label="已完成航班数"
         />
+        <!-- <CountBox
+          :count-number="tableDataCount.weightCount"
+          label="已转载重量"
+        /> -->
       </div>
       <div class="airport-settings">
         <div v-permission="getPermission('count')">
@@ -51,9 +65,9 @@
           >
             <template #footer>
               <div class="table-footer">
-                <span class="table-footer-count"
+                <!-- <span class="table-footer-count"
                   >今日航班总数:{{ tableDataCount.flightCount }}</span
-                >
+                > -->
                 <span class="table-footer-count"
                   >货运航班总数:{{ tableDataCount.freightFlightCount }}</span
                 >
@@ -211,6 +225,8 @@ const rowClass: RowClassGetter = params => {
     ) {
       classes.push('underline-red')
     }
+  } else if (rowData.loadPlaneSureTime) {
+    classes.push('bg-light')
   }
   if (selectedRowKey.value && rowData.rowKey === selectedRowKey.value) {
     classes.push('is-selected')
@@ -231,11 +247,11 @@ const rowEventHandlers: RowEventHandlers = {
 const tableDataCount = computed(() =>
   tableData.value.reduce(
     (counts: { [x: string]: number }, current) => {
-      const preCount = current[isDeparture ? 'preLoad' : 'preUnload']
-      if (preCount) {
-        counts.waybillCount += Number(String(preCount).split('/')[0])
-        counts.goodsCount += Number(String(preCount).split('/')[1])
-      }
+      // const preCount = current[isDeparture ? 'preLoad' : 'preUnload']
+      // if (preCount) {
+      //   counts.waybillCount += Number(String(preCount).split('/')[0])
+      //   counts.goodsCount += Number(String(preCount).split('/')[1])
+      // }
       if (typeof current['allNumber'] === 'number') {
         counts.flightCount = current['allNumber']
       }
@@ -254,16 +270,21 @@ const tableDataCount = computed(() =>
       if (current['unLoadTime']) {
         counts.unloadCount++
       }
+      if (current['tallyTime_in']) {
+        counts.tallyCount++
+      }
       return counts
     },
     {
-      waybillCount: 0,
-      goodsCount: 0,
+      // waybillCount: 0,
+      // goodsCount: 0,
       flightCount: 0,
       depotFlightCount: 0,
       freightFlightCount: 0,
       loadCount: 0,
       unloadCount: 0,
+      tallyCount: 0,
+      weightCount: 0,
     }
   )
 )
@@ -292,6 +313,56 @@ const flightStateFilter = computed<{} | { [x: string]: string[] }>(() => {
       return {}
   }
 })
+
+/* 离港视图默认的排序方式:
+ * 1.已起飞排在前
+ * 2.未起飞中已装机在前
+ * 3.已起飞和未起飞分类中各自按照预计起飞时间排序
+ */
+const defaultSortFunction = (a: CommonData, b: CommonData) => {
+  const departureTimeCompare = (a: CommonData, b: CommonData) => {
+    if (a.planDepartureTime) {
+      if (b.planDepartureTime) {
+        if (a.planDepartureTime > b.planDepartureTime) {
+          return 1
+        } else if (a.planDepartureTime < b.planDepartureTime) {
+          return -1
+        } else {
+          return 0
+        }
+      } else {
+        return -1
+      }
+    } else if (b.planDepartureTime) {
+      return 1
+    } else {
+      return 0
+    }
+  }
+
+  if (a.hasTakenOff) {
+    if (b.hasTakenOff) {
+      return departureTimeCompare(a, b)
+    } else {
+      return -1
+    }
+  } else if (b.hasTakenOff) {
+    return 1
+  } else {
+    if (a.loadPlaneSureTime) {
+      if (b.loadPlaneSureTime) {
+        return departureTimeCompare(a, b)
+      } else {
+        return -1
+      }
+    } else if (b.loadPlaneSureTime) {
+      return 1
+    } else {
+      return departureTimeCompare(a, b)
+    }
+  }
+}
+
 const {
   filterOptionMap,
   filterValueMap,
@@ -301,11 +372,12 @@ const {
 } = useTableFilterAndSort(tableColumns, tableData, {
   defaultFilterValueMap,
   extraFilterValueMap: flightStateFilter,
-  defaultSortRuleMap: {
-    [props.name.includes('Departure')
-      ? 'planDepartureTime'
-      : 'planLandingTime']: 'ascending',
-  },
+  defaultSortRuleMap: isDeparture
+    ? undefined
+    : {
+        planLandingTime: 'ascending',
+      },
+  defaultSortFunction: isDeparture ? defaultSortFunction : undefined,
 })
 const columnsShouldCache = ['IATACode']
 watch(filterValueMap, map => {

+ 0 - 3
src/views/realTime/components/FlightView/index.vue

@@ -151,9 +151,6 @@ const tableFormatter: CommonTableFormatter = (
     if (Number.isNaN(execResult)) {
       return cellValue
     }
-    if (props.name === 'InternationalDepartureFlight') {
-      return execResult ? '通过' : '异常'
-    }
     return execResult ? '通过' : '未通过'
   }
   const value = String(cellValue ?? '').trim()

+ 6 - 6
src/views/realTime/components/FlightView/useFlightInfo.ts

@@ -49,7 +49,7 @@ const flightInfoItemsMap = {
         key: 'loadPlane',
       },
       {
-        label: '拉下集装器/货物数',
+        label: '拉下集装器/数',
         key: 'pull',
       },
       // {
@@ -100,11 +100,11 @@ const flightInfoItemsMap = {
       //   label: '中转进运单/货物数',
       //   key: "transIn",
       // },
-      {
-        label: '已卸载集装器',
-        key: 'unloadStowageNum',
-        showOverflowTooltip: true,
-      },
+      // {
+      //   label: '已卸载集装器',
+      //   key: 'unloadStowageNum',
+      //   showOverflowTooltip: true,
+      // },
       {
         label: '卸载数量(板/箱/卡)',
         key: 'unloadPlaneInfo',

+ 1 - 1
src/views/realTime/components/WaybillView/index.vue

@@ -64,7 +64,7 @@
                   >航班号:{{ trackAirline.flightNO }}</span
                 >
                 <span
-                  v-if="!name.includes('InterNationalDeparture')"
+                  v-if="!name.includes('InternationalDeparture')"
                   class="title-span"
                   >{{ trackAirport.isDeparture ? '出港' : '进港' }}:{{
                     trackAirport.airport

+ 14 - 2
src/views/realTime/hooks/useTable.ts

@@ -17,7 +17,13 @@ const tableColumnsMap: {
   } & { [x: string]: any })[]
 } = {
   DepartureFlightContainer: [
-    { columnLabel: '集装器编号', columnName: 'stowageNo', width: 120 },
+    {
+      columnLabel: '集装器编号',
+      columnName: 'stowageNo',
+      width: 120,
+      needCount: 1,
+      countMode: 'all',
+    },
     { columnLabel: '配载运单', columnName: 'list', width: 60 },
     { columnLabel: '件数', columnName: 'number', width: 60, needCount: 1 },
     { columnLabel: '重量', columnName: 'weight', width: 60, needCount: 1 },
@@ -417,7 +423,13 @@ const tableColumnsMap: {
     { columnLabel: '发往位置描述', columnName: 'C13' },
   ],
   InternationalDepartureFlightContainer: [
-    { columnLabel: '集装器编号', columnName: 'stowageNo', width: 120 },
+    {
+      columnLabel: '集装器编号',
+      columnName: 'stowageNo',
+      width: 120,
+      needCount: 1,
+      countMode: 'all',
+    },
     { columnLabel: '配载运单', columnName: 'list', width: 60 },
     { columnLabel: '件数', columnName: 'number', width: 60, needCount: 1 },
     { columnLabel: '重量', columnName: 'weight', width: 60, needCount: 1 },