<template>
    <div>
            <el-form ref="form" :model="form" :rules="rules" label-width="100px">
                <el-form-item label="客户类型" prop="customerType">
                    <el-select v-model="form.customerType" placeholder="请选择客户类型" clearable size="small">
                        <el-option
                                v-for="item in typeOptions"
                                :key="item.dictValue"
                                :label="item.dictLabel"
                                :value="item.dictValue"
                            />
                    </el-select>
                </el-form-item>
            </el-form>
            <div class="footer">
                <el-button type="primary" @click="submitForm">确 定</el-button>
            </div>
       
    </div>
</template>
  
<script>
     import { getCustomerDetails,updateCustomer  } from "@/api/crm/customer";
    export default {
        name: "visit",
        data() {
            return {
                 
                typeOptions:[],
                form: {
                    customerId:null,
                    customerType:null,
                 
                },
                // 表单校验
                rules: {
                    customerType: [
                        { required: true, message: "类型不能为空", trigger: "change" }
                    ],
         
                }
                 
            };
        },
        created() {
            this.getDicts("crm_customer_type").then((response) => {
                this.typeOptions = response.data;
            });
        },
        methods: {
            reset(customer) {
                this.form.customerId=customer.customerId;
                this.form.customerType=customer.customerType.toString();
            },
            submitForm() {
                this.$refs["form"].validate(valid => {
                    if (valid) {
                        updateCustomer(this.form).then(response => {
                            if (response.code === 200) {
                                this.msgSuccess("操作成功");
                                
                                this.$emit('close');
                            }
                        });
                    }
                });
            },
        }
    };
</script>
<style lang="scss" scoped>
.contents{
    height: 100%;
    background-color: #fff;
    padding: 20px;
        
}
.footer{
    display: flex;
    align-items: center;
    justify-content: flex-end;
}
</style>

 