terminal.js 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. /*
  2. * @Author: Badguy
  3. * @Date: 2022-03-04 11:41:55
  4. * @LastEditTime: 2022-05-05 17:57:24
  5. * @LastEditors: your name
  6. * @Description: 航站视图通用部分
  7. * have a nice day!
  8. */
  9. import { queryMap, myQuery } from '@/api/dataIntegration'
  10. import {
  11. CurrentAirportQuery,
  12. RelatedAirportQuery,
  13. AirCompanyQuery,
  14. CraftTypeQuery,
  15. FlightAttrQuery,
  16. IntegratedQuery,
  17. IntegratedQueryTransfer
  18. } from '@/api/flight'
  19. export default {
  20. data() {
  21. return {
  22. // 表格数据
  23. tableData: [],
  24. spanArr: [],
  25. pos: 0,
  26. loading: false
  27. }
  28. },
  29. // created() {
  30. // this.currentAirportQuery()
  31. // },
  32. mounted() {
  33. // this.queryDepartureAirport()
  34. },
  35. computed: {
  36. dates() {
  37. return [this.startDate, this.endDate]
  38. },
  39. flightQueryParams() {
  40. return [
  41. this.startDate,
  42. this.endDate,
  43. this.departureAirPort,
  44. this.departureAirPort,
  45. this.landingAirport,
  46. this.landingAirport,
  47. this.carrier,
  48. this.carrier,
  49. this.craftType,
  50. this.craftType,
  51. this.flightAttr,
  52. this.flightAttr,
  53. this.search,
  54. this.search
  55. ]
  56. }
  57. },
  58. methods: {
  59. // 数据处理
  60. formatData(arr) {
  61. arr.forEach(item => {
  62. item['name'] = item['name'] + item['code3']
  63. item.builds &&
  64. item.builds.forEach(p => {
  65. p['code3'] = p.name
  66. })
  67. })
  68. return arr
  69. },
  70. // 表格数据格式化
  71. tableFormat(row, column, cellValue) {
  72. if (cellValue || cellValue === 0) {
  73. switch (column.property) {
  74. case 'FlightDate':
  75. return cellValue.split('-').slice(1).join('-')
  76. case 'PlanLandingTime':
  77. case 'PlanDepartureTime':
  78. case 'PrePlanLandingTime':
  79. case 'TransferFlightPlanDepartureTime':
  80. return cellValue.split('T')[1].split(':').slice(0, 2).join(':')
  81. default:
  82. return cellValue
  83. }
  84. } else {
  85. return ''
  86. }
  87. },
  88. // 合计行
  89. summaryMethod({ columns, data }) {
  90. const sums = []
  91. if (columns.length > 0) {
  92. columns.forEach((column, index) => {
  93. if (index === 0) {
  94. sums[index] = '合计'
  95. } else if (
  96. // 需要计算的列
  97. [
  98. 'passagernum',
  99. 'checkNumber',
  100. 'not_actived',
  101. 'expect_load',
  102. 'security_all',
  103. 'sortNumber',
  104. 'loadNumber',
  105. 'waitfanj',
  106. 'unLoad',
  107. 'delbag',
  108. 'noBSM',
  109. 'transfer_all',
  110. 'reach',
  111. 'did_not_arrive',
  112. 'special',
  113. 'claim',
  114. 'uninstalled',
  115. 'to_be_uninstalled',
  116. 'terminateArrive',
  117. 'terminatedNotArrived',
  118. 'delivered',
  119. 'not_shipped',
  120. 'container',
  121. 'bulk',
  122. 'checkInTravellerNumber',
  123. 'checkInNumber',
  124. 'unActive',
  125. 'preLoad',
  126. 'noCheckInNumber',
  127. 'midIn',
  128. ].includes(column.property)
  129. ) {
  130. const values = data.map(item => Number(item[column.property]))
  131. if (values.some(value => !isNaN(value))) {
  132. sums[index] = values.reduce((prev, curr) => {
  133. const value = Number(curr)
  134. if (!isNaN(value)) {
  135. return Number(prev) + Number(curr)
  136. } else {
  137. return Number(prev)
  138. }
  139. }, 0)
  140. } else {
  141. sums[index] = 0
  142. }
  143. } else {
  144. // 过滤某些字段不参与计算
  145. sums[index] = '-'
  146. }
  147. })
  148. }
  149. return sums
  150. },
  151. // 表格行点击跳转
  152. rowClick(row, column, event) {
  153. // this.$router.push({
  154. // path: `/${this.$route.path.split('/').slice(1, -1).join('/')}/flightView`,
  155. // query: row
  156. // })
  157. this.$router.push({ path: '/advance/flightView', query: row })
  158. },
  159. // 全部机场查询
  160. async currentAirportQuery() {
  161. const params = {
  162. startDate: this.startDate,
  163. endDate: this.endDate
  164. }
  165. try {
  166. const res = await CurrentAirportQuery(params)
  167. if (res.code === 0) {
  168. if (res.returnData.length) {
  169. const datas = this.formatData(res.returnData)
  170. const datasCopy = this._.cloneDeep(datas)
  171. this.currentAirportList = datas
  172. const defaultData = datasCopy[0]
  173. // this.formData.currentAirport = [[defaultData.code3, defaultData.builds[0].code3]]
  174. // this.formData.currentAirport = [[defaultData.code3]]
  175. this.formData.currentAirport = [defaultData.code3]
  176. params.currentAirport = this.currentAirport
  177. this.getFormData(params)
  178. this.getTableData({
  179. ...params,
  180. world: this.formData.search
  181. })
  182. }
  183. } else {
  184. this.$message.error(res.message)
  185. }
  186. } catch (error) {
  187. console.log('出错了', error)
  188. }
  189. },
  190. // 目的站/始飞站查询
  191. async relatedAirportQuery(params = {}) {
  192. try {
  193. const res = await RelatedAirportQuery(params)
  194. if (res.code === 0) {
  195. const datas = this.formatData(res.returnData)
  196. this.relatedAirportList = datas
  197. } else {
  198. this.$message.error(res.message)
  199. }
  200. } catch (error) {
  201. console.log('出错了', error)
  202. }
  203. },
  204. // 航司查询
  205. async inboundCarrierQuery(params = {}) {
  206. try {
  207. const res = await AirCompanyQuery({
  208. ...params,
  209. type: 'IN'
  210. })
  211. if (res.code === 0) {
  212. this.carrierList = res.returnData
  213. } else {
  214. this.$message.error(res.message)
  215. }
  216. } catch (error) {
  217. console.log('出错了', error)
  218. }
  219. },
  220. // 航司查询
  221. async outgoingAirlineQuery(params = {}) {
  222. try {
  223. const res = await AirCompanyQuery({
  224. ...params,
  225. type: 'OUT'
  226. })
  227. if (res.code === 0) {
  228. this.carrierList = res.returnData
  229. } else {
  230. this.$message.error(res.message)
  231. }
  232. } catch (error) {
  233. console.log('出错了', error)
  234. }
  235. },
  236. // 机型查询
  237. async craftTypeQuery(params = {}) {
  238. try {
  239. const res = await CraftTypeQuery(params)
  240. if (res.code === 0) {
  241. this.craftTypeList = res.returnData.map(item => ({
  242. code3: item,
  243. name: item
  244. }))
  245. } else {
  246. this.$message.error(res.message)
  247. }
  248. } catch (error) {
  249. console.log('出错了', error)
  250. }
  251. },
  252. // 航线查询
  253. async flightAttrQuery(params = {}) {
  254. try {
  255. const res = await FlightAttrQuery(params)
  256. if (res.code === 0) {
  257. this.flightAttrList = res.returnData
  258. } else {
  259. this.$message.error(res.message)
  260. }
  261. } catch (error) {
  262. console.log('出错了', error)
  263. }
  264. },
  265. // 综合查询
  266. async integratedQuery(params = {}) {
  267. try {
  268. this.loading = true
  269. const res = await IntegratedQuery(params)
  270. if (res.code === 0) {
  271. const tableData = res.returnData
  272. this.initTableData(tableData)
  273. this.loading = false
  274. } else {
  275. this.$message.error(res.message)
  276. this.loading = false
  277. }
  278. } catch (error) {
  279. console.log('出错了', error)
  280. this.loading = false
  281. }
  282. },
  283. // 中转综合查询
  284. async integratedQueryTransfer(params = {}) {
  285. try {
  286. this.loading = true
  287. const res = await IntegratedQueryTransfer(params)
  288. if (res.code === 0) {
  289. const tableData = res.returnData
  290. this.initTableData(tableData)
  291. this.loading = false
  292. } else {
  293. this.$message.error(res.message)
  294. this.loading = false
  295. }
  296. } catch (error) {
  297. console.log('出错了', error)
  298. this.loading = false
  299. }
  300. },
  301. // 查询起飞机场 id: 31
  302. queryDepartureAirport() {
  303. return myQuery(queryMap.departureAirPort, ...this.dates)
  304. },
  305. // 查询降落机场 id: 32
  306. queryLandingAirport() {
  307. return myQuery(queryMap.landingAirport, ...this.dates)
  308. },
  309. // 按照降落机场查询起飞机场 id: 33
  310. queryDepartureAirportByLandingAirport() {
  311. return myQuery(queryMap.departureAirPortBylandingAirport, this.currentAirport, ...this.dates)
  312. },
  313. // 按照起飞机场查询降落机场 id: 34
  314. queryLandingAirportByDepartureAirport() {
  315. return myQuery(queryMap.landingAirportBydepartureAirPort, this.currentAirport, ...this.dates)
  316. },
  317. // 查询航司 id: 35
  318. queryCarrier() {
  319. return myQuery(queryMap.carrier, ...this.dates)
  320. },
  321. // 查询机型 id: 36
  322. queryCraftType() {
  323. return myQuery(queryMap.craftType, ...this.dates)
  324. },
  325. // 查询航线 id: 37
  326. queryAirline() {
  327. return myQuery(queryMap.flightAttr, ...this.dates)
  328. },
  329. // 查询进港航班 id: 38
  330. queryLandingFlight() {
  331. return myQuery(queryMap.landingFlight, ...this.flightQueryParams)
  332. },
  333. // 查询离港航班 id: 39
  334. queryDepartureFlight() {
  335. return myQuery(queryMap.departureFlight, ...this.flightQueryParams)
  336. },
  337. // 查询中转航班 id: 40
  338. queryTrasferFlight() {
  339. return myQuery(queryMap.transferFlight, ...this.flightQueryParams)
  340. }
  341. }
  342. }