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