Explorar o código

航班查询、运单查询表头

zhongxiaoyu hai 1 ano
pai
achega
838ff2d4a0

+ 2 - 0
public/extraConfig.js

@@ -30,6 +30,8 @@ var NODE_CODE = {
     { nodeName: '海关放行', nodeCode: 'MTREL' },
     { nodeName: '出库', nodeCode: 'DLV' },
     { nodeName: '理货', nodeCode: 'RCF报' },
+    { nodeName: '理货', nodeCode: 'CARTON_LIST' },
+    { nodeName: '发起货站交接', nodeCode: 'CARGOS_DEP_ULD_HANDOVER' },
     { nodeName: '货站交接', nodeCode: 'CARGOS_HANDOVER_STATUS99' },
   ],
   departure: [

+ 204 - 199
src/components/SimpleTable/index.vue

@@ -25,8 +25,8 @@
   >
     <el-table-column
       v-if="sequence"
+      prop="index"
       :fixed="hasFixedColumn"
-      type="index"
       :width="50"
       align="center"
     >
@@ -50,8 +50,8 @@
           :sortable="!!column.needSort"
           filter-style="arrow"
           @update:sort-rule="
-            (sortRule) => {
-              sortRuleChangeHandler(column.columnName, sortRule);
+            sortRule => {
+              sortRuleChangeHandler(column.columnName, sortRule)
             }
           "
         />
@@ -64,223 +64,223 @@
 </template>
 
 <script setup lang="ts">
-import TableHeaderCell from "@/components/TableHeaderCell/index.vue";
-import type { CSSProperties, VNode } from "vue";
-import { TableColumnCtx } from "element-plus/es/components/table/src/table-column/defaults";
-import { CommonData, CommonTableColumn } from "~/common";
-import { Options, useTableFilterAndSort } from "@/hooks/useTableFilterAndSort";
-import { ElTable } from "element-plus";
-import { useTableSettingsStore } from "@/store/tableSettings";
+import TableHeaderCell from '@/components/TableHeaderCell/index.vue'
+import type { CSSProperties, VNode } from 'vue'
+import { TableColumnCtx } from 'element-plus/es/components/table/src/table-column/defaults'
+import { CommonData, CommonTableColumn } from '~/common'
+import { Options, useTableFilterAndSort } from '@/hooks/useTableFilterAndSort'
+import { ElTable } from 'element-plus'
+import { useTableSettingsStore } from '@/store/tableSettings'
 
 type SummaryMethod<T> = (data: {
-  columns: TableColumnCtx<T>[];
-  data: T[];
-}) => string[];
-type ColumnCls<T> = string | ((data: { row: T; rowIndex: number }) => string);
+  columns: TableColumnCtx<T>[]
+  data: T[]
+}) => string[]
+type ColumnCls<T> = string | ((data: { row: T; rowIndex: number }) => string)
 type ColumnStyle<T> =
   | CSSProperties
-  | ((data: { row: T; rowIndex: number }) => CSSProperties);
+  | ((data: { row: T; rowIndex: number }) => CSSProperties)
 type CellCls<T> =
   | string
   | ((data: {
-      row: T;
-      rowIndex: number;
-      column: TableColumnCtx<T>;
-      columnIndex: number;
-    }) => string);
+      row: T
+      rowIndex: number
+      column: TableColumnCtx<T>
+      columnIndex: number
+    }) => string)
 type CellStyle<T> =
   | CSSProperties
   | ((data: {
-      row: T;
-      rowIndex: number;
-      column: TableColumnCtx<T>;
-      columnIndex: number;
-    }) => CSSProperties);
+      row: T
+      rowIndex: number
+      column: TableColumnCtx<T>
+      columnIndex: number
+    }) => CSSProperties)
 type Sort = {
-  prop: string;
-  order: "ascending" | "descending";
-  init?: any;
-  silent?: any;
-};
+  prop: string
+  order: 'ascending' | 'descending'
+  init?: any
+  silent?: any
+}
 type TreeNode = {
-  expanded?: boolean;
-  loading?: boolean;
-  noLazyChildren?: boolean;
-  indent?: number;
-  level?: number;
-  display?: boolean;
-};
-type Layout = "fixed" | "auto";
+  expanded?: boolean
+  loading?: boolean
+  noLazyChildren?: boolean
+  indent?: number
+  level?: number
+  display?: boolean
+}
+type Layout = 'fixed' | 'auto'
 type TableColumnProps<T> = {
-  type?: string;
-  index?: number | ((index: number) => number);
-  columnKey?: string;
-  width?: string | number;
-  minWidth?: string | number;
-  fixed?: boolean | string;
-  renderHeader?: (data: { column: TableColumnCtx<T>; $index: number }) => VNode;
-  resizable?: boolean;
+  type?: string
+  index?: number | ((index: number) => number)
+  columnKey?: string
+  width?: string | number
+  minWidth?: string | number
+  fixed?: boolean | string
+  renderHeader?: (data: { column: TableColumnCtx<T>; $index: number }) => VNode
+  resizable?: boolean
   formatter?: (
     row: T,
     column: TableColumnCtx<T>,
     cellValue: any,
     index: number
-  ) => VNode | string;
-  showOverflowTooltip?: boolean;
-  align?: string;
-  headerAlign?: string;
-  className?: string;
-  labelClassName?: string;
-  selectable?: (row: T, index: number) => boolean;
-  reserveSelection?: boolean;
-};
+  ) => VNode | string
+  showOverflowTooltip?: boolean
+  align?: string
+  headerAlign?: string
+  className?: string
+  labelClassName?: string
+  selectable?: (row: T, index: number) => boolean
+  reserveSelection?: boolean
+}
 
 const props = withDefaults(
   defineProps<{
-    data: CommonData[];
-    size?: string;
-    width?: string | number;
-    height?: string | number;
-    maxHeight?: string | number;
-    fit?: boolean;
-    stripe?: boolean;
-    border?: boolean;
-    rowKey?: string | ((row: CommonData) => string);
-    showHeader?: boolean;
-    showSummary?: boolean;
-    sumText?: string;
-    summaryMethod?: SummaryMethod<CommonData>;
-    rowClassName?: ColumnCls<CommonData>;
-    rowStyle?: ColumnStyle<CommonData>;
-    cellClassName?: CellCls<CommonData>;
-    cellStyle?: CellStyle<CommonData>;
-    headerRowClassName?: ColumnCls<CommonData>;
-    headerRowStyle?: ColumnStyle<CommonData>;
-    headerCellClassName?: CellCls<CommonData>;
-    headerCellStyle?: CellStyle<CommonData>;
-    highlightCurrentRow?: boolean;
-    currentRowKey?: string | number;
-    emptyText?: string;
-    expandRowKeys?: any[];
-    defaultExpandAll?: boolean;
-    defaultSort?: Sort;
-    tooltipEffect?: string;
+    data: CommonData[]
+    size?: string
+    width?: string | number
+    height?: string | number
+    maxHeight?: string | number
+    fit?: boolean
+    stripe?: boolean
+    border?: boolean
+    rowKey?: string | ((row: CommonData) => string)
+    showHeader?: boolean
+    showSummary?: boolean
+    sumText?: string
+    summaryMethod?: SummaryMethod<CommonData>
+    rowClassName?: ColumnCls<CommonData>
+    rowStyle?: ColumnStyle<CommonData>
+    cellClassName?: CellCls<CommonData>
+    cellStyle?: CellStyle<CommonData>
+    headerRowClassName?: ColumnCls<CommonData>
+    headerRowStyle?: ColumnStyle<CommonData>
+    headerCellClassName?: CellCls<CommonData>
+    headerCellStyle?: CellStyle<CommonData>
+    highlightCurrentRow?: boolean
+    currentRowKey?: string | number
+    emptyText?: string
+    expandRowKeys?: any[]
+    defaultExpandAll?: boolean
+    defaultSort?: Sort
+    tooltipEffect?: string
     spanMethod?: (data: {
-      row: CommonData;
-      rowIndex: number;
-      column: TableColumnCtx<CommonData>;
-      columnIndex: number;
+      row: CommonData
+      rowIndex: number
+      column: TableColumnCtx<CommonData>
+      columnIndex: number
     }) =>
       | number[]
       | {
-          rowspan: number;
-          colspan: number;
+          rowspan: number
+          colspan: number
         }
-      | undefined;
-    selectOnIndeterminate?: boolean;
-    indent?: number;
+      | undefined
+    selectOnIndeterminate?: boolean
+    indent?: number
     treeProps?: {
-      hasChildren?: string;
-      children?: string;
-    };
-    lazy?: boolean;
+      hasChildren?: string
+      children?: string
+    }
+    lazy?: boolean
     load?: (
       row: CommonData,
       treeNode: TreeNode,
       resolve: (data: CommonData[]) => void
-    ) => void;
-    className?: string;
-    style?: CSSProperties;
-    tableLayout?: Layout;
-    flexible?: boolean;
-    scrollbarAlwaysOn?: boolean;
-    columnProps?: TableColumnProps<CommonData>;
-    columns: (CommonTableColumn & TableColumnProps<CommonData>)[];
-    sequence?: boolean;
-    filterSortOptions?: Options;
-    cacheKeys?: string[];
-    labelFormatter?: (label: string) => string;
+    ) => void
+    className?: string
+    style?: CSSProperties
+    tableLayout?: Layout
+    flexible?: boolean
+    scrollbarAlwaysOn?: boolean
+    columnProps?: TableColumnProps<CommonData>
+    columns: (CommonTableColumn & TableColumnProps<CommonData>)[]
+    sequence?: boolean
+    filterSortOptions?: Options
+    cacheKeys?: string[]
+    labelFormatter?: (label: string) => string
   }>(),
   {
-    size: "default",
-    height: "100%",
-    maxHeight: "100%",
+    size: 'default',
+    height: '100%',
+    maxHeight: '100%',
     stripe: true,
     border: true,
     fit: true,
     showHeader: true,
     labelFormatter: (label: string) => label,
   }
-);
+)
 
 const defaultSummaryMethod: SummaryMethod<CommonData> = ({ columns, data }) => {
-  const sums: string[] = [];
+  const sums: string[] = []
   columns.forEach((column, index) => {
     const countColumn = tableColumns.value.find(
-      (col) => column.property === col.columnName && col.needCount
-    );
+      col => column.property === col.columnName && col.needCount
+    )
     if (countColumn) {
       const sumNumber = data.reduce((prev: number, curr: CommonData) => {
-        const cellData = curr[column.property];
-        if (countColumn.countMode === "all") {
-          return prev + 1;
+        const cellData = curr[column.property]
+        if (countColumn.countMode === 'all') {
+          return prev + 1
         }
-        if (countColumn.countMode === "notNull") {
-          return cellData ? prev + 1 : prev;
+        if (countColumn.countMode === 'notNull') {
+          return cellData ? prev + 1 : prev
         }
-        const value = Number(cellData);
+        const value = Number(cellData)
         if (!Number.isNaN(value)) {
-          prev += value;
+          prev += value
         }
-        return prev;
-      }, 0);
-      sums[index] = sumNumber.toString();
+        return prev
+      }, 0)
+      sums[index] = sumNumber.toString()
     }
-  });
-  sums[0] = "合计:" + (sums[0] ?? "");
-  return sums;
-};
+  })
+  sums[0] = '合计:' + (sums[0] ?? '')
+  return sums
+}
 
 const tableProps = computed(() => {
-  const rawProps = toRaw(props);
-  const result: { [x: string]: any } = {};
+  const rawProps = toRaw(props)
+  const result: { [x: string]: any } = {}
   Object.entries(rawProps).forEach(([key, value]) => {
     if (
       ![
-        "columnProps",
-        "columns",
-        "sequence",
-        "filterSortOptions",
-        "cacheKeys",
-        "labelFormatter",
+        'columnProps',
+        'columns',
+        'sequence',
+        'filterSortOptions',
+        'cacheKeys',
+        'labelFormatter',
       ].includes(key) &&
-      (value ?? "") !== ""
+      (value ?? '') !== ''
     ) {
-      result[key] = value;
+      result[key] = value
     }
-    if (props.columns.some((column) => column.needCount)) {
-      result.showSummary = true;
+    if (props.columns.some(column => column.needCount)) {
+      result.showSummary = true
     }
     if (!result.summaryMethod) {
-      result.summaryMethod = defaultSummaryMethod;
+      result.summaryMethod = defaultSummaryMethod
     }
-  });
-  return result;
-});
+  })
+  return result
+})
 
 const computedColumnProps = computed(() => {
   const defaultColumnProps: TableColumnProps<CommonData> = {
-    align: "center",
-  };
+    align: 'center',
+  }
   return (column: CommonTableColumn & TableColumnProps<CommonData>) => ({
     ...defaultColumnProps,
     ...props.columnProps,
     ...column,
-  });
-});
+  })
+})
 
-const tableColumns = ref<CommonTableColumn[]>([]);
-const tableData = ref<CommonData[]>([]);
+const tableColumns = ref<CommonTableColumn[]>([])
+const tableData = ref<CommonData[]>([])
 watchEffect(() => {
   tableColumns.value = props.columns.reduce(
     (prevColumns: CommonTableColumn[], column) => {
@@ -289,18 +289,23 @@ watchEffect(() => {
           label: column.columnLabel,
           prop: column.columnName,
           ...column,
-        });
+        })
       }
-      return prevColumns;
+      return prevColumns
     },
     []
-  );
-  tableData.value = props.data;
-});
+  )
+  tableData.value = props.data.map((row, rowIndex) => {
+    if (props.sequence && (row.index ?? '') === '') {
+      row.index = rowIndex + 1
+    }
+    return row
+  })
+})
 
 const hasFixedColumn = computed(() =>
-  tableColumns.value.some((column) => column.fixed)
-);
+  tableColumns.value.some(column => column.fixed)
+)
 
 const {
   filterOptionMap,
@@ -308,64 +313,64 @@ const {
   sortRuleMap,
   dealedTableData,
   sortChangeHandler,
-} = useTableFilterAndSort(tableColumns, tableData, props.filterSortOptions);
+} = useTableFilterAndSort(tableColumns, tableData, props.filterSortOptions)
 
-const { saveTableFilterValues } = useTableSettingsStore();
+const { saveTableFilterValues } = useTableSettingsStore()
 
 watch(
   sortRuleMap,
-  (map) => {
-    emit("sortRuleChange", map);
+  map => {
+    emit('sortRuleChange', map)
   },
   { deep: true }
-);
+)
 
 const sortRuleChangeHandler = (columnName: string, sortRule: string) => {
-  sortRuleMap[columnName] = sortRule;
-  sortChangeHandler(columnName, sortRule);
-};
+  sortRuleMap[columnName] = sortRule
+  sortChangeHandler(columnName, sortRule)
+}
 
 if (props.cacheKeys?.length) {
-  watch(filterValueMap, (map) => {
-    const values: { [x: string]: string[] } = {};
-    props.cacheKeys!.forEach((columnName) => {
-      values[columnName] = map[columnName];
-    });
-    saveTableFilterValues(values);
-  });
+  watch(filterValueMap, map => {
+    const values: { [x: string]: string[] } = {}
+    props.cacheKeys!.forEach(columnName => {
+      values[columnName] = map[columnName]
+    })
+    saveTableFilterValues(values)
+  })
 }
 
 const emit = defineEmits([
-  "select",
-  "selectAll",
-  "selectionChange",
-  "cellMouseEnter",
-  "cellMouseLeave",
-  "cellClick",
-  "cellDblclick",
-  "cellContextmenu",
-  "rowClick",
-  "rowContextmenu",
-  "rowDblclick",
-  "headerClick",
-  "headerContextmenu",
-  "sortChange",
-  "filterChange",
-  "currentChange",
-  "headerDragend",
-  "expandChange",
-  "sortRuleChange",
-  "scrollOver",
-]);
+  'select',
+  'selectAll',
+  'selectionChange',
+  'cellMouseEnter',
+  'cellMouseLeave',
+  'cellClick',
+  'cellDblclick',
+  'cellContextmenu',
+  'rowClick',
+  'rowContextmenu',
+  'rowDblclick',
+  'headerClick',
+  'headerContextmenu',
+  'sortChange',
+  'filterChange',
+  'currentChange',
+  'headerDragend',
+  'expandChange',
+  'sortRuleChange',
+  'scrollOver',
+])
 
 const scrollOver = () => {
-  emit("scrollOver");
-};
+  emit('scrollOver')
+}
 
-const table = ref<InstanceType<typeof ElTable> | null>(null);
+const table = ref<InstanceType<typeof ElTable> | null>(null)
 defineExpose({
   table,
-});
+})
 </script>
 
 <style scoped lang="scss">
@@ -376,7 +381,7 @@ defineExpose({
     &.cell-filter {
       position: relative;
       &::before {
-        content: "";
+        content: '';
         position: absolute;
         width: 100%;
         height: 100%;

+ 6 - 5
src/views/dataQuery/components/DataQueryView/index.vue

@@ -174,6 +174,7 @@
           tableData.slice((currentPage - 1) * pagesize, currentPage * pagesize)
         "
         :columns="tableColumns"
+        sequence
         :cell-class-name="cellClass"
         :column-props="{ formatter }"
         height="calc(100vh - 220px)"
@@ -215,8 +216,8 @@ const props = defineProps({
     required: true,
   },
 });
-const currentPage = ref<number>(1);
-const pagesize = ref<number>(11);
+const currentPage = ref(1);
+const pagesize = ref(11);
 const today = parseTime(new Date(), "{y}-{m}-{d}") as string;
 const formData = reactive({
   flightDate: today,
@@ -342,9 +343,9 @@ const dataQuery = () => {
   formRef.value?.validate((valid) => {
     if (valid) {
       if (stockCode) {
-        formData.keyWords = stockCode;
-        formData.startDate = flightDate;
-        formData.endDate = flightDate;
+        formData.keyWords = stockCode as string;
+        formData.startDate = flightDate as string;
+        formData.endDate = flightDate as string;
       }
       tableInit();
       getTableData();

+ 164 - 64
src/views/dataQuery/components/DataQueryView/useTable.ts

@@ -1,8 +1,111 @@
-import { Query } from "@/api/webApi";
-import { Ref } from "vue";
-import { CommonData, CommonTableColumn, CommonValue } from "~/common";
+import { Query } from '@/api/webApi'
+import { Ref } from 'vue'
+import { CommonData, CommonTableColumn, CommonValue } from '~/common'
 
-const idGetter = (name: string) => DATACONTENT_ID[name + "DataQuery"];
+const idGetter = (name: string) => DATACONTENT_ID[name + 'DataQuery']
+
+const tableColumnsMap: {
+  [tableName: string]: {
+    columnLabel: string
+    columnName: string
+    [x: string]: any
+  }[]
+} = {
+  flight: [
+    {
+      columnLabel: '航司二字码',
+      columnName: 'IATACode',
+      width: 80,
+    },
+    {
+      columnLabel: '航班号',
+      columnName: 'flightNO',
+      width: 80,
+    },
+    {
+      columnLabel: '机型',
+      columnName: 'planeType',
+    },
+    {
+      columnLabel: '起飞机场',
+      columnName: 'departureAirport',
+    },
+    {
+      columnLabel: '经停机场',
+      columnName: 'transferAirport',
+    },
+    {
+      columnLabel: '降落机场',
+      columnName: 'landingAirport',
+    },
+    {
+      columnLabel: '计划起飞时间',
+      columnName: 'planDepartureTime',
+    },
+    {
+      columnLabel: '实际起飞时间',
+      columnName: 'acDepartureTime',
+    },
+    {
+      columnLabel: '计划降落时间',
+      columnName: 'planLandingTime',
+    },
+    {
+      columnLabel: '实际降落时间',
+      columnName: 'acLandingTime',
+    },
+    {
+      columnLabel: '航班类型',
+      columnName: 'flightType',
+    },
+    {
+      columnLabel: '航班状态',
+      columnName: 'flightState',
+    },
+    {
+      columnLabel: '国内国际',
+      columnName: 'DIType',
+    },
+  ],
+  waybill: [
+    {
+      columnLabel: '运单号',
+      columnName: 'stockCode',
+    },
+    {
+      columnLabel: '品名',
+      columnName: 'typeCode',
+    },
+    {
+      columnLabel: '离港航班号',
+      columnName: 'flightNO',
+    },
+    {
+      columnLabel: '离港航班日期',
+      columnName: 'flightDate',
+    },
+    {
+      columnLabel: '离港出发机场',
+      columnName: 'departureAirport',
+    },
+    {
+      columnLabel: '离港到达机场',
+      columnName: 'arriveAirport',
+    },
+    {
+      columnLabel: '总重量',
+      columnName: 'weight',
+    },
+    {
+      columnLabel: 'luggageCount',
+      columnName: '总件数',
+    },
+    {
+      columnLabel: '计费重量',
+      columnName: 'feeWeight',
+    },
+  ],
+}
 
 export function useTable(
   tableName: string,
@@ -11,15 +114,15 @@ export function useTable(
   noMore: Ref<boolean>,
   loading?: Ref<boolean>
 ) {
-  const tableColumns = ref<CommonTableColumn[]>([]);
-  const tableData = ref<CommonData[]>([]);
+  const tableColumns = ref<CommonTableColumn[]>([])
+  const tableData = ref<CommonData[]>([])
 
   const getTableData = async (defaultDataContent?: CommonValue[]) => {
     if (!idGetter(tableName)) {
-      return;
+      return
     }
     if (loading) {
-      loading.value = true;
+      loading.value = true
     }
     try {
       let {
@@ -34,16 +137,16 @@ export function useTable(
         startDate,
         endDate,
         keyWords,
-      } = formData;
+      } = formData
       if (
-        tableName === "waybill" &&
-        typeof keyWords === "string" &&
+        tableName === 'waybill' &&
+        typeof keyWords === 'string' &&
         keyWords.length === 11
       ) {
-        keyWords = `${keyWords.slice(0, 3)}-${keyWords.slice(3)}`;
+        keyWords = `${keyWords.slice(0, 3)}-${keyWords.slice(3)}`
       }
       let dataContent =
-        tableName === "flight"
+        tableName === 'flight'
           ? [
               keyWords,
               company,
@@ -54,8 +157,8 @@ export function useTable(
               flightType,
               sFlightDate,
             ]
-          : [startDate, endDate, keyWords];
-      dataContent = dataContent.map((v) => (v === "" ? null : v));
+          : [startDate, endDate, keyWords]
+      dataContent = dataContent.map(v => (v === '' ? null : v))
       const {
         code,
         returnData: { columnSet, listValues },
@@ -64,76 +167,73 @@ export function useTable(
         id: idGetter(tableName),
         dataContent: defaultDataContent ?? dataContent,
         // needPage: page.value,
-      });
+      })
       if (Number(code) !== 0) {
-        throw new Error(message || "失败");
+        throw new Error(message || '失败')
+      }
+      if (!tableColumnsMap[tableName]) {
+        tableColumns.value = columnSet
       }
-      tableColumns.value = columnSet.map((column) => ({
-        ...column,
-        width:
-          (tableName === "flight" &&
-            ["IATACode", "flightNO"].includes(column.columnName) &&
-            80) ||
-          undefined,
-      }));
-      tableColumns.value.unshift({
-        columnDescribe: "序号",
-        columnLabel: "序号",
-        columnName: "indexs",
-        dataType: "varchar(2)",
-        listqueryTemplateID: 0,
-        needCount: 0,
-        needFilters: 0,
-        needGroup: 0,
-        needSearch: null,
-        needShow: 1,
-        needSort: 0,
-        orderNumber: 1,
-        queryTemplateColumnSetID: 410,
-        queryTemplateID: 1803439,
-      });
       if (listValues.length) {
         tableData.value.push(
           ...listValues.filter(
-            (row) =>
+            row =>
               !Object.values(row).some(
-                (cellValue) =>
-                  typeof cellValue === "string" &&
-                  cellValue.includes("undefined")
+                cellValue =>
+                  typeof cellValue === 'string' &&
+                  cellValue.includes('undefined')
               )
           )
-        );
-        tableData.value.forEach((item, index) => {
-          item.indexs = index + 1;
-        });
+        )
+        tableData.value.forEach((row, rowIndex) => {
+          row.index = rowIndex + 1
+        })
       } else {
-        page.value--;
-        noMore.value = true;
+        page.value--
+        noMore.value = true
       }
     } catch (error) {
-      console.error(error);
-      page.value--;
-      noMore.value = true;
+      console.error(error)
+      page.value--
+      noMore.value = true
     }
     if (loading) {
-      loading.value = false;
+      loading.value = false
     }
-  };
-  const route = useRoute();
+  }
+  const route = useRoute()
   onMounted(() => {
-    const { flightDate, stockCode } = route.query;
+    if (tableColumnsMap[tableName]) {
+      tableColumns.value = tableColumnsMap[tableName].map(column => ({
+        columnDescribe: '',
+        dataType: '',
+        listqueryTemplateID: null,
+        needCount: null,
+        needFilters: null,
+        needGroup: null,
+        needSearch: null,
+        needShow: 1,
+        needSort: null,
+        orderNumber: null,
+        queryTemplateColumnSetID: null,
+        queryTemplateID: null,
+        ...column,
+      }))
+    }
+
+    const { flightDate, stockCode } = route.query
     const defaultDataContent =
-      tableName === "flight"
-        ? [null, null, "2000-01-01", null, null, null, null, null]
+      tableName === 'flight'
+        ? [null, null, '2000-01-01', null, null, null, null, null]
         : stockCode
         ? [flightDate, flightDate, stockCode]
-        : [null, null, null];
-    getTableData(defaultDataContent);
-  });
+        : [null, null, null]
+    getTableData(defaultDataContent as CommonValue[])
+  })
 
   return {
     tableColumns,
     tableData,
     getTableData,
-  };
+  }
 }

+ 118 - 115
src/views/dataQuery/message/index.vue

@@ -109,116 +109,116 @@
 
 <script lang="tsx">
 export default {
-  name: "MessageQuery",
-};
+  name: 'MessageQuery',
+}
 </script>
 
 <script setup lang="tsx">
-import { Search } from "@element-plus/icons-vue";
-import ColumnSet from "@/components/ColumnSet/index.vue";
-import SimpleTable from "@/components/SimpleTable/index.vue";
-import { ElMessage, FormInstance } from "element-plus";
-import { parseTime } from "@/utils/validate";
-import { useTableColumnSet } from "@/hooks/useTableColumnSet";
+import { Search } from '@element-plus/icons-vue'
+import ColumnSet from '@/components/ColumnSet/index.vue'
+import SimpleTable from '@/components/SimpleTable/index.vue'
+import { ElMessage, FormInstance } from 'element-plus'
+import { parseTime } from '@/utils/validate'
+import { useTableColumnSet } from '@/hooks/useTableColumnSet'
 import {
   CommonData,
   CommonTableColumn,
   CommonTableFormatter,
   CommonValue,
-} from "~/common";
-import { Query } from "@/api/webApi";
-const currentPage = ref<number>(1);
-const pagesize = ref<number>(11);
-const today = parseTime(new Date(), "{y}-{m}-{d}") as string;
+} from '~/common'
+import { Query } from '@/api/webApi'
+const currentPage = ref<number>(1)
+const pagesize = ref<number>(11)
+const today = parseTime(new Date(), '{y}-{m}-{d}') as string
 const formData = reactive({
   startDate: today,
   endDate: today,
-  messageType: "",
-  waybillNO: "",
-});
+  messageType: '',
+  waybillNO: '',
+})
 
 watchEffect(() => {
   if (!formData.startDate || !formData.endDate) {
-    return;
+    return
   }
-  const start = new Date(formData.startDate).getTime();
-  const end = new Date(formData.endDate).getTime();
+  const start = new Date(formData.startDate).getTime()
+  const end = new Date(formData.endDate).getTime()
   if (start > end) {
-    ElMessage.warning("开始时间不能晚于结束时间");
-    formData.endDate = "";
+    ElMessage.warning('开始时间不能晚于结束时间')
+    formData.endDate = ''
   }
   if (start <= end - 2 * 24 * 60 * 60 * 1000) {
-    ElMessage.warning("间隔不能超过2天");
-    formData.endDate = "";
+    ElMessage.warning('间隔不能超过2天')
+    formData.endDate = ''
   }
-});
-const handleSizeChange = (val) => {
-  pagesize.value = val;
-};
-const handleCurrentChange = (val) => {
-  currentPage.value = val;
-};
+})
+const handleSizeChange = val => {
+  pagesize.value = val
+}
+const handleCurrentChange = val => {
+  currentPage.value = val
+}
 const disabledEndDate = (endDate: Date) => {
-  const start = new Date(formData.startDate + " 00:00:00").getTime();
-  const end = endDate.getTime();
-  return start > end || start <= end - 2 * 24 * 60 * 60 * 1000;
-};
+  const start = new Date(formData.startDate + ' 00:00:00').getTime()
+  const end = endDate.getTime()
+  return start > end || start <= end - 2 * 24 * 60 * 60 * 1000
+}
 const datePreTitle = (title: string) => {
-  return <div class="date-pre-title">{title}:</div>;
-};
+  return <div class="date-pre-title">{title}:</div>
+}
 
 const messageTypeOptions = ref(
   Object.entries(MESSAGE_TYPE).map(([value, label]) => ({
     label,
     value,
   }))
-);
+)
 
 const waybillValidator = (rule: any, value: any, callback: any) => {
   if (!value) {
-    return callback();
+    return callback()
   }
   const notMatched = [
     /^[0-9]{8}$/,
     /^[0-9]{11}$/,
     /^[0-9]{3}\-[0-9]{8}$/,
-  ].every((reg) => !reg.test(value));
+  ].every(reg => !reg.test(value))
   if (notMatched) {
-    return callback(new Error("请输入正确的运单号"));
+    return callback(new Error('请输入正确的运单号'))
   }
-  return callback();
-};
+  return callback()
+}
 const rules = {
-  waybillNO: [{ validator: waybillValidator, trigger: "blur" }],
-};
+  waybillNO: [{ validator: waybillValidator, trigger: 'blur' }],
+}
 
-const formRef = ref<FormInstance | null>();
+const formRef = ref<FormInstance | null>()
 const dataQuery = () => {
-  formRef.value?.validate((valid) => {
+  formRef.value?.validate(valid => {
     if (valid) {
-      tableInit();
-      getTableData();
+      tableInit()
+      getTableData()
     }
-  });
-};
+  })
+}
 const resetForm = () => {
-  formRef.value?.resetFields();
-};
+  formRef.value?.resetFields()
+}
 
-const loading = ref(false);
-const page = ref(1);
-const noMore = ref(true);
-const tableColumns = ref<CommonTableColumn[]>([]);
-const tableData = ref<CommonData[]>([]);
+const loading = ref(false)
+const page = ref(1)
+const noMore = ref(true)
+const tableColumns = ref<CommonTableColumn[]>([])
+const tableData = ref<CommonData[]>([])
 const getTableData = async (defaultDataContent?: CommonValue[]) => {
   if (loading) {
-    loading.value = true;
+    loading.value = true
   }
   try {
-    let { startDate, endDate, messageType, waybillNO } = formData;
+    let { startDate, endDate, messageType, waybillNO } = formData
     const dataContent = [startDate, endDate, messageType, waybillNO].map(
-      (v) => v || null
-    );
+      v => v || null
+    )
     const {
       code,
       returnData: { listValues },
@@ -226,84 +226,87 @@ const getTableData = async (defaultDataContent?: CommonValue[]) => {
     } = await Query<CommonData>({
       id: DATACONTENT_ID.messageDataQuery,
       dataContent: defaultDataContent ?? dataContent,
-    });
+    })
     if (Number(code) !== 0) {
-      throw new Error(message || "失败");
+      throw new Error(message || '失败')
     }
     if (listValues.length) {
       tableData.value.push(
         ...listValues.filter(
-          (row) =>
+          row =>
             !Object.values(row).some(
-              (cellValue) =>
-                typeof cellValue === "string" && cellValue.includes("undefined")
+              cellValue =>
+                typeof cellValue === 'string' && cellValue.includes('undefined')
             )
         )
-      );
+      )
+      tableData.value.forEach((row, rowIndex) => {
+        row.index = rowIndex + 1
+      })
     } else {
-      page.value--;
-      noMore.value = true;
+      page.value--
+      noMore.value = true
     }
   } catch (error) {
-    console.error(error);
-    page.value--;
-    noMore.value = true;
+    console.error(error)
+    page.value--
+    noMore.value = true
   }
   if (loading) {
-    loading.value = false;
+    loading.value = false
   }
-};
+}
 const load = () => {
   if (loading.value || noMore.value) {
-    return;
+    return
   }
-  page.value++;
-  getTableData();
-};
+  page.value++
+  getTableData()
+}
 const tableInit = () => {
-  page.value = 0;
-  noMore.value = false;
-  tableData.value = [];
-};
+  page.value = 0
+  noMore.value = false
+  tableData.value = []
+}
 
-const { columnChecked } = useTableColumnSet(tableColumns);
+const { columnChecked } = useTableColumnSet(tableColumns)
 
 const columns = [
   {
-    columnName: "waybillNO",
-    columnLabel: "运单号",
+    columnName: 'waybillNO',
+    columnLabel: '运单号',
   },
   {
-    columnName: "fileName",
-    columnLabel: "文件名称",
+    columnName: 'fileName',
+    columnLabel: '文件名称',
   },
   {
-    columnName: "messageName",
-    columnLabel: "报文名称",
+    columnName: 'messageName',
+    columnLabel: '报文名称',
   },
   {
-    columnName: "messageState",
-    columnLabel: "收发状态",
+    columnName: 'messageState',
+    columnLabel: '收发状态',
   },
   {
-    columnName: "execTime",
-    columnLabel: "执行时间",
+    columnName: 'execTime',
+    columnLabel: '执行时间',
   },
   {
-    columnName: "airportState",
-    columnLabel: "报文收发方",
+    columnName: 'airportState',
+    columnLabel: '报文收发方',
   },
   {
-    columnName: "messageDetails",
-    columnLabel: "报文明细",
+    columnName: 'messageDetails',
+    columnLabel: '报文明细',
     showOverflowTooltip: true,
     width: 300,
   },
-];
+]
 onMounted(() => {
-  tableColumns.value = columns.map((column) => ({
-    columnDescribe: "",
-    dataType: "",
+  tableColumns.value = columns.map(column => ({
+    columnDescribe: '',
+    dataType: '',
     needCount: null,
     needFilters: null,
     needGroup: null,
@@ -315,26 +318,26 @@ onMounted(() => {
     queryTemplateID: null,
     orderNumber: null,
     ...column,
-  }));
-});
+  }))
+})
 
 const messageStateMap = {
-  in: "收",
-  out: "发",
-};
+  in: '收',
+  out: '发',
+}
 const formatter: CommonTableFormatter = (row, column, cellValue, index) => {
-  const value = String(cellValue ?? "").trim();
-  if (column.property === "fileName") {
-    return MESSAGE_TYPE[value] ?? value;
+  const value = String(cellValue ?? '').trim()
+  if (column.property === 'fileName') {
+    return MESSAGE_TYPE[value] ?? value
   }
-  if (column.property === "execTime") {
-    return value.replace("T", " ");
+  if (column.property === 'execTime') {
+    return value.replace('T', ' ')
   }
-  if (column.property === "messageState") {
-    return messageStateMap[value] ?? "";
+  if (column.property === 'messageState') {
+    return messageStateMap[value] ?? ''
   }
-  return value;
-};
+  return value
+}
 </script>
 
 <style lang="scss" scoped>