index.vue 14 KB

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