index.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <template>
  2. <div class="airport-view">
  3. <div class="airport-header">
  4. <AirportForm :name="name" @form-data-change="formDataChangeHandler" />
  5. <div class="airport-count">
  6. <CountBox
  7. :count-number="tableDataCount.waybillCount"
  8. label="预计装载总运单数"
  9. />
  10. <CountBox
  11. v-show="goodsCountFlag"
  12. :count-number="tableDataCount.goodsCount"
  13. label="预计装载总件数"
  14. />
  15. </div>
  16. <div class="airport-settings">
  17. <CommonSwitch v-model:flag="goodsCountFlag" label="显示件数" />
  18. <CommonSwitch v-model:flag="UTCFlag" label="开启UTC" />
  19. <ColumnSet
  20. :table-columns="tableColumns"
  21. @checked-submit="columnChecked"
  22. />
  23. </div>
  24. </div>
  25. <div class="airport-table">
  26. <el-auto-resizer>
  27. <template #default="{ height, width }">
  28. <el-table-v2
  29. :columns="tableColumns"
  30. :data="dealedTableData"
  31. :width="width"
  32. :height="height"
  33. :fixed="name.includes('Departure')"
  34. :footer-height="60"
  35. :row-class="rowClassV2"
  36. :cell-props="cellPropsGetter"
  37. >
  38. <template #header-cell="slot: HeaderCellSlotProps">
  39. <TableHeaderCell
  40. v-model:filter-values="filterValueMap[slot.column.columnName]"
  41. v-model:sort-rule="tableDataSortRuleMap[slot.column.columnName]"
  42. :label="slot.column.title"
  43. :filter-options="filterOptionMap[slot.column.columnName]"
  44. :sortable="slot.column.needSort"
  45. filter-style="arrow"
  46. />
  47. </template>
  48. <template #cell="slot: CellSlotProps">
  49. <div
  50. class="el-table-v2__cell-text"
  51. @click="cellClickHandlerV2(slot)"
  52. >
  53. {{ slot.rowData[slot.column.columnName] }}
  54. </div>
  55. </template>
  56. <template #footer>
  57. <div class="table-footer">
  58. <span class="table-footer-count"
  59. >航班总数:{{ tableDataCount.flightCount }}</span
  60. >
  61. <span class="table-footer-count"
  62. >货运航班总数:{{ tableDataCount.freightFlightCount }}</span
  63. >
  64. <span class="table-footer-count"
  65. >已装机总数:{{ tableDataCount.loadCount }}</span
  66. >
  67. <span class="table-footer-count"
  68. >已起飞总数:{{ tableDataCount.takeOffCount }}</span
  69. >
  70. </div>
  71. </template>
  72. </el-table-v2>
  73. </template>
  74. </el-auto-resizer>
  75. </div>
  76. </div>
  77. </template>
  78. <script lang="ts" setup>
  79. import type { CellSlotProps } from '../../type'
  80. import AirportForm from './AirportForm.vue'
  81. import ColumnSet from '../../components/ColumnSet/index.vue'
  82. import CountBox from '../../components/CountBox/index.vue'
  83. import CommonSwitch from '../../components/CommonSwitch/index.vue'
  84. import TableHeaderCell from '@/components/TableHeaderCell/index.vue'
  85. import useTableColumnSet from '../../hooks/useTableColumnSet'
  86. import useAirportTable from './useAirportTable'
  87. import useTableStyle from '../../hooks/useTableStyle'
  88. import useTableCellClick from '../../hooks/useTableCellClick'
  89. import useTableFilterAndSort from '@/hooks/useTableFilterAndSort'
  90. import { HeaderCellSlotProps } from 'element-plus'
  91. import { CommonData } from '~/common'
  92. const props = defineProps({
  93. name: {
  94. type: String,
  95. required: true,
  96. },
  97. })
  98. const formData = reactive<CommonData>({})
  99. const formDataChangeHandler = (data: CommonData) => {
  100. Object.assign(formData, data)
  101. }
  102. const goodsCountFlag = ref(true)
  103. const UTCFlag = ref(true)
  104. const { tableColumns, tableData } = useAirportTable(props.name, formData)
  105. const { columnChecked } = useTableColumnSet(tableColumns)
  106. const { rowClassV2, cellClassV2 } = useTableStyle(props.name)
  107. const cellPropsGetter = params => ({
  108. class: cellClassV2(params),
  109. })
  110. const tableDataCount = computed(() => ({
  111. waybillCount: tableData.value.length,
  112. goodsCount: tableData.value.length,
  113. flightCount: tableData.value.length,
  114. freightFlightCount: tableData.value.length,
  115. loadCount: tableData.value.length,
  116. takeOffCount: tableData.value.length,
  117. }))
  118. const { cellClickHandlerV2 } = useTableCellClick(props.name)
  119. const {
  120. filterOptionMap,
  121. filterValueMap,
  122. tableDataSortRuleMap,
  123. dealedTableData,
  124. } = useTableFilterAndSort(tableColumns, tableData)
  125. </script>
  126. <style lang="scss" scoped>
  127. @import './index.scss';
  128. </style>