<template>
	<view class="app">
		<view class="">

		</view>
		<view class="formlist">
			<view class="titles">企业基本信息</view>
			<view class="item">
				<view class="itemdata">单位注册地址</view>
				<view class="">
					<!-- <u-input v-model="datalist.dwzcdz" :type="type" :border="border" height="100" class="inputs" :style="datalist.dwzcdz ? '' : 'background:#F5F5F5'"/> -->
					<u-input v-model="datalist.dwzcdz" :type="type" :border="border" height="100" class="inputs"/>
				</view>
			</view>
			<view class="item">
				<view class="itemdata">企业规模</view>
				<view class="">
					<u-input v-model="datalist.dwgm" :border="border" height="100" class="inputs" type="select"
						@click="showSex = true" />
				</view>

				<u-action-sheet :list="list" v-model="showSex" @click="actionSheetCallback"></u-action-sheet>
			</view>
			<view class="item">
				<view class="itemdata">上属单位(或主管)</view>
				<view class="">
					<u-input v-model="datalist.ssdw" :type="type" :border="border" height="100" class="inputs" />
				</view>
			</view>
			<view class="item">
				<view class="itemdata">法定代表人</view>
				<view class="">
					<u-input v-model="datalist.legelName" :type="type" :border="border" height="100" class="inputs" />
				</view>
			</view>
			<view class="item">
				<view class="itemdata">法定代表人电话</view>
				<view class="">
					<u-input v-model="datalist.legelPhone" :type="type" :border="border" height="100" class="inputs" />
				</view>
			</view>
			<view class="item">
				<view class="itemdata">职业卫生管理机构</view>
				<view class="">
					<u-input v-model="datalist.zywsgljg" :border="border" height="100" class="inputs"
						type="select" @click="showhealth = true" />
				</view>
				<u-action-sheet :list="listhealth" v-model="showhealth" @click="action"></u-action-sheet>

			</view>
		</view>
		<view class="formlist">
			<view class="titles">职业健康/职业卫生</view>
			<view class="itemzhiye">
				<view class="itemdata1">职业卫生管理人数</view>
			</view>
			<view class="itemzhiye">
				<view class="heathy">
					<view class="heathyitem">
						专职
					</view>
					<view class="uinput">
						<u-input v-model="datalist.zywsglrsZz" :type="type" :border="border" height="100"
							class="inputs1" />
					</view>
				</view>
				<view class="heathy">
					<view class="heathyitem">
						兼职
					</view>
					<view class="uinput">
						<u-input v-model="datalist.zywsglrsJz" :type="type" :border="border" height="100"
							class="inputs1" />
					</view>
				</view>
			</view>
			<view class="itemzhiye">
				<view class="itemdata1">职业健康检查人数(含外委)</view>
			</view>
			<view class="itemzhiye">
				<view class="heathy">
					<view class="heathyitem">
						上岗
					</view>
					<view class="uinput">
						<u-input v-model="datalist.zyjkjcSg" :type="type" :border="border" height="100"
							class="inputs1" />
					</view>
				</view>
				<view class="heathy">
					<view class="heathyitem">
						在岗
					</view>
					<view class="uinput">
						<u-input v-model="datalist.zyjkjcZg" :type="type" :border="border" height="100"
							class="inputs1" />
					</view>
				</view>
				<view class="heathy">
					<view class="heathyitem">
						离岗
					</view>
					<view class="uinput">
						<u-input v-model="datalist.zyjkjcLg" :type="type" :border="border" height="100"
							class="inputs1" />
					</view>
				</view>
			</view>
			<view class="item">
				<view class="itemdata2">劳动者总人数(含外委)</view>
				<view class="">
					<u-input v-model="datalist.dwzcrs" :type="type" :border="border" height="100" class="inputs" disabled/>
				</view>

			</view>
			<view class="item">
				<view class="itemdata2">接触职业病危害总人数(含外委)</view>
				<view class="">
					<u-input v-model="datalist.dwjhrs" :type="type" :border="border" height="100" class="inputs" disabled/>
				</view>
			</view>
			<view class="itemzhiye">
				<view class="itemdata1">职业病累计人数</view>
			</view>
			<view class="itemzhiye">
				<view class="heathy">
					<view class="heathyitem">
						目前在岗
					</view>
					<view class="uinput">
						<u-input v-model="datalist.zybljrsMqzg" :type="type" :border="border" height="100"
							class="inputs1" />
					</view>
				</view>
				<view class="heathy">
					<view class="heathyitem">
						历年累计
					</view>
					<view class="uinput">
						<u-input v-model="datalist.zybljrsLnlj" :type="type" :border="border" height="100"
							class="inputs1" />
					</view>
				</view>
			</view>
			<view class="item">
				<view class="itemdata2">职业健康管理状况等级</view>
				<view class="">
					<u-input v-model="datalist.level" :type="type" :border="border" height="100" class="inputs" disabled/>
				</view>

			</view>
			<view class="item">
				<view class="itemdata2">职业病危害暴露风险等级</view>
				<view class="">
					<u-input v-model="datalist.zybblfx" :type="type" :border="border" height="100" class="inputs" disabled/>
				</view>

			</view>
			<view class="item">
				<view class="itemdata2">职业病危害综合风险类别</view>
				<view class="">
					<u-input v-model="datalist.qydj" :type="type" :border="border" height="100" class="inputs" disabled/>
				</view>
			</view>
		</view>
		<view class="formlist">
			<view class="titles">总结</view>
			<view class="item">
				<view class="itemdata">本次评估情况概述</view>
				<view class="">
					<u-input v-model="datalist.qkfgs" :type="type" :border="border" height="100" class="inputs" placeholder="主要包括单位职业病防治工作概况、综合风险评估过程、存在问题及改正措施方案等情况。(输入长度255个字符)"/>
				</view>
			</view>
		</view>
		<view class="but">
			<view class="sub" @tap="submitdata()">
				提交
			</view>
			<view class="res" @tap="res()">
				重置
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getQyDataItem,
		saveQyData
	} from '@/api/perfect/perfect.js'
	export default {
		data() {
			return {
				// value:'1',
				showSex: false,
				showhealth: false,
				// value: '主要包括单位职业病防治工作概况、综合风险评估过程、存在问题及改正措施方案等情况。(输入长度255个字符)',
				type: 'text',
				border: true,
				listhealth: [{
						value: 0,
						text: '无'
					},
					{
						value: 1,
						text: '有'

					}

				],
				list: [{
						value: 1,
						text: '大'
					},

					{
						value: 2,
				 	// value="2"
						text: '中'

					},
					{
						value: 3,

						text: '小'

					},
					{
						value: 4,
						text: '微'

					}

				],
				datalist: {
					dwzcdz: '',
					dwgm: '',
					ssdw: '',
					legelName: '',
					legelPhone: '',
					zywsgljg: '',
					zywsglrsZz: '',
					zywsglrsJz: '',
					zyjkjcSg: '',
					zyjkjcZg: '',
					zyjkjcLg: '',
					dwzcrs: '',
					dwjhrs: '',
					zybljrsMqzg: '',
					zybljrsLnlj: '',
					zybblfx: '',
					qydj: '',
					id:'',
				},
			}
		},
		onShow() {
			this.getQyData();

		},
		methods: {
			actionSheetCallback(index) {
				console.log('111', index)
				uni.hideKeyboard();
				this.datalist.dwgm = this.list[index].text;
				// this.list= this.list[index].value;

			},
			action(index) {
				console.log('33',index)
				this.datalist.zywsgljg = this.listhealth[index].text;

			},


			getQyData() {
				getQyDataItem().then(res => {
					this.datalist = res.data
					//  下面这一步 多余哈
					this.datalist.id = res.data.id
					if (res.data.dwgm == '1') {
						this.datalist.dwgm = '大'
					} else if (res.data.dwgm == '2') {
						this.datalist.dwgm = '中'
					} else if (res.data.dwgm == '3') {
						this.datalist.dwgm = '小'
					} else if (res.data.dwgm == '4') {
						this.datalist.dwgm = '微'
					}
					if (res.data.zywsgljg == '0') {
						this.datalist.zywsgljg = '无'

					} else if (res.data.zywsgljg == '1') {
						this.datalist.zywsgljg = '有'
					}
				})
			},
			// 提交
			submitdata() {
				console.log(this.datalist,'打印datalist')

				if (this.datalist.dwgm == '大') {
					this.datalist.dwgm = 1
				} else if (this.datalist.dwgm == '中') {
					this.datalist.dwgm = 2
				} else if (this.datalist.dwgm == '小') {
					this.datalist.dwgm = 3
				} else {
					this.datalist.dwgm = 4
				}

				if(this.datalist.zywsgljg == '无'){
					this.datalist.zywsgljg = 0
				}
				else if (this.datalist.zywsgljg == '有') {
					this.datalist.zywsgljg = 1
				}
				saveQyData(this.datalist).then(res => {
					uni.showToast({
						title: "提交成功",
						duration: 2000,
						icon: "none",
					});

				})
				uni.switchTab({
					url: '/pages/management/management'
				})

			},
			// 重置
			res() {
				this.datalist = [];

			},
		}
	}
</script>


<style lang="scss">
	//css函数 声明函数
	@function tovmin($rpx) {
		//$rpx为需要转换的字号
		@return #{$rpx * 100 / 750}vmin;
	}
	.app {
		
		/* font-family: DengXian; */
		color: #C3C1C1;
		font-weight: 400;
		height: 100vh;

		::v-deep .uni-input-wrapper {
			font-size: tovmin(28);
		}
		::v-deep .u-input{
			width: tovmin(400);
			height: tovmin(90);
		}
		::v-deep .app[data-v-4ad6e9bc] .uni-input-input{
			font-size: tovmin(28);

		}
		// ::v-deep .uni-input-input{
		// 	font-size: tovmin(28);
		// }


		.formlist {
			.itemzhiye {
				display: flex;
				width: 100%;
				margin-top: 3%;

				.heathy {
					display: flex;
				}
			}

		}

		.titles {
			font-size: tovmin(35);
			color: black;
			margin-top: 3%;
			margin-left: 2%;
			width: 95%;
			height: tovmin(60);
			line-height: tovmin(60);
			padding-left: tovmin(10);

			// border-bottom: #C3C1C1 1rpx solid;
			background-color: #EAF2FD;

		}

		.inputs {
			// font-size: tovmin(80);
			width: tovmin(400);
			height: tovmin(90);
			margin-left: 7%;
			background-color: #F7F3F4;
		}

		.inputs1 {
			width: tovmin(100);
			height: tovmin(90);
			background-color: #F7F3F4;
		}

		.item {
			display: flex;
			margin-top: 4%;
		}

		.itemdata {
			height: tovmin(90);
			width: 35%;
			line-height: tovmin(90);
			font-size: tovmin(30);
			text-align: right;
			color: black;
			margin-left: 3%;
			word-wrap: break-word;
			word-break: normal;

		}

		.itemdata1 {
			height: tovmin(90);
			width: 60%;
			line-height: tovmin(90);
			font-size: tovmin(30);
			color: black;
			margin-left: 3%;

		}

		.itemdata2 {
			height: tovmin(90);
			width: 35%;
			font-size: tovmin(30);
			text-align: right;
			color: black;
			margin-left: 3%;

		}

		.itemdatazy {
			height: tovmin(90);
			width: 35%;
			line-height: tovmin(90);
			font-size: tovmin(30);
			text-align: right;
			color: black;
			margin-left: 3%;

		}

		.heathyitem {
			height: tovmin(90);
			line-height: tovmin(90);
			color: #000;
			margin-left: tovmin(30);
			font-size: tovmin(30);

		}

		.uinput {
			margin-left: tovmin(40);
		}

		.but {
			font-size: tovmin(30);
			display: flex;
			justify-content: space-around;
			margin-top: tovmin(30);
			// background-color: red;
			margin-bottom: tovmin(50);
			.res {
				font-size: tovmin(30);
				width: tovmin(170);
				height: tovmin(70);
				line-height: tovmin(70);
				text-align: center;
				color: #fff;
				background-color: #3C9CFF;
				border-radius: tovmin(10);
			}
			.sub {
				font-size: tovmin(30);
				width: tovmin(170);
				height: tovmin(70);
				line-height: tovmin(70);
				text-align: center;
				color: #fff;
				background-color: #3C9CFF;
				border-radius: tovmin(10);
			}
		}
	}
</style>
