审查视图

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


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

    .el-main {
        margin: 0 auto;
        height: 400px;
    }
朱兆平 authored
234
    flight
235 236 237 238 239
    p {
        font-size: 25px;
        font-weight: bold;
    }
</style>