<template>
	<view class="">
		<view class="line">

		</view>
		<view class="body">
			<p class="p">自测试模式</p>
			<!-- <input class="input" type="text" v-model="M17" /> -->
			<!-- <button type="primary" class="button" @click="update('M-17',M17)">
				<p class="p2">更新</P>
			</button> -->
			<button type="primary" class="button" @click="update('M17','0')">
				<p class="p2">启动</P>
			</button>
			<button type="primary" class="button" @click="update('M17','1')">
				<p class="p2">关闭</P>
			</button>
		</view>
		<view class="line2"></view>
		<view class="body">
			<p class="p">A轴正转</p>
			<!-- <input class="input" type="text" v-model="M311" /> -->
			<button type="primary" class="button" @click="update('M311','0')">
				<p class="p2">启动</P>
			</button>
			<button type="primary" class="button" @click="update('M311','1')">
				<p class="p2">关闭</P>
			</button>
		</view>
		<view class="line2"></view>
		<view class="body">
			<p class="p">A轴反转</p>
			<!-- <input class="input" type="text" v-model="M312" />
			<button type="primary" class="button" @click="update('M-312',M312)">
				<p class="p2">更新</P>
			</button> -->
			<button type="primary" class="button" @click="update('M312','0')">
				<p class="p2">启动</P>
			</button>
			<button type="primary" class="button" @click="update('M312','1')">
				<p class="p2">关闭</P>
			</button>
		</view>
		<view class="line2"></view>
		<view class="body">
			<p class="p">喷水泵启动</p>
			<!-- <input class="input" type="text" v-model="M313" />
			<button type="primary" class="button" @click="update('M-313',M313)">
				<p class="p2">更新</P>
			</button> -->
			<button type="primary" class="button" @click="update('M313','0')">
				<p class="p2">启动</P>
			</button>
			<button type="primary" class="button" @click="update('M313','1')">
				<p class="p2">关闭</P>
			</button>
		</view>
		<view class="line2"></view>
		<view class="body">
			<p class="p">气泵启动</p>
			<!-- <input class="input" type="text" v-model="M315" />
			<button type="primary" class="button" @click="update('M-315',M315)">
				<p class="p2">更新</P>
			</button> -->
			<button type="primary" class="button" @click="update('M315','0')">
				<p class="p2">启动</P>
			</button>
			<button type="primary" class="button" @click="update('M315','1')">
				<p class="p2">关闭</P>
			</button>
		</view>
		<view class="line2"></view>
		<view class="body">
			<p class="p">清洁消毒喷水泵</p>
			<!-- <input class="input" type="text" v-model="M316" />
			<button type="primary" class="button" @click="update('M-316',M316)">
				<p class="p2">更新</P>
			</button> -->
			<button type="primary" class="button" @click="update('M316','0')">
				<p class="p2">启动</P>
			</button>
			<button type="primary" class="button" @click="update('M316','1')">
				<p class="p2">关闭</P>
			</button>
		</view>
		<view class="line2"></view>
		<view class="body">
			<p class="p">清洗洁厕灵+水</p>
			<!-- <input class="input" type="text" v-model="M317" />
			<button type="primary" class="button" @click="update('M-317',M317)">
				<p class="p2">更新</P>
			</button> -->
			<button type="primary" class="button" @click="update('M317','0')">
				<p class="p2">启动</P>
			</button>
			<button type="primary" class="button" @click="update('M317','1')">
				<p class="p2">关闭</P>
			</button>
		</view>
		<view class="line2"></view>
		<view class="body">
			<p class="p">消毒液+水</p>
			<!-- <input class="input" type="text" v-model="M318" /> -->
			<!-- <button type="primary" class="button" @click="update('M-318',M318)">
				<p class="p2">更新</P>
			</button> -->
			<button type="primary" class="button" @click="update('M318','0')">
				<p class="p2">启动</P>
			</button>
			<button type="primary" class="button" @click="update('M318','1')">
				<p class="p2">关闭</P>
			</button>
		</view>
	</view>
</template>

<script>
	import {
		mapState,
		mapActions,
		mapMutations
	} from 'vuex'
	export default {
		data() {
			return {
				M17: 0,
				M311: 0,
				M312: 0,
				M313: 0,
				M315: 0,
				M316: 0,
				M317: 0,
				M318: 0,
			}
		},
		onShow() {
			this.getParam();
		},
		methods: {
			...mapActions('chart', ['getParameters', 'updateParameters']),
			getParam() {
				const param = {};
				param['id'] = uni.getStorageSync("nowEquipmentId");
				param['code'] = '0';
				this.getParameters(param).then(data => {
					var info = data;
					if (info!=null||info!='') {
						for (var i = 0; i < info.length; i++) {
							if(info[i].name=='M-17'){
								this.M17=info[i].val;
							}
							if(info[i].name=='M-311'){
								this.M311=info[i].val;
							}
							if(info[i].name=='M-312'){
								this.M312=info[i].val;
							}
							if(info[i].name=='M-313'){
								this.M313=info[i].val;
							}
							if(info[i].name=='M-315'){
								this.M315=info[i].val;
							}
							if(info[i].name=='M-316'){
								this.M316=info[i].val;
							}
							if(info[i].name=='M-317'){
								this.M317=info[i].val;
							}
							if(info[i].name=='M-318'){
								this.M318=info[i].val;
							}
						}
					}
			
				}, _ => void uni.stopPullDownRefresh());
			},
			update(name, val) {
				const param = {};
				param['id'] = uni.getStorageSync("nowEquipmentId");
				param['name'] = name;
				param['val'] = val;
				this.updateParameters(param).then(data => {
					if (data == 'SUCCESS') {
						uni.showToast({
							title: '修改成功',
							duration: 1000
						});
					}
				}, _ => void uni.stopPullDownRefresh());
			},
		},
	}
</script>

<style>
	.line {
		height: 50upx;
	}

	.line2 {
		height: 10upx;
	}

	.body {
		padding-top: 10upx;
		background-color: #FFFFFF;
		width: 550upx;
		padding: 10upx 10upx 10upx 10upx;
		display: flex;
		flex-direction: row;
		justify-content: flex-start;
		font-size: 32upx;
	}

	.p {
		width: 250upx;
		padding-top: 3upx;
		text-align: right;
	}

	.input {
		width: 200upx;
		box-shadow: 0upx 0upx 20upx #D3D3D3;
		border-radius: 5upx;
	}

	.button {
		width: 120upx;
		height: 60upx;
		text-align: left;
		border-radius: 10upx;

	}

	.p2 {
		font-size: 30upx;
		/* #ifndef H5 */
		padding-top: 3upx;
		/* #endif */
		position: absolute;
		/* 水平居中 */
		left: 50%;
		-webkit-transform: translateX(-50%);
		transform: translateX(-50%);
	}
</style>
