index.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. <template>
  2. <div class="flight-view">
  3. <div class="flight-view-top">
  4. <div class="flight-info-wrapper">
  5. <div class="air-line">{{ airLine }}</div>
  6. <div class="flight-info-box-wrapper">
  7. <template v-for="(group, index) in flightInfoItems" :key="index">
  8. <div class="info-box">
  9. <div v-for="(item, i) in group" :key="i" class="info-item">
  10. <div>{{ item.label }}:</div>
  11. <el-tooltip
  12. v-if="computedFlightInfo(item) && item.showOverflowTooltip"
  13. :content="computedFlightInfo(item)"
  14. effect="light"
  15. >
  16. <div>{{ computedFlightInfo(item) }}</div>
  17. </el-tooltip>
  18. <div v-else>{{ computedFlightInfo(item) }}</div>
  19. </div>
  20. </div>
  21. <div v-if="index < flightInfoItems.length - 1" class="icon-box">
  22. <el-icon color="#ffffff" :size="22"><CaretRight /></el-icon>
  23. </div>
  24. </template>
  25. </div>
  26. </div>
  27. <div v-if="name.includes('Departure')" class="container-list">
  28. <SimpleTable
  29. :data="containerTableData"
  30. :columns="containerTableColumns"
  31. scrollbar-always-on
  32. :row-class-name="flightContainerRowClass"
  33. :cell-class-name="flightContainerCellClass"
  34. @cell-click="flightContainerCellClickHandler"
  35. />
  36. </div>
  37. </div>
  38. <div class="waybill-list-wrapper">
  39. <div class="waybill-list-header">
  40. <CommonSwitch v-model:flag="UTCFlag" label="开启UTC" />
  41. <!-- <el-button
  42. class="button-sqaure"
  43. :icon="Refresh"
  44. color="#ac014d"
  45. @click="refreshHandler"
  46. /> -->
  47. <el-button
  48. class="button-sqaure"
  49. :icon="Download"
  50. color="#ac014d"
  51. @click="downloadHandler"
  52. />
  53. <ColumnSet
  54. class="button-sqaure"
  55. :table-columns="waybillTableColumns"
  56. @checked-submit="columnChecked"
  57. />
  58. <Search @search="search" @clear="clear" />
  59. </div>
  60. <div class="waybill-list">
  61. <SimpleTable
  62. ref="waybillTableRef"
  63. :data="waybillTableData"
  64. :columns="filteredWaybillColumns"
  65. :row-class-name="flightWaybillRowClass"
  66. :cell-class-name="flightWaybillCellClass"
  67. :column-props="{ formatter: waybillTableFormatter }"
  68. @cell-click="flightWaybillCellClickHandler"
  69. />
  70. </div>
  71. </div>
  72. <ContainerWaybillDialog
  73. v-model:flag="dialogFlag"
  74. :data-content="containerWaybillDataContent"
  75. :is-departure="isDeparture"
  76. />
  77. </div>
  78. </template>
  79. <script setup lang="ts">
  80. import Search from '@/components/search/index.vue'
  81. import { CaretRight, Download, Refresh } from '@element-plus/icons-vue'
  82. import ContainerWaybillDialog from './ContainerWaybillDialog.vue'
  83. import SimpleTable from '@/components/SimpleTable/index.vue'
  84. import CommonSwitch from '../../components/CommonSwitch/index.vue'
  85. import ColumnSet from '../../components/ColumnSet/index.vue'
  86. import { useTable } from '../../hooks/useTable'
  87. import { useTableColumnSet } from '../../hooks/useTableColumnSet'
  88. import { useTableExport } from '../../hooks/useTableExport'
  89. import { useTableStyle } from '../../hooks/useTableStyle'
  90. import { useTableCellClick } from '../../hooks/useTableCellClick'
  91. import { useFlightInfo } from './useFlightInfo'
  92. const props = defineProps({
  93. name: {
  94. type: String,
  95. required: true,
  96. },
  97. })
  98. // onMounted(() => {
  99. // console.log('mounted', 'flight')
  100. // })
  101. // onActivated(() => {
  102. // console.log('activated', 'flight')
  103. // })
  104. // onDeactivated(() => {
  105. // console.log('deactivated', 'flight')
  106. // })
  107. const isDeparture = computed(() => props.name.includes('Departure'))
  108. const route = useRoute()
  109. const {
  110. flightNO,
  111. flightDate,
  112. // departureAirport,
  113. // landingAirport
  114. } = route.query
  115. // if (!flightNO || !flightDate) {
  116. // router.push('/')
  117. // }
  118. const dataContent = [
  119. flightDate,
  120. flightNO,
  121. // departureAirport,
  122. // landingAirport,
  123. ] as string[]
  124. const { flightInfoItems, flightInfo, computedFlightInfo } = useFlightInfo(
  125. props.name,
  126. dataContent
  127. )
  128. const airLine = toRef(flightInfo, 'flightinfo')
  129. const {
  130. tableColumns: containerTableColumns,
  131. tableData: containerTableData,
  132. } = useTable(`${props.name}Container`, dataContent)
  133. const waybillTableFormatter = (row, column, cellValue, index) => {
  134. if (column.property.includes('Time') && typeof cellValue === 'string') {
  135. return cellValue.replace('T', '\n')
  136. }
  137. return String(cellValue ?? '')
  138. }
  139. const {
  140. tableColumns: waybillTableColumns,
  141. tableData: waybillTableData,
  142. } = useTable(`${props.name}Waybill`, dataContent)
  143. const UTCFlag = ref(true)
  144. // const refreshHandler = () => {
  145. // ElMessage.info('开发中')
  146. // }
  147. const {
  148. filteredColumns: filteredWaybillColumns,
  149. columnChecked,
  150. } = useTableColumnSet(waybillTableColumns)
  151. const waybillTableRef = ref<InstanceType<typeof SimpleTable> | null>(null)
  152. const { exportToExcel } = useTableExport()
  153. //点击下载按钮
  154. const downloadHandler = () => {
  155. const table = waybillTableRef.value!.table!
  156. exportToExcel({ table })
  157. }
  158. //清空搜索
  159. const clear = () => {}
  160. //点击搜索按钮
  161. const search = (text: string) => {
  162. console.log(text)
  163. }
  164. const {
  165. rowClass: flightContainerRowClass,
  166. cellClass: flightContainerCellClass,
  167. } = useTableStyle(`${props.name}Container`)
  168. const {
  169. rowClass: flightWaybillRowClass,
  170. cellClass: flightWaybillCellClass,
  171. } = useTableStyle(`${props.name}Waybill`)
  172. const {
  173. cellClickHandler: flightContainerCellClickHandler,
  174. dialogFlag,
  175. containerNO,
  176. } = useTableCellClick(`${props.name}Container`)
  177. const containerWaybillDataContent = computed(
  178. () => [flightDate, flightNO, unref(containerNO)] as string[]
  179. )
  180. const { cellClickHandler: flightWaybillCellClickHandler } = useTableCellClick(
  181. `${props.name}Waybill`
  182. )
  183. </script>
  184. <style lang="scss" scoped>
  185. .flight-view {
  186. width: 100%;
  187. height: 100%;
  188. display: flex;
  189. flex-direction: column;
  190. .flight-view-top {
  191. width: 100%;
  192. height: 345px;
  193. display: flex;
  194. .flight-info-wrapper {
  195. min-width: 1040px;
  196. flex: 1;
  197. height: 100%;
  198. background: #410425;
  199. box-sizing: border-box;
  200. padding: 18px 32px;
  201. overflow: hidden;
  202. display: flex;
  203. flex-direction: column;
  204. .air-line {
  205. font-size: 18px;
  206. font-weight: bold;
  207. color: #ffffff;
  208. width: 100%;
  209. margin-bottom: 16px;
  210. }
  211. .flight-info-box-wrapper {
  212. width: 100%;
  213. max-width: 976px;
  214. flex: 1;
  215. display: flex;
  216. justify-content: flex-start;
  217. justify-items: center;
  218. .info-box {
  219. width: calc(33.3% - 10px);
  220. background: #561638;
  221. padding: 10px 15px;
  222. .info-item {
  223. width: 100%;
  224. height: 30px;
  225. line-height: 30px;
  226. font-size: 14px;
  227. font-weight: 400;
  228. color: #ffffff;
  229. display: flex;
  230. .el-tooltip__trigger {
  231. flex: 1;
  232. overflow: hidden;
  233. white-space: nowrap;
  234. text-overflow: ellipsis;
  235. }
  236. }
  237. }
  238. .icon-box {
  239. display: flex;
  240. flex-direction: column;
  241. width: 60px;
  242. justify-content: center;
  243. align-items: center;
  244. }
  245. }
  246. }
  247. .container-list {
  248. width: 0;
  249. flex: 1;
  250. height: 100%;
  251. margin-left: 16px;
  252. .el-table :deep {
  253. .el-table__body .el-table__row {
  254. &.row-warning .el-table__cell {
  255. background-color: #f0c579;
  256. }
  257. }
  258. }
  259. }
  260. }
  261. .waybill-list-wrapper {
  262. height: 0;
  263. flex: 1;
  264. display: flex;
  265. flex-direction: column;
  266. .waybill-list-header :deep {
  267. height: 72px;
  268. display: flex;
  269. justify-content: flex-end;
  270. align-items: center;
  271. .button-sqaure {
  272. margin-left: 24px;
  273. width: 30px;
  274. height: 30px;
  275. border-radius: 4px;
  276. font-size: 16px;
  277. &:last-of-type {
  278. margin-right: 48px;
  279. }
  280. }
  281. }
  282. .waybill-list {
  283. height: 0;
  284. flex: 1;
  285. .el-table :deep {
  286. .el-table__body .el-table__row {
  287. &.row-warning .el-table__cell {
  288. background-color: #f0c579;
  289. }
  290. &.row-alarm .el-table__cell {
  291. background-color: #f38080;
  292. }
  293. }
  294. }
  295. }
  296. }
  297. }
  298. </style>