审查视图

src/views/nmms_import/EnterFlightTally.vue 9.6 KB
1 2 3 4 5 6 7 8 9 10 11
<template>
    <el-container>
        <el-main>
            <!--表单检索条件-->
            <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
            <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>
12
            <el-row type="flex" class="row-bg" justify="center" style="margin-top: 30px">
13 14
                <el-col :span="5">
                    <el-form-item label="航班号" prop="flightno">
15
                        <el-input onkeyup="value=value.replace(/[\u4e00-\u9fa5]/ig,'')" placeholder="" v-model="flightno" style="width:100%"></el-input>
16 17
                    </el-form-item>
                </el-col>
18
                <el-col :span="6">
19 20 21 22 23 24 25 26 27
                    <el-form-item label="航班日期" required>
                        <el-col :span="24">
                            <el-form-item prop="flightdate">
                                <el-date-picker type="date" placeholder="选择日期" :clearable="false" v-model="ruleForm.flightdate" style="width: 100%;"></el-date-picker>
                            </el-form-item>
                        </el-col>
                    </el-form-item>
                </el-col>
                <el-col :span="5">
28
                    <!--<el-form-item label="始发站" prop="originstation">
29
                        <el-input placeholder="" v-model="ruleForm.originstation"></el-input>
30 31
                    </el-form-item>-->
                    <el-form-item label="始发站" prop="originstation">
32
                        <el-select v-model="originstation" filterable
33
                                   allow-create
34 35 36 37 38
                                   default-first-option
                                   remote
                                   :remote-method="remoteMethod"
                                   :loading="loading"
                                   placeholder="请选择">
39 40 41 42 43 44 45 46 47
                            <el-option
                                    v-for="item in options"
                                    :key="item.airportid"
                                    :label="item.airportid"
                                    :value="item.airportid">
                                <span style="float: left">{{ item.airportid }}</span>
                                <span style="float: right; color: #8492a6; font-size: 13px">{{ item.airportdescchn }}</span>
                            </el-option>
                        </el-select>
48 49 50
                    </el-form-item>
                </el-col>
                <el-col :span="5">
51
                    <!--<el-form-item label="目的站" prop="destinationstation">
52
                        <el-input placeholder="" v-model="ruleForm.destinationstation" :disabled="true"></el-input>
53 54
                    </el-form-item>-->
                    <el-form-item label="目的站" prop="destinationstation">
55
                        <el-select v-model="destinationstation"
56
                                   filterable
57
                                   allow-create
58 59 60 61 62
                                   default-first-option
                                   remote
                                   :remote-method="remoteMethod"
                                   :loading="loading"
                                   placeholder="请选择">
63 64 65 66 67 68 69 70 71
                            <el-option
                                    v-for="item in options"
                                    :key="item.airportid"
                                    :label="item.airportid"
                                    :value="item.airportid">
                                <span style="float: left">{{ item.airportid }}</span>
                                <span style="float: right; color: #8492a6; font-size: 13px">{{ item.airportdescchn }}</span>
                            </el-option>
                        </el-select>
72 73 74
                    </el-form-item>
                </el-col>
            </el-row>
75
            <el-row>
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
                <el-col :span="4" :offset="10">
                    <div class="grid-content">
                        <el-button type="primary" @click="submitForm('ruleForm')">下一步</el-button>
                    </div>
                </el-col>
            </el-row>
                </el-form>
        </el-main>
    </el-container>
</template>
<!--自定义CSS-->
<style scoped>
    .el-container{text-align: center}
    .el-main{margin:0 auto;height:400px;}
    p{font-size:25px;font-weight: bold;}
    .row-bg{padding:30px 0;}
    .el-form-item {margin-bottom: 0px;}
</style>

<script>
96
    import { selectAirport } from '../../api/mt1201'
97 98
    import jsutil from "@/common/js/util";
99 100 101 102 103 104 105 106
    export default {
        data() {
            return {
                /*初始化值*/
                ruleForm: {
                    flightno: '',
                    flightdate:'',
                    originstation:'',
107
                    destinationstation:'',
108
                },
109 110
                options: [],
                airportid:'',
111
                loading: false,
112 113 114 115 116 117 118 119
                /*表单验证方法*/
                rules: {
                    flightno: [
                        {required: true, message: '请输入航班号', trigger: 'blur'},
                        {min: 3, max: 6, message: '输入不符合规范', trigger: 'blur'}
                    ],
                    originstation: [
                        {required: true, message: '请输入航班起始站', trigger: 'blur'},
120
                        {min: 3, max: 3, message: '长度为 3 ', trigger: 'blur'}
121 122 123
                    ],
                    destinationstation: [
                        {required: true, message: '请输入目的站', trigger: 'blur'},
124
                        {min: 3, max: 3, message: '长度为 3 ', trigger: 'blur'}
125 126 127 128 129 130 131
                    ],
                    flightdate: [
                        { required: true, message: '请选择日期', trigger: 'change' }
                    ]
                }
            };
        },
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
        computed:{
            originstation:{
                get:function () {
                    return this.ruleForm.originstation;
                },
                set:function (val) {
                    this.ruleForm.originstation=val.toUpperCase();
                }
            },
            destinationstation:{
                get:function () {
                    return this.ruleForm.destinationstation;
                },
                set:function (val) {
                    this.ruleForm.destinationstation=val.toUpperCase();
                }
            },
            flightno:{
                get:function () {
                    return this.ruleForm.flightno;
                },
                set:function (val) {
                    this.ruleForm.flightno=val.toUpperCase();
                }
            }
        },
158
        methods:{
159 160 161 162
            remoteMethod:function(query) {
                this.options = [];
                let params={airportid:query};
                this.loading = true;
163
                selectAirport(params).then(res=>{
164 165 166 167 168 169 170 171 172
                    if (res !== '') {
                        setTimeout(() => {
                            this.loading = false;
                            this.options=res.data.data;
                            this.options2=res.data.data;
                        }, 200);
                    } else {
                        this.options = [];
                    }
173 174
                });
            },
175 176 177 178
            /*按钮点击请求方法*/
            submitForm(formName) {
                this.$refs[formName].validate((valid) => {
                    if (valid) {
179 180 181 182 183 184
                        this.$router.push({path:'/tallymaster',query:
                                {flightno:JSON.stringify(this.ruleForm.flightno),
                                    flightdate:JSON.stringify(this.dateConversion(this.ruleForm.flightdate)),
                                    originstation:JSON.stringify(this.ruleForm.originstation),
                                    destinationstation:JSON.stringify(this.ruleForm.destinationstation),
                                    awba:JSON.stringify("")}});
185 186 187 188 189 190 191 192 193 194 195 196 197 198
                    } else {
                        //console.log('error submit!!');
                return false;
            }
            });
            },
            /*航班日期格式化方法*/
            dateConversion(value){
                var date = new Date(value);
                var date = date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate();
                return date;
            },
            /*获取默认值方法*/
            getDefaultData(){
199 200 201 202 203 204 205 206 207 208 209 210
                if(
                    jsutil.checkNull(this.$route.query)
                    && jsutil.checkNull(this.$route.query.flightno)
                    && jsutil.checkNull(this.$route.query.flightdate)
                    && jsutil.checkNull(this.$route.query.originstation)
                    && jsutil.checkNull(this.$route.query.destinationstation)
                )
                {
                    this.ruleForm.flightno=(this.$route.query.flightno);
                    this.ruleForm.flightdate=(this.$route.query.flightdate);
                    this.ruleForm.originstation=(this.$route.query.originstation);
                    this.ruleForm.destinationstation=(this.$route.query.destinationstation);
211 212 213 214
                }
            }
        },
        /*渲染方法*/
215
        activated(){
216 217 218 219 220
            this.getDefaultData();
        }
    };

</script>