<template>
    <div class="addVehicleDialog">
        <el-dialog center width="636px" @close="cancel()" title="添加机车信息" :visible.sync="addVehicleData.dialogVisible">
            <el-form label-width="80px" ref="ruleForm" :rules="rules" :model="addVehicleForm">
                <el-form-item label="机车号" prop="vehicleCode">
                    <el-input placeholder="请输入机车号" v-model="addVehicleForm.vehicleCode"></el-input>
                </el-form-item>
                <el-form-item label="车型" prop="vehicleType">
                    <el-input placeholder="请输入车型" v-model="addVehicleForm.vehicleType"></el-input>
                </el-form-item>
                <el-form-item label="AB端" prop="ends">
                    <el-input placeholder="请输入AB端" v-model="addVehicleForm.ends"></el-input>
                </el-form-item>
                <!-- <el-form-item label="机车名称" prop="vehicleName">
                    <el-input placeholder="请输入机车名称" v-model="addVehicleForm.vehicleName"></el-input>
                </el-form-item> -->
                <el-form-item label="备注">
                    <el-input placeholder="请输入备注" v-model="addVehicleForm.remark"></el-input>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <!-- <el-button @click="cancel()">取 消</el-button>
                <el-button type="primary" @click="addVehicle()">保 存</el-button> -->
                <div class="search" @click="addVehicle()">保 存</div>
                <div class="reset" @click="cancel()">取 消</div>
            </span>
        </el-dialog>
    </div>
</template>
<script>
export default {
    props: {
        addVehicleData: {
            type: Object,
            default: {}
        }
    },
    data() {
        return {
            addVehicleForm: {
                vehicleCode: '',
                vehicleName: '',
                remark: ''
            },
            rules: {
                vehicleCode: [{ required: true, message: '请输入机车编码', trigger: 'blur' },],
                vehicleName: [{ required: true, message: '请输入机车名称', trigger: 'blur' }],
                vehicleType: [{ required: true, message: '请输入车型', trigger: 'blur' }],
                ends: [{ required: true, message: '请输入AB端', trigger: 'blur' }],
            }
        }
    },
    methods: {
        cancel() {
            this.addVehicleData.dialogVisible = false
            this.addVehicleForm = {
                vehicleCode: '',
                vehicleName: '',
                remark: ''
            }
        },
        addVehicle() {
            this.$refs.ruleForm.validate(valid => {
                if (valid) {
                    this.$emit('addVehicleBtn', this.addVehicleForm)
                }
            })
        }
    }
}
</script>
<style lang="scss" scoped>
::v-deep .el-dialog__body {
    padding: 20px 95px !important;
}
</style>
