ExitFlightDesc.vue 6.9 KB
<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">
                    <el-input placeholder="必填" v-model="originstation">
                        <template slot="prepend">始发站</template>
                    </el-input>
                </el-col>
                <el-col :span="4" style="margin-left: 20px">
                    <el-input placeholder="必填" v-model="destinationstation">
                        <template slot="prepend">目的站</template>
                    </el-input>
                </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";

    export default {
        name: 'ExitFlightDesc',
        data() {
            return {
                flight: {
                    flightno: undefined,
                    flightdate: undefined,
                    originstation: undefined,
                    destinationstation: undefined,
                    awba: undefined,
                    messageType:undefined
                },
                btnStatus: true
            };
        },
        created() {
            if (this.$route.params.scopeRow !== undefined) {
                if(this.$route.params.scopeRow.carrier === undefined){
                    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
                if(this.$route.params.scopeRow.awba !== undefined){
                    this.flight.awba = this.$route.params.scopeRow.awba.replace('-','')
                }

            }
        },
        computed:{
            flightno : {
                get: function () {
                    return this.flight.flightno
                },
                set: function(val){
                    this.flight.flightno = val.toUpperCase().trim()
                }
            },
            originstation :{
                get: function () {
                    return this.flight.originstation
                },
                set: function(val){
                    this.flight.originstation = val.toUpperCase().trim()
                }
            },
            destinationstation :{
                get: function () {
                    return this.flight.destinationstation
                },
                set: function(val){
                    this.flight.destinationstation = val.toUpperCase().trim()
                }
            },
            awba :{
                get: function () {
                    return this.flight.awba
                },
                set: function(val){
                    this.flight.awba = val.trim()
                }
            }
        },
        methods: {
            nstep() {
                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){
                        const manifest = this.flight.awba;
                        const reg = /^[0-9]{11}$/
                        if(!reg.test(manifest)){
                            Message.error("主单号只支持数字并且最多11位")
                            return
                        }
                        const num = (manifest.substring(3,10)) % 7
                        if(num !== eval(manifest.substring(10))){
                            Message.error("主单号不符合模7校验")
                            return
                        }
                    } else {
                        this.flight.awba = undefined
                    }

                    if(this.flight.messageType ==="MT5201"){
                        this.$router.push({name: '出港理货', params: {flightData: this.flight}});
                    }
                    if(this.flight.messageType ==="MT4201"){
                        this.$router.push({name: '出港装载', params: {flightData: this.flight}});
                    }
                    if(this.flight.messageType ==="MT3201"){
                        this.$router.push({name:'出港运抵',params:{flightData: this.flight}})
                    }
                    if(this.flight.messageType ==="MT2201"){
                        this.$router.push({name:'出港预配舱单',params:{flightData: this.flight}})
                    }
                } else {
                    Message.warning("请将航班信息填写完整")
                }

            }
        }
    };
</script>
<style scoped>
    .el-container {
        text-align: center
    }

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

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