<template>
    <div>
        <el-form ref="form" :model="form" :rules="rules" label-width="80px">
            <el-form-item label="客户数量" >
                {{ids.length}}个
            </el-form-item>
            <el-form-item label="客户来源" prop="source">
                <el-select v-model="form.source" placeholder="请选择客户来源" clearable size="small">
                    <el-option
                        v-for="item in sourceOptions"
                        :key="item.dictValue"
                        :label="item.dictLabel"
                        :value="item.dictValue"
                        />
                </el-select>
            </el-form-item>
        </el-form>
        <div   class="dialog-footer">
            <el-button type="primary" @click="submitForm">确 定</el-button>
            <el-button @click="cancel">取 消</el-button>
        </div>
    </div>
</template>
  
<script>
import { listCustomer,getCustomer,addCustomer,updateCustomerSource,delCustomer,exportCustomer  } from "@/api/crm/customer";
export default {
        name: "customerVisit",
        data() {
            return {
                sourceOptions:[],
                ids:[],
                // 表单参数
                form: {},
                // 表单校验
                rules: {
                    source: [
                    { required: true, message: "客户来源不能为空", trigger: "blur" }
                    ],
                }
            };
        },
        created() {
            this.getDicts("sys_crm_customer_source").then((response) => {
                this.sourceOptions = response.data;
            });
           
        },
        methods: {
            cancel(){
                this.$emit('close');
            },
            handleEdit(ids) {
                console.log(ids)
                this.ids=ids;
                 
            },
            /** 提交按钮 */
            submitForm() {
                this.$refs["form"].validate(valid => {
                    if (valid) {
                        this.form.ids=this.ids.toString();
                        updateCustomerSource(this.form).then(response => {
                            if (response.code === 200) {
                                this.msgSuccess("修改成功");
                                this.$emit('close');
                            }
                        });
                    }
                });
            },
        }
    };
</script>
<style lang="scss" scoped> 
.dialog-footer{
    margin-bottom: 10px;
    text-align: right;
}
</style>
 