<template>
	<view class="tranfer_clue">
		<view class="fllow_form">
			<view style="color: #333;font-size: 32rpx;"><text>*</text>接收对象</view>
			<view class="form_right" @click="changeStaff">
				<view>{{staffname ? staffname : '点击选择'}}</view>
				<view class="iconfont icon-arrows_right"></view>
			</view>
		</view>
		<view id="btn" class="btn_g bg-blue button-hover round" @click="Totrans">
			保存
		</view>
		
		<!-- 选择员工 -->
		<select-staff ref="staffChild" @sureStaff="sureSelect" :type="2"></select-staff>
	</view>
</template>

<script>
	import { netStaffList, netTransKehu } from '@/api/kehu.js'
	import { BASE_IMG_URL } from '@/util/api.js'
	import selectStaff from '@/components/selectStaff.vue'
	export default {
		components:{
			selectStaff
		},
		data() {
			return {
				id:'',   //客户id
				staff_id:'',    //员工id
				staffname:'',
				staffList:[],
				staffIndex:null
			}
		},
		onLoad(options) {
			this.id = options.id
			
		},
		onShow() {
			this.getList()
		},
		methods: {
			getList() {
				netStaffList().then(res=>{
					this.staffList = res.data
				})
			},
			changeStaff(e) {
				this.$refs.staffChild.init()
			},
			sureSelect(obj) {
				this.staff_id = obj.id
				this.staffname = obj.name
			},
			Totrans() {
				if(!this.staff_id){
					uni.showToast({
						title:'请选择接受对象',
						icon:'none'
					})
					return
				}
				let params = {
					id:this.id,
					staff_id: this.staff_id
				}
				netTransKehu(params).then(res=>{
					uni.showToast({
						title:res.msg,
						icon:'none'
					})
					setTimeout(()=>{
						uni.redirectTo({
							url:"/pagesA/crm/customerManagement/customerManagement"
						})
					},1000)
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
  .fllow_form {
		display: flex;
		justify-content: space-between;
		height: 100rpx;
		line-height: 100rpx;
		background-color: #fff;
		border-bottom: 1rpx solid #EAEAEA;
		padding: 0 30rpx 0 47rpx;
		margin: 0 0 30rpx;
		.form_right {
			display: flex;
			color: #999;
			image {
				width: 40rpx;
				height: 40rpx;
				margin: 28rpx 5rpx 0 0;
			}
		}
		text {
			color: #f00;
			margin-left: 10rpx;
		}
	}
	.fllow_area {
				background-color: #fff;
				margin-bottom: 30rpx;
				padding-bottom: 30rpx;
				color: #999;
				.area_head {
					height: 100rpx;
					line-height: 100rpx;
					font-size: 32rpx;
					padding: 0 70rpx;
					text {
						color: #f00;
					}
				}
				textarea {
					width: 80%;
					height: 300rpx;
					padding: 30rpx;
					background: #f8f8f8;
					margin: 0 auto;
				}
			}
	#btn {
		font-size: 26rpx;
		color: #fff;
		text-align: center;
		line-height: 88rpx;
		width: 500rpx;
		height: 88rpx;
		background: $uni-text-color;
		border-radius: 29rpx;
	}
</style>
