<template>
	<view>
		<cu-custom bgColor="bg-blue" :isBack="true" v-if="title == '问题诉求情况'">
			<block slot="backText">返回</block>
			<!-- <block slot="content">问题诉求情况</block> -->
		</cu-custom>

		<form @submit="formSubmit" class="cu-list menu">

			<view class="titlebg2">
				<view class="titlet2">企业信息</view>
			</view>


			<view class="textbg">
				<view class="text12">
					企业名称：
				</view>
				<view class="text22">
					 <uni-data-select
					      v-model="companyName"
					      :localdata="companys"
					      @change="getCompany"
					    ></uni-data-select>
				</view>
			</view>

			<view class="textbg">
				<view class="text12">
					属地：
				</view>
				<view class="text22">
					{{company.des1}}
				</view>
			</view>

			<view class="textbg">
				<view class="text12">
					企业负责人：
				</view>
				<view class="text22">
					{{company.lxr}}
				</view>
			</view>

			<view class="textbg">
				<view class="text12">
					负责人号码：
				</view>
				<view class="text22">
					{{company.phone}}
				</view>
			</view>

			<view style="height: 30rpx;background-color: white;"></view>

			<view class="titlebg2" style="margin-top:10rpx ;">
				<view class="titlet2">挂钩干部</view>
			</view>

			<view class="textbg">
				<view class="text12">
					姓名：
				</view>
				<view class="text22">
					{{inputForm.qy.des14}}
				</view>
			</view>

			<view style="height: 30rpx;background-color: white;"></view>

			<view class="titlebg2" style="margin-top:10rpx ;">
				<view class="titlet2">对接方式</view>
			</view>
			<view class="titlebg2">
				<radio-group @change="radioChange">
					<label class="radio">
						<radio value="上门沟通" checked="true" />上门沟通
					</label>
					<label class="radio">
						<radio value="电话联系" />电话联系
					</label>
					<label class="radio">
						<radio value="平台沟通" />平台沟通
					</label>
				</radio-group>
			</view>
			<view class="titlebg2" style="margin-top:10rpx ;">
				<view class="titlet2" style="width: 20%;">记录时间</view>
				<uni-datetime-picker type="date" :v-model="inputForm.contactDate" placeholder="请选择近期与企业沟通时间"
					@change="changeLog" />
			</view>
			<view style="height: 40rpx;"></view>
			<view class="flexC" v-if="canedit">
				<button form-type="submit" class="bt1 cu-btn block bg-blue margin-tb-sm lg">提交</button>
			</view>
			<view style="height: 40rpx;"></view>
		</form>
	</view>
</template>

<script>
	import loginService from '@/api/auth/loginService.js'
	import lyServiceService from '@/api/service/lyServiceService.js'
	export default {
		onShow() {
			this.$auth.checkLogin()
		},
		data() {
			return {
				title: '问题诉求情况',
				inputForm: {
					id: '',
					qy: {
						id: '',
						name: '',
						lxr: '',
						phone: '',
						des14: '',
						des1: '',
						des13: ''
					},
					method: '上门沟通',
					contactDate: ''
				},
				picLists: [],
				canedit: true,
				companys: [],
				companyList: [],
				companyName: '',
				company: {
					id: '',
					name: '',
					lxr: '',
					phone: '',
					des14: '',
					des1: '',
					des13: ''
				},
			}
		},
		async onLoad(query) {
			//新增
			let data2 = await loginService.queryByUserNameList()
			for (var i = 0; i < data2.data.length; i++) {
				this.companys.push({value:data2.data[i].name,text:data2.data[i].name});
				this.companyList.push(data2.data[i]);
			}
			this.inputForm.qy = this.recover(this.inputForm.qy, data2.data[0])
			this.inputForm.id = "";
			// this.company = data2.data[0]
			// this.companyName = data2.data[0].name
		},
		methods: {
			radioChange(e) {
				this.inputForm.method = e.detail.value
			},

			getCompany(e) {
				let company = this.companyList.filter((item) => {
					return item.name.indexOf(e) > -1
				})
				if (company.length == 1) {
					this.company = company[0]
				}

			},

			changeLog(e) {
				this.inputForm.contactDate = e
			},

			formSubmit: function(e) {
				this.inputForm.qy = this.company;
				lyServiceService.save(this.inputForm).then(res => {
					console.log("res", res);
					if (res.statusCode == 200) {
						uni.redirectTo({
							url: '/pages/service/LyService'
						})
					}
				})
			},


		}
	}
</script>
<style>
	/* .file-title) {
	    font-size: 17px !important;
	} */
	input,
	textarea {
		color: #8799a3;
	}

	.input1 {
		background-color: #ffffff;
		padding: 1upx 40upx;
		display: flex;
		align-items: center;
		padding-top: 20upx;
		border-bottom: 1px solid #eee;
	}

	.input1 .title {
		text-align: justify;
		padding-right: 30upx;
		font-size: 30upx;
		position: relative;
		height: 60upx;
		line-height: 60upx;
		border: ;
	}

	.title2 {
		width: 75%;
		text-align: left;
	}

	.input2 {
		flex: 1;
		font-size: 30upx;
		color: #555;
		padding-right: 20upx;
		width: 500rpx;
	}

	.uni-input {}

	.textbg {
		display: flex;
		background-color: white;
		padding-top: 29rpx;
	}

	.text12 {
		width: 200rpx;
		margin-left: 30rpx;
		color: #000000;
		font-size: 29rpx;
	}

	.text2 {
		flex: 1;
		color: #000000;
		font-size: 30rpx;
		padding-bottom: 2rpx;
	}

	.text22 {
		flex: 1;
		color: #666666;
		font-size: 29rpx;
		padding-bottom: 2rpx;
		align-self: flex-end;
	}

	.titlebg2 {
		display: flex;
		background-color: white;
		padding-left: 22rpx;
		padding-top: 35rpx;
		padding-bottom: 25rpx;
		margin-bottom: 2rpx;
	}

	.titlet1 {
		width: 7rpx;
		margin-top: 7rpx;
		margin-bottom: 7rpx;
		background-color: #2752eb;
		margin-right: 8rpx;
	}

	.titlet2 {
		font-weight: 800;
		color: #000;
	}

	.titlebb {
		color: #000000;
		font-weight: 800;
		padding-left: 40rpx;
		background-color: #ffffff;
		padding-top: 20rpx;

	}

	.flexC {
		display: flex;
	}

	.bt1 {
		flex: 1;
		margin: 30rpx;
	}

	.bt2 {
		flex: 1;
		margin: 30rpx;
	}
</style>