<template>
	<view>
		<view class="white">
			<view class="title">
				<text class="param">参数修正</text>
				<view class="tiao"></view>
			</view>

			<!-- 输入框WDXZ -->
			<view>
				<uni-popup ref="inputDialogWDXZ" type="dialog">
					<uni-popup-dialog ref="inputClose" mode="input" title="(输入范围: -50 ~ 50)" :value="formData.WD1_XZ"
						placeholder="输入范围: -50 ~ 50的值!" @confirm="dialogInputConfirmWDXZ"></uni-popup-dialog>
				</uni-popup>
			</view>
			<!-- 输入框SDXZ -->
			<view>
				<uni-popup ref="inputDialogSDXZ" type="dialog">
					<uni-popup-dialog ref="inputClose" mode="input" title="(输入范围: -100 ~ 100)" :value="formData.SD1_XZ"
						placeholder="输入范围: -100 ~ 100的值!" @confirm="dialogInputConfirmSDXZ"></uni-popup-dialog>
				</uni-popup>
			</view>

			<!-- 输入框JRP -->
			<view>
				<uni-popup ref="inputDialogJRP" type="dialog">
					<uni-popup-dialog ref="inputClose" mode="input" title="(输入范围: -100 ~ 100)" :value="formData.JR_P"
						placeholder="输入范围: -100 ~ 100的值!" @confirm="dialogInputConfirmJRP"></uni-popup-dialog>
				</uni-popup>
			</view>
			<!-- 输入框JRI -->
			<view>
				<uni-popup ref="inputDialogJRI" type="dialog">
					<uni-popup-dialog ref="inputClose" mode="input" title="(输入范围: -100 ~ 100)" :value="formData.JR_I"
						placeholder="输入范围: -100 ~ 100的值!" @confirm="dialogInputConfirmJRI"></uni-popup-dialog>
				</uni-popup>
			</view>
			<!-- 输入框ZLP -->
			<view>
				<uni-popup ref="inputDialogZLP" type="dialog">
					<uni-popup-dialog ref="inputClose" mode="input" title="(输入范围: -100 ~ 100)" :value="formData.ZL_P"
						placeholder="输入范围: -100 ~ 100的值!" @confirm="dialogInputConfirmZLP"></uni-popup-dialog>
				</uni-popup>
			</view>
			<!-- 输入框ZLI -->
			<view>
				<uni-popup ref="inputDialogZLI" type="dialog">
					<uni-popup-dialog ref="inputClose" mode="input" title="(输入范围: -100 ~ 100)" :value="formData.ZL_I"
						placeholder="输入范围: -100 ~ 100的值!" @confirm="dialogInputConfirmZLI"></uni-popup-dialog>
				</uni-popup>
			</view>
			<!-- 输入框JSP -->
			<view>
				<uni-popup ref="inputDialogJSP" type="dialog">
					<uni-popup-dialog ref="inputClose" mode="input" title="(输入范围: -100 ~ 100)" :value="formData.JS_P"
						placeholder="输入范围: -100 ~ 100的值!" @confirm="dialogInputConfirmJSP"></uni-popup-dialog>
				</uni-popup>
			</view>
			<!-- 输入框JSI -->
			<view>
				<uni-popup ref="inputDialogJSI" type="dialog">
					<uni-popup-dialog ref="inputClose" mode="input" title="(输入范围: -100 ~ 100)" :value="formData.JS_I"
						placeholder="输入范围: -100 ~ 100的值!" @confirm="dialogInputConfirmJSI"></uni-popup-dialog>
				</uni-popup>
			</view>
			<!-- 输入框CSP -->
			<view>
				<uni-popup ref="inputDialogCSP" type="dialog">
					<uni-popup-dialog ref="inputClose" mode="input" title="(输入范围: -100 ~ 100)" :value="formData.CS_P"
						placeholder="输入范围: -100 ~ 100的值!" @confirm="dialogInputConfirmCSP"></uni-popup-dialog>
				</uni-popup>
			</view>
			<!-- 输入框CSI -->
			<view>
				<uni-popup ref="inputDialogCSI" type="dialog">
					<uni-popup-dialog ref="inputClose" mode="input" title="(输入范围: -100 ~ 100)" :value="formData.CS_I"
						placeholder="输入范围: -100 ~ 100的值!" @confirm="dialogInputConfirmCSI"></uni-popup-dialog>
				</uni-popup>
			</view>

			<form>
				<view class="setmenu">
					<view class="setItem">
						<view class="text">
							<text>排风温度修正</text>
						</view>
						<view class="input" @click="inputDialogToggleWDXZ()">
							<input style="margin-left: 20rpx;" placeholder="请输入" v-model="formData.WD1_XZ" />
							<view class="danwei">
								<text style="margin-left: 10rpx;">℃</text>
							</view>
						</view>
					</view>
					<view class="setItem">
						<view class="text">
							<text>排风湿度修正</text>
						</view>
						<view class="input" @click="inputDialogToggleSDXZ()">
							<input style="margin-left: 20rpx;" placeholder="请输入" v-model="formData.SD1_XZ" />
							<view class="danwei"> <text style="margin-left: 14rpx;">%</text></view>
						</view>
					</view>

					<view class="setItem">
						<view class="text">
							<text>加热比例</text>
						</view>
						<view class="input" @click="inputDialogToggleJRP()">
							<input style="margin-left: 20rpx;" placeholder="请输入" v-model="formData.JR_P" />
						</view>
					</view>
					<view class="setItem">
						<view class="text">
							<text>加热积分</text>
						</view>
						<view class="input" @click="inputDialogToggleJRI()">
							<input style="margin-left: 20rpx;" placeholder="请输入" v-model="formData.JR_I" />
						</view>
					</view>
					<view class="setItem">
						<view class="text">
							<text>降温比例</text>
						</view>
						<view class="input" @click="inputDialogToggleZLP()">
							<input style="margin-left: 20rpx;" placeholder="请输入" v-model="formData.ZL_P" />
						</view>
					</view>
					<view class="setItem">
						<view class="text">
							<text>降温积分</text>
						</view>
						<view class="input" @click="inputDialogToggleZLI()">
							<input style="margin-left: 20rpx;" placeholder="请输入" v-model="formData.ZL_I" />
						</view>
					</view>
					<view class="setItem">
						<view class="text">
							<text>加湿比例</text>
						</view>
						<view class="input" @click="inputDialogToggleJSP()">
							<input style="margin-left: 20rpx;" placeholder="请输入" v-model="formData.JS_P" />
						</view>
					</view>
					<view class="setItem">
						<view class="text">
							<text>加湿积分</text>
						</view>
						<view class="input" @click="inputDialogToggleJSI()">
							<input style="margin-left: 20rpx;" placeholder="请输入" v-model="formData.JS_I" />
						</view>
					</view>
					<view class="setItem">
						<view class="text">
							<text>除湿比例</text>
						</view>
						<view class="input" @click="inputDialogToggleCSP()">
							<input style="margin-left: 20rpx;" placeholder="请输入" v-model="formData.CS_P" />
						</view>
					</view>
					<view class="setItem">
						<view class="text">
							<text>除湿积分</text>
						</view>
						<view class="input" @click="inputDialogToggleCSI()">
							<input style="margin-left: 20rpx;" placeholder="请输入" v-model="formData.CS_I" />
						</view>
					</view>

					<view class="stopButton">
						<button class="button" @tap="HFCC()"
							:class="{'active_button': formData.HF_CC == 0}">恢复出厂设定</button>
					</view>

				</view>

			</form>

			<view class="anniu">
				<image class="anniu" src="../../static/设备菜单/前往列表@2x.png" @tap="back"></image>
			</view>




		</view>



	</view>
</template>

<script>
	export default {
		data() {
			return {
				formData: {
					ZL_P: '0.0', //制冷回路增益P
					ZL_I: '0.0', //制冷积分时间I
					CS_P: '0.0', //除湿回路增益P
					CS_I: '0.0', //除湿积分时间I
					JR_P: '0.0', //加热回路增益P
					JR_I: '0.0', //加热积分时间I
					JS_P: '0.0', //加湿回路增益P
					JS_I: '0.0', //加湿积分时间I
					WD1_XZ: '0.0', //排风温度修正(单位为℃)
					SD1_XZ: '0.0', //排风湿度修正(单位为%RH)

					HF_CC: '0', //恢复出厂
				}
			}
		},

		onLoad() {
			this.getWDXZ()
			this.getSDXZ()
			this.getJR_I()
			this.getJR_P()
			this.getJW_I()
			this.getJW_P()
			this.getJS_I()
			this.getJS_P()
			this.getCS_I()
			this.getCS_P()

		},

		methods: {
			//修改设置
			//WDXZ
			inputDialogToggleWDXZ() {
				this.$refs.inputDialogWDXZ.open()
			},
			async dialogInputConfirmWDXZ(val) {
				this.formData.WD1_XZ = val;
				this.updateWDXZ()
				console.log(this.formData.WD1_XZ);
			},
			async updateWDXZ(e) {
				let vm = this;
				let url = uni.$api.deviceParam.updateParam;
				let data = {
					id: "235",
					sn: "CK1",
					name: "WD1_XZ",
					value: this.formData.WD1_XZ

				};

				let res = await uni.$http.get(url, data);

				console.log(res);
			},

			//SDXZ
			inputDialogToggleSDXZ() {
				this.$refs.inputDialogSDXZ.open()
			},
			async dialogInputConfirmSDXZ(val) {
				this.formData.SD1_XZ = val;
				this.updateSDXZ()
				console.log(this.formData.SD1_XZ);
			},
			async updateSDXZ(e) {
				let vm = this;
				let url = uni.$api.deviceParam.updateParam;
				let data = {
					id: "287",
					sn: "CK1",
					name: "SD1_XZ",
					value: this.formData.SD1_XZ
				};

				let res = await uni.$http.get(url, data);

				console.log(res);
			},

			//JRP
			inputDialogToggleJRP() {
				this.$refs.inputDialogJRP.open()
			},
			async dialogInputConfirmJRP(val) {
				this.formData.JR_P = val;
				this.updateJRP()
				console.log(this.formData.JR_P);
			},
			async updateJRP(e) {
				let vm = this;
				let url = uni.$api.deviceParam.updateParam;
				let data = {
					id: "226",
					sn: "CK1",
					name: "JR_P",
					value: this.formData.JR_P
				};

				let res = await uni.$http.get(url, data);

				console.log(res);
			},
			//JRI
			inputDialogToggleJRI() {
				this.$refs.inputDialogJRI.open()
			},
			async dialogInputConfirmJRI(val) {
				this.formData.JR_I = val;
				this.updateJRI()
				console.log(this.formData.JR_I);
			},
			async updateJRI(e) {
				let vm = this;
				let url = uni.$api.deviceParam.updateParam;
				let data = {
					id: "220",
					sn: "CK1",
					name: "JR_I",
					value: this.formData.JR_I
				};

				let res = await uni.$http.get(url, data);

				console.log(res);
			},
			//ZLP
			inputDialogToggleZLP() {
				this.$refs.inputDialogZLP.open()
			},
			async dialogInputConfirmZLP(val) {
				this.formData.ZL_P = val;
				this.updateZLP()
				console.log(this.formData.ZL_P);
			},
			async updateZLP(e) {
				let vm = this;
				let url = uni.$api.deviceParam.updateParam;
				let data = {
					id: "275",
					sn: "CK1",
					name: "ZL_P",
					value: this.formData.ZL_P
				};

				let res = await uni.$http.get(url, data);

				console.log(res);
			},
			//ZLI
			inputDialogToggleZLI() {
				this.$refs.inputDialogZLI.open()
			},
			async dialogInputConfirmZLI(val) {
				this.formData.ZL_I = val;
				this.updateZLI()
				console.log(this.formData.ZL_I);
			},
			async updateZLI(e) {
				let vm = this;
				let url = uni.$api.deviceParam.updateParam;
				let data = {
					id: "236",
					sn: "CK1",
					name: "ZL_I",
					value: this.formData.ZL_I
				};

				let res = await uni.$http.get(url, data);

				console.log(res);
			},
			//JSP
			inputDialogToggleJSP() {
				this.$refs.inputDialogJSP.open()
			},
			async dialogInputConfirmJSP(val) {
				this.formData.JS_P = val;
				this.updateJSP()
				console.log(this.formData.JS_P);
			},
			async updateJSP(e) {
				let vm = this;
				let url = uni.$api.deviceParam.updateParam;
				let data = {
					id: "304",
					sn: "CK1",
					name: "JS_P",
					value: this.formData.JS_P
				};

				let res = await uni.$http.get(url, data);

				console.log(res);
			},
			//JSI
			inputDialogToggleJSI() {
				this.$refs.inputDialogJSI.open()
			},
			async dialogInputConfirmJSI(val) {
				this.formData.JS_I = val;
				this.updateJSI()
				console.log(this.formData.JS_I);
			},
			async updateJSI(e) {
				let vm = this;
				let url = uni.$api.deviceParam.updateParam;
				let data = {
					id: "299",
					sn: "CK1",
					name: "JS_I",
					value: this.formData.JS_I
				};

				let res = await uni.$http.get(url, data);

				console.log(res);
			},

			//CSP
			inputDialogToggleCSP() {
				this.$refs.inputDialogCSP.open()
			},
			async dialogInputConfirmCSP(val) {
				this.formData.CS_P = val;
				this.updateCSP()
				console.log(this.formData.CS_P);
			},
			async updateCSP(e) {
				let vm = this;
				let url = uni.$api.deviceParam.updateParam;
				let data = {
					id: "240",
					sn: "CK1",
					name: "CS_P",
					value: this.formData.CS_P
				};

				let res = await uni.$http.get(url, data);

				console.log(res);
			},

			//CSI
			inputDialogToggleCSI() {
				this.$refs.inputDialogCSI.open()
			},
			async dialogInputConfirmCSI(val) {
				this.formData.CS_I = val;
				this.updateCSI()
				console.log(this.formData.CS_I);
			},
			async updateCSI(e) {
				let vm = this;
				let url = uni.$api.deviceParam.updateParam;
				let data = {
					id: "217",
					sn: "CK1",
					name: "CS_I",
					value: this.formData.CS_I
				};

				let res = await uni.$http.get(url, data);

				console.log(res);
			},

			async HFCC(e) {
				this.formData.HF_CC == 1 ? this.formData.HF_CC = 0 : this.formData.HF_CC = 1;

				let vm = this;
				let url = uni.$api.deviceParam.updateParam;
				let data = {
					id: "237",
					value: this.formData.HF_CC,
					name: "HF_CC",
					sn: "CK1"
				};

				let res = await uni.$http.get(url, data);
				console.log(res.data.data.value);
			},

			back() {
				uni.navigateTo({
					url: '/pages/device/deviceInfo/deviceInfo'
				})
			},

			async getWDXZ(e) {
				let vm = this;
				let url = uni.$api.deviceParam.detail;
				let data = {
					id: "235",
				};

				let res = await uni.$http.get(url, data);

				this.formData.WD1_XZ = res.data.data.deviceParam.value;
			},
			async getSDXZ(e) {
				let vm = this;
				let url = uni.$api.deviceParam.detail;
				let data = {
					id: "287",
				};

				let res = await uni.$http.get(url, data);

				this.formData.SD1_XZ = res.data.data.deviceParam.value;
			},
			async getJR_P(e) {
				let vm = this;
				let url = uni.$api.deviceParam.detail;
				let data = {
					id: "226",
				};

				let res = await uni.$http.get(url, data);

				this.formData.JR_P = res.data.data.deviceParam.value;
			},
			async getJR_I(e) {
				let vm = this;
				let url = uni.$api.deviceParam.detail;
				let data = {
					id: "220",
				};

				let res = await uni.$http.get(url, data);

				this.formData.JR_I = res.data.data.deviceParam.value;
			},
			async getJW_P(e) {
				let vm = this;
				let url = uni.$api.deviceParam.detail;
				let data = {
					id: "275",
				};

				let res = await uni.$http.get(url, data);

				this.formData.ZL_P = res.data.data.deviceParam.value;
			},
			async getJW_I(e) {
				let vm = this;
				let url = uni.$api.deviceParam.detail;
				let data = {
					id: "236",
				};

				let res = await uni.$http.get(url, data);

				this.formData.ZL_I = res.data.data.deviceParam.value;
			},
			async getJS_P(e) {
				let vm = this;
				let url = uni.$api.deviceParam.detail;
				let data = {
					id: "304",
				};


				let res = await uni.$http.get(url, data);

				this.formData.JS_P = res.data.data.deviceParam.value;
			},
			async getJS_I(e) {
				let vm = this;
				let url = uni.$api.deviceParam.detail;
				let data = {
					id: "299",
				};

				let res = await uni.$http.get(url, data);

				this.formData.JS_I = res.data.data.deviceParam.value;
			},
			async getCS_P(e) {
				let vm = this;
				let url = uni.$api.deviceParam.detail;
				let data = {
					id: "240",
				};

				let res = await uni.$http.get(url, data);

				this.formData.CS_P = res.data.data.deviceParam.value;
			},
			async getCS_I(e) {
				let vm = this;
				let url = uni.$api.deviceParam.detail;
				let data = {
					id: "217",
				};

				let res = await uni.$http.get(url, data);

				this.formData.CS_I = res.data.data.deviceParam.value;
			}
		}
	}
</script>

<style>
	.button {
		background: #007AFF;
		color: white;
		width: 654rpx;
		margin-left: 24rpx;
		margin-top: 44rpx;
	}

	.text {
		margin-top: 40rpx;
		margin-bottom: 16rpx;
		color: #444546;
		font-size: 26rpx;
	}

	.input {
		width: 320rpx;
		height: 98rpx;
		background-color: #eaeaea;
		display: flex;
		flex-direction: row;
		align-items: center;
		border-radius: 6rpx;
		border: 1px solid #eaeaea;
	}

	.danwei {
		width: 78rpx;
		height: 98rpx;
		background-color: white;
		display: flex;
		align-items: center;
	}

	.setmenu {
		display: flex;
		flex-wrap: wrap;
	}

	.active_button {
		background-color: crimson;
	}

	.setItem {
		margin-left: 20rpx;
	}

	.white {
		width: 702rpx;
		height: 1230rpx;
		margin-left: 24rpx;
		margin-top: 24rpx;
		border-radius: 10rpx;
		background-color: white;
	}

	.title {
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	.tiao {
		width: 60px;
		height: 3px;
		margin-top: 20rpx;
		background: #007AFF;
	}

	.param {
		font-size: 38rpx;
		font-weight: 550;
		margin-top: 40rpx;
	}

	.anniu {
		width: 116rpx;
		height: 116rpx;
		float: right;
		margin-top: 20rpx;
	}
</style>
