terminal.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471
  1. /*
  2. * @Author: Badguy
  3. * @Date: 2022-03-04 11:41:55
  4. * @LastEditTime: 2022-06-09 16:24:07
  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. 'landingNumber',
  133. 'tounLoad',
  134. 'unLoad',
  135. 'delbag',
  136. 'noBSM',
  137. 'reach',
  138. 'did_not_arrive',
  139. 'special',
  140. 'claim',
  141. 'uninstalled',
  142. 'to_be_uninstalled',
  143. 'terminateArrive',
  144. 'terminatedNotArrived',
  145. 'delivered',
  146. 'not_shipped',
  147. 'container',
  148. 'bulk',
  149. 'checkInTravellerNumber',
  150. 'checkInNumber',
  151. 'unActive',
  152. 'preLoad',
  153. 'noCheckInNumber',
  154. 'midIn',
  155. 'checkIns',
  156. 'projectedLoad',
  157. 'loadedQuantity',
  158. 'numberOfDestinationArrivals',
  159. 'endPointNotReached',
  160. 'specialQuantity',
  161. 'numberOfClaims',
  162. 'numberToBeUninstalled',
  163. 'terminateArrivalQuantity',
  164. 'terminateUnreachedQuantity',
  165. 'quantityShipped',
  166. 'undeliveredQuantity',
  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. 'unLoad',
  207. 'checkInNumber',
  208. 'unActive',
  209. 'midIn',
  210. 'noCheckInNumber',
  211. 'checkNumber',
  212. 'sortNumber',
  213. 'loadNumber',
  214. 'landingNumber',
  215. 'checkIns',
  216. 'noBSM'
  217. ].includes(column.property) &&
  218. row[column.property]
  219. ) {
  220. classes.push('cell-click')
  221. if (
  222. this.clickedCells.some(
  223. cell =>
  224. cell.pageName === this.$route.name &&
  225. Object.entries(cell.row).every(([key, value]) => row[key] === value) &&
  226. cell.columnProp === column.property
  227. )
  228. ) {
  229. classes.push('cell-clicked')
  230. }
  231. }
  232. if (column.property === 'tounLoad' && row[column.property]) {
  233. classes.push('cell-tounLoad')
  234. }
  235. return classes.join(' ')
  236. },
  237. cellClickHandler(row, column, cell, event) {
  238. if (
  239. [
  240. 'flightNO',
  241. 'preFlightNO',
  242. 'inTransferBaggageCount',
  243. 'inTransferredBaggageCount',
  244. 'outTransferBaggageCount',
  245. 'outTransferredBaggageCount',
  246. 'tounLoad',
  247. 'unLoad',
  248. 'checkInNumber',
  249. 'unActive',
  250. 'midIn',
  251. 'noCheckInNumber',
  252. 'checkNumber',
  253. 'sortNumber',
  254. 'loadNumber',
  255. 'landingNumber',
  256. 'checkIns',
  257. 'noBSM'
  258. ].includes(column.property)
  259. ) {
  260. this.$store.dispatch('keepAlive/addClickedCell', {
  261. row,
  262. columnProp: column.property,
  263. pageName: this.$route.name
  264. })
  265. }
  266. switch (column.property) {
  267. case 'flightNO':
  268. this.$router.push({
  269. path: `${this.$route.path}/flightView`,
  270. query: {
  271. flightNO: row.flightNO,
  272. flightDate: row.flightDate
  273. }
  274. })
  275. break
  276. case 'preFlightNO':
  277. this.$router.push({
  278. path: '/transfer/arrival/flightView',
  279. query: {
  280. flightNO: row.preFlightNO,
  281. flightDate: row.flightDate
  282. }
  283. })
  284. break
  285. case 'inTransferBaggageCount':
  286. this.$router.push({
  287. path: '/advance',
  288. query: {
  289. flightNO: row.preFlightNO,
  290. transferDeparture: row.flightNO,
  291. startDate: row.preFlightDate,
  292. endDate: row.preFlightDate,
  293. departureStation: row.preAirport,
  294. destination: this.formData.currentAirport
  295. }
  296. })
  297. break
  298. case 'inTransferredBaggageCount':
  299. this.$router.push({
  300. path: '/advance',
  301. query: {
  302. flightNO: row.flightNO,
  303. transferArrival: row.preFlightNO,
  304. startDate: row.flightDate,
  305. endDate: row.flightDate,
  306. departureStation: this.formData.currentAirport,
  307. destination: row.targetAirport
  308. }
  309. })
  310. break
  311. case 'outTransferBaggageCount':
  312. this.$router.push({
  313. path: '/advance',
  314. query: {
  315. flightNO: row.preFlightNO,
  316. transferDeparture: row.flightNO,
  317. startDate: row.preFlightDate,
  318. endDate: row.preFlightDate,
  319. departureStation: row.preAirport,
  320. destination: this.formData.currentAirport
  321. }
  322. })
  323. break
  324. case 'outTransferredBaggageCount':
  325. this.$router.push({
  326. path: '/advance',
  327. query: {
  328. flightNO: row.flightNO,
  329. transferArrival: row.preFlightNO,
  330. startDate: row.flightDate,
  331. endDate: row.flightDate,
  332. departureStation: this.formData.currentAirport,
  333. destination: row.targetAirport
  334. }
  335. })
  336. break
  337. case 'tounLoad':
  338. this.$router.push({
  339. path: '/advance',
  340. query: {
  341. flightNO: row.flightNO,
  342. startDate: row.flightDate,
  343. endDate: row.flightDate,
  344. departureStation: this.formData.currentAirport,
  345. destination: row.targetAirport,
  346. unLoad: 0
  347. }
  348. })
  349. break
  350. case 'unLoad':
  351. this.$router.push({
  352. path: '/advance',
  353. query: {
  354. flightNO: row.flightNO,
  355. startDate: row.flightDate,
  356. endDate: row.flightDate,
  357. departureStation: this.formData.currentAirport,
  358. destination: row.targetAirport,
  359. unLoad: 1
  360. }
  361. })
  362. break
  363. case 'checkInNumber':
  364. this.$router.push({
  365. path: '/advance',
  366. query: {
  367. flightNO: row.flightNO,
  368. startDate: row.flightDate,
  369. endDate: row.flightDate,
  370. departureStation: this.formData.currentAirport,
  371. destination: row.targetAirport,
  372. checkIn: 1
  373. }
  374. })
  375. break
  376. case 'unActive':
  377. this.$router.push({
  378. path: '/advance',
  379. query: {
  380. flightNO: row.flightNO,
  381. startDate: row.flightDate,
  382. endDate: row.flightDate,
  383. departureStation: this.formData.currentAirport,
  384. destination: row.targetAirport,
  385. active: 0
  386. }
  387. })
  388. break
  389. case 'midIn':
  390. this.$router.push({
  391. path: '/advance',
  392. query: {
  393. flightNO: row.flightNO,
  394. startDate: row.flightDate,
  395. endDate: row.flightDate,
  396. departureStation: this.formData.currentAirport,
  397. destination: row.targetAirport,
  398. transferIn: 1
  399. }
  400. })
  401. break
  402. case 'noCheckInNumber':
  403. this.$router.push({
  404. path: '/advance',
  405. query: {
  406. flightNO: row.flightNO,
  407. startDate: row.flightDate,
  408. endDate: row.flightDate,
  409. departureStation: this.formData.currentAirport,
  410. destination: row.targetAirport,
  411. canceled: 1
  412. }
  413. })
  414. break
  415. case 'noBSM':
  416. this.$router.push({
  417. path: '/advance',
  418. query: {
  419. flightNO: row.flightNO,
  420. startDate: row.flightDate,
  421. endDate: row.flightDate,
  422. departureStation: this.formData.currentAirport,
  423. destination: row.targetAirport,
  424. noBSM: 0
  425. }
  426. })
  427. break
  428. case 'checkNumber':
  429. case 'sortNumber':
  430. case 'loadNumber':
  431. case 'landingNumber': {
  432. const reflect = {
  433. checkNumber: '安检',
  434. sortNumber: '分拣',
  435. loadNumber: '装车',
  436. landingNumber: '装机'
  437. }
  438. this.$router.push({
  439. path: '/advance',
  440. query: {
  441. flightNO: row.flightNO,
  442. startDate: row.flightDate,
  443. endDate: row.flightDate,
  444. departureStation: this.formData.currentAirport,
  445. destination: row.targetAirport,
  446. status: reflect[column.property]
  447. }
  448. })
  449. break
  450. }
  451. case 'checkIns':
  452. this.$router.push({
  453. path: '/advance',
  454. query: {
  455. flightNO: row.flightNO,
  456. startDate: row.flightDate,
  457. endDate: row.flightDate,
  458. departureStation: row.departureAirport,
  459. destination: this.formData.currentAirport,
  460. checkIn: 1
  461. }
  462. })
  463. break
  464. default:
  465. break
  466. }
  467. }
  468. }
  469. }