terminal.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  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: 0
  23. }
  24. },
  25. created() {
  26. this.setFilterAndSort(this.tableCols)
  27. },
  28. updated() {
  29. const headerHeight = 80
  30. const bottomBlankHeight = 41
  31. const formWrapHeight = this.$refs['formWrap'].offsetHeight
  32. this.computedTableHeight = `calc(100vh - ${headerHeight + bottomBlankHeight + formWrapHeight}px)`
  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. setFilterAndSort (tableCols) {
  88. const self = this
  89. Object.values(tableCols).forEach(({ prop, filterable, sortable, children }) => {
  90. if (children) {
  91. self.setFilterAndSort(children)
  92. } else {
  93. if (filterable) {
  94. self.$set(self.tableDataFilters, prop, [])
  95. self.$set(self.filterValues, prop, [])
  96. }
  97. if (sortable) {
  98. self.$set(self.tableDataSortRules, prop, '')
  99. }
  100. }
  101. })
  102. },
  103. // 合计行
  104. summaryMethod({ columns, data }) {
  105. const sums = []
  106. if (columns.length > 0) {
  107. columns.forEach((column, index) => {
  108. if (index === 0) {
  109. sums[index] = '合计'
  110. } else if (index === 1) {
  111. sums[index] = '航班数:' + this.tableData.length
  112. } else if (
  113. // 需要计算的列
  114. [
  115. 'passagernum',
  116. 'checkNumber',
  117. 'not_actived',
  118. 'expect_load',
  119. 'security_all',
  120. 'sortNumber',
  121. 'loadNumber',
  122. 'tounLoad',
  123. 'unLoad',
  124. 'delbag',
  125. 'noBSM',
  126. 'reach',
  127. 'did_not_arrive',
  128. 'special',
  129. 'claim',
  130. 'uninstalled',
  131. 'to_be_uninstalled',
  132. 'terminateArrive',
  133. 'terminatedNotArrived',
  134. 'delivered',
  135. 'not_shipped',
  136. 'container',
  137. 'bulk',
  138. 'checkInTravellerNumber',
  139. 'checkInNumber',
  140. 'unActive',
  141. 'preLoad',
  142. 'noCheckInNumber',
  143. 'midIn',
  144. 'checkIns',
  145. 'projectedLoad',
  146. 'loadedQuantity',
  147. 'numberOfDestinationArrivals',
  148. 'endPointNotReached',
  149. 'specialQuantity',
  150. 'numberOfClaims',
  151. 'numberToBeUninstalled',
  152. 'terminateArrivalQuantity',
  153. 'terminateUnreachedQuantity',
  154. 'quantityShipped',
  155. 'undeliveredQuantity',
  156. 'numberOfBulk',
  157. 'inTransferBaggageCount',
  158. 'inTransferredBaggageCount',
  159. 'outTransferBaggageCount',
  160. 'outTransferredBaggageCount'
  161. ].includes(column.property)
  162. ) {
  163. const values = data.map(item => Number(item[column.property]))
  164. if (values.some(value => !isNaN(value))) {
  165. sums[index] = values.reduce((prev, curr) => {
  166. const value = Number(curr)
  167. if (!isNaN(value)) {
  168. return Number(prev) + Number(curr)
  169. } else {
  170. return Number(prev)
  171. }
  172. }, 0)
  173. } else {
  174. sums[index] = 0
  175. }
  176. } else {
  177. // 过滤某些字段不参与计算
  178. sums[index] = '-'
  179. }
  180. })
  181. }
  182. return sums
  183. },
  184. cellClass({ row, column, rowIndex, columnIndex }) {
  185. const classes = commonTableCellClass({ row, column, rowIndex, columnIndex })
  186. if (
  187. [
  188. 'flightNO',
  189. 'preFlightNO',
  190. 'inTransferBaggageCount',
  191. 'inTransferredBaggageCount',
  192. 'tounLoad',
  193. 'unLoad',
  194. 'checkInNumber',
  195. 'unActive',
  196. 'midIn',
  197. 'noCheckInNumber',
  198. 'checkNumber',
  199. 'sortNumber',
  200. 'loadNumber',
  201. 'landingNumber',
  202. 'checkIns'
  203. ].includes(column.property) &&
  204. row[column.property]
  205. ) {
  206. classes.push('cell-click')
  207. if (
  208. this.clickedCells.some(
  209. cell =>
  210. cell.pageName === this.$route.name &&
  211. Object.entries(cell.row).every(([key, value]) => row[key] === value) &&
  212. cell.columnProp === column.property
  213. )
  214. ) {
  215. classes.push('cell-clicked')
  216. }
  217. }
  218. if (column.property === 'tounLoad' && row[column.property]) {
  219. classes.push('cell-tounLoad')
  220. }
  221. return classes.join(' ')
  222. },
  223. cellClickHandler(row, column, cell, event) {
  224. if (
  225. [
  226. 'flightNO',
  227. 'preFlightNO',
  228. 'inTransferBaggageCount',
  229. 'inTransferredBaggageCount',
  230. 'tounLoad',
  231. 'unLoad',
  232. 'checkInNumber',
  233. 'unActive',
  234. 'midIn',
  235. 'noCheckInNumber',
  236. 'checkNumber',
  237. 'sortNumber',
  238. 'loadNumber',
  239. 'landingNumber',
  240. 'checkIns'
  241. ].includes(column.property)
  242. ) {
  243. this.$store.dispatch('keepAlive/addClickedCell', {
  244. row,
  245. columnProp: column.property,
  246. pageName: this.$route.name
  247. })
  248. }
  249. switch (column.property) {
  250. case 'flightNO':
  251. this.$router.push({
  252. path: `${this.$route.path}/flightView`,
  253. query: {
  254. flightNO: row.flightNO,
  255. flightDate: row.flightDate
  256. }
  257. })
  258. break
  259. case 'preFlightNO':
  260. this.$router.push({
  261. path: '/transfer/arrival/flightView',
  262. query: {
  263. flightNO: row.preFlightNO,
  264. flightDate: row.flightDate
  265. }
  266. })
  267. break
  268. case 'inTransferBaggageCount':
  269. this.$router.push({
  270. path: '/advance',
  271. query: {
  272. flightNO: row.preFlightNO,
  273. transferDeparture: row.flightNO,
  274. startDate: row.preFlightDate,
  275. endDate: row.preFlightDate
  276. }
  277. })
  278. break
  279. case 'inTransferredBaggageCount':
  280. this.$router.push({
  281. path: '/advance',
  282. query: {
  283. flightNO: row.flightNO,
  284. transferArrival: row.preFlightNO,
  285. startDate: row.flightDate,
  286. endDate: row.flightDate
  287. }
  288. })
  289. break
  290. case 'tounLoad':
  291. this.$router.push({
  292. path: '/advance',
  293. query: {
  294. flightNO: row.flightNO,
  295. startDate: row.flightDate,
  296. endDate: row.flightDate,
  297. unLoad: 0
  298. }
  299. })
  300. break
  301. case 'unLoad':
  302. this.$router.push({
  303. path: '/advance',
  304. query: {
  305. flightNO: row.flightNO,
  306. startDate: row.flightDate,
  307. endDate: row.flightDate,
  308. unLoad: 1
  309. }
  310. })
  311. break
  312. case 'checkInNumber':
  313. this.$router.push({
  314. path: '/advance',
  315. query: {
  316. flightNO: row.flightNO,
  317. startDate: row.flightDate,
  318. endDate: row.flightDate,
  319. checkIn: 1
  320. }
  321. })
  322. break
  323. case 'unActive':
  324. this.$router.push({
  325. path: '/advance',
  326. query: {
  327. flightNO: row.flightNO,
  328. startDate: row.flightDate,
  329. endDate: row.flightDate,
  330. active: 0
  331. }
  332. })
  333. break
  334. case 'midIn':
  335. this.$router.push({
  336. path: '/advance',
  337. query: {
  338. flightNO: row.flightNO,
  339. startDate: row.flightDate,
  340. endDate: row.flightDate,
  341. transferIn: 1
  342. }
  343. })
  344. break
  345. case 'noCheckInNumber':
  346. this.$router.push({
  347. path: '/advance',
  348. query: {
  349. flightNO: row.flightNO,
  350. startDate: row.flightDate,
  351. endDate: row.flightDate,
  352. canceled: 1
  353. }
  354. })
  355. break
  356. case 'checkNumber':
  357. case 'sortNumber':
  358. case 'loadNumber':
  359. case 'landingNumber': {
  360. const reflect = {
  361. checkNumber: '安检',
  362. sortNumber: '分拣',
  363. loadNumber: '装车',
  364. landingNumber: '装机'
  365. }
  366. this.$router.push({
  367. path: '/advance',
  368. query: {
  369. flightNO: row.flightNO,
  370. startDate: row.flightDate,
  371. endDate: row.flightDate,
  372. status: reflect[column.property]
  373. }
  374. })
  375. break
  376. }
  377. case 'checkIns':
  378. this.$router.push({
  379. path: '/advance',
  380. query: {
  381. flightNO: row.flightNO,
  382. startDate: row.flightDate,
  383. endDate: row.flightDate,
  384. checkIn: 1
  385. }
  386. })
  387. break
  388. default:
  389. break
  390. }
  391. }
  392. }
  393. }