<template>
	<view class="appWrapper">
		<form action="">
			<view style="height:30rpx"></view>
			<view class="form-item">
				<view class="title">
					<text class="necessary">*</text>
					户号:
				</view>
				<input name="input" v-model="formMess.account_number"></input>
			</view>
			<view class="form-item">
				<view class="title"><text class="necessary">*</text>流变变比:</view>
				<input name="input" v-model="formMess.rheological_change"></input>
			</view>
			<view class="form-item">
				<view class="title" style="width:240rpx"><text class="necessary">*</text>单路电源容量:</view>
				<input name="input" v-model="formMess.power_capacity"></input>
			</view>
			<view class="form-item">
				<view class="title"><text class="necessary">*</text>线路:</view>
				<!-- <input name="input" v-model="formMess.route_id"></input> -->
				<select name="" id="" filterable clearable v-model="formMess.route_id">
					<option value="0">请选择</option>
					<option :value=item.id v-for="item in routeListData">{{ item.route_name}}</option>
				</select>
				
				
			</view>
			<view class="form-item">
				<view class="title"><text class="necessary">*</text>站点名称:</view>
				<select name="" id="" v-model="formMess.site_id" filterable clearable>
					<option value="0">请选择</option>
					<option :value="item.id"  v-for="item in siteListData">{{ item.site_name}}</option>
				</select>
			</view>
			<view class="form-item">
				<view class="title"><text class="necessary">*</text>监察:</view>
				<select name="" id="" filterable clearable v-model="formMess.supervision_department_id">
					<option value="0">请选择</option>
					<option :value=item.id v-for="item in supervisionListData">{{ item.supervision_name}}</option>
				</select>
			</view>
			
			<view class="info-tit margin-left-xs">
				<text class="cuIcon-titles "></text>
				四防一通
			</view>
			<view class="form-item extraDis">
				<view class="title"><text class="necessary">*</text>电缆孔洞:</view>
				<evan-radio v-model="formMess.cable_hole" label="1" class="margin-right-xl">是</evan-radio>
				<evan-radio v-model="formMess.cable_hole" label="0">否</evan-radio>
			
			</view>
			<view class="form-item extraDis">
				<view class="title"><text class="necessary">*</text>门窗、墙壁破损:</view>
				<evan-radio v-model="formMess.damage" label="1" class="margin-right-xl">是</evan-radio>
				<evan-radio v-model="formMess.damage" label="0">否</evan-radio>
			</view>
			
			<view class="form-item extraDis">
				<view class="title"><text class="necessary">*</text>屋顶墙壁渗漏水:</view>
				<evan-radio v-model="formMess.water_leakage" label="1" class="margin-right-xl">是</evan-radio>
				<evan-radio v-model="formMess.water_leakage" label="0">否</evan-radio>
			</view>
			<view class="form-item extraDis">
				<view class="title"><text class="necessary">*</text>灭火器配置不足:</view>
				<evan-radio v-model="formMess.annihilator_insufficient_configuration" label="1" class="margin-right-xl">是</evan-radio>
				<evan-radio v-model="formMess.annihilator_insufficient_configuration" label="0">否</evan-radio>
			</view>
			<view class="form-item extraDis">
				<view class="title"><text class="necessary">*</text>灭火器超期:</view>
				<evan-radio v-model="formMess.annihilator_overdue" label="1" class="margin-right-xl">是</evan-radio>
				<evan-radio v-model="formMess.annihilator_overdue" label="0">否</evan-radio>
			</view>
			
			<view class="info-tit margin-left-xs">
				<text class="cuIcon-titles margin-right-xs"></text>
				室内环境
			</view>
			<view class="form-item extraDis">
				<view class="title"><text class="necessary">*</text>堆放杂物:</view>
				<evan-radio v-model="formMess.pile_up_sundries" label="1" class="margin-right-xl">是</evan-radio>
				<evan-radio v-model="formMess.pile_up_sundries" label="0">否</evan-radio>
			</view>
			<view class="form-item extraDis">
				<view class="title"><text class="necessary">*</text>积灰严重:</view>
				<evan-radio v-model="formMess.serious_ash_deposition" label="1" class="margin-right-xl">是</evan-radio>
				<evan-radio v-model="formMess.serious_ash_deposition" label="0">否</evan-radio>
			</view>
			<view class="form-item extraDis">
				<view class="title"><text class="necessary">*</text>配电房周围环境潮湿:</view>
				<evan-radio v-model="formMess.around_environment_humid" label="1" class="margin-right-xl">是</evan-radio>
				<evan-radio v-model="formMess.around_environment_humid" label="0">否</evan-radio>
			</view>
			
			<view class="form-item extraDis">
				<view class="title"><text class="necessary">*</text>配电房周围对方杂物:</view>
				<evan-radio v-model="formMess.around_pile_up_sundries" label="1" class="margin-right-xl">是</evan-radio>
				<evan-radio v-model="formMess.around_pile_up_sundries" label="0">否</evan-radio>
			</view>
			
			<view class="info-tit margin-left-xs">
				<text class="cuIcon-titles margin-right-xs"></text>
				电工
			</view>
			<view class="form-item extraDis">
				<view class="title"><text class="necessary">*</text>无电工:</view>
				<evan-radio v-model="formMess.no_electrician" label="1" class="margin-right-xl">是</evan-radio>
				<evan-radio v-model="formMess.no_electrician" label="0">否</evan-radio>
			</view>
			<view class="form-item extraDis">
				<view class="title"><text class="necessary">*</text>电工人数配置不足:</view>
				<evan-radio v-model="formMess.electrician_lack" label="1" class="margin-right-xl">是</evan-radio>
				<evan-radio v-model="formMess.electrician_lack" label="0">否</evan-radio>
			</view>
			<view class="form-item extraDis">
				<view class="title"><text class="necessary">*</text>电工证超期:</view>
				<evan-radio v-model="formMess.overdue_electrician_certificate" label="1" class="margin-right-xl">是</evan-radio>
				<evan-radio v-model="formMess.overdue_electrician_certificate" label="0">否</evan-radio>
			</view>
			
			<!-- 电试 -->
			<view class="info-tit margin-left-xs">
				<text class="cuIcon-titles margin-right-xs"></text>
				电试
			</view>
			<view class="form-item extraDis">
				<view class="title"><text class="necessary">*</text>电试超期:</view>
				<evan-radio v-model="formMess.electric_test_overdue" label="1" class="margin-right-xl">是</evan-radio>
				<evan-radio v-model="formMess.electric_test_overdue" label="0">否</evan-radio>
			</view>
			
			<!-- 设备 -->
			<view class="info-tit margin-left-xs">
				<text class="cuIcon-titles margin-right-xs"></text>
				设备
			</view>
			<view class="form-item extraDis">
				<view class="title">设备老旧(标明出厂或投运日期):</view>
				<input type="text" style="width:35%" v-model="formMess.old_equipment">
			</view>
			
			<!-- 安全工器具 -->
			<view class="info-tit margin-left-xs">
				<text class="cuIcon-titles margin-right-xs"></text>
				安全工器具
			</view>
			<view class="form-item extraDis">
				<view class="title"><text class="necessary">*</text>配置不足（绝缘体）:</view>
				<evan-radio v-model="formMess.blanket_insufficient_configuration" label="1" class="margin-right-xl">是</evan-radio>
				<evan-radio v-model="formMess.blanket_insufficient_configuration" label="0">否</evan-radio>
			</view>
			<view class="form-item extraDis">
				<view class="title"><text class="necessary">*</text>接地线与存放位置编号:</view>
				<evan-radio v-model="formMess.ground_wire" label="1" class="margin-right-xl">是</evan-radio>
				<evan-radio v-model="formMess.ground_wire" label="0">否</evan-radio>
			</view>
			
			<!-- 安全工器具 -->
			<view class="info-tit margin-left-xs">
				<text class="cuIcon-titles margin-right-xs"></text>
				模拟屏
			</view>
			<view class="form-item extraDis">
				<view class="title"><text class="necessary">*</text>模拟屏:</view>
				<evan-radio v-model="formMess.analog_screen" label="1" class="margin-right-xl">是</evan-radio>
				<evan-radio v-model="formMess.analog_screen" label="0">否</evan-radio>
			</view>
			<view class="form-item">
				<view class="title">备注:</view>
				<input type="text" v-model="formMess.remarks">
			</view>
			
			<view class="btn-area submitBottomBtn padding-lr-sm  " style="position:static">
				<button class="bg-blue round  margin-top" @click="addSubmit">提 交 </button>
			</view>
			<br>
		</form>
	</view>
</template>

<script>
	export default {

		data() {
			return {
				
				baseValue: '1',
				
				supervisionListData: [],
				routeListData:[],
				siteListData:[],
				radioOne: 1,
				formMess: {
					"account_number": "",
					"rheological_change": "",
					"power_capacity": "",
					"route_id": 0,
					"site_id": 0,
					"supervision_department_id": 0,
					
					"cable_hole": "0",
					"damage": "0",
					"water_leakage": "0",
					"annihilator_insufficient_configuration": "0",
					"annihilator_overdue": "0",
					
					"pile_up_sundries": "0",
					"serious_ash_deposition": "0",
					"around_environment_humid": "0",
					"around_pile_up_sundries": "0",
					
					"no_electrician": "0",
					"electrician_lack": "0",
					"overdue_electrician_certificate": "0",
					
					"electric_test_overdue": "0",
					
					"old_equipment": "",
					
					"blanket_insufficient_configuration": "0",
					"ground_wire": "0",
					
					
					"analog_screen": "0",
					"remarks": "",
				},


			}
		},
		onLoad: function(option) {
			this.getDataList();
			this.getTitleList();
			this.getRoutrBox();
			console.log('this.formMess.cable_hole')
		console.log(this.formMess.cable_hole)

		},
		methods: {
			
			//线路名称下拉数据请求
			async getRoutrBox(params = {}) {
				const res = await this.$myRequest({
					url: 'Archives/getRoutrBox',
					showLoading: true,
					data: params
				})
				this.routeListData = res.data.data;
				console.log(this.routeListData)
			},
			
			//监察下拉下拉数据请求
			async getTitleList(params = {}) {
				const res = await this.$myRequest({
					url: 'Archives/getsupervisionBox',
					showLoading: true,
					data: params
				})
			
				this.supervisionListData = res.data.data
			},
			//数据请求
			async getDataList(params = {}) {
				const res = await this.$myRequest({
					url: 'BlackoutPlan/getSiteBox',
					showLoading: true,
					data: params
				})
				console.log('res.data.data')
				console.log(res.data.data)
				this.siteListData = res.data.data
			},
			
			radioChange(e) {
				console.log('type:' + e.detail.value);
				this.radioOne = e.detail.value;
			},
			
			//新增提交
			async addSubmit() {
				
				//提交验证
				if (!this.formMess.account_number) {
					uni.showToast({
						title: "请输入户号",
						icon: "none"
					});
					return
				}
				if (!this.formMess.rheological_change) {
					uni.showToast({
						title: "请输入流变变化",
						icon: "none"
					});
					return
				}
				if (!this.formMess.power_capacity) {
					uni.showToast({
						title: "请输入单路电源容量",
						icon: "none"
					});
					return
				}
				if (!this.formMess.route_id) {
					uni.showToast({
						title: "请输入所属线路",
						icon: "none"
					});
					return
				}
				if (!this.formMess.site_id) {
					uni.showToast({
						title: "请选择所属站点",
						icon: "none"
					});
					return
				}
				if (!this.formMess.supervision_department_id) {
					uni.showToast({
						title: "请输入所属监察",
						icon: "none"
					});
					return
				}
				
				
				let res = await this.addArchive({
					"account_number": this.formMess.account_number,
					"rheological_change": this.formMess.rheological_change,
					"power_capacity": this.formMess.power_capacity,
					"route_id": this.formMess.route_id,
					"site_id": this.formMess.site_id,
					"supervision_department_id": this.formMess.supervision_department_id,
					"cable_hole":this.formMess.cable_hole,
					"damage":this.formMess.damage,
					"water_leakage":this.formMess.water_leakage,
					"annihilator_insufficient_configuration":this.formMess.annihilator_insufficient_configuration,
					"annihilator_overdue":this.formMess.annihilator_overdue,
					"pile_up_sundries":this.formMess.pile_up_sundries,
					"serious_ash_deposition":this.formMess.serious_ash_deposition,
					"around_environment_humid":this.formMess.around_environment_humid,
					"around_pile_up_sundries":this.formMess.around_pile_up_sundries,
					"no_electrician":this.formMess.no_electrician,
					"electrician_lack":this.formMess.electrician_lack,
					"overdue_electrician_certificate":this.formMess.overdue_electrician_certificate,
					"electric_test_overdue":this.formMess.electric_test_overdue,
					"blanket_insufficient_configuration":this.formMess.blanket_insufficient_configuration,
					
					"ground_wire":this.formMess.ground_wire,
					"analog_screen":this.formMess.analog_screen,					
					
					"old_equipment": this.formMess.old_equipment,
					"remarks": this.formMess.remarks,
					
			
				})
			
				if (!res.data.flag) {
					uni.showToast({
						title: "添加失败",
						icon: "none"
					});
				} else {
					uni.showToast({
						title: "添加成功",
					});
				}
				setTimeout(() => {
					uni.navigateTo({
						url: '/pages/siteArchive/siteArchive',
			
					});
				}, 1000);
			
			},
			
			addArchive(params = {}) {
				return this.$myRequest({
					url: 'Archives/addArchives',
					data: params
				})
			},
			
			
			
	
	

		}
	}
</script>




<style lang="scss">
	
</style>
