statisticsHeader.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603
  1. <template>
  2. <div class="flight-statistics-header">
  3. <template v-if="title">
  4. <div class="title">{{ title }}</div>
  5. </template>
  6. <el-form
  7. ref="form"
  8. class="form"
  9. :model="formData"
  10. >
  11. <el-form-item
  12. v-for="item in formItems"
  13. :key="item.prop"
  14. :prop="item.prop"
  15. :label="item.label"
  16. :style="{
  17. width: item.width || '144px'
  18. }"
  19. >
  20. <template v-if="item.inputType === 'input'">
  21. <el-input
  22. v-model="formData[item.prop]"
  23. :size="item.size || 'small'"
  24. :placeholder="item.placeholder || '请输入'"
  25. :clearable="item.clearable"
  26. />
  27. </template>
  28. <template v-if="item.inputType === 'select'">
  29. <el-select
  30. v-model="formData[item.prop]"
  31. :filterable="item.filterable"
  32. :size="item.size || 'small'"
  33. :placeholder="item.placeholder || '请选择'"
  34. :clearable="item.clearable"
  35. :disabled="item.disabled"
  36. @change="
  37. (value) => {
  38. item.changeHandler && call(item.changeHandler, value)
  39. }
  40. "
  41. >
  42. <el-option
  43. v-for="option in item.options"
  44. :key="option.value"
  45. :value="option.value"
  46. :label="option.label"
  47. />
  48. </el-select>
  49. </template>
  50. <template v-if="item.inputType === 'datePicker'">
  51. <el-date-picker
  52. v-model="formData[item.prop]"
  53. :size="item.size || 'small'"
  54. type="daterange"
  55. value-format="yyyy-MM-dd"
  56. range-separator="至"
  57. start-placeholder="开始日期"
  58. end-placeholder="结束日期"
  59. />
  60. </template>
  61. <template v-if="item.inputType === 'cascader'">
  62. <el-cascader
  63. v-model="formData[item.prop]"
  64. :size="item.size || 'small'"
  65. :placeholder="item.placeholder || '请选择'"
  66. :options="item.options"
  67. :props="item.props"
  68. :clearable="item.clearable"
  69. :disabled="item.disabled"
  70. />
  71. </template>
  72. </el-form-item>
  73. <el-form-item v-if="formItems.length">
  74. <el-button
  75. type="primary"
  76. size="small"
  77. @click="getData"
  78. >{{ buttonText }}</el-button>
  79. </el-form-item>
  80. <el-form-item v-if="withExport">
  81. <img
  82. src="../../../assets/nav/ic_export.png"
  83. title="导出"
  84. class="btn-icon-only"
  85. @click="exportClickHandler"
  86. >
  87. </el-form-item>
  88. </el-form>
  89. </div>
  90. </template>
  91. <script>
  92. import { Query } from '@/api/dataIntegration'
  93. export default {
  94. name: 'StatisticsHeader',
  95. props: {
  96. title: {
  97. type: String,
  98. default: ''
  99. },
  100. items: {
  101. type: Array,
  102. default: undefined
  103. },
  104. data: {
  105. type: Object,
  106. default: undefined
  107. },
  108. buttonText: {
  109. type: String,
  110. default: '查询'
  111. },
  112. withExport: {
  113. type: Boolean,
  114. default: true
  115. }
  116. },
  117. data() {
  118. return {
  119. formData: {
  120. range: '',
  121. inOrOut: '',
  122. interval: '',
  123. airline: '',
  124. company: '',
  125. airport: '',
  126. terminal: '',
  127. dateTime: ''
  128. },
  129. formItems: [
  130. {
  131. prop: 'range',
  132. inputType: 'select',
  133. placeholder: '请选择统计范围',
  134. options: [
  135. {
  136. value: '全部',
  137. label: '全部'
  138. },
  139. {
  140. value: '航线',
  141. label: '航线'
  142. },
  143. {
  144. value: '基地分公司',
  145. label: '基地分公司'
  146. },
  147. {
  148. value: '航站',
  149. label: '航站'
  150. },
  151. {
  152. value: '航站楼',
  153. label: '航站楼'
  154. }
  155. ],
  156. changeHandler(value) {
  157. this.formData.inOrOut = ''
  158. // this.formData.interval = ''
  159. this.formData.company = ''
  160. this.formData.airline = ''
  161. this.formData.airport = ''
  162. this.formData.terminal = ''
  163. this.setInOrOutOptions(value)
  164. this.formItems[4].disabled = true
  165. this.formItems[5].disabled = true
  166. this.formItems[6].disabled = true
  167. this.formItems[7].disabled = true
  168. switch (value) {
  169. case '航线':
  170. this.formItems[4].disabled = false
  171. break
  172. case '基地分公司':
  173. this.formItems[5].disabled = false
  174. break
  175. case '航站':
  176. this.formItems[6].disabled = false
  177. break
  178. case '航站楼':
  179. this.formItems[7].disabled = false
  180. break
  181. default:
  182. break
  183. }
  184. }
  185. },
  186. {
  187. prop: 'inOrOut',
  188. inputType: 'select',
  189. placeholder: '请选择进离港',
  190. clearable: true,
  191. options: []
  192. },
  193. {
  194. prop: 'interval',
  195. inputType: 'select',
  196. placeholder: '统计时间维度',
  197. clearable: true,
  198. options: [
  199. {
  200. value: '日',
  201. label: '按日统计'
  202. },
  203. {
  204. value: '月',
  205. label: '按月统计'
  206. },
  207. {
  208. value: '季',
  209. label: '按季统计'
  210. },
  211. {
  212. value: '年',
  213. label: '按年统计'
  214. }
  215. ]
  216. },
  217. {
  218. prop: 'dateTime',
  219. inputType: 'datePicker',
  220. clearable: true,
  221. width: '240px',
  222. options: []
  223. },
  224. {
  225. prop: 'airline',
  226. inputType: 'select',
  227. placeholder: '航线选择',
  228. filterable: true,
  229. clearable: true,
  230. disabled: true,
  231. queryId: DATACONTENT_ID.AirlineId,
  232. setKey: 'a2',
  233. options: []
  234. },
  235. {
  236. prop: 'company',
  237. inputType: 'select',
  238. placeholder: '基地分公司选择',
  239. filterable: true,
  240. clearable: true,
  241. disabled: true,
  242. queryId: DATACONTENT_ID.AreaId,
  243. setKey: 'a5',
  244. options: []
  245. },
  246. {
  247. prop: 'airport',
  248. inputType: 'select',
  249. placeholder: '航站选择',
  250. filterable: true,
  251. clearable: true,
  252. // multiple: true,
  253. disabled: true,
  254. queryId: DATACONTENT_ID.AirportId,
  255. setKey: 'a2',
  256. options: []
  257. },
  258. {
  259. prop: 'terminal',
  260. inputType: 'select',
  261. placeholder: '航站楼选择',
  262. filterable: true,
  263. props: {
  264. multiple: true
  265. },
  266. clearable: true,
  267. disabled: true,
  268. queryId: DATACONTENT_ID.TerminalId,
  269. setKey: 'a2',
  270. options: []
  271. }
  272. ]
  273. }
  274. },
  275. watch: {
  276. items: {
  277. handler(val) {
  278. val && (this.formItems = val)
  279. },
  280. deep: true,
  281. immediate: true
  282. },
  283. data: {
  284. handler(val) {
  285. val && (this.formData = val)
  286. },
  287. deep: true,
  288. immediate: true
  289. }
  290. },
  291. created() {
  292. this.formItems.forEach(item => {
  293. if (item.queryId && item.setKey) {
  294. this.getOptions(item.queryId, item.setKey, item.prop)
  295. }
  296. })
  297. },
  298. methods: {
  299. call(func, ...args) {
  300. func.call(this, ...args)
  301. },
  302. getData() {
  303. // console.log(this.formData)
  304. this.$emit('getFormData', this.formData)
  305. },
  306. exportClickHandler() {
  307. this.$emit('export')
  308. // this.$message.info('开发中')
  309. },
  310. setInOrOutOptions(range) {
  311. const theInOrOutItem = this.formItems.find(item => item.prop === 'inOrOut')
  312. switch (range) {
  313. case '全部':
  314. case '航线':
  315. theInOrOutItem.options = [
  316. {
  317. label: '全部',
  318. value: '全部'
  319. }
  320. ]
  321. this.formData.inOrOut = '全部'
  322. this.formItems[1].disabled = true
  323. break
  324. case '基地分公司':
  325. case '航站':
  326. case '航站楼':
  327. theInOrOutItem.options = [
  328. {
  329. value: '全部',
  330. label: '全部'
  331. },
  332. {
  333. value: '进港',
  334. label: '进港'
  335. },
  336. {
  337. value: '离港',
  338. label: '离港'
  339. }
  340. ]
  341. this.formItems[1].disabled = false
  342. break
  343. default:
  344. theInOrOutItem.options = []
  345. this.formItems[1].disabled = false
  346. break
  347. }
  348. },
  349. async getOptions(queryId, setKey, prop) {
  350. try {
  351. const { code, returnData, message } = await Query({
  352. id: queryId,
  353. dataContent: []
  354. })
  355. if (Number(code) === 0) {
  356. const arr = returnData.listValues.map(element => ({
  357. label: element[setKey],
  358. value: element[setKey]
  359. }))
  360. const theItem = this.formItems.find(item => item.prop === prop)
  361. theItem.options = arr
  362. } else {
  363. this.$message.error(message)
  364. }
  365. } catch (error) {
  366. console.log('出错了', error.message || error)
  367. }
  368. }
  369. // async getInOrOut(data) {
  370. // try {
  371. // const res = await Query({
  372. // id: DATACONTENT_ID.inOrOutId,
  373. // dataContent: [data]
  374. // })
  375. // if (res.code === '0') {
  376. // const arr = []
  377. // for (let i = 0; i < res.returnData.listValues.length; i++) {
  378. // arr.push({
  379. // label: res.returnData.listValues[i].a5,
  380. // value: res.returnData.listValues[i].a5
  381. // })
  382. // }
  383. // const theItem = this.formItems.find(item => item.prop === 'inOrOut')
  384. // theItem && (theItem.options = arr)
  385. // } else {
  386. // this.$message.error(res.message)
  387. // }
  388. // } catch (error) {
  389. // console.log('出错了', error.message || error)
  390. // }
  391. // },
  392. // async getAirline() {
  393. // try {
  394. // const res = await Query({
  395. // id: DATACONTENT_ID.AirlineId,
  396. // dataContent: []
  397. // })
  398. // if (res.code === '0') {
  399. // const arr = []
  400. // for (let i = 0; i < res.returnData.listValues.length; i++) {
  401. // arr.push({
  402. // label: res.returnData.listValues[i].a2,
  403. // value: res.returnData.listValues[i].a2
  404. // })
  405. // }
  406. // const theItem = this.formItems.find(item => item.prop === 'airline')
  407. // theItem && (theItem.options = arr)
  408. // } else {
  409. // this.$message.error(res.message)
  410. // }
  411. // } catch (error) {
  412. // console.log('出错了', error.message || error)
  413. // }
  414. // },
  415. // async getCompany() {
  416. // try {
  417. // const res = await Query({
  418. // id: DATACONTENT_ID.AreaId,
  419. // dataContent: []
  420. // })
  421. // if (res.code === '0') {
  422. // const arr = []
  423. // for (let i = 0; i < res.returnData.listValues.length; i++) {
  424. // arr.push({
  425. // label: res.returnData.listValues[i].a4,
  426. // value: res.returnData.listValues[i].a4
  427. // })
  428. // }
  429. // const theItem = this.formItems.find(item => item.prop === 'company')
  430. // theItem && (theItem.options = arr)
  431. // } else {
  432. // this.$message.error(res.message)
  433. // }
  434. // } catch (error) {
  435. // console.log('出错了', error.message || error)
  436. // }
  437. // },
  438. // async getAirport() {
  439. // try {
  440. // const res = await Query({
  441. // id: DATACONTENT_ID.AirportId,
  442. // dataContent: []
  443. // })
  444. // if (res.code === '0') {
  445. // const arr = []
  446. // for (let i = 0; i < res.returnData.listValues.length; i++) {
  447. // arr.push({
  448. // label: res.returnData.listValues[i].a2,
  449. // value: res.returnData.listValues[i].a2
  450. // })
  451. // }
  452. // const theItem = this.formItems.find(item => item.prop === 'airport')
  453. // theItem && (theItem.options = arr)
  454. // } else {
  455. // this.$message.error(res.message)
  456. // }
  457. // } catch (error) {
  458. // console.log('出错了', error.message || error)
  459. // }
  460. // },
  461. // async getTerminal() {
  462. // try {
  463. // const res = await Query({
  464. // id: DATACONTENT_ID.TerminalId,
  465. // dataContent: []
  466. // })
  467. // if (res.code === '0') {
  468. // const arr = []
  469. // for (let i = 0; i < res.returnData.listValues.length; i++) {
  470. // arr.push({
  471. // label: res.returnData.listValues[i].a2,
  472. // value: res.returnData.listValues[i].a2
  473. // })
  474. // }
  475. // const theItem = this.formItems.find(item => item.prop === 'terminal')
  476. // theItem && (theItem.options = arr)
  477. // } else {
  478. // this.$message.error(res.message)
  479. // }
  480. // } catch (error) {
  481. // console.log('出错了', error.message || error)
  482. // }
  483. // }
  484. }
  485. }
  486. </script>
  487. <style lang="scss" scoped>
  488. .flight-statistics-header {
  489. padding-top: 24px;
  490. min-height: 80px;
  491. display: flex;
  492. justify-content: space-between;
  493. align-items: flex-start;
  494. .title {
  495. // margin-right: 24px;
  496. padding-left: 16px;
  497. min-width: 176px;
  498. height: 32px;
  499. line-height: 32px;
  500. font-size: 18px;
  501. font-family: Helvetica, 'Microsoft YaHei';
  502. font-weight: bold;
  503. position: relative;
  504. &::before {
  505. content: '';
  506. width: 4px;
  507. height: 20px;
  508. background: #2d67e3;
  509. position: absolute;
  510. top: 0;
  511. bottom: 0;
  512. left: 0;
  513. margin: auto;
  514. }
  515. }
  516. ::v-deep .form {
  517. display: flex;
  518. flex-wrap: wrap;
  519. > .el-form-item {
  520. margin-bottom: 24px;
  521. // width: 185px;
  522. &:not(:last-child) {
  523. margin-right: 8px;
  524. }
  525. &:nth-last-child(2),
  526. &:nth-last-child(3) {
  527. margin-right: 16px;
  528. }
  529. .el-form-item__content {
  530. height: 32px;
  531. line-height: 30px;
  532. .el-input {
  533. &.is-disabled .el-input__inner {
  534. border: none;
  535. }
  536. .el-input__inner {
  537. border-radius: 4px;
  538. font-family: Helvetica, 'Microsoft YaHei';
  539. color: #303133;
  540. border-color: #ffffff;
  541. &:hover {
  542. border-color: #c0c4cc;
  543. }
  544. &:focus {
  545. border-color: #409eff;
  546. }
  547. }
  548. }
  549. .el-date-editor--daterange.el-input,
  550. .el-date-editor--daterange.el-input__inner,
  551. .el-date-editor--timerange.el-input,
  552. .el-date-editor--timerange.el-input__inner {
  553. width: 100%;
  554. border-radius: 4px;
  555. border-color: #ffffff;
  556. color: #303133;
  557. font-family: Helvetica, 'Microsoft YaHei';
  558. &:hover {
  559. border-color: #c0c4cc;
  560. }
  561. &.is-active {
  562. border-color: #409eff;
  563. }
  564. .el-input__icon {
  565. color: #303133;
  566. }
  567. .el-range-separator {
  568. line-height: 28px;
  569. }
  570. }
  571. .el-select,
  572. .el-cascader {
  573. .el-input {
  574. .el-icon-arrow-up::before {
  575. content: '\e78f';
  576. }
  577. .el-icon-arrow-down::before {
  578. content: '\e790';
  579. }
  580. &:not(.is-disabled) {
  581. .el-input__icon,
  582. .el-input__inner::-webkit-input-placeholder {
  583. color: #303133;
  584. }
  585. }
  586. }
  587. }
  588. .el-button {
  589. border-radius: 4px;
  590. font-family: Helvetica, 'Microsoft YaHei';
  591. }
  592. .btn-icon-only {
  593. width: 32px;
  594. height: 32px;
  595. cursor: pointer;
  596. }
  597. }
  598. }
  599. }
  600. }
  601. </style>