terminal.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  1. /*
  2. * @Author: Badguy
  3. * @Date: 2022-03-04 11:41:55
  4. * @LastEditTime: 2022-08-26 15:32:54
  5. * @LastEditors: your name
  6. * @Description: 航站视图通用部分
  7. * have a nice day!
  8. */
  9. import { mapGetters } from 'vuex'
  10. import { commonTableCellClass } from '@/utils/table'
  11. export default {
  12. data() {
  13. return {
  14. // 表格数据
  15. tableData: [],
  16. tableDataFilters: {},
  17. filterValues: {},
  18. tableDataSortRules: {},
  19. spanArr: [],
  20. pos: 0,
  21. loading: false,
  22. computedTableHeight: undefined
  23. }
  24. },
  25. created() {
  26. this.setFilterAndSort(this.tableCols)
  27. },
  28. updated() {
  29. this.setTableHeight()
  30. },
  31. activated() {
  32. this.setTableHeight()
  33. },
  34. computed: {
  35. ...mapGetters(['clickedCells']),
  36. dealedTableData() {
  37. const filtered = this.tableData.filter(item => {
  38. let flag = true
  39. Object.entries(this.filterValues).forEach(([key, arr]) => {
  40. if (arr.length && !arr.includes(item[key])) {
  41. flag = false
  42. }
  43. })
  44. return flag
  45. })
  46. const sortRules = Object.entries(this.tableDataSortRules).reduce(
  47. (pre, [key, value]) => {
  48. if (value) {
  49. pre[0].push(key)
  50. value = value === 'ascending' ? 'asc' : 'desc'
  51. pre[1].push(value)
  52. }
  53. return pre
  54. },
  55. [[], []]
  56. )
  57. return this._.orderBy(filtered, sortRules[0], sortRules[1])
  58. }
  59. },
  60. watch: {
  61. dealedTableData: {
  62. handler(val) {
  63. this.spanArr = []
  64. let contactDot = this.contactDot
  65. val.forEach((item, index, arr) => {
  66. if (index === 0) {
  67. this.spanArr.push(1)
  68. } else {
  69. if (
  70. item['flightNO'] === arr[index - 1]['flightNO'] &&
  71. item['flightDate'] === arr[index - 1]['flightDate']
  72. ) {
  73. this.spanArr[contactDot] += 1
  74. this.spanArr.push(0)
  75. } else {
  76. this.spanArr.push(1)
  77. contactDot = index
  78. }
  79. }
  80. })
  81. },
  82. deep: true
  83. }
  84. },
  85. methods: {
  86. // 设置表格高度
  87. setTableHeight() {
  88. const headerHeight = 80
  89. const bottomBlankHeight = 41
  90. const formWrapHeight = this.$refs['formWrap'].offsetHeight
  91. this.computedTableHeight = `calc(100vh - ${headerHeight + bottomBlankHeight + formWrapHeight}px)`
  92. this.$nextTick(() => {
  93. this.$refs.table?.doLayout()
  94. })
  95. },
  96. // 设置筛选和排序
  97. setFilterAndSort(tableCols) {
  98. const self = this
  99. Object.values(tableCols).forEach(({ prop, filterable, sortable, children }) => {
  100. if (children) {
  101. self.setFilterAndSort(children)
  102. } else {
  103. if (filterable) {
  104. self.$set(self.tableDataFilters, prop, [])
  105. self.$set(self.filterValues, prop, [])
  106. }
  107. if (sortable) {
  108. self.$set(self.tableDataSortRules, prop, '')
  109. }
  110. }
  111. })
  112. },
  113. // 合计行
  114. summaryMethod({ columns, data }) {
  115. const sums = []
  116. if (columns.length > 0) {
  117. columns.forEach((column, index) => {
  118. if (index === 0) {
  119. sums[index] = '合计'
  120. } else if (index === 1) {
  121. sums[index] = '航班数:' + this.tableData.length
  122. } else if (
  123. // 需要计算的列
  124. [
  125. 'passagernum',
  126. 'checkNumber',
  127. 'not_actived',
  128. 'expect_load',
  129. 'security_all',
  130. 'sortNumber',
  131. 'loadNumber',
  132. 'boardID',
  133. 'tounLoad',
  134. 'OFFCount',
  135. 'delbag',
  136. 'noBSM',
  137. 'reach',
  138. 'did_not_arrive',
  139. 'special',
  140. 'claim',
  141. 'uninstalled',
  142. 'terminateArrive',
  143. 'terminatedNotArrived',
  144. 'delivered',
  145. 'not_shipped',
  146. 'container',
  147. 'bulk',
  148. 'checkInTravellerNumber',
  149. 'checkInNumber',
  150. 'unActive',
  151. 'preLoad',
  152. 'noCheckInNumber',
  153. 'midIn',
  154. 'checkIns',
  155. 'projectedLoad',
  156. 'loadedQuantity',
  157. 'numberOfDestinationArrivals',
  158. 'endPointNotReached',
  159. 'specialQuantity',
  160. 'numberOfClaims',
  161. 'numberToBeUninstalled',
  162. 'terminateArrivalQuantity',
  163. 'terminateUnreachedQuantity',
  164. 'quantityShipped',
  165. 'undeliveredQuantity',
  166. 'numberOfContainers',
  167. 'numberOfBulk',
  168. 'inTransferBaggageCount',
  169. 'inTransferredBaggageCount',
  170. 'outTransferBaggageCount',
  171. 'outTransferredBaggageCount'
  172. ].includes(column.property)
  173. ) {
  174. const values = data.map(item => Number(item[column.property]))
  175. if (values.some(value => !isNaN(value))) {
  176. sums[index] = values.reduce((prev, curr) => {
  177. const value = Number(curr)
  178. if (!isNaN(value)) {
  179. return Number(prev) + Number(curr)
  180. } else {
  181. return Number(prev)
  182. }
  183. }, 0)
  184. } else {
  185. sums[index] = 0
  186. }
  187. } else {
  188. // 过滤某些字段不参与计算
  189. sums[index] = '-'
  190. }
  191. })
  192. }
  193. return sums
  194. },
  195. cellClass({ row, column, rowIndex, columnIndex }) {
  196. const classes = commonTableCellClass({ row, column, rowIndex, columnIndex })
  197. if (
  198. [
  199. 'flightNO',
  200. 'preFlightNO',
  201. 'inTransferBaggageCount',
  202. 'inTransferredBaggageCount',
  203. 'outTransferBaggageCount',
  204. 'outTransferredBaggageCount',
  205. 'tounLoad',
  206. 'OFFCount',
  207. 'checkInNumber',
  208. 'unActive',
  209. 'preLoad',
  210. 'midIn',
  211. 'noCheckInNumber',
  212. 'checkNumber',
  213. 'sortNumber',
  214. 'loadNumber',
  215. 'boardID',
  216. 'checkIns',
  217. 'terminateArrivalQuantity',
  218. 'projectedLoad',
  219. 'loadedQuantity',
  220. 'numberOfDestinationArrivals',
  221. 'uninstalled',
  222. 'numberOfContainers',
  223. 'numberOfBulk',
  224. 'noBSM'
  225. ].includes(column.property) &&
  226. row[column.property]
  227. ) {
  228. classes.push('cell-click')
  229. if (
  230. this.clickedCells.some(
  231. cell =>
  232. cell.pageName === this.$route.name &&
  233. Object.entries(cell.row).every(([key, value]) => row[key] === value) &&
  234. cell.columnProp === column.property
  235. )
  236. ) {
  237. classes.push('cell-clicked')
  238. }
  239. }
  240. if (column.property === 'tounLoad' && row[column.property]) {
  241. classes.push('cell-tounLoad')
  242. }
  243. return classes.join(' ')
  244. },
  245. cellClickHandler(row, column, cell, event) {
  246. if (
  247. [
  248. 'flightNO',
  249. 'preFlightNO',
  250. 'inTransferBaggageCount',
  251. 'inTransferredBaggageCount',
  252. 'outTransferBaggageCount',
  253. 'outTransferredBaggageCount',
  254. 'tounLoad',
  255. 'OFFCount',
  256. 'checkInNumber',
  257. 'unActive',
  258. 'preLoad',
  259. 'midIn',
  260. 'noCheckInNumber',
  261. 'checkNumber',
  262. 'sortNumber',
  263. 'loadNumber',
  264. 'boardID',
  265. 'checkIns',
  266. 'terminateArrivalQuantity',
  267. 'projectedLoad',
  268. 'loadedQuantity',
  269. 'numberOfDestinationArrivals',
  270. 'uninstalled',
  271. 'numberOfContainers',
  272. 'numberOfBulk',
  273. 'noBSM'
  274. ].includes(column.property) &&
  275. row[column.property]
  276. ) {
  277. this.$store.dispatch('keepAlive/addClickedCell', {
  278. row,
  279. columnProp: column.property,
  280. pageName: this.$route.name
  281. })
  282. switch (column.property) {
  283. case 'flightNO':
  284. this.$router.push({
  285. path: `${this.$route.path}/flightView`,
  286. query: {
  287. flightNO: row.flightNO,
  288. flightDate: row.flightDate
  289. }
  290. })
  291. break
  292. case 'preFlightNO':
  293. this.$router.push({
  294. path: '/transfer/arrival/flightView',
  295. query: {
  296. flightNO: row.preFlightNO,
  297. flightDate: row.flightDate
  298. }
  299. })
  300. break
  301. case 'inTransferBaggageCount':
  302. this.$router.push({
  303. path: '/advance',
  304. query: {
  305. flightNO: row.preFlightNO,
  306. transferDeparture: row.flightNO,
  307. startDate: row.preFlightDate,
  308. endDate: row.preFlightDate,
  309. departureStation: row.preAirport,
  310. destination: this.formData.currentAirport
  311. }
  312. })
  313. break
  314. case 'inTransferredBaggageCount':
  315. this.$router.push({
  316. path: '/advance',
  317. query: {
  318. flightNO: row.flightNO,
  319. transferArrival: row.preFlightNO,
  320. startDate: row.flightDate,
  321. endDate: row.flightDate,
  322. departureStation: this.formData.currentAirport,
  323. destination: row.targetAirport
  324. }
  325. })
  326. break
  327. case 'outTransferBaggageCount':
  328. this.$router.push({
  329. path: '/advance',
  330. query: {
  331. flightNO: row.preFlightNO,
  332. transferDeparture: row.flightNO,
  333. startDate: row.preFlightDate,
  334. endDate: row.preFlightDate,
  335. departureStation: row.preAirport,
  336. destination: this.formData.currentAirport
  337. }
  338. })
  339. break
  340. case 'outTransferredBaggageCount':
  341. this.$router.push({
  342. path: '/advance',
  343. query: {
  344. flightNO: row.flightNO,
  345. transferArrival: row.preFlightNO,
  346. startDate: row.flightDate,
  347. endDate: row.flightDate,
  348. departureStation: this.formData.currentAirport,
  349. destination: row.targetAirport
  350. }
  351. })
  352. break
  353. case 'tounLoad':
  354. this.$router.push({
  355. path: '/advance',
  356. query: {
  357. flightNO: row.flightNO,
  358. startDate: row.flightDate,
  359. endDate: row.flightDate,
  360. departureStation: this.formData.currentAirport,
  361. destination: row.targetAirport,
  362. unLoad: 0
  363. }
  364. })
  365. break
  366. case 'OFFCount':
  367. this.$router.push({
  368. path: '/advance',
  369. query: {
  370. flightNO: row.flightNO,
  371. startDate: row.flightDate,
  372. endDate: row.flightDate,
  373. departureStation: this.formData.currentAirport,
  374. destination: row.targetAirport,
  375. unLoad: 1
  376. }
  377. })
  378. break
  379. // case 'checkInNumber':
  380. // this.$router.push({
  381. // path: '/advance',
  382. // query: {
  383. // flightNO: row.flightNO,
  384. // startDate: row.flightDate,
  385. // endDate: row.flightDate,
  386. // departureStation: this.formData.currentAirport,
  387. // destination: row.targetAirport,
  388. // checkIn: 1
  389. // }
  390. // })
  391. // break
  392. case 'unActive':
  393. this.$router.push({
  394. path: '/advance',
  395. query: {
  396. flightNO: row.flightNO,
  397. startDate: row.flightDate,
  398. endDate: row.flightDate,
  399. departureStation: this.formData.currentAirport,
  400. destination: row.targetAirport,
  401. active: 0
  402. }
  403. })
  404. break
  405. case 'preLoad':
  406. this.$router.push({
  407. path: '/advance',
  408. query: {
  409. flightNO: row.flightNO,
  410. startDate: row.flightDate,
  411. endDate: row.flightDate,
  412. departureStation: this.formData.currentAirport,
  413. destination: row.targetAirport,
  414. active: 1,
  415. canceled: 0
  416. }
  417. })
  418. break
  419. case 'midIn':
  420. this.$router.push({
  421. path: '/advance',
  422. query: {
  423. flightNO: row.flightNO,
  424. startDate: row.flightDate,
  425. endDate: row.flightDate,
  426. departureStation: this.formData.currentAirport,
  427. destination: row.targetAirport,
  428. transferIn: 1
  429. }
  430. })
  431. break
  432. case 'noCheckInNumber':
  433. this.$router.push({
  434. path: '/advance',
  435. query: {
  436. flightNO: row.flightNO,
  437. startDate: row.flightDate,
  438. endDate: row.flightDate,
  439. departureStation: this.formData.currentAirport,
  440. destination: row.targetAirport,
  441. canceled: 1
  442. }
  443. })
  444. break
  445. case 'noBSM':
  446. this.$router.push({
  447. path: '/advance',
  448. query: {
  449. flightNO: row.flightNO,
  450. startDate: row.flightDate,
  451. endDate: row.flightDate,
  452. departureStation: this.formData.currentAirport,
  453. destination: row.targetAirport,
  454. noBSM: 0
  455. }
  456. })
  457. break
  458. case 'checkInNumber':
  459. case 'checkNumber':
  460. case 'sortNumber':
  461. {
  462. const reflect = {
  463. checkInNumber: '值机',
  464. checkNumber: '安检',
  465. sortNumber: '分拣'
  466. }
  467. this.$router.push({
  468. path: '/advance',
  469. query: {
  470. flightNO: row.flightNO,
  471. startDate: row.flightDate,
  472. endDate: row.flightDate,
  473. departureStation: this.formData.currentAirport,
  474. destination: row.targetAirport,
  475. status: reflect[column.property]
  476. }
  477. })
  478. }
  479. break
  480. case 'loadNumber':
  481. case 'boardID':
  482. {
  483. const reflect = {
  484. loadNumber: '装车',
  485. boardID: '装机'
  486. }
  487. this.$router.push({
  488. path: '/advance',
  489. query: {
  490. flightNO: row.flightNO,
  491. startDate: row.flightDate,
  492. endDate: row.flightDate,
  493. departureStation: this.formData.currentAirport,
  494. destination: row.targetAirport,
  495. status: reflect[column.property],
  496. canceled: 0
  497. }
  498. })
  499. }
  500. break
  501. case 'checkIns':
  502. case 'numberOfDestinationArrivals':
  503. case 'uninstalled':
  504. {
  505. const reflect = {
  506. checkIns: '值机',
  507. numberOfDestinationArrivals: '到达',
  508. uninstalled: '卸机'
  509. }
  510. this.$router.push({
  511. path: '/advance',
  512. query: {
  513. flightNO: row.flightNO,
  514. startDate: row.flightDate,
  515. endDate: row.flightDate,
  516. departureStation: row.departureAirport,
  517. destination: this.formData.currentAirport,
  518. status: reflect[column.property]
  519. }
  520. })
  521. }
  522. break
  523. case 'projectedLoad':
  524. this.$router.push({
  525. path: '/advance',
  526. query: {
  527. flightNO: row.flightNO,
  528. startDate: row.flightDate,
  529. endDate: row.flightDate,
  530. departureStation: row.departureAirport,
  531. destination: this.formData.currentAirport,
  532. active: 1,
  533. canceled: 0
  534. }
  535. })
  536. break
  537. case 'loadedQuantity':
  538. this.$router.push({
  539. path: '/advance',
  540. query: {
  541. flightNO: row.flightNO,
  542. startDate: row.flightDate,
  543. endDate: row.flightDate,
  544. departureStation: row.departureAirport,
  545. destination: this.formData.currentAirport,
  546. status: '装车',
  547. canceled: 0
  548. }
  549. })
  550. break
  551. case 'terminateArrivalQuantity':
  552. this.$router.push({
  553. path: '/advance',
  554. query: {
  555. flightNO: row.flightNO,
  556. startDate: row.flightDate,
  557. endDate: row.flightDate,
  558. departureStation: row.departureAirport,
  559. destination: this.formData.currentAirport,
  560. status: '到达',
  561. transferIn: 0
  562. }
  563. })
  564. break
  565. case 'numberOfContainers':
  566. case 'numberOfBulk':
  567. this.$router.push({
  568. path: '/advance',
  569. query: {
  570. flightNO: row.flightNO,
  571. startDate: row.flightDate,
  572. endDate: row.flightDate,
  573. departureStation: row.departureAirport,
  574. destination: this.formData.currentAirport,
  575. loadType: column.property === 'numberOfContainers' ? 0 : 1
  576. }
  577. })
  578. break
  579. default:
  580. break
  581. }
  582. }
  583. }
  584. }
  585. }