terminal.js 19 KB

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