<template>
	<view class="follow_wrap">
		<u-navbar placeholder :autoBack="true" title="添加跟进记录" @rightClick="handleNavSaveClick">
			<view class="u-nav-slot" slot="right">
				保存
			</view>
		</u-navbar>
		<view class="form_wrap">
			<u--form labelPosition="left" labelWidth="80" :model="form" :rules="rules" ref="form" class="form_wrap">
				<u-form-item label="跟进内容" prop="content">
					<u--textarea v-model="form.content" placeholder="请输入内容" count confirmType="done" maxlength="500">
					</u--textarea>
				</u-form-item>
			</u--form>
		</view>
		<!-- <drag-button :isDock="true" /> -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				rules: {
					'content': {
						type: 'string',
						required: true,
						message: '请输入内容',
						trigger: ['blur', 'change']
					},
				},
				form: {
					clueId : undefined,
					content: ''
				},
			}
		},
		methods: {
			handleNavSaveClick() {
				this.$refs.form.validate().then(async () => {
					await uni.$u.api.addClueFollow(this.form);
					uni.$u.toast("保存成功");
					this.timer = setTimeout(()=>{
						uni.$emit('addFollowSuccess');
						uni.navigateBack();
						clearTimeout(this.timer);
					},1000)
				})
			},
		},
		onLoad(option) {
			this.form.clueId = option.clueId;
		}
	}
</script>

<style lang="scss" scoped>
	.form_wrap {
		background-color: #fff;
		margin: 20rpx 0;

		.form_wrap {
			::v-deep .u-form-item__body {
				padding: 20rpx 40rpx;
			}
		}
	}
</style>
