<template>
	<view class="create_customer">
		<form-item v-for="(item,index) in listForm" @changeData="changeData" :key="index" :objInfo="item" ></form-item>
		<view class="btn_g bg-blue button-hover round" @click="$noMultipleClicks(subSave)">
			保存
		</view>
	</view>
</template>

<script>
	import formItem from '@/components/form/formitem.vue'
	import { netSetForm } from '@/api/index.js'
	import { checkPhone } from '@/util/util.js'
	import { netSelect } from '@/api/kehu.js'
	import { netCluesDetail, netEditClues } from '@/api/clues.js'
	import { dateTimePicker, getMonthDay } from '@/util/dateTimePicker.js'
	export default {
		components:{
			formItem
		},
		data() {
			return {
				noClick:true,    //防止  重复点击
				id:'',
				info:{},
				
				source_list:[],   //线索 来源列表
				sourceIndex:null,
				industry_list:[],   //行业列表
				industryIndex:null,
				remindList:['准时提醒','5分钟前','15分钟前','30分钟前','一个小时前','两个小时前','一天前','两天前','一周前'],   //提醒
				remindIndex:null,
				
				dateTimeArray:null,
				dateTime:null,
				dateArr:null,
				
				listForm:[],
			}
		},
		onLoad(options) {
			this.id = options.id
			//获取 线索 信息
			this.getinfo()
		},
		onShow() {
			
		},
		methods: {
			getForm() {
				let params = {type:'leads'}
				netSetForm(params).then(res=>{
					let list = res.data.data
					list.forEach(ele=>{
						ele.value = this.info[ele.id]?this.info[ele.id]:''
					})
					this.listForm = list
				})
			},
			// 获取 线索 信息
			getinfo() {
				netCluesDetail({id:this.id}).then(res=>{
					res = res.data
					this.info = res
					this.getForm()
				})
			},
			changeData(name,value,obj){
				let arr = this.listForm
				arr.forEach((ele,index)=>{
					if(ele.id == obj.id){
						ele.value = value
						this.$set(this.listForm,index,ele)
					}
				})
			},
			//是否创建 下次跟进任务
			changeIs() {
				this.is_event = !this.is_event
			},
			//任务提醒
			changeRemind(e) {
				this.remindIndex = e.detail.value
				this.remindtype = this.remindList[e.detail.value]
			},
			//完成
			subSave() {
				let params = this.checkCommonForm(this.listForm)
				if(!params){
					return
				}
				params.id = this.id
				netEditClues(params).then(res=>{
					uni.showToast({
						title:res.msg,
						icon:'none'
					})
					setTimeout(()=>{
						uni.navigateBack({
							delta:1
						})
					},2000)
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
.create_customer {
	font-size: 28rpx;
	.info_head {
		height: 80rpx;
		line-height: 80rpx;
		font-size: 24rpx;
		color: #999;
		padding-left: 24rpx;
	}
	.mar_top {
		margin-top: 30rpx;
	}
	.fllow_form {
		display: flex;
		justify-content: space-between;
		height: 100rpx;
		line-height: 100rpx;
		background-color: #fff;
		border-bottom: 1rpx solid #EAEAEA;
		padding: 0 24rpx;
		input {
			height: 100rpx;
			line-height: 100rpx;
		}
		.form_right {
			display: flex;
			color: #999;
			text-align: right;
			image {
				width: 40rpx;
				height: 40rpx;
				margin: 28rpx 5rpx 0 0;
			}
		}
		.theme {
			color: #5ca9fe;
		}
		text {
			color: #f00;
			margin-left: 10rpx;
		}
		.form_input {
			input {
				height: 100rpx;
				line-height: 100rpx;
				text-align: right;
				margin-right: 10rpx;
			}
		}
	}
	.fllow_area {
		background-color: #fff;
		padding: 0 30rpx;
		margin-bottom: 30rpx;
		.area_head {
			height: 100rpx;
			line-height: 100rpx;
			text {
				color: #f00;
			}
		}
		textarea {
			width: 100%;
			height: 300rpx;
			background: #f8f8f8;
		}
	}
}
</style>
