﻿<template>
	<el-dialog :title="!dataForm.id ? '新建' :  isDetail ? '详情':'编辑'" :close-on-click-modal="false" :visible.sync="visible" class="NCC-dialog NCC-dialog_center" lock-scroll width="90%">
		<el-row :gutter="15" class="" >
				<el-form ref="elForm" :model="dataForm" size="small" label-width="100px" label-position="right" :disabled="!!isDetail" :rules="rules">
					<el-col :span="8">
						<el-form-item label="客户编码" prop="id">
							<el-input v-model="dataForm.id" placeholder="请输入" clearable readonly :style='{"width":"100%"}' >
							</el-input>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="客户名称" prop="khmc">
							<el-input v-model="dataForm.khmc" placeholder="请输入" clearable :style='{"width":"100%"}' >
							</el-input>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="手机号" prop="sjh">
							<el-input v-model="dataForm.sjh" placeholder="请输入" clearable :style='{"width":"100%"}' >
							</el-input>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="档案号" prop="dah">
							<el-input v-model="dataForm.dah" placeholder="请输入" clearable :style='{"width":"100%"}' >
							</el-input>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="性别" prop="xb">
							<el-select v-model="dataForm.xb" placeholder="请选择" clearable :style='{"width":"100%"}' >
								<el-option v-for="(item, index) in xbOptions" :key="index" :label="item.fullName" :value="item.id" ></el-option>
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="公众号状态" prop="gzhzt">
							<el-select v-model="dataForm.gzhzt" placeholder="请选择" clearable :style='{"width":"100%"}' >
								<el-option v-for="(item, index) in gzhztOptions" :key="index" :label="item.fullName" :value="item.id" ></el-option>
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="微信昵称" prop="wxnc">
							<el-input v-model="dataForm.wxnc" placeholder="请输入" clearable :style='{"width":"100%"}' >
							</el-input>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="小程序状态" prop="wxxcxzt">
							<el-select v-model="dataForm.wxxcxzt" placeholder="请选择" clearable :style='{"width":"100%"}' >
								<el-option v-for="(item, index) in wxxcxztOptions" :key="index" :label="item.fullName" :value="item.id" ></el-option>
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="最近登录时间" prop="zjdlsj">
							<el-date-picker v-model="dataForm.zjdlsj" placeholder="请选择" clearable :style='{"width":"100%"}' type='date' format="yyyy-MM-dd" value-format="timestamp" >
							</el-date-picker>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="客户目前归属" prop="khmqgs">
							<el-select v-model="dataForm.khmqgs" placeholder="请选择" clearable :style='{"width":"100%"}' >
								<el-option v-for="(item, index) in khmqgsOptions" :key="index" :label="item.fullName" :value="item.id" ></el-option>
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="归属门店" prop="gsmd">
							<el-input v-model="dataForm.gsmd" placeholder="请输入" clearable :style='{"width":"100%"}' >
							</el-input>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="注册时间" prop="zcsj">
							<el-date-picker v-model="dataForm.zcsj" placeholder="请选择" clearable :style='{"width":"100%"}' type='date' format="yyyy-MM-dd" value-format="timestamp" >
							</el-date-picker>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="客户类型" prop="khlx">
							<el-select v-model="dataForm.khlx" placeholder="请选择" clearable :style='{"width":"100%"}' >
								<el-option v-for="(item, index) in khlxOptions" :key="index" :label="item.fullName" :value="item.id" ></el-option>
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="客户阶段" prop="khjd">
							<el-select v-model="dataForm.khjd" placeholder="请选择" clearable :style='{"width":"100%"}' >
								<el-option v-for="(item, index) in khjdOptions" :key="index" :label="item.fullName" :value="item.id" ></el-option>
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="客户消费" prop="khxf">
							<el-checkbox-group v-model="dataForm.khxf" :style='{}' >
								<el-checkbox v-for="(item, index) in khxfOptions" :key="index" :label="item.id" >{{item.fullName}}</el-checkbox>
							</el-checkbox-group>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="消费频次" prop="xfpc">
							<el-select v-model="dataForm.xfpc" placeholder="请选择" clearable :style='{"width":"100%"}' >
								<el-option v-for="(item, index) in xfpcOptions" :key="index" :label="item.fullName" :value="item.id" ></el-option>
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="推荐人" prop="tjr">
							<el-input v-model="dataForm.tjr" placeholder="请输入" clearable :style='{"width":"100%"}' >
							</el-input>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="负责顾问" prop="fzgw">
							<el-input v-model="dataForm.fzgw" placeholder="请输入" clearable :style='{"width":"100%"}' >
							</el-input>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="美容师" prop="mrs">
							<el-input v-model="dataForm.mrs" placeholder="请输入" clearable :style='{"width":"100%"}' >
							</el-input>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="进店渠道" prop="jdqd">
							<el-input v-model="dataForm.jdqd" placeholder="请输入" clearable :style='{"width":"100%"}' >
							</el-input>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="联系地址" prop="lxdz">
							<el-input v-model="dataForm.lxdz" placeholder="请输入" clearable :style='{"width":"100%"}' >
							</el-input>
						</el-form-item>
					</el-col>
					<el-col :span="24">
						<el-form-item label="备注" prop="bz">
							<el-input v-model="dataForm.bz" placeholder="请输入" show-word-limit :style='{"width":"100%"}' type='textarea' :autosize='{"minRows":4,"maxRows":4}' >
							</el-input>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="首次到店" prop="scdd">
							<el-date-picker v-model="dataForm.scdd" placeholder="请选择" clearable :style='{"width":"100%"}' type='date' format="yyyy-MM-dd" value-format="timestamp" >
							</el-date-picker>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="最近到店" prop="zjdd">
							<el-date-picker v-model="dataForm.zjdd" placeholder="请选择" clearable :style='{"width":"100%"}' type='date' format="yyyy-MM-dd" value-format="timestamp" >
							</el-date-picker>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="未到店天数" prop="wddts">
							<el-input v-model="dataForm.wddts" placeholder="请输入" clearable :style='{"width":"100%"}' >
							</el-input>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="阳历生日" prop="yanglsr">
							<el-date-picker v-model="dataForm.yanglsr" placeholder="请选择" clearable :style='{"width":"100%"}' type='date' format="yyyy-MM-dd" value-format="timestamp" >
							</el-date-picker>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="阴历生日" prop="yinlsr">
							<el-date-picker v-model="dataForm.yinlsr" placeholder="请选择" clearable :style='{"width":"100%"}' type='date' format="yyyy-MM-dd" value-format="timestamp" >
							</el-date-picker>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="年龄" prop="ml">
							<el-input v-model="dataForm.ml" placeholder="请输入" clearable :style='{"width":"100%"}' >
							</el-input>
						</el-form-item>
					</el-col>
					<el-col :span="24">
						<el-form-item label="最近服务人员" prop="zjycfwry">
							<el-input v-model="dataForm.zjycfwry" placeholder="请输入" clearable :style='{"width":"100%"}' >
							</el-input>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="期间到店频次" prop="qjddpc">
							<el-input v-model="dataForm.qjddpc" placeholder="请输入" clearable :style='{"width":"100%"}' >
							</el-input>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="期间服务单次" prop="qjfwdc">
							<el-input v-model="dataForm.qjfwdc" placeholder="请输入" clearable :style='{"width":"100%"}' >
							</el-input>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="期间现金消费" prop="qjxjxf">
							<el-input v-model="dataForm.qjxjxf" placeholder="请输入" clearable :style='{"width":"100%"}' >
							</el-input>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="期间项目耗卡" prop="qjxmhk">
							<el-input v-model="dataForm.qjxmhk" placeholder="请输入" clearable :style='{"width":"100%"}' >
							</el-input>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="期间储值消耗" prop="qjczxh">
							<el-input v-model="dataForm.qjczxh" placeholder="请输入" clearable :style='{"width":"100%"}' >
							</el-input>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="剩余储值" prop="sycz">
							<el-input v-model="dataForm.sycz" placeholder="请输入" clearable :style='{"width":"100%"}' >
							</el-input>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="剩余积分" prop="syjf">
							<el-input v-model="dataForm.syjf" placeholder="请输入" clearable :style='{"width":"100%"}' >
							</el-input>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="剩余品项金额" prop="sypxje">
							<el-input v-model="dataForm.sypxje" placeholder="请输入" clearable :style='{"width":"100%"}' >
							</el-input>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="剩余套餐金额" prop="sytcje">
							<el-input v-model="dataForm.sytcje" placeholder="请输入" clearable :style='{"width":"100%"}' >
							</el-input>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="项目耗卡金额" prop="ljxmhkje">
							<el-input v-model="dataForm.ljxmhkje" placeholder="请输入" clearable :style='{"width":"100%"}' >
							</el-input>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="累计储值消耗" prop="ljczxh">
							<el-input v-model="dataForm.ljczxh" placeholder="请输入" clearable :style='{"width":"100%"}' >
							</el-input>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="累计消费次数" prop="ljxfcs">
							<el-input v-model="dataForm.ljxfcs" placeholder="请输入" clearable :style='{"width":"100%"}' >
							</el-input>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="累计服务次数" prop="ljfwcs">
							<el-input v-model="dataForm.ljfwcs" placeholder="请输入" clearable :style='{"width":"100%"}' >
							</el-input>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="现金消费金额" prop="ljxjxfje">
							<el-input v-model="dataForm.ljxjxfje" placeholder="请输入" clearable :style='{"width":"100%"}' >
							</el-input>
						</el-form-item>
					</el-col>
				</el-form>
		</el-row>
		<span slot="footer" class="dialog-footer">
			<el-button @click="visible = false">取 消</el-button>
			<el-button type="primary" @click="dataFormSubmit()" v-if="!isDetail">确 定</el-button>
		</span>
	</el-dialog>
</template>
<script>
	import request from '@/utils/request'
	import { getDictionaryDataSelector } from '@/api/systemData/dictionary'
	import { previewDataInterface } from '@/api/systemData/dataInterface'
	export default {
		components: {},
		props: [],
		data() {
			return {
				loading: false,
				visible: false,
				isDetail: false,
				dataForm: {
					id:'',
					id:undefined,
					khmc:undefined,
					sjh:undefined,
					dah:undefined,
					xb:undefined,
					gzhzt:undefined,
					wxnc:undefined,
					wxxcxzt:undefined,
					zjdlsj:undefined,
					khmqgs:undefined,
					gsmd:undefined,
					zcsj:undefined,
					khlx:undefined,
					khjd:undefined,
					khxf:[],
					xfpc:undefined,
					tjr:undefined,
					fzgw:undefined,
					mrs:undefined,
					jdqd:undefined,
					lxdz:undefined,
					bz:undefined,
					scdd:undefined,
					zjdd:undefined,
					wddts:undefined,
					yanglsr:undefined,
					yinlsr:undefined,
					ml:undefined,
					zjycfwry:undefined,
					qjddpc:undefined,
					qjfwdc:undefined,
					qjxjxf:undefined,
					qjxmhk:undefined,
					qjczxh:undefined,
					sycz:undefined,
					syjf:undefined,
					sypxje:undefined,
					sytcje:undefined,
					ljxmhkje:undefined,
					ljczxh:undefined,
					ljxfcs:undefined,
					ljfwcs:undefined,
					ljxjxfje:undefined,
				},
				rules: {
				},
				xbOptions:[{"fullName":"男","id":"男"},{"fullName":"女","id":"女"}],
				gzhztOptions:[{"fullName":"已绑定","id":"已绑定"},{"fullName":"未绑定","id":"未绑定"}],
				wxxcxztOptions:[{"fullName":"已绑定","id":"已绑定"},{"fullName":"未绑定","id":"未绑定"}],
				khmqgsOptions:[{"fullName":"会员","id":"会员"},{"fullName":"线索池","id":"线索池"},{"fullName":"会员-归档","id":"会员-归档"}],
				khlxOptions:[{"fullName":"新客","id":"新客"},{"fullName":"老客","id":"老客"},{"fullName":"潜客","id":"潜客"},{"fullName":"线索","id":"线索"}],
				khjdOptions:[{"fullName":"体验","id":"体验"},{"fullName":"有效","id":"有效"},{"fullName":"沉睡","id":"沉睡"},{"fullName":"流失","id":"流失"}],
				khxfOptions:[{"fullName":"D客","id":"D客"},{"fullName":"有效","id":"有效"}],
				xfpcOptions:[{"fullName":"高频","id":"高频"},{"fullName":"低频","id":"低频"}],
			}
		},
		computed: {},
        watch: {},
        created() {
		},
		mounted() {
        },
		methods: {
			goBack() {
                this.$emit('refresh')
            },
			init(id, isDetail) {
				this.dataForm.id = id || 0;
                this.visible = true;
                this.isDetail = isDetail || false;
				this.$nextTick(() => {
					this.$refs['elForm'].resetFields();
					if (this.dataForm.id) {
						request({
							url: '/api/Extend/LqKhxx/' + this.dataForm.id,
							method: 'get'
						}).then(res =>{
							this.dataForm = res.data;
							if(!this.dataForm.khxf)this.dataForm.khxf=[];
						})
					}
				})
			},
			dataFormSubmit() {
				this.$refs['elForm'].validate((valid) => {
                    if (valid) {
                        if (!this.dataForm.id) {
                            request({
                                url: `/api/Extend/LqKhxx`,
                                method: 'post',
                                data: this.dataForm,
                            }).then((res) => {
                                this.$message({
                                    message: res.msg,
                                    type: 'success',
                                    duration: 1000,
                                    onClose: () => {
                                        this.visible = false,
                                            this.$emit('refresh', true)
                                    }
                                })
                            })
                        } else {
                            request({
                                url: '/api/Extend/LqKhxx/' + this.dataForm.id,
                                method: 'PUT',
                                data: this.dataForm
                            }).then((res) => {
                                this.$message({
                                    message: res.msg,
                                    type: 'success',
                                    duration: 1000,
                                    onClose: () => {
                                        this.visible = false
                                        this.$emit('refresh', true)
                                    }
                                })
                            })
                        }
                    }
                })
			},
		}
	}
</script>
