<template>
	<view class="mainBox">
		<uni-nav-bar background-color="#157A2C" color="#fff" fixed="true" statusBar="true" left-icon="back" title="跟进记录"
			@clickLeft="back">
		</uni-nav-bar>

		<followList ref="followListRef" :linkList="linkList" :isDrawer="true">
		</followList>

	</view>
</template>

<script>
	import followList from "@/pages/saleManage/contact/components/followList.vue"
	import {
		contactDetail,
		contactSave
	} from '@/api/saleManage/contact/index.js'

	export default {
		components: {
			followList,
		},

		data() {
			return {
				form: {
					address: '',
					addressId: '',
					addressName: '',
					authorizationLimit: 0,
					businessLicenseFiles: [],
					businessLicenseFile: [],
					businessScope: '',
					categoryId: '',
					categoryName: '',
					companyCategoryId: '',
					companyCategoryName: '',
					enterpriseTypeId: '',
					enterpriseTypeName: '',
					legalPerson: '',
					registeredCapital: '',
					parentId: '',
					industry: [],
					industryCode: '',
					industryFullName: '',
					mainProduct: '',
					name: '',
					officialIndustry: '',
					phone: '',
					registerDate: '',
					remark: '',
					serialNo: '',
					simpleName: '',
					type: 1,
					unifiedSocialCreditCode: ''
				},
				otherForm: {
					settlementMode: '',
					settlementModeName: '',
					taxRate: 0,
					address: '',
					addressId: '',
					deptId: '',
					deptName: '',
					discount: 0,
					salesmanId: '',
					salesmanName: '',
					sender: '',
					senderPhone: ''
				},
				bankList: [],
				linkList: [],
			}
		},
		computed: {

		},


		onLoad(data) {
			uni.$off('setContact')
			uni.$on('setContact', ({
				key,
				data
			}) => {
				this[key] = data
				this.save()
			})
			contactDetail(data.id).then(async res => {

				this.form = res.base
				this.otherForm = res.other
				this.bankList = res.bankList
				this.linkList = res.linkList
				this.$nextTick(() => {
					this.$refs.followListRef.init(res.base)
				})
			})
		},
		onUnload() {
			uni.$off('setContact')
		},
		methods: {
			save() {
				try {

					const data = {
						base: this.form,
						other: this.otherForm,
						bankList: this.bankList,
						linkList: this.linkList,
					};

					contactSave(data)

				} catch (error) {
					console.log(error, 'error')
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	.add {
		width: 96rpx;
		height: 96rpx;
		border-radius: 48rpx;
		background: #3c9cff;
		position: fixed;
		bottom: 100rpx;
		right: 24rpx;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.top-wrapper {
		background-color: #fff;
		display: flex;
		width: 750rpx;
		height: 88rpx;
		padding: 16rpx 32rpx;
		align-items: center;
		gap: 16rpx;

		/deep/.uni-section {
			margin-top: 0px;
		}

		/deep/.uni-section-header {
			padding: 0px;

		}

		.search_btn {
			width: 120rpx;
			height: 70rpx;
			line-height: 70rpx;
			padding: 0 24rpx;
			background: $theme-color;
			font-size: 32rpx;
			color: #fff;
			margin: 0;
			margin-left: 26rpx;
		}

		.menu_icon {
			width: 44rpx;
			height: 44rpx;
			margin-left: 14rpx;
		}
	}
</style>