terminal.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. /*
  2. * @Author: Badguy
  3. * @Date: 2022-03-04 11:41:55
  4. * @LastEditTime: 2022-05-03 15:14:10
  5. * @LastEditors: your name
  6. * @Description: 航站视图通用部分
  7. * have a nice day!
  8. */
  9. import {
  10. CurrentAirportQuery,
  11. RelatedAirportQuery,
  12. AirCompanyQuery,
  13. CraftTypeQuery,
  14. FlightAttrQuery,
  15. IntegratedQuery,
  16. IntegratedQueryTransfer
  17. } from '@/api/flight'
  18. export default {
  19. data() {
  20. return {
  21. // 表格数据
  22. tableData: [],
  23. spanArr: [],
  24. pos: 0,
  25. loading: false
  26. }
  27. },
  28. created() {
  29. this.currentAirportQuery()
  30. },
  31. methods: {
  32. // 数据处理
  33. formatData(arr) {
  34. arr.forEach(item => {
  35. item['name'] = item['name'] + item['code3']
  36. item.builds &&
  37. item.builds.forEach(p => {
  38. p['code3'] = p.name
  39. })
  40. })
  41. return arr
  42. },
  43. // 表格数据格式化
  44. tableFormat(row, column, cellValue) {
  45. if (cellValue || cellValue === 0) {
  46. switch (column.property) {
  47. case 'FlightDate':
  48. return cellValue.split('-').slice(1).join('-')
  49. case 'PlanLandingTime':
  50. case 'PlanDepartureTime':
  51. case 'PrePlanLandingTime':
  52. case 'TransferFlightPlanDepartureTime':
  53. return cellValue.split('T')[1].split(':').slice(0, 2).join(':')
  54. default:
  55. return cellValue
  56. }
  57. } else {
  58. return ''
  59. }
  60. },
  61. // 合计行
  62. summaryMethod({ columns, data }) {
  63. const sums = []
  64. if (columns.length > 0) {
  65. columns.forEach((column, index) => {
  66. if (index === 0) {
  67. sums[index] = '合计'
  68. } else if (
  69. // 需要计算的列
  70. [
  71. 'passagernum',
  72. 'checkin',
  73. 'not_actived',
  74. 'expect_load',
  75. 'security_all',
  76. 'fenj',
  77. 'loadcar',
  78. 'loadflight',
  79. 'waitfanj',
  80. 'hasfanj',
  81. 'delbag',
  82. 'no_bsm',
  83. 'transfer_all',
  84. 'reach',
  85. 'did_not_arrive',
  86. 'special',
  87. 'claim',
  88. 'uninstalled',
  89. 'to_be_uninstalled',
  90. 'terminateArrive',
  91. 'terminatedNotArrived',
  92. 'delivered',
  93. 'not_shipped',
  94. 'container',
  95. 'bulk'
  96. ].includes(column.property)
  97. ) {
  98. const values = data.map(item => Number(item[column.property]))
  99. if (values.some(value => !isNaN(value))) {
  100. sums[index] = values.reduce((prev, curr) => {
  101. const value = Number(curr)
  102. if (!isNaN(value)) {
  103. return Number(prev) + Number(curr)
  104. } else {
  105. return Number(prev)
  106. }
  107. }, 0)
  108. } else {
  109. sums[index] = 0
  110. }
  111. } else {
  112. // 过滤某些字段不参与计算
  113. sums[index] = '-'
  114. }
  115. })
  116. }
  117. return sums
  118. },
  119. // 表格行点击跳转
  120. rowClick(row, column, event) {
  121. this.$router.push({
  122. path: `/${this.$route.path.split('/').slice(1, -1).join('/')}/flightView`,
  123. query: row
  124. })
  125. },
  126. // 全部机场查询
  127. async currentAirportQuery() {
  128. const params = {
  129. startDate: this.startDate,
  130. endDate: this.endDate
  131. }
  132. try {
  133. const res = await CurrentAirportQuery(params)
  134. if (res.code === 0) {
  135. if (res.returnData.length) {
  136. const datas = this.formatData(res.returnData)
  137. const datasCopy = this._.cloneDeep(datas)
  138. this.currentAirportOptions = datas
  139. const defaultData = datasCopy[0]
  140. // this.formData.currentAirport = [[defaultData.code3, defaultData.builds[0].code3]]
  141. // this.formData.currentAirport = [[defaultData.code3]]
  142. this.formData.currentAirport = [defaultData.code3]
  143. params.currentAirport = this.currentAirport
  144. this.getFormData(params)
  145. this.getTableData({
  146. ...params,
  147. world: this.formData.search
  148. })
  149. }
  150. } else {
  151. this.$message.error(res.message)
  152. }
  153. } catch (error) {
  154. console.log('出错了', error)
  155. }
  156. },
  157. // 目的站/始飞站查询
  158. async relatedAirportQuery(params = {}) {
  159. try {
  160. const res = await RelatedAirportQuery(params)
  161. if (res.code === 0) {
  162. const datas = this.formatData(res.returnData)
  163. this.relatedAirportOptions = datas
  164. } else {
  165. this.$message.error(res.message)
  166. }
  167. } catch (error) {
  168. console.log('出错了', error)
  169. }
  170. },
  171. // 航司查询
  172. async inboundCarrierQuery(params = {}) {
  173. try {
  174. const res = await AirCompanyQuery({
  175. ...params,
  176. type: 'IN'
  177. })
  178. if (res.code === 0) {
  179. this.inboundCarrierOptions = res.returnData
  180. } else {
  181. this.$message.error(res.message)
  182. }
  183. } catch (error) {
  184. console.log('出错了', error)
  185. }
  186. },
  187. // 航司查询
  188. async outgoingAirlineQuery(params = {}) {
  189. try {
  190. const res = await AirCompanyQuery({
  191. ...params,
  192. type: 'OUT'
  193. })
  194. if (res.code === 0) {
  195. this.outgoingAirlineOptions = res.returnData
  196. } else {
  197. this.$message.error(res.message)
  198. }
  199. } catch (error) {
  200. console.log('出错了', error)
  201. }
  202. },
  203. // 机型查询
  204. async craftTypeQuery(params = {}) {
  205. try {
  206. const res = await CraftTypeQuery(params)
  207. if (res.code === 0) {
  208. this.craftTypeOptions = res.returnData.map(item => ({
  209. code3: item,
  210. name: item
  211. }))
  212. } else {
  213. this.$message.error(res.message)
  214. }
  215. } catch (error) {
  216. console.log('出错了', error)
  217. }
  218. },
  219. // 航线查询
  220. async flightAttrQuery(params = {}) {
  221. try {
  222. const res = await FlightAttrQuery(params)
  223. if (res.code === 0) {
  224. this.flightAttrOptions = res.returnData
  225. } else {
  226. this.$message.error(res.message)
  227. }
  228. } catch (error) {
  229. console.log('出错了', error)
  230. }
  231. },
  232. // 综合查询
  233. async integratedQuery(params = {}) {
  234. try {
  235. this.loading = true
  236. const res = await IntegratedQuery(params)
  237. if (res.code === 0) {
  238. const tableData = res.returnData
  239. this.initTableData(tableData)
  240. this.loading = false
  241. } else {
  242. this.$message.error(res.message)
  243. this.loading = false
  244. }
  245. } catch (error) {
  246. console.log('出错了', error)
  247. this.loading = false
  248. }
  249. },
  250. // 中转综合查询
  251. async integratedQueryTransfer(params = {}) {
  252. try {
  253. this.loading = true
  254. const res = await IntegratedQueryTransfer(params)
  255. if (res.code === 0) {
  256. const tableData = res.returnData
  257. this.initTableData(tableData)
  258. this.loading = false
  259. } else {
  260. this.$message.error(res.message)
  261. this.loading = false
  262. }
  263. } catch (error) {
  264. console.log('出错了', error)
  265. this.loading = false
  266. }
  267. }
  268. }
  269. }