index.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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="isDeparture ? '预计装载总运单数' : '预计卸载总运单数'"
  9. />
  10. <CountBox
  11. v-show="goodsCountFlag"
  12. :count-number="tableDataCount.goodsCount"
  13. :label="isDeparture ? '预计装载总件数' : '预计卸载总件数'"
  14. />
  15. </div>
  16. <div class="airport-settings">
  17. <div v-permission="getPermission('count')">
  18. <CommonSwitch v-model:flag="goodsCountFlag" label="显示件数" />
  19. </div>
  20. <div v-permission="getPermission('UTC')">
  21. <CommonSwitch v-model:flag="UTCFlag" label="开启UTC" />
  22. </div>
  23. <div v-permission="getPermission('columnSet')">
  24. <ColumnSet
  25. :table-columns="tableColumns"
  26. @checked-submit="columnChecked"
  27. />
  28. </div>
  29. </div>
  30. </div>
  31. <div class="airport-table">
  32. <el-auto-resizer>
  33. <template #default="{ height, width }">
  34. <el-table-v2
  35. :columns="tableColumns"
  36. :data="dealedTableData"
  37. :width="width"
  38. :height="height"
  39. :fixed="isDeparture"
  40. :footer-height="60"
  41. :row-class="rowClassV2"
  42. :cell-props="cellPropsGetter"
  43. >
  44. <template #header-cell="slot: HeaderCellSlotProps">
  45. <TableHeaderCell
  46. v-model:filter-values="filterValueMap[slot.column.columnName]"
  47. v-model:sort-rule="tableDataSortRuleMap[slot.column.columnName]"
  48. :label="slot.column.title"
  49. :filter-options="filterOptionMap[slot.column.columnName]"
  50. :sortable="slot.column.needSort"
  51. filter-style="arrow"
  52. />
  53. </template>
  54. <template #cell="slot: CellSlotProps">
  55. <div
  56. class="el-table-v2__cell-text"
  57. @click="cellClickHandlerV2(slot)"
  58. >
  59. <el-tooltip v-if="slot.column.columnName.includes('Time')" :content="slot.rowData[slot.column.columnName]">
  60. {{ slot.rowData[slot.column.columnName] }}
  61. </el-tooltip>
  62. <span v-else>{{ slot.rowData[slot.column.columnName] }}</span>
  63. </div>
  64. </template>
  65. <template #footer>
  66. <div class="table-footer">
  67. <span class="table-footer-count"
  68. >航班总数:{{ tableDataCount.flightCount }}</span
  69. >
  70. <span class="table-footer-count"
  71. >货运航班总数:{{ tableDataCount.freightFlightCount }}</span
  72. >
  73. <span class="table-footer-count"
  74. >已装机总数:{{ tableDataCount.loadCount }}</span
  75. >
  76. <span class="table-footer-count"
  77. >已起飞总数:{{ tableDataCount.takeOffCount }}</span
  78. >
  79. </div>
  80. </template>
  81. </el-table-v2>
  82. </template>
  83. </el-auto-resizer>
  84. </div>
  85. </div>
  86. </template>
  87. <script lang="ts" setup>
  88. import type { CellSlotProps } from '../../type'
  89. import AirportForm from './AirportForm.vue'
  90. import ColumnSet from '../../components/ColumnSet/index.vue'
  91. import CountBox from '../../components/CountBox/index.vue'
  92. import CommonSwitch from '../../components/CommonSwitch/index.vue'
  93. import TableHeaderCell from '@/components/TableHeaderCell/index.vue'
  94. import useTableColumnSet from '../../hooks/useTableColumnSet'
  95. import useAirportTable from './useAirportTable'
  96. import useTableStyle from '../../hooks/useTableStyle'
  97. import useTableCellClick from '../../hooks/useTableCellClick'
  98. import useTableFilterAndSort from '@/hooks/useTableFilterAndSort'
  99. import { HeaderCellSlotProps } from 'element-plus'
  100. import { CommonData } from '~/common'
  101. const props = defineProps({
  102. name: {
  103. type: String,
  104. required: true,
  105. },
  106. })
  107. const isDeparture = props.name.includes('Departure')
  108. const formData = reactive<CommonData>({})
  109. const formDataChangeHandler = (data: CommonData) => {
  110. Object.assign(formData, data)
  111. }
  112. const goodsCountFlag = ref(true)
  113. const UTCFlag = ref(true)
  114. const { tableColumns, tableData } = useAirportTable(props.name, formData)
  115. const { columnChecked } = useTableColumnSet(tableColumns)
  116. const { rowClassV2, cellClassV2 } = useTableStyle(props.name)
  117. const cellPropsGetter = params => ({
  118. class: cellClassV2(params),
  119. })
  120. const tableDataCount = computed(() => ({
  121. waybillCount: tableData.value.reduce((count, current) => {
  122. const countValue = current[isDeparture ? 'preLoad' : 'preUnload']
  123. if (countValue) {
  124. count += Number(String(countValue).split('/')[0])
  125. }
  126. return count
  127. }, 0),
  128. goodsCount: tableData.value.reduce((count, current) => {
  129. const countValue = current[isDeparture ? 'preLoad' : 'preUnload']
  130. if (countValue) {
  131. count += Number(String(countValue).split('/')[1])
  132. }
  133. return count
  134. }, 0),
  135. flightCount: tableData.value.length,
  136. freightFlightCount: tableData.value.length,
  137. loadCount: tableData.value.length,
  138. takeOffCount: tableData.value.length,
  139. }))
  140. const { cellClickHandlerV2 } = useTableCellClick(props.name)
  141. const {
  142. filterOptionMap,
  143. filterValueMap,
  144. tableDataSortRuleMap,
  145. dealedTableData,
  146. } = useTableFilterAndSort(tableColumns, tableData)
  147. const permissionMap = {
  148. DepartureAirport: {
  149. count:
  150. 'number_of_pieces_displayed_in_domestic_departure_terminal_view_button',
  151. UTC: 'turn_on_utc_in_view_of_domestic_departure_terminal_button',
  152. columnSet: 'domestic_departure_terminal_view_column_setting_button',
  153. },
  154. InternationalDepartureAirport: {
  155. count:
  156. 'number_of_pieces_displayed_in_international_departure_terminal_view_button',
  157. UTC: 'international_departure_terminal_view_opens_utc_button',
  158. columnSet: 'international_departure_terminal_view_column_setting_button',
  159. },
  160. ArrivalAirport: {
  161. count:
  162. 'number_of_pieces_displayed_in_domestic_inbound_terminal_view_button',
  163. UTC: 'turn_on_utc_in_view_of_domestic_inbound_terminal_button',
  164. columnSet: 'domestic_inbound_terminal_view_column_setting_button',
  165. },
  166. InternationalArrivalAirport: {
  167. count:
  168. 'number_of_display_pieces_of_international_inbound_terminal_view_button',
  169. UTC: 'the_view_of_international_inbound_terminal_opens_utc_button',
  170. columnSet: 'view_column_setting_of_international_inbound_terminal_button',
  171. },
  172. }
  173. const getPermission = (type?: string) => {
  174. return [permissionMap[props.name][type]]
  175. }
  176. </script>
  177. <style lang="scss" scoped>
  178. @import './index.scss';
  179. </style>