审查视图

src/views/nmms/ExitFlightDesc.vue 9.5 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
<template>
    <el-container>
        <el-main>
            <el-row>
                <el-col :span="24">
                    <div class="grid-content"><p>请输入航班信息:</p></div>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="24">
                    <div class="grid-content"><h1>Please Enter The Flight Information:</h1></div>
                </el-col>
            </el-row>
            <el-row type="flex" class="row-bg" justify="center">
                <el-col :span="4">
                    <el-input placeholder="必填" v-model="flightno">
                        <template slot="prepend">航班号</template>
                    </el-input>
                </el-col>
                <el-col :span="4">
                    <el-date-picker
                            v-model="flight.flightdate"
                            type="date"
                            value-format="yyyy-MM-dd"
                            placeholder="选择日期">
                    </el-date-picker>
                </el-col>
                <el-col :span="4">
29
                    <el-select
30
                            :remote-method="remoteMethodAirport"
31 32 33 34 35 36 37 38
                            :loading="listLoading"
                            v-model="flight.originstation"
                            allow-create
                            filterable
                            remote
                            placeholder="请选择起始站" clearable>
                        <el-option
                                v-for="item in airportCode"
39 40 41 42 43
                                :key="item.airportid"
                                :label="item.airportid"
                                :value="item.airportid">
                            <span style="float: left">{{ item.airportdescchn }}</span>
                            <span style="float: right; color: #8492a6; font-size: 13px">{{ item.airportid }}</span>
44 45
                        </el-option>
                    </el-select>
46 47
                </el-col>
                <el-col :span="4" style="margin-left: 20px">
48
                    <el-select
49
                            :remote-method="remoteMethodAirport"
50 51 52 53 54 55 56 57
                            :loading="listLoading"
                            v-model="flight.destinationstation"
                            allow-create
                            filterable
                            remote
                            placeholder="请选择目的站" clearable>
                        <el-option
                                v-for="item in airportCode"
58 59 60 61 62
                                :key="item.airportid"
                                :label="item.airportdescchn"
                                :value="item.airportid">
                            <span style="float: left">{{ item.airportdescchn }}</span>
                            <span style="float: right; color: #8492a6; font-size: 13px">{{ item.airportid }}</span>
63 64
                        </el-option>
                    </el-select>
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
                </el-col>
                <el-col :span="4" style="margin-left: 20px">
                    <el-input placeholder="可为空" v-model="awba">
                        <template slot="prepend">主单号</template>
                    </el-input>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="4" :offset="10">
                    <div class="grid-content">
                        <el-button type="primary" @click="nstep">下一步</el-button>
                    </div>
                </el-col>
            </el-row>
        </el-main>
    </el-container>
</template>


<script>
    import {Message} from "element-ui";
86 87
    import {getCountry, getAirportCode} from "@/api/country";
88 89 90 91 92 93 94 95 96 97
    export default {
        name: 'ExitFlightDesc',
        data() {
            return {
                flight: {
                    flightno: undefined,
                    flightdate: undefined,
                    originstation: undefined,
                    destinationstation: undefined,
                    awba: undefined,
98
                    messageType: undefined
99
                },
100 101
                btnStatus: true,
                listLoading: false,
102
                airportList: [],
103 104
                airportResultCode: [],
                airportCode: [],
105 106 107 108
            };
        },
        created() {
            if (this.$route.params.scopeRow !== undefined) {
109
                if (this.$route.params.scopeRow.carrier === undefined) {
110 111 112 113 114 115 116 117
                    this.flight.flightno = this.$route.params.scopeRow.flightno
                } else {
                    this.flight.flightno = this.$route.params.scopeRow.carrier + this.$route.params.scopeRow.flightno
                }
                this.flight.flightdate = this.$route.params.scopeRow.flightdate
                this.flight.originstation = this.$route.params.scopeRow.originstation
                this.flight.destinationstation = this.$route.params.scopeRow.destinationstation
                this.flight.messageType = this.$route.params.scopeRow.messageType
118 119
                if (this.$route.params.scopeRow.awba !== undefined) {
                    this.flight.awba = this.$route.params.scopeRow.awba.replace('-', '')
120 121 122
                }
            }
        },
123 124 125 126 127 128 129 130 131 132
        // mounted() {
        //     // 延迟加载,否则会出错
        //     setTimeout(() => {
        //         this.airportResultCode = this.airportCode.map(item =>{
        //             return {label: item.airportdescchn,value: item.airportid}
        //         })
        //     }, 6000)
        // },
        computed: {
            flightno: {
133 134 135
                get: function () {
                    return this.flight.flightno
                },
136
                set: function (val) {
137 138 139
                    this.flight.flightno = val.toUpperCase().trim()
                }
            },
140
            originstation: {
141 142 143
                get: function () {
                    return this.flight.originstation
                },
144
                set: function (val) {
145 146 147
                    this.flight.originstation = val.toUpperCase().trim()
                }
            },
148
            destinationstation: {
149 150 151
                get: function () {
                    return this.flight.destinationstation
                },
152
                set: function (val) {
153 154 155
                    this.flight.destinationstation = val.toUpperCase().trim()
                }
            },
156
            awba: {
157 158 159
                get: function () {
                    return this.flight.awba
                },
160
                set: function (val) {
161 162 163 164 165 166
                    this.flight.awba = val.trim()
                }
            }
        },
        methods: {
            nstep() {
167 168 169 170 171
                if (this.flight.flightno !== undefined && this.flight.flightno !== '' &&
                    this.flight.flightdate !== undefined && this.flight.flightdate !== '' &&
                    this.flight.destinationstation !== undefined && this.flight.destinationstation !== '' &&
                    this.flight.originstation !== undefined && this.flight.originstation !== '') {
                    if (this.flight.awba !== '' && this.flight.awba !== undefined) {
172 173
                        const manifest = this.flight.awba;
                        const reg = /^[0-9]{11}$/
174
                        if (!reg.test(manifest)) {
175 176 177
                            Message.error("主单号只支持数字并且最多11位")
                            return
                        }
178 179
                        const num = (manifest.substring(3, 10)) % 7
                        if (num !== eval(manifest.substring(10))) {
180 181 182 183 184 185 186
                            Message.error("主单号不符合模7校验")
                            return
                        }
                    } else {
                        this.flight.awba = undefined
                    }
187
                    if (this.flight.messageType === "MT5202") {
188 189
                        this.$router.push({name: '出港理货', params: {flightData: this.flight}});
                    }
190
                    if (this.flight.messageType === "MT4201") {
191 192
                        this.$router.push({name: '出港装载', params: {flightData: this.flight}});
                    }
193 194
                    if (this.flight.messageType === "MT3201") {
                        this.$router.push({name: '出港运抵', params: {flightData: this.flight}})
195
                    }
196 197
                    if (this.flight.messageType === "MT2201") {
                        this.$router.push({name: '出港预配舱单', params: {flightData: this.flight}})
198 199 200 201 202
                    }
                } else {
                    Message.warning("请将航班信息填写完整")
                }
203
            },
204 205
            remoteMethodAirport(query) {
                this.airportCode = []
206 207
                if (query !== '') {
                    this.listLoading = true
208 209 210 211 212 213 214 215
                    getAirportCode({airportid: query}).then(res => {
                        if(res !== null){
                            setTimeout(() => {
                                this.listLoading = false
                                this.airportCode = res.data.data
                            }, 200)
                        }
                    })
216 217 218 219
                } else {
                    this.airportCode = []
                }
            },
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237
        }
    };
</script>
<style scoped>
    .el-container {
        text-align: center
    }

    .el-main {
        margin: 0 auto;
        height: 400px;
    }

    p {
        font-size: 25px;
        font-weight: bold;
    }
</style>