baggageView.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  1. <template>
  2. <div v-loading="loading" element-loading-text="拼命加载中" element-loading-spinner="el-icon-loading" element-loading-background="rgba(0, 0, 0, 0.8)" class="baggageView">
  3. <el-scrollbar style="height: 100%">
  4. <div v-infinite-scroll="load" class="baggageView-content">
  5. <div v-for="(item,index) in tableData" :key="index" class="baggageView-list">
  6. <div class="part2">
  7. <div class="part2_info">
  8. <div class="title">
  9. <div class="fightNo">{{ item.carrierFlights || item.inflightNo }}</div>
  10. <div class="fightDate">{{ item.carrierFlightsDate || item.inflightDate }}</div>
  11. <div class="fightLine">{{ item.outAirport }}{{ item.takeoff_terminal }} -- {{item.landAirport}}{{ item.target_terminal }}</div>
  12. <div class="fightTime">{{ item.takeTime }} -- {{ item.landTime }}</div>
  13. </div>
  14. <div class="baggage-track-chart">
  15. <div class="step-line">
  16. <div v-for="(line, index) in 6" :key="index" :class="['step-line-segment', { 'step-line-active': activeStepLine(index,item.bagStatus) }]"></div>
  17. </div>
  18. <div v-for="(p, cindex) in item.bagStatus" :key="cindex" :class="{ 'step-item': true, 'active-item': p.timeValue }">
  19. <div :class="activeStepLineDanger(cindex,item)" class="step-circle">
  20. <span class="step-name">{{ p.nodeName }}</span>
  21. </div>
  22. <div v-if="p.timeValue || p.stateValue || p.loclValue || p.fourSecurity" class="step-info">
  23. <div :class="statusClasses(p.stateValue)">{{ p.stateValue }}</div>
  24. <span class="step-time">{{ p.timeValue }}</span>
  25. <div class="step-location">{{ p.loclValue }}</div>
  26. <div :class="statusClasses(p.fourSecurity)">{{ p.fourSecurity }}</div>
  27. </div>
  28. <div v-else class="step-info">无</div>
  29. </div>
  30. </div>
  31. </div>
  32. </div>
  33. </div>
  34. </div>
  35. </el-scrollbar>
  36. </div>
  37. </template>
  38. <script>
  39. import pf from '@/layout/mixin/publicFunc'
  40. export default {
  41. name: 'BaggageView',
  42. mixins: [pf],
  43. props: {
  44. queryObj: {
  45. type: Object,
  46. default: () => { }
  47. },
  48. tagObj: {
  49. type: Object,
  50. default: () => { }
  51. }
  52. },
  53. data () {
  54. return {
  55. stepNodes: [
  56. {
  57. nodeCode: 'CHECKIN',
  58. nodeName: '值机',
  59. timeProp: 'checkInDate',
  60. timeValue: '',
  61. loclProp: 'checkInLocation',
  62. loclValue: '',
  63. stateProp: 'checkState',
  64. stateValue: '',
  65. },
  66. {
  67. nodeCode: 'SECURITY',
  68. nodeName: '安检',
  69. timeProp: 'security_check_time',
  70. timeValue: '',
  71. loclProp: 'security_location',
  72. loclValue: '',
  73. stateProp: 'securityInspectionResults',
  74. stateValue: '',
  75. },
  76. {
  77. nodeCode: 'SORT',
  78. nodeName: '分拣',
  79. timeProp: 'sorting_time',
  80. timeValue: '',
  81. loclProp: 'sorting_location',
  82. loclValue: '',
  83. stateProp: 'sortState',
  84. stateValue: '',
  85. },
  86. {
  87. nodeCode: 'LOAD',
  88. nodeName: '装车',
  89. timeProp: 'loading_time',
  90. timeValue: '',
  91. loclProp: 'installationAddress',
  92. loclValue: '',
  93. stateProp: 'loadState',
  94. stateValue: '',
  95. },
  96. {
  97. nodeCode: 'INFL',
  98. nodeName: '装机',
  99. timeProp: 'installation_time',
  100. timeValue: '',
  101. loclProp: 'installation_location',
  102. loclValue: '',
  103. stateProp: 'normal',
  104. stateValue: '',
  105. },
  106. {
  107. nodeCode: 'UNLOAD',
  108. nodeName: '卸机',
  109. timeProp: 'unloadtime',
  110. timeValue: '',
  111. loclProp: 'unloadLocation',
  112. loclValue: '',
  113. stateProp: 'normal',
  114. stateValue: '',
  115. },
  116. {
  117. nodeCode: 'ARRIVED',
  118. nodeName: '到达',
  119. timeProp: 'arrivedtime',
  120. timeValue: '',
  121. loclProp: 'arrviedLocation',
  122. loclValue: '',
  123. stateProp: 'normal',
  124. stateValue: '',
  125. }
  126. ],
  127. tableData: [],
  128. tableDataCopy: [],
  129. page: 0,
  130. pageSize: 20,
  131. dataContent: {},
  132. loading: false,
  133. noMore: false
  134. }
  135. },
  136. computed: {
  137. activeStepLine () {
  138. return function (index, arrs) {
  139. return (arrs[index].stateValue || arrs[index].loclValue || arrs[index].timeValue) && (arrs[index + 1].stateValue || arrs[index + 1].loclValue || arrs[index + 1].timeValue)
  140. }
  141. },
  142. activeStepLineDanger () {
  143. return function (index, item) {
  144. function diffMinutes () {
  145. const { takeTime } = item
  146. const [hour, minutes] = takeTime?.split(':')
  147. if (minutes - 15 >= 0) {
  148. return `${hour}: ${minutes - 15 >= 10 ? minutes - 15 : '0' + (minutes - 15)}`
  149. } else {
  150. if (hour - 1 > 0) {
  151. return `${hour - 1}:${minutes - 15 + 60 >= 10 ? minutes - 15 + 60 : '0' + (minutes - 15 + 60)}`
  152. } else {
  153. return `23:${minutes - 15 + 60 >= 10 ? minutes - 15 + 60 : '0' + (minutes - 15 + 60)}`
  154. }
  155. }
  156. }
  157. const arrs = item.bagStatus
  158. const { stateProp, stateValue } = arrs[index]
  159. if (stateProp == 'securityInspectionResults' && stateValue == 'UCL') {
  160. if (arrs[index + 1].stateValue || arrs[index + 1].loclValue || arrs[index + 1].timeValue || arrs[index + 2].stateValue || arrs[index + 2].loclValue || arrs[index + 2].timeValue) {
  161. return 'step-circle-waring'
  162. } else {
  163. return 'step-circle-danger'
  164. }
  165. }
  166. // if (stateProp == 'securityInspectionResults' && !stateValue) {
  167. // if (this.tableData.length >= 2 || arrs[index + 1].stateValue || arrs[index + 1].loclValue || arrs[index + 1].timeValue || arrs[index + 2].stateValue || arrs[index + 2].loclValue || arrs[index + 2].timeValue) {
  168. // return 'step-circle-waring'
  169. // }
  170. // }
  171. }
  172. },
  173. statusClasses () {
  174. return function (status) {
  175. const classes = ['step-status']
  176. if (typeof status === 'string') {
  177. if (status.includes('不正常') || status.includes('不通过')) {
  178. classes.push('step-status-abnormal')
  179. }
  180. else if (status.includes('正常') || status.includes('通过')) {
  181. classes.push('step-status-normal')
  182. }
  183. else {
  184. classes.push('step-status-abnormal')
  185. }
  186. }
  187. return classes
  188. }
  189. }
  190. },
  191. watch: {
  192. tagObj: {
  193. handler (obj) {
  194. this.dataContent = obj
  195. this.restTable()
  196. this.load()
  197. },
  198. deep: true
  199. },
  200. queryObj: {
  201. handler (obj) {
  202. this.tableDataCopy = []
  203. this.tableData = []
  204. this.dataContent = obj
  205. this.restTable()
  206. this.load()
  207. },
  208. deep: true
  209. },
  210. },
  211. created () {
  212. this.dataContent = this.queryObj
  213. },
  214. methods: {
  215. //获取行李信息
  216. async getLuggageList (id, dataContent = this.dataContent, page, pageSize) {
  217. try {
  218. this.loading = true
  219. const { code, returnData } = await this.getQueryList(id, dataContent, page, pageSize)
  220. if (code == 0) {
  221. if (returnData.length === 0) {
  222. this.page--;
  223. this.noMore = true;
  224. this.loading = false;
  225. }
  226. returnData.forEach(item => {
  227. item.bagStatus = _.cloneDeep(this.stepNodes)
  228. })
  229. this.tableDataCopy.push(...returnData)
  230. // this.tableDataCopy = _.uniqBy(this.tableDataCopy, 'ID')
  231. // this.tableDataCopy = this.tableDataCopy.sort((a, b) => Date.parse(a.carrierFlightsDate) - Date.parse(b.carrierFlightsDate))
  232. this.tableDataCopy.forEach(item => {
  233. item.bagStatus.map(p => {
  234. const { timeProp, loclProp, stateProp } = p
  235. if (item.hasOwnProperty(timeProp) || item.hasOwnProperty(loclProp) || item.hasOwnProperty(stateProp)) {
  236. p.timeValue = item[timeProp]
  237. p.loclValue = item[loclProp]
  238. p.stateValue = item[stateProp]
  239. }
  240. })
  241. })
  242. this.getBagTime(this.tableDataCopy)
  243. this.loading = false
  244. } else {
  245. this.page--
  246. this.loading = false
  247. this.$message.error("获取表格数据失败")
  248. }
  249. } catch (error) {
  250. this.loading = false;
  251. console.log(error)
  252. }
  253. },
  254. statusSecurity (item) {
  255. const { securityInspectionResults, security_location } = item
  256. const securityNums = ['XSA001', 'XSA003', 'XSB001', 'XSB004']
  257. // if (securityInspectionResults == 'CLR') return securityInspectionResults
  258. // if (securityInspectionResults == 'UCLR') return securityInspectionResults
  259. if (securityNums.includes(security_location)) return 'ULR'
  260. else return securityInspectionResults
  261. },
  262. restTable () {
  263. this.loading = false
  264. this.noMore = false
  265. this.page = 0
  266. this.tableData = []
  267. },
  268. load () {
  269. if (Object.keys(this.queryObj).length || Object.keys(this.tagObj).length) {
  270. if (this.noMore || this.loading) {
  271. return;
  272. }
  273. this.getLuggageList(SERVICE_ID.bagTableDqId, this.dataContent, ++this.page, this.pageSize);
  274. }
  275. },
  276. async getBagTime (arr) {
  277. const newArr = [...arr]
  278. const reqUrls = []
  279. newArr.forEach(item => {
  280. const { carrierFlights, carrierFlightsDate, outAirport, landAirport, bagStatus } = item
  281. const index = bagStatus.findIndex(citem => citem.stateProp == 'securityInspectionResults')
  282. if (index > -1) {
  283. bagStatus[index]['stateValue'] = this.statusSecurity(item)
  284. bagStatus[index]['fourSecurity'] = item.fourSecurity
  285. }
  286. const reqItem = this.getQueryList(SERVICE_ID.baggageTime, {
  287. carrierFlights,
  288. carrierFlightsDate,
  289. outAirport,
  290. landAirport
  291. })
  292. reqUrls.push(reqItem)
  293. })
  294. const allReqs = await Promise.allSettled(reqUrls)
  295. allReqs.forEach((item, index) => {
  296. const { status, value } = item
  297. if (status == 'fulfilled') {
  298. const { returnData } = value
  299. const newArray = [...returnData]
  300. if (newArray && newArray.length) {
  301. const itemObj = newArray[0]
  302. const newObj = {}
  303. const { actualTakeOffTime, estimateTakeOffTime, scheduleTakeOffTime, actualLandInTime, estimateLandInTime, scheduleLandInTime } = itemObj
  304. newObj.newTakeoff_time = actualTakeOffTime ? actualTakeOffTime : estimateTakeOffTime ? estimateTakeOffTime : scheduleTakeOffTime
  305. newObj.newLand_time = actualLandInTime ? actualLandInTime : estimateLandInTime ? estimateLandInTime : scheduleLandInTime
  306. newObj.takeTime = newObj.newTakeoff_time?.split('T').at(-1)
  307. newObj.landTime = newObj.newLand_time?.split('T').at(-1)
  308. newArr[index] = Object.assign(newArr[index], newObj)
  309. }
  310. }
  311. })
  312. this.tableData = _.orderBy([...newArr], ["carrierFlightsDate", "takeTime"], ["asc"]);
  313. }
  314. }
  315. }
  316. </script>
  317. <style lang="scss" scoped>
  318. .baggageView {
  319. height: 100%;
  320. &-list {
  321. height: 183px;
  322. border-bottom: 1px solid #dfe3ea;
  323. padding: 30px 32px 47px 32px;
  324. &:last-child {
  325. border-bottom: none;
  326. }
  327. .part2 {
  328. width: 100%;
  329. background: #ffffff;
  330. display: flex;
  331. flex-direction: row;
  332. justify-content: space-between;
  333. align-items: flex-start;
  334. .part2_info {
  335. flex: 1;
  336. display: flex;
  337. flex-direction: row;
  338. justify-content: flex-start;
  339. align-items: flex-start;
  340. line-height: 42px;
  341. .title {
  342. width: 160px;
  343. margin-right: 30px;
  344. font-size: 14px;
  345. font-family: Helvetica;
  346. font-weight: 400;
  347. color: #101116;
  348. line-height: 1;
  349. .fightNo {
  350. font-size: 24px;
  351. font-family: Helvetica;
  352. font-weight: bold;
  353. margin-bottom: 8px;
  354. }
  355. .fightDate {
  356. margin-bottom: 15px;
  357. }
  358. .fightLine {
  359. margin-bottom: 8px;
  360. }
  361. .fightTime {
  362. margin-top: 13px;
  363. }
  364. }
  365. .type {
  366. font-size: 18px;
  367. font-weight: bold;
  368. margin-right: 20px;
  369. .warn {
  370. color: #df3559;
  371. }
  372. .normal {
  373. color: #519f6b;
  374. }
  375. }
  376. .airline {
  377. width: 120px;
  378. margin-right: 20px;
  379. }
  380. .baggage-track-chart {
  381. flex: 1;
  382. height: 124px;
  383. position: relative;
  384. display: flex;
  385. flex-direction: row;
  386. justify-content: space-between;
  387. width: 100%;
  388. }
  389. .step-line {
  390. width: calc(100% - 80px);
  391. height: 10px;
  392. position: absolute;
  393. top: 16px;
  394. right: 0;
  395. left: 0;
  396. margin: auto;
  397. display: flex;
  398. .step-line-segment {
  399. width: calc(100% / 6);
  400. height: 100%;
  401. background: #afb4bf;
  402. &.step-line-active {
  403. background: #2d67e3;
  404. }
  405. }
  406. }
  407. .step-item {
  408. width: 80px;
  409. height: 100%;
  410. text-align: center;
  411. font-size: 14px;
  412. display: flex;
  413. flex-direction: column;
  414. align-items: center;
  415. justify-content: flex-start;
  416. z-index: 1;
  417. font-family: Helvetica, "Microsoft Yahei";
  418. .step-circle {
  419. width: 42px;
  420. height: 42px;
  421. border-radius: 50%;
  422. background: #aaacb2;
  423. .step-name {
  424. color: #ffffff;
  425. font-size: 14px;
  426. font-weight: bold;
  427. }
  428. }
  429. .step-info {
  430. margin-top: 8px;
  431. color: #101116;
  432. line-height: 22px;
  433. .step-status {
  434. &-normal {
  435. color: #4ab36f;
  436. }
  437. &-abnormal {
  438. color: #e9af4b;
  439. }
  440. }
  441. .step-time {
  442. white-space: pre-line;
  443. font-size: 12px;
  444. line-height: 20px;
  445. }
  446. }
  447. &.active-item .step-circle {
  448. background: #2d67e3;
  449. }
  450. .step-circle-danger {
  451. background: #ff3303 !important;
  452. }
  453. .step-circle-waring {
  454. background: #2d67e3;
  455. }
  456. }
  457. }
  458. .btns {
  459. margin-top: 6px;
  460. }
  461. }
  462. }
  463. }
  464. </style>