statisticsHeader.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525
  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 || '120px'
  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-item v-if="withSetting">
  89. <img
  90. src="../../../assets/nav/ic_setting.png"
  91. title="节点设置"
  92. class="btn-icon-only"
  93. @click="settingClickHandler"
  94. >
  95. </el-form-item>
  96. </el-form>
  97. </div>
  98. </template>
  99. <script>
  100. import { Query } from '@/api/dataIntegration'
  101. export default {
  102. name: 'StatisticsHeader',
  103. props: {
  104. title: {
  105. type: String,
  106. default: ''
  107. },
  108. items: {
  109. type: Array,
  110. default: undefined
  111. },
  112. customItems: {
  113. type: Array,
  114. default: () => []
  115. },
  116. data: {
  117. type: Object,
  118. default: undefined
  119. },
  120. buttonText: {
  121. type: String,
  122. default: '查询'
  123. },
  124. withExport: {
  125. type: Boolean,
  126. default: true
  127. },
  128. withSetting: {
  129. type: Boolean,
  130. default: false
  131. }
  132. },
  133. data() {
  134. return {
  135. formData: {
  136. range: '',
  137. inOrOut: '',
  138. interval: '',
  139. airline: '',
  140. area: '',
  141. airport: '',
  142. terminal: '',
  143. dateTime: '',
  144. flightType: '',
  145. baggageType: ''
  146. },
  147. formItems: [
  148. {
  149. prop: 'range',
  150. inputType: 'select',
  151. placeholder: '统计范围',
  152. options: [
  153. {
  154. value: '全部',
  155. label: '全部'
  156. },
  157. {
  158. value: '航线',
  159. label: '航线'
  160. },
  161. {
  162. value: '基地分公司',
  163. label: '基地分公司'
  164. },
  165. {
  166. value: '航站',
  167. label: '航站'
  168. },
  169. {
  170. value: '航站楼',
  171. label: '航站楼'
  172. }
  173. ],
  174. changeHandler(value) {
  175. this.formData.inOrOut = ''
  176. // this.formData.interval = ''
  177. this.formData.area = ''
  178. this.formData.airline = ''
  179. this.formData.airport = ''
  180. this.formData.terminal = ''
  181. this.setInOrOutOptions(value)
  182. const airlineItem = this.formItems.find(item => item.prop === 'airline')
  183. const areaItem = this.formItems.find(item => item.prop === 'area')
  184. const airportItem = this.formItems.find(item => item.prop === 'airport')
  185. const terminalItem = this.formItems.find(item => item.prop === 'terminal')
  186. airlineItem && (airlineItem.disabled = true)
  187. areaItem && (areaItem.disabled = true)
  188. airportItem && (airportItem.disabled = true)
  189. terminalItem && (terminalItem.disabled = true)
  190. switch (value) {
  191. case '航线':
  192. airlineItem && (airlineItem.disabled = false)
  193. break
  194. case '基地分公司':
  195. areaItem && (areaItem.disabled = false)
  196. break
  197. case '航站':
  198. airportItem && (airportItem.disabled = false)
  199. break
  200. case '航站楼':
  201. terminalItem && (terminalItem.disabled = false)
  202. break
  203. default:
  204. break
  205. }
  206. }
  207. },
  208. {
  209. prop: 'inOrOut',
  210. inputType: 'select',
  211. placeholder: '进离港',
  212. clearable: true,
  213. options: []
  214. },
  215. {
  216. prop: 'interval',
  217. inputType: 'select',
  218. placeholder: '时间维度',
  219. clearable: true,
  220. options: [
  221. {
  222. value: '日',
  223. label: '按日统计'
  224. },
  225. {
  226. value: '月',
  227. label: '按月统计'
  228. },
  229. {
  230. value: '季',
  231. label: '按季统计'
  232. },
  233. {
  234. value: '年',
  235. label: '按年统计'
  236. }
  237. ]
  238. },
  239. {
  240. prop: 'dateTime',
  241. inputType: 'datePicker',
  242. clearable: true,
  243. width: '240px',
  244. options: []
  245. },
  246. {
  247. prop: 'airline',
  248. inputType: 'select',
  249. placeholder: '航线',
  250. filterable: true,
  251. clearable: true,
  252. disabled: true,
  253. queryId: DATACONTENT_ID.airlineOptions,
  254. setKey: 'a2',
  255. options: []
  256. },
  257. {
  258. prop: 'area',
  259. inputType: 'select',
  260. placeholder: '基地分公司',
  261. filterable: true,
  262. clearable: true,
  263. disabled: true,
  264. queryId: DATACONTENT_ID.areaOptions,
  265. setKey: 'a5',
  266. options: []
  267. },
  268. {
  269. prop: 'airport',
  270. inputType: 'select',
  271. placeholder: '航站',
  272. filterable: true,
  273. clearable: true,
  274. // multiple: true,
  275. disabled: true,
  276. queryId: DATACONTENT_ID.AirportId,
  277. setKey: 'a2',
  278. options: []
  279. },
  280. {
  281. prop: 'terminal',
  282. inputType: 'select',
  283. placeholder: '航站楼',
  284. filterable: true,
  285. props: {
  286. multiple: true
  287. },
  288. clearable: true,
  289. disabled: true,
  290. queryId: DATACONTENT_ID.TerminalId,
  291. setKey: 'a2',
  292. options: []
  293. }
  294. ]
  295. }
  296. },
  297. watch: {
  298. items: {
  299. handler(val) {
  300. val && (this.formItems = val)
  301. },
  302. deep: true,
  303. immediate: true
  304. },
  305. data: {
  306. handler(val) {
  307. val && (this.formData = val)
  308. },
  309. deep: true,
  310. immediate: true
  311. }
  312. },
  313. created() {
  314. this.customItems.forEach(item => {
  315. if (typeof item.itemIndex === 'number') {
  316. if (item.prop) {
  317. this.formItems.splice(item.itemIndex, item.replaceNum, item)
  318. } else {
  319. this.formItems.splice(item.itemIndex, item.replaceNum)
  320. }
  321. } else {
  322. this.formItems.push(item)
  323. }
  324. })
  325. this.formItems.forEach(item => {
  326. if (item.queryId && item.setKey) {
  327. this.getOptions(item.queryId, item.setKey, item.prop)
  328. }
  329. })
  330. },
  331. methods: {
  332. call(func, ...args) {
  333. func.call(this, ...args)
  334. },
  335. getData() {
  336. // console.log(this.formData)
  337. this.$emit('getFormData', this.formData)
  338. },
  339. exportClickHandler() {
  340. this.$emit('export')
  341. // this.$message.info('开发中')
  342. },
  343. settingClickHandler() {
  344. this.$emit('setting')
  345. },
  346. setInOrOutOptions(range) {
  347. const theInOrOutItem = this.formItems.find(item => item.prop === 'inOrOut')
  348. switch (range) {
  349. case '全部':
  350. case '航线':
  351. theInOrOutItem.options = [
  352. {
  353. label: '全部',
  354. value: '全部'
  355. }
  356. ]
  357. this.formData.inOrOut = '全部'
  358. this.formItems[1].disabled = true
  359. break
  360. case '基地分公司':
  361. case '航站':
  362. case '航站楼':
  363. theInOrOutItem.options = [
  364. {
  365. value: '全部',
  366. label: '全部'
  367. },
  368. {
  369. value: '进港',
  370. label: '进港'
  371. },
  372. {
  373. value: '离港',
  374. label: '离港'
  375. }
  376. ]
  377. this.formItems[1].disabled = false
  378. break
  379. default:
  380. theInOrOutItem.options = []
  381. this.formItems[1].disabled = false
  382. break
  383. }
  384. },
  385. async getOptions(queryId, setKey, prop) {
  386. try {
  387. const { code, returnData, message } = await Query({
  388. id: queryId,
  389. dataContent: []
  390. })
  391. if (Number(code) === 0) {
  392. const arr = returnData.listValues.map(element => ({
  393. label: element[setKey],
  394. value: element[setKey]
  395. }))
  396. const theItem = this.formItems.find(item => item.prop === prop)
  397. theItem.options = arr
  398. } else {
  399. this.$message.error(message)
  400. }
  401. } catch (error) {
  402. console.log('出错了', error.message || error)
  403. }
  404. }
  405. }
  406. }
  407. </script>
  408. <style lang="scss" scoped>
  409. .flight-statistics-header {
  410. padding-top: 24px;
  411. min-height: 80px;
  412. display: flex;
  413. justify-content: space-between;
  414. align-items: flex-start;
  415. .title {
  416. margin-right: 24px;
  417. padding-left: 16px;
  418. // min-width: 190px;
  419. height: 32px;
  420. line-height: 32px;
  421. font-size: 18px;
  422. font-family: Helvetica, 'Microsoft YaHei';
  423. font-weight: bold;
  424. white-space: nowrap;
  425. position: relative;
  426. &::before {
  427. content: '';
  428. width: 4px;
  429. height: 20px;
  430. background: #2d67e3;
  431. position: absolute;
  432. top: 0;
  433. bottom: 0;
  434. left: 0;
  435. margin: auto;
  436. }
  437. }
  438. ::v-deep .form {
  439. display: flex;
  440. flex-wrap: wrap;
  441. > .el-form-item {
  442. margin-bottom: 24px;
  443. // width: 185px;
  444. &:not(:last-child) {
  445. margin-right: 8px;
  446. }
  447. &:nth-last-child(2),
  448. &:nth-last-child(3) {
  449. margin-right: 16px;
  450. }
  451. .el-form-item__content {
  452. height: 32px;
  453. line-height: 30px;
  454. .el-input {
  455. &.is-disabled .el-input__inner {
  456. border: none;
  457. }
  458. .el-input__inner {
  459. border-radius: 4px;
  460. font-family: Helvetica, 'Microsoft YaHei';
  461. color: #303133;
  462. border-color: #ffffff;
  463. &:hover {
  464. border-color: #c0c4cc;
  465. }
  466. &:focus {
  467. border-color: #409eff;
  468. }
  469. }
  470. }
  471. .el-date-editor--daterange.el-input,
  472. .el-date-editor--daterange.el-input__inner,
  473. .el-date-editor--timerange.el-input,
  474. .el-date-editor--timerange.el-input__inner {
  475. width: 100%;
  476. border-radius: 4px;
  477. border-color: #ffffff;
  478. color: #303133;
  479. font-family: Helvetica, 'Microsoft YaHei';
  480. &:hover {
  481. border-color: #c0c4cc;
  482. }
  483. &.is-active {
  484. border-color: #409eff;
  485. }
  486. .el-input__icon {
  487. color: #303133;
  488. }
  489. .el-range-separator {
  490. line-height: 28px;
  491. }
  492. }
  493. .el-select,
  494. .el-cascader {
  495. .el-input {
  496. .el-icon-arrow-up::before {
  497. content: '\e78f';
  498. }
  499. .el-icon-arrow-down::before {
  500. content: '\e790';
  501. }
  502. &:not(.is-disabled) {
  503. .el-input__icon,
  504. .el-input__inner::-webkit-input-placeholder {
  505. color: #303133;
  506. }
  507. }
  508. }
  509. }
  510. .el-button {
  511. border-radius: 4px;
  512. font-family: Helvetica, 'Microsoft YaHei';
  513. }
  514. .btn-icon-only {
  515. width: 32px;
  516. height: 32px;
  517. cursor: pointer;
  518. }
  519. }
  520. }
  521. }
  522. }
  523. </style>