configure.vue 6.8 KB
<template>
    <el-container>
        <el-main>
            <el-row class="row-bg">
                <el-col :span="24">
                    <div class="grid-content content">进港航班配置</div>
                </el-col>
            </el-row>
            <el-row>
                <el-form :model="configure" :rules="rules" ref="configure" label-width="100%" class="demo-ruleForm">
                    <el-col :span="8">
                        <el-form-item label="航班号" prop="flightNo" label-width="120px">
                            <el-input v-model="configure.flightNo"  @input="e => configure.flightNo=inputMe(e)"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="进出标识" prop="ietype" label-width="120px">
                            <el-select v-model="configure.ietype" placeholder="" style="display:inline">
                                <el-option v-for="item in linesTypes" :key="item.value" :label="item.label"
                                           :value="item.value"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
<!--                    <el-col :span="8">-->
<!--                        <el-form-item label="国籍" prop="country" label-width="120px">-->
<!--                            <Nationality v-on:tellFarther="fromCountry"></Nationality>-->
<!--                        </el-form-item>-->
<!--                    </el-col>-->
<!--                    <el-col :span="8">-->
<!--                        <el-form-item label="证件" prop="certType" label-width="120px">-->
<!--                            <Document v-on:tellFa="fromDocument"></Document>-->
<!--                        </el-form-item>-->
<!--                    </el-col>-->
                    <el-col :span="24">
                        <el-form-item label="备注" prop="reamrk" label-width="120px">
                            <el-input v-model="configure.reamrk"></el-input>
                        </el-form-item>
                    </el-col>
                </el-form>
            </el-row>
            <el-row style="margin-left: 120px">
                <el-col :span="24">   <el-button type="primary" @click="submitForm('configure')">保 存</el-button>
                </el-col>
            </el-row>
            <!--对话提示框-->
            <el-row>
                <el-dialog
                        title="系统提示"
                        :visible.sync="centerDialogVisible"
                        width="30%"
                        center>
                    <span>{{msg}}</span>
                    <span slot="footer" class="dialog-footer">
                          <el-button @click="centerDialogVisible = false">取 消</el-button>
                        <el-button type="primary" @click="centerDialogVisible = false">确 定</el-button>
                      </span>
                </el-dialog>
            </el-row>
        </el-main>
    </el-container>
</template>
<style scoped>
    .grid-content {
        height: 36px;
        line-height: 36px;
    }
    .el-dialog__body{text-align: center}
    .content {
        border-left: 4px #409EFF solid;
        padding-left: 10px;
        background-color: #f9fafc;
        margin-bottom: 2px
    }

    .row-bg{
        background-color: white;
    }
    .el-col{margin-right: 0px;}
</style>
<script>
    import { addSchedule} from "../../api/transport";
    import loginUserInfo from '../../api/base';
    import Nationality from './Nationality'
    import Document from './Document'

    export default {
        components: { Nationality, Document },

        data(){
            return{
                //国籍数据
                // countryOptions:[],
                configure:{
                    username:loginUserInfo.username,
                    flightNo:undefined,
                    ietype:'1',
                    reamrk:undefined,
                    // accessFlag:'1',
                    country:'',
                    certType:'',
                    createBy:loginUserInfo.username,
                    updateBy:loginUserInfo.username,
                },
                LoginUserInfo: loginUserInfo,
                rules: {
                    flightNo: [
                        {required: true, message: '请输入', trigger: 'blur'}
                    ],
                    ietype: [
                        {required: true, message: '请输入', trigger: 'change'}
                    ],
                },
                linesTypes:[
                    {value:'',label:'请选择'},
                    {value:'1',label:'进港'},
                    {value:'2',label:'出港'}
                ],
                tableData:[],
                msg:undefined,
                centerDialogVisible:false,
            }
        },
        methods:{
            //从子组件获取国籍数据
            fromCountry:function(val){
                console.log("来自子组件的值:"+val)
                this.configure.country = val;
            },
            //从子组件获取证件数据
            fromDocument:function(val){
                console.log("来自子组件的值:"+val)
                this.configure.certType = val;
            },
            //新增进港确报申报(保存按钮)
            submitForm(formName) {
                let _this = this;
                this.$refs[formName].validate((valid) => {
                    if (valid) {
                        this.configure.createBy=loginUserInfo.username
                        this.configure.username=loginUserInfo.username
                        addSchedule(this.configure).then(res=>{
                            let response=res.data;
                            if(response.code=='200'){
                                //this.centerDialogVisible=true;
                                //this.msg=response.msg;
                                this.$router.push({path:'/queryConfigure',query:{flightNo:this.configure.flightNo}});
                                this.$message.success(response.msg)
                            }else{
                                this.$message.error(response.msg)
                            }
                        });
                    } else {
                        console.log('error submit!!');
                        return false;
                    }
                });
            },
            //加载默认值
            defaultData(){
                if(this.$route.query!=null){
                    Object.assign(this.configure, this.$route.query);
                }
            },
            // 过滤中英文
            inputMe(e){
                return e.replace(/[^a-zA-Z0-9.-]/g,'').toUpperCase();
            }
        },
        activated(){
            this.defaultData();
        }
    }
</script>