index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559
  1. <template>
  2. <div class="container-view">
  3. <div class="container-basic">
  4. <div class="title">
  5. <div class="manageTitle">容器基本信息</div>
  6. <el-button
  7. type="primary"
  8. size="small"
  9. @click="toContainerHistory"
  10. >历史记录</el-button>
  11. </div>
  12. <div
  13. ref="basicBox"
  14. class="basic-info-box"
  15. >
  16. <el-row :gutter="10">
  17. <el-col
  18. :xs="6"
  19. :sm="6"
  20. :xl="4"
  21. >
  22. <div class="grid-content">容器编号:{{ $route.query.containerID }}</div>
  23. </el-col>
  24. <el-col
  25. :xs="6"
  26. :sm="6"
  27. :xl="3"
  28. >
  29. <div class="grid-content">容器类型:{{ $route.query.containerType }}</div>
  30. </el-col>
  31. <el-col
  32. :xs="6"
  33. :sm="6"
  34. :xl="3"
  35. >
  36. <div class="grid-content">舱位:{{ $route.query.containerSpace }}</div>
  37. </el-col>
  38. <el-col
  39. :xs="6"
  40. :sm="6"
  41. :xl="3"
  42. >
  43. <div class="grid-content">航班号:{{ $route.query.flightNO }}</div>
  44. </el-col>
  45. <el-col
  46. :xs="12"
  47. :sm="12"
  48. :xl="5"
  49. >
  50. <div class="grid-content">航班日期:{{ $route.query.flightDate }}</div>
  51. </el-col>
  52. <el-col
  53. :xs="6"
  54. :sm="6"
  55. :xl="3"
  56. >
  57. <div class="grid-content">起飞站:{{ $route.query.departureAirport }}</div>
  58. </el-col>
  59. <el-col
  60. :xs="6"
  61. :sm="6"
  62. :xl="3"
  63. >
  64. <div class="grid-content">目的站:{{ $route.query.landingAirport }}</div>
  65. </el-col>
  66. </el-row>
  67. </div>
  68. </div>
  69. <div class="container-table">
  70. <div class="title">
  71. <div class="manageTitle">容器行李列表</div>
  72. <!-- <TimeZoneSelector /> -->
  73. <img
  74. class="btn-square btn-shadow"
  75. src="@/assets/baggage/ic_export.png"
  76. title="导出"
  77. @click="exportHandler('table', '容器行李列表')"
  78. >
  79. <img
  80. class="btn-square btn-shadow"
  81. src="@/assets/baggage/ic_setting.png"
  82. title="列设置"
  83. @click="show"
  84. >
  85. </div>
  86. <div class="table-wrapper">
  87. <el-table
  88. ref="table"
  89. :data="dealedTableData"
  90. :height="computedTableHeight"
  91. border
  92. stripe
  93. size="mini"
  94. show-summary
  95. :summary-method="summaryRow(dealedTableData.length)"
  96. :header-cell-class-name="headerCellClass"
  97. :header-cell-style="{ color: '#101116' }"
  98. :row-class-name="rowClass"
  99. :cell-class-name="cellClass"
  100. @cell-click="cellClickHandler"
  101. >
  102. <el-table-column
  103. v-for="col in tableColsCopy"
  104. :key="col.index"
  105. :prop="col.prop"
  106. :label="col.label"
  107. :align="col.align || 'center'"
  108. :width="col.width"
  109. :fixed="col.fixed"
  110. :formatter="tableFormat"
  111. >
  112. <template #header>
  113. <TableHeaderCell
  114. :label="col.label"
  115. :filter-options="tableDataFilters[col.prop]"
  116. :filter-values.sync="filterValues[col.prop]"
  117. :sortable="col.sortable"
  118. :sort-rule.sync="tableDataSortRules[col.prop]"
  119. />
  120. </template>
  121. </el-table-column>
  122. </el-table>
  123. </div>
  124. </div>
  125. <!--列设置-->
  126. <Dialog
  127. :flag="dialogFlag"
  128. class="dialog-check-group"
  129. >
  130. <div class="dialog-wrapper">
  131. <div class="title">列设置</div>
  132. <div class="content">
  133. <el-tree
  134. :data="tableCols"
  135. :class="colsCheckClass"
  136. show-checkbox
  137. node-key="index"
  138. :default-expand-all="true"
  139. :props="{
  140. label: 'label',
  141. children: 'children',
  142. }"
  143. :default-checked-keys="checkedKeysTemp"
  144. @check="handleCheck"
  145. />
  146. </div>
  147. <div class="foot right t30">
  148. <el-button
  149. size="medium"
  150. class="r24"
  151. type="primary"
  152. @click="onCheck('tableData')"
  153. >确定</el-button>
  154. <el-button
  155. size="medium"
  156. @click="hide"
  157. >取消</el-button>
  158. </div>
  159. </div>
  160. </Dialog>
  161. </div>
  162. </template>
  163. <script>
  164. import Dialog from '@/layout/components/Dialog/index.vue'
  165. // import TimeZoneSelector from '@/components/TimeZoneSelector'
  166. import { myQuery } from '@/api/dataIntegration'
  167. import tableColsMixin from '../../mixins/tableCols'
  168. import timeZoneMixin from '../../mixins/timeZone'
  169. import TableHeaderCell from '@/components/TableHeaderCell'
  170. import { setTableFilters } from '@/utils/table'
  171. import { mapGetters } from 'vuex'
  172. import { throttledExportToExcel } from '@/utils/table'
  173. export default {
  174. name: 'ContainerView',
  175. components: {
  176. // TimeZoneSelector,
  177. Dialog,
  178. TableHeaderCell
  179. },
  180. mixins: [tableColsMixin, timeZoneMixin],
  181. data() {
  182. return {
  183. fullscreenLoading: false,
  184. queryData: {},
  185. computedTableHeight: undefined,
  186. tableCols: [
  187. {
  188. prop: 'passengerName',
  189. label: '旅客姓名',
  190. desc: '指旅客姓名的拼音大写',
  191. filterable: true,
  192. sortable: true
  193. },
  194. {
  195. prop: 'luggageSN',
  196. label: '行李牌号',
  197. desc: '指行李的10位数字行李牌号码',
  198. filterable: true,
  199. sortable: true
  200. },
  201. {
  202. prop: 'specialType',
  203. label: '特殊行李类型',
  204. desc: '指有别于普通托运行李的特殊行李分类,包括(装笼动物、机组行李、易碎行李、VIP行李等),参考BSM报文.E项说明',
  205. width: 120,
  206. filterable: true,
  207. sortable: true
  208. },
  209. {
  210. prop: 'isDEL',
  211. label: '删除',
  212. desc: '指旅客是否取消值机托运,根据BSM报文状态是否有DEL判断,已删除的行李记录为斜体灰色字体',
  213. filterable: true,
  214. sortable: true
  215. },
  216. {
  217. prop: 'activeState',
  218. label: '激活',
  219. desc: '指托运行李是否被激活,参照BSM报文.S项说明',
  220. filterable: true,
  221. sortable: true
  222. },
  223. {
  224. prop: 'luggageWeight',
  225. label: '重量',
  226. desc: '指托运行李的重量,参照BSM报文.W项说明'
  227. },
  228. {
  229. prop: 'lastStatus',
  230. label: '最新状态',
  231. desc: '指托运行李的当前查询时间所在的节点状态',
  232. filterable: true,
  233. sortable: true
  234. },
  235. {
  236. prop: 'lastLocation',
  237. label: '最新位置',
  238. desc: '指托运行李的当前查询时间所在的节点状态的识读位置代号',
  239. filterable: true,
  240. sortable: true
  241. },
  242. {
  243. prop: 'inFlightNO',
  244. label: '中转进航班',
  245. desc: '指有中转行李转出的进港航班号',
  246. width: 110,
  247. filterable: true,
  248. sortable: true
  249. },
  250. {
  251. prop: 'transferFlightNO',
  252. label: '中转出航班',
  253. desc: '指有中转行李转入的离港航班号',
  254. width: 110,
  255. filterable: true,
  256. sortable: true
  257. }
  258. ],
  259. tableData: [],
  260. tableDataFilters: {},
  261. filterValues: {},
  262. tableDataSortRules: {}
  263. }
  264. },
  265. computed: {
  266. ...mapGetters(['clickedCells']),
  267. dealedTableData() {
  268. const filtered = this.tableData.filter(item => {
  269. let flag = true
  270. Object.entries(this.filterValues).forEach(([key, arr]) => {
  271. if (arr.length && !arr.includes(String(item[key]))) {
  272. flag = false
  273. }
  274. })
  275. return flag
  276. })
  277. const sortRules = Object.entries(this.tableDataSortRules).reduce(
  278. (pre, [key, value]) => {
  279. if (value) {
  280. pre[0].push(key)
  281. value = value === 'ascending' ? 'asc' : 'desc'
  282. pre[1].push(value)
  283. }
  284. return pre
  285. },
  286. [[], []]
  287. )
  288. return this._.orderBy(filtered, sortRules[0], sortRules[1])
  289. }
  290. },
  291. watch: {
  292. $route: {
  293. handler({ path, query }) {
  294. if (path.includes('containerView')) {
  295. const { flightNO, flightDate, departureAirport, landingAirport, containerID } = query
  296. if (flightNO && flightDate && departureAirport && landingAirport && containerID) {
  297. const {
  298. flightNO: oldFlightNO,
  299. flightDate: oldFlightDate,
  300. departureAirport: oldDepartureAirport,
  301. landingAirport: oldLandingAirport,
  302. containerID: oldContainerID
  303. } = this.queryData
  304. if (
  305. flightNO !== oldFlightNO ||
  306. flightDate !== oldFlightDate ||
  307. departureAirport !== oldDepartureAirport ||
  308. landingAirport !== oldLandingAirport ||
  309. containerID !== oldContainerID
  310. ) {
  311. this.queryData = { flightNO, flightDate, departureAirport, landingAirport, containerID }
  312. this.queryContainerBaggage([flightNO, flightDate, departureAirport, landingAirport, containerID])
  313. }
  314. } else {
  315. this.$router.push('/')
  316. }
  317. }
  318. },
  319. deep: true,
  320. immediate: true
  321. },
  322. fullscreenLoading(val) {
  323. if (val) {
  324. this.loading = this.$loading({
  325. lock: true,
  326. text: '加载中',
  327. spinner: 'el-icon-loading',
  328. background: 'rgba(0, 0, 0, 0.7)'
  329. })
  330. } else {
  331. this.loading?.close()
  332. }
  333. }
  334. },
  335. created() {
  336. Object.values(this.tableCols).forEach(({ prop, filterable, sortable }) => {
  337. if (filterable) {
  338. this.$set(this.tableDataFilters, prop, [])
  339. this.$set(this.filterValues, prop, [])
  340. }
  341. if (sortable) {
  342. this.$set(this.tableDataSortRules, prop, '')
  343. }
  344. })
  345. },
  346. activated() {
  347. this.setTableHeight()
  348. },
  349. updated() {
  350. this.setTableHeight()
  351. },
  352. deactivated() {
  353. this.loading?.close()
  354. },
  355. beforeDestroy() {
  356. this.loading?.close()
  357. },
  358. methods: {
  359. setTableHeight() {
  360. const headerHeight = 80
  361. const bottomBlankHeight = 16
  362. const titleHeight = 64
  363. const basicBoxHeight = this.$refs['basicBox'].offsetHeight
  364. this.computedTableHeight = `calc(100vh - ${
  365. headerHeight + bottomBlankHeight + titleHeight * 2 + basicBoxHeight
  366. }px)`
  367. this.$nextTick(() => {
  368. this.$refs['table']?.doLayout()
  369. })
  370. },
  371. rowClass({ row, rowIndex }) {
  372. const classes = []
  373. if (row['Status'] === 'DEL') {
  374. classes.push('bgl-deleted')
  375. }
  376. return classes.join(' ')
  377. },
  378. // 给表头单元格加上 ascending 或 descending 使用 element 自带的排序箭头变色
  379. headerCellClass({ row, column, rowIndex, columnIndex }) {
  380. const classes = []
  381. const rule = this.tableDataSortRules[column.property]
  382. if (rule) {
  383. classes.push(rule)
  384. }
  385. return classes.join(' ')
  386. },
  387. cellClass({ row, column, rowIndex, columnIndex }) {
  388. const classes = []
  389. if (
  390. ['checkInTime', 'DealInfo', 'sortLocationMark', 'loadLocationMark', 'inflLocationMark'].includes(
  391. column.property
  392. )
  393. ) {
  394. classes.push('pre-line')
  395. }
  396. if (
  397. [
  398. 'passengerName',
  399. 'luggageSN'
  400. // 'inFlightNO',
  401. // 'transferFlightNO'
  402. ].includes(column.property) &&
  403. row[column.property]
  404. ) {
  405. classes.push('cell-click')
  406. if (
  407. this.clickedCells.some(
  408. cell =>
  409. cell.pageName === this.$route.name &&
  410. Object.entries(cell.row).every(([key, value]) => row[key] === value) &&
  411. cell.columnProp === column.property
  412. )
  413. ) {
  414. classes.push('cell-clicked')
  415. }
  416. }
  417. return classes.join(' ')
  418. },
  419. cellClickHandler(row, column, cell, event) {
  420. if (
  421. [
  422. 'passengerName',
  423. 'luggageSN'
  424. // 'inFlightNO',
  425. // 'transferFlightNO'
  426. ].includes(column.property) &&
  427. row[column.property]
  428. ) {
  429. this.$store.dispatch('keepAlive/addClickedCell', {
  430. row,
  431. columnProp: column.property,
  432. pageName: this.$route.name
  433. })
  434. switch (column.property) {
  435. case 'passengerName':
  436. this.$message.info('开发中')
  437. break
  438. case 'luggageSN':
  439. this.$router.push({
  440. path: `${this.$route.path.split('/').slice(0, -1).join('/')}/baggageView`,
  441. query: {
  442. bagSN: row.luggageSN,
  443. flightNO: this.queryData.flightNO,
  444. flightDate: this.queryData.flightDate
  445. }
  446. })
  447. break
  448. default:
  449. break
  450. }
  451. }
  452. },
  453. toContainerHistory() {
  454. this.$router.push({
  455. path: `${this.$route.path.split('/').slice(0, -1).join('/')}/containerHistory`,
  456. query: {
  457. containerID: this.queryData.containerID
  458. }
  459. })
  460. },
  461. // 统计行数
  462. summaryRow(num) {
  463. return function () {
  464. return ['合计', `共${num}件`]
  465. }
  466. },
  467. exportHandler(refName, tableName) {
  468. const table = this.$refs[refName].$el.cloneNode(true)
  469. const fileName = `${tableName}-${Object.values(this.queryData).join('-')}.xlsx`
  470. throttledExportToExcel(table, tableName, fileName)
  471. },
  472. async queryContainerBaggage(dataContent) {
  473. this.fullscreenLoading = true
  474. this.tableData = []
  475. try {
  476. const tableData = await myQuery(DATACONTENT_ID.containerBaggage, ...dataContent)
  477. this.tableData = tableData
  478. setTableFilters(this.tableData, this.tableDataFilters)
  479. } catch {
  480. this.$message.error('失败')
  481. }
  482. this.fullscreenLoading = false
  483. }
  484. }
  485. }
  486. </script>
  487. <style lang="scss" scoped>
  488. .container-view {
  489. width: 100%;
  490. height: calc(100vh - 80px - 16px);
  491. overflow: hidden;
  492. background: #dfe3ea;
  493. padding: 0px 8px;
  494. .title {
  495. display: flex;
  496. justify-content: space-between;
  497. padding: 16px 0;
  498. margin-right: 0;
  499. }
  500. .container-basic {
  501. .basic-info-box {
  502. width: 100%;
  503. background: #041741;
  504. padding: 16px 30px;
  505. color: #fff;
  506. }
  507. }
  508. .container-table {
  509. .title {
  510. height: 64px;
  511. .manageTitle {
  512. flex: 1;
  513. }
  514. .el-dropdown {
  515. height: 30px;
  516. }
  517. .btn-square {
  518. height: 30px;
  519. margin-left: 20px;
  520. &:last-child {
  521. margin-right: 30px;
  522. }
  523. }
  524. }
  525. .table-wrapper {
  526. background-color: #fff;
  527. ::v-deep .el-table {
  528. width: 100%;
  529. .cell {
  530. padding: 0;
  531. text-align: center;
  532. font-size: 14px;
  533. font-family: Helvetica, 'Microsoft YaHei';
  534. letter-spacing: 0;
  535. }
  536. .cell-click {
  537. cursor: pointer;
  538. color: #2d7cff;
  539. &.cell-clicked {
  540. color: purple;
  541. }
  542. }
  543. .el-table__body-wrapper,
  544. .el-table__fixed-body-wrapper {
  545. tr.bgl-deleted {
  546. background: #d2d6df;
  547. td {
  548. background: #d2d6df;
  549. font-style: italic;
  550. }
  551. }
  552. }
  553. }
  554. }
  555. }
  556. }
  557. </style>