terminal.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  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. debounceTime: 300
  24. }
  25. },
  26. created() {
  27. this.setFilterAndSort(this.tableCols)
  28. },
  29. updated() {
  30. this.resizeHandler()
  31. },
  32. activated() {
  33. this.resizeHandler()
  34. this.debouncedResizeHandler = this._.debounce(this.resizeHandler, this.debounceTime)
  35. window.addEventListener('resize', this.debouncedResizeHandler)
  36. },
  37. deactivated() {
  38. window.removeEventListener('resize', this.debouncedResizeHandler)
  39. },
  40. computed: {
  41. ...mapGetters(['clickedCells']),
  42. dealedTableData() {
  43. const filtered = this.tableData.filter(item => {
  44. let flag = true
  45. Object.entries(this.filterValues).forEach(([key, arr]) => {
  46. if (arr.length && !arr.includes(String(item[key]))) {
  47. flag = false
  48. }
  49. })
  50. return flag
  51. })
  52. const sortRules = Object.entries(this.tableDataSortRules).reduce(
  53. (pre, [key, value]) => {
  54. if (value) {
  55. pre[0].push(key)
  56. value = value === 'ascending' ? 'asc' : 'desc'
  57. pre[1].push(value)
  58. }
  59. return pre
  60. },
  61. [[], []]
  62. )
  63. return this._.orderBy(filtered, sortRules[0], sortRules[1])
  64. }
  65. },
  66. watch: {
  67. dealedTableData: {
  68. handler(val) {
  69. this.spanArr = []
  70. let contactDot = this.contactDot
  71. val.forEach((item, index, arr) => {
  72. if (index === 0) {
  73. this.spanArr.push(1)
  74. } else {
  75. if (
  76. item['flightNO'] === arr[index - 1]['flightNO'] &&
  77. item['flightDate'] === arr[index - 1]['flightDate']
  78. ) {
  79. this.spanArr[contactDot] += 1
  80. this.spanArr.push(0)
  81. } else {
  82. this.spanArr.push(1)
  83. contactDot = index
  84. }
  85. }
  86. })
  87. },
  88. deep: true
  89. }
  90. },
  91. methods: {
  92. // 设置表格高度
  93. resizeHandler() {
  94. const headerHeight = 80
  95. const bottomBlankHeight = 41
  96. const formWrapHeight = this.$refs['formWrap'].offsetHeight
  97. this.computedTableHeight = `calc(100vh - ${headerHeight + bottomBlankHeight + formWrapHeight}px)`
  98. this.$refs.table?.doLayout()
  99. },
  100. // 设置筛选和排序
  101. setFilterAndSort(tableCols) {
  102. const self = this
  103. Object.values(tableCols).forEach(({ prop, filterable, sortable, children }) => {
  104. if (children) {
  105. self.setFilterAndSort(children)
  106. } else {
  107. if (filterable) {
  108. self.$set(self.tableDataFilters, prop, [])
  109. self.$set(self.filterValues, prop, [])
  110. }
  111. if (sortable) {
  112. self.$set(self.tableDataSortRules, prop, '')
  113. }
  114. }
  115. })
  116. },
  117. // 合计行
  118. summaryMethod({ columns, data }) {
  119. const sums = []
  120. if (columns.length > 0) {
  121. columns.forEach((column, index) => {
  122. if (index === 0) {
  123. sums[index] = '合计'
  124. } else if (index === 1) {
  125. sums[index] = '航班数:' + this.tableData.length
  126. } else if (
  127. // 需要计算的列
  128. [
  129. 'passagernum',
  130. 'checkNumber',
  131. 'not_actived',
  132. 'expect_load',
  133. 'security_all',
  134. 'sortNumber',
  135. 'loadNumber',
  136. 'boardID',
  137. 'toUnload',
  138. 'OFFCount',
  139. 'delbag',
  140. 'noBSM',
  141. 'reach',
  142. 'did_not_arrive',
  143. 'special',
  144. 'claim',
  145. 'uninstalled',
  146. 'terminateArrive',
  147. 'terminatedNotArrived',
  148. 'delivered',
  149. 'not_shipped',
  150. 'container',
  151. 'bulk',
  152. 'checkInTravellerNumber',
  153. 'checkInNumber',
  154. 'unActive',
  155. 'preLoad',
  156. 'noCheckInNumber',
  157. 'midIn',
  158. 'checkIns',
  159. 'projectedLoad',
  160. 'loadedQuantity',
  161. 'numberOfDestinationArrivals',
  162. 'endPointNotReached',
  163. 'specialQuantity',
  164. 'numberOfClaims',
  165. 'numberToBeUninstalled',
  166. 'terminateArrivalQuantity',
  167. 'terminateUnreachedQuantity',
  168. 'quantityShipped',
  169. 'undeliveredQuantity',
  170. 'numberOfContainers',
  171. 'numberOfBulk',
  172. 'inTransferBaggageCount',
  173. 'inTransferredBaggageCount',
  174. 'outTransferBaggageCount',
  175. 'outTransferredBaggageCount',
  176. 'exceptions',
  177. 'warning'
  178. ].includes(column.property)
  179. ) {
  180. const values = data.map(item => Number(item[column.property]))
  181. if (values.some(value => !isNaN(value))) {
  182. sums[index] = values.reduce((prev, curr) => {
  183. const value = Number(curr)
  184. if (!isNaN(value)) {
  185. return Number(prev) + Number(curr)
  186. } else {
  187. return Number(prev)
  188. }
  189. }, 0)
  190. } else {
  191. sums[index] = 0
  192. }
  193. } else {
  194. // 过滤某些字段不参与计算
  195. sums[index] = '-'
  196. }
  197. })
  198. }
  199. return sums
  200. },
  201. cellClass({ row, column, rowIndex, columnIndex }) {
  202. const classes = commonTableCellClass({
  203. row,
  204. column,
  205. rowIndex,
  206. columnIndex
  207. })
  208. if (
  209. [
  210. 'flightNO',
  211. 'preFlightNO',
  212. 'inTransferBaggageCount',
  213. 'inTransferredBaggageCount',
  214. 'outTransferBaggageCount',
  215. 'outTransferredBaggageCount',
  216. 'toUnload',
  217. 'OFFCount',
  218. 'checkInNumber',
  219. 'unActive',
  220. 'preLoad',
  221. 'warning',
  222. 'midIn',
  223. 'noCheckInNumber',
  224. 'checkNumber',
  225. 'sortNumber',
  226. 'loadNumber',
  227. 'boardID',
  228. 'checkIns',
  229. 'terminateArrivalQuantity',
  230. 'projectedLoad',
  231. 'loadedQuantity',
  232. 'numberOfDestinationArrivals',
  233. 'uninstalled',
  234. 'numberOfContainers',
  235. 'numberOfBulk',
  236. 'noBSM'
  237. ].includes(column.property) &&
  238. row[column.property]
  239. ) {
  240. classes.push('cell-click')
  241. if (
  242. this.clickedCells.some(
  243. cell =>
  244. cell.pageName === this.$route.name &&
  245. Object.entries(cell.row).every(([key, value]) => row[key] === value) &&
  246. cell.columnProp === column.property
  247. )
  248. ) {
  249. classes.push('cell-clicked')
  250. }
  251. }
  252. if (column.property === 'toUnload' && row[column.property]) {
  253. classes.push('cell-toUnload')
  254. }
  255. if (column.property === 'warning' && row['warningState'] && row['warningState'] == 2) {
  256. classes.push('cell-toUnload')
  257. }
  258. if (column.property === 'warning' && row['warningState'] && row['warningState'] == 1) {
  259. classes.push('cell-toUnloadNew')
  260. }
  261. if (column.property === 'outTransferredBaggageCount' && row['warningState'] && row['warningState'] == 2) {
  262. classes.push('cell-toUnload')
  263. }
  264. if (column.property === 'outTransferredBaggageCount' && row['warningState'] && row['warningState'] == 1) {
  265. classes.push('cell-toUnloadNew')
  266. }
  267. if (column.property === 'outTransferBaggageCount' && row['sharpSign']) {
  268. classes.push('cell-toUnloadNew')
  269. }
  270. if (column.property === 'inTransferredBaggageCount' && row['warningState'] && row['warningState'] == 2) {
  271. classes.push('cell-toUnload')
  272. }
  273. if (column.property === 'inTransferredBaggageCount' && row['warningState'] && row['warningState'] == 1) {
  274. classes.push('cell-toUnloadNew')
  275. }
  276. if (column.property === 'inTransferBaggageCount' && row['sharpSign']) {
  277. classes.push('cell-toUnloadNew')
  278. }
  279. return classes.join(' ')
  280. },
  281. cellClickHandler(row, column, cell, event) {
  282. if (
  283. [
  284. 'flightNO',
  285. 'preFlightNO',
  286. 'inTransferBaggageCount',
  287. 'inTransferredBaggageCount',
  288. 'outTransferBaggageCount',
  289. 'outTransferredBaggageCount',
  290. 'toUnload',
  291. 'OFFCount',
  292. 'checkInNumber',
  293. 'unActive',
  294. 'preLoad',
  295. 'warning',
  296. 'midIn',
  297. 'noCheckInNumber',
  298. 'checkNumber',
  299. 'sortNumber',
  300. 'loadNumber',
  301. 'boardID',
  302. 'checkIns',
  303. 'terminateArrivalQuantity',
  304. 'projectedLoad',
  305. 'loadedQuantity',
  306. 'numberOfDestinationArrivals',
  307. 'uninstalled',
  308. 'numberOfContainers',
  309. 'numberOfBulk',
  310. 'noBSM'
  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. const path = `${this.$route.path}/flightView`
  320. const query = {}
  321. switch (column.property) {
  322. case 'flightNO':
  323. Object.assign(query, {
  324. flightNO: row.flightNO,
  325. flightDate: row.flightDate
  326. })
  327. break
  328. case 'preFlightNO':
  329. Object.assign(query, {
  330. flightNO: row.preFlightNO,
  331. flightDate: row.preFlightDate
  332. })
  333. break
  334. case 'inTransferBaggageCount':
  335. case 'outTransferBaggageCount':
  336. Object.assign(query, {
  337. flightNO: row.preFlightNO,
  338. flightDate: row.preFlightDate,
  339. fastFilter: `transferFlightNO,${row.flightNO}`
  340. })
  341. break
  342. case 'inTransferredBaggageCount':
  343. case 'outTransferredBaggageCount':
  344. Object.assign(query, {
  345. flightNO: row.flightNO,
  346. flightDate: row.flightDate,
  347. fastFilter: `inFlightNO,${row.preFlightNO}`
  348. })
  349. break
  350. case 'warning':
  351. Object.assign(query, {
  352. flightNO: row.flightNO,
  353. flightDate: row.flightDate,
  354. fastFilter: row['warningState'] === 1 ? 'warning' : 'alarm'
  355. })
  356. break
  357. default: {
  358. const reflect = {
  359. toUnload: 'toUnload', // 装车或装机后,isDEL为'DEL',waitOFF为1
  360. OFFCount: 'unloaded', // 装车或装机后,isDEL为'DEL',waitOFF为0
  361. unActive: 'unActive', // STATUS为'I'
  362. preLoad: 'preLoad', // STATUS不为'I',isDEL不为'del'
  363. projectedLoad: 'preLoad',
  364. midIn: 'inFlightNO',
  365. noCheckInNumber: 'canceled', // isDEL为'DEL'
  366. noBSM: 'NOBSM', // 1/0
  367. checkInNumber: 'checkInTime',
  368. checkNumber: 'securityTime',
  369. sortNumber: 'sortTime',
  370. loadNumber: 'loadTime',
  371. boardID: 'inflTime',
  372. checkIns: 'checkInTime',
  373. numberOfDestinationArrivals: 'arrivedID', // 1/0
  374. uninstalled: 'unloadID', // 1/0
  375. loadedQuantity: 'loaded', // 'loadTime'不为空,isDEL不为'DEL'
  376. terminateArrivalQuantity: 'destination', // 'arrivedID'为1,transferFlightNO为null
  377. numberOfContainers: 'inContainer', // 有容器ID
  378. numberOfBulk: 'FBULK' // 容器ID为'FBULK'
  379. }
  380. Object.assign(query, {
  381. flightNO: row.flightNO,
  382. flightDate: row.flightDate,
  383. fastFilter: reflect[column.property]
  384. })
  385. break
  386. }
  387. }
  388. switch (this.$route.path.split('/').at(-1)) {
  389. case 'departure':
  390. Object.assign(query, {
  391. departureAirport: this.formData.currentAirport ?? '',
  392. landingAirport: row.targetAirport ?? ''
  393. })
  394. break
  395. case 'arrival':
  396. Object.assign(query, {
  397. departureAirport: row.departureAirport ?? '',
  398. landingAirport: this.formData.currentAirport ?? ''
  399. })
  400. break
  401. case 'transferDeparture':
  402. case 'transferArrival':
  403. Object.assign(query, {
  404. departureAirport: row.preAirport ?? '',
  405. landingAirport: row.targetAirport ?? ''
  406. })
  407. break
  408. default:
  409. break
  410. }
  411. this.$router.push({
  412. path,
  413. query
  414. })
  415. }
  416. }
  417. }
  418. }