|
@@ -1,69 +1,30 @@
|
|
|
import { Query } from '@/api/webApi'
|
|
|
+import { Ref } from 'vue'
|
|
|
import { CommonData, CommonTableColumn } from '~/common'
|
|
|
|
|
|
const idGetter = (name: string) => DATACONTENT_ID[name + 'DataQuery']
|
|
|
|
|
|
-const tableColumnsMap: {
|
|
|
- [tableName: string]: ({
|
|
|
- columnLabel: string
|
|
|
- columnName: string
|
|
|
- } & { [x: string]: any })[]
|
|
|
-} = {
|
|
|
- flight: [],
|
|
|
- waybill: [],
|
|
|
- freight: [
|
|
|
- { columnLabel: '起飞航站', columnName: 'departureAirport' },
|
|
|
- { columnLabel: '目的航站', columnName: 'arriveAirport' },
|
|
|
- { columnLabel: '航班号', columnName: 'flightAllNO' },
|
|
|
- { columnLabel: '航班日期', columnName: 'flightDate' },
|
|
|
- { columnLabel: '直达/中转', columnName: 'ynTrans' },
|
|
|
- { columnLabel: '货物牌号', columnName: 'pcsCode' },
|
|
|
- { columnLabel: '特殊货物类型', columnName: 'specialType' },
|
|
|
- { columnLabel: '位置', columnName: 'nodeCode' },
|
|
|
- { columnLabel: '状态', columnName: 'status' },
|
|
|
- { columnLabel: '运单号', columnName: 'stockCode' },
|
|
|
- { columnLabel: '值机号', columnName: 'checkNo' },
|
|
|
- { columnLabel: '安检序号', columnName: 'securityNo' },
|
|
|
- { columnLabel: '货代', columnName: 'cargoCompany' },
|
|
|
- { columnLabel: '货代等级', columnName: 'Grade' },
|
|
|
- { columnLabel: '批次号', columnName: 'batchNo' },
|
|
|
- ],
|
|
|
-}
|
|
|
-
|
|
|
-export function useTable(tableName: string, formData: CommonData) {
|
|
|
+export function useTable(
|
|
|
+ tableName: string,
|
|
|
+ formData: CommonData,
|
|
|
+ loading?: Ref<boolean>
|
|
|
+) {
|
|
|
const tableColumns = ref<CommonTableColumn[]>([])
|
|
|
const tableData = ref<CommonData[]>([])
|
|
|
- const getTableColumns = () => {
|
|
|
- if (!tableColumnsMap[tableName]) {
|
|
|
- return
|
|
|
- }
|
|
|
- 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 getTableData = async () => {
|
|
|
if (!idGetter(tableName)) {
|
|
|
return
|
|
|
}
|
|
|
+ if (loading) {
|
|
|
+ loading.value = true
|
|
|
+ }
|
|
|
try {
|
|
|
const { startDate, endDate, keyWords } = formData
|
|
|
- const dataContent = [startDate, endDate, keyWords]
|
|
|
+ const dataContent = [startDate, endDate, keyWords || null]
|
|
|
const {
|
|
|
code,
|
|
|
- returnData: { listValues },
|
|
|
+ returnData: { columnSet, listValues },
|
|
|
message,
|
|
|
} = await Query<CommonData>({
|
|
|
id: idGetter(tableName),
|
|
@@ -72,6 +33,7 @@ export function useTable(tableName: string, formData: CommonData) {
|
|
|
if (Number(code) !== 0) {
|
|
|
throw new Error(message || '失败')
|
|
|
}
|
|
|
+ tableColumns.value = columnSet
|
|
|
tableData.value = listValues.filter(
|
|
|
row =>
|
|
|
!Object.values(row).some(
|
|
@@ -82,10 +44,13 @@ export function useTable(tableName: string, formData: CommonData) {
|
|
|
} catch (error) {
|
|
|
console.error(error)
|
|
|
}
|
|
|
+ if (loading) {
|
|
|
+ loading.value = false
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
onMounted(() => {
|
|
|
- getTableColumns()
|
|
|
+ getTableData()
|
|
|
})
|
|
|
|
|
|
return {
|