123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243 |
- import { parseTime } from '@/utils'
- const defaultDate = parseTime(new Date(), '{y}-{m}-{d}')
- export default {
- data() {
- return {
- formData: {
-
- currentAirport: [],
- relatedAirport: [],
- inboundCarrier: [],
- outgoingAirline: [],
- craftType: [],
- flightAttr: [],
- startDate: defaultDate,
- endDate: defaultDate,
- search: ''
- },
- currentAirportList: [],
- relatedAirportList: [],
- carrierList: [],
- craftTypeList: [],
- flightAttrList: [],
- currentAirportProps: {
-
- checkStrictly: true,
- expandTrigger: 'hover',
- value: 'code3',
- label: 'name',
- children: 'builds'
- },
- relatedAirportProps: {
- multiple: true,
- value: 'code3',
- label: 'name'
- },
- carrierProps: {
- multiple: true,
- value: 'code2',
- label: 'name'
- },
- craftTypeProps: {
- multiple: true,
- value: 'code3',
- label: 'name'
- },
- flightAttrProps: {
- multiple: true,
- value: 'code',
- label: 'name'
- },
-
- rules: {
- currentAirport: [{ required: true, message: '请选择当前机场', trigger: 'change' }],
- startDate: [{ required: true, message: '请选择开始时间', trigger: 'change' }],
- endDate: [{ required: true, message: '请选择结束时间', trigger: 'change' }]
- }
- }
- },
- computed: {
- currentAirport() {
- return this.getSingleData(this.formData.currentAirport)
- },
- relatedAirport() {
- return this.formData.relatedAirport.map(item => item[0])
- },
- inboundCarrier() {
- return this.formData.inboundCarrier.map(item => item[0])
- },
- outgoingAirline() {
- return this.formData.outgoingAirline.map(item => item[0])
- },
- craftType() {
- return this.formData.craftType.map(item => item[0])
- },
- flightAttr() {
- return this.formData.flightAttr.map(item => item[0])
- },
- startDate() {
-
- return this.formData.startDate
- },
- endDate() {
-
- return this.formData.endDate
- }
-
-
-
-
-
-
-
-
-
-
- },
- methods: {
-
- getMultipleData(arr) {
- const newArr = []
- arr.length &&
- arr.forEach(airport => {
- const temp = this._.cloneDeep(this.currentAirportList.find(airport1 => airport1.code3 === airport[0]))
- if (temp) {
- temp.builds = airport[1] ? [{ name: airport[1] }] : []
- const item = newArr.find(item => item.code3 === temp.code3)
- if (item) {
- item.builds.push(...temp.builds)
- } else {
- newArr.push(temp)
- }
- }
- })
- return newArr
- },
-
- getSingleData(arr) {
- const newArr = []
- if (arr.length > 0) {
- const temp = this._.cloneDeep(this.currentAirportList.find(airport1 => airport1.code3 === arr[0]))
- if (temp) {
- temp.builds = arr[1] ? [{ name: arr[1] }] : []
- newArr.push(temp)
- }
- }
- return newArr
- },
-
- formClear(range) {
- if (range === 'all') {
- this.formData.currentAirport = []
- this.currentAirportList = []
- }
- this.formData.relatedAirport = []
- this.relatedAirportList = []
- this.formData.inboundCarrier = []
- this.formData.outgoingAirline = []
- this.carrierList = []
- this.formData.craftType = []
- this.craftTypeList = []
- this.formData.flightAttr = []
- this.flightAttrList = []
- },
-
- inputClear() {
- this.onSubmit()
- },
-
- setCurrentAirport(data) {
- this.formClear()
- if (data.length === 0) {
- return
- }
- const params = {
- currentAirport: this.currentAirport,
- startDate: this.startDate,
- endDate: this.endDate
- }
- this.getFormData(params)
- },
-
- setStartDate(val) {
-
- if (!val) {
- return
- }
- if (this.formData.endDate && this.formData.endDate < val) {
- this.formData.endDate = ''
- this.$message.error('结束时间不能小于开始时间,请重新选择')
- return false
- } else {
- this.getTableData()
-
- return true
- }
- },
- setEndDate(val) {
-
- if (!val) {
- return
- }
- if (this.formData.startDate && this.formData.startDate > val) {
- this.formData.endDate = ''
- this.$message.error('结束时间不能小于开始时间,请重新选择')
- return false
- } else {
- this.getTableData()
-
- return true
- }
- },
-
- onSubmit(data) {
- this.$refs['form'].validate(valid => {
- if (valid) {
- const az = /^[a-zA-Z]+$/
- const azNum = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]*$/
-
- const top2 = /^([a-zA-Z][0-9])|([0-9][a-zA-Z])|([a-zA-Z]{2})/
- const num = /^[0-9]+$/
- const queryData = {
- startDate: this.formData.startDate,
- endDate: this.formData.endDate
- }
- if (Number(data) === 1) {
- queryData['destination'] = this.formData.currentAirport
- } else {
- queryData['station'] = this.formData.currentAirport
- }
- if (az.test(this.formData.search)) {
-
- queryData['name'] = this.formData.search
- } else if (azNum.test(this.formData.search) && top2.test(this.formData.search)) {
-
- queryData['FlightNO'] = this.formData.search
- } else if (num.test(this.formData.search) && this.formData.search.length === 10) {
-
- queryData['grade'] = this.formData.search
- } else {
-
- }
- this.$router.push({
- path: '/advance',
- query: queryData
- })
- } else {
- return false
- }
- })
- }
- }
- }
|