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

		</view>
		<!-- <view class="body">
			<p class="p">X轴回零速度：</p>
			<input class="input" type="text" v-model="D420" />
			<button type="primary" class="button" @click="update('D-420',D420)">
				<p class="p2">更新</P>
			</button>
		</view>
		<view class="line2"></view>
		<view class="body">
			<p class="p">X轴爬行速度：</p>
			<input class="input" type="text" v-model="D421" />
			<button type="primary" class="button" @click="update('D-421',D421)">
				<p class="p2">更新</P>
			</button>
		</view>
		<view class="line2"></view>
		<view class="body">
			<p class="p">Y轴回零速度：</p>
			<input class="input" type="text" v-model="D422" />
			<button type="primary" class="button" @click="update('D-422',D422)">
				<p class="p2">更新</P>
			</button>
		</view>
		<view class="line2"></view>
		<view class="body">
			<p class="p">Y轴爬行速度：</p>
			<input class="input" type="text" v-model="D423" />
			<button type="primary" class="button" @click="update('D-423',D423)">
				<p class="p2">更新</P>
			</button>
		</view>
		<view class="line2"></view>
		<view class="body">
			<p class="p">E轴回零速度：</p>
			<input class="input" type="text" v-model="D424" />
			<button type="primary" class="button" @click="update('D-424',D424)">
				<p class="p2">更新</P>
			</button>
		</view>
		<view class="line2"></view>
		<view class="body">
			<p class="p">E轴爬行速度：</p>
			<input class="input" type="text" v-model="D425" />
			<button type="primary" class="button" @click="update('D-425',D425)">
				<p class="p2">更新</P>
			</button>
		</view>
		<view class="line2"></view> -->
		<view class="body">
			<p class="p">X轴加速度：</p>
			<input class="input" type="text" v-model="D426" />
			<button type="primary" class="button" @click="update('D426',D426)">
				<p class="p2">更新</P>
			</button>
		</view>
		<view class="line2"></view>
		<view class="body">
			<p class="p">X轴减速度：</p>
			<input class="input" type="text" v-model="D427" />
			<button type="primary" class="button" @click="update('D427',D427)">
				<p class="p2">更新</P>
			</button>
		</view>
		<view class="line2"></view>
		<view class="body">
			<p class="p">Y轴加速度：</p>
			<input class="input" type="text" v-model="D428" />
			<button type="primary" class="button" @click="update('D428',D428)">
				<p class="p2">更新</P>
			</button>
		</view>
		<view class="line2"></view>
		<view class="body">
			<p class="p">Y轴减速度：</p>
			<input class="input" type="text" v-model="D429" />
			<button type="primary" class="button" @click="update('D429',D429)">
				<p class="p2">更新</P>
			</button>
		</view>
		<view class="line2"></view>
		<view class="body">
			<p class="p">E轴加速度：</p>
			<input class="input" type="text" v-model="D430" />
			<button type="primary" class="button" @click="update('D430',D430)">
				<p class="p2">更新</P>
			</button>
		</view>
		<view class="line2"></view>
		<view class="body">
			<p class="p">E轴加速度：</p>
			<input class="input" type="text" v-model="D431" />
			<button type="primary" class="button" @click="update('D431',D431)">
				<p class="p2">更新</P>
			</button>
		</view>
		<view class="line2"></view>
	</view>
</template>
<script>
	import {
		mapState,
		mapActions,
		mapMutations
	} from 'vuex'
	export default {
		data() {
			return {
				D420: 0,
				D421: 0,
				D422: 0,
				D423: 0,
				D424: 0,
				D425: 0,
				D426: 0,
				D427: 0,
				D428: 0,
				D429: 0,
				D430: 0,
				D431: 0,
			}
		},
		onShow() {
			this.getParam();
		},
		methods: {
			...mapActions('chart', ['getParameters', 'updateParameters']),
			getParam() {
				const param = {};
				param['id'] = uni.getStorageSync("nowEquipmentId");
				param['code'] = '1';
				this.getParameters(param).then(data => {
					var info = data;
					if (info!=null||info!='') {
						for (var i = 0; i < info.length; i++) {
							if(info[i].name=='D-420'){
								this.D420=info[i].val;
							}
							if(info[i].name=='D-421'){
								this.D421=info[i].val;
							}
							if(info[i].name=='D-422'){
								this.D422=info[i].val;
							}
							if(info[i].name=='D-423'){
								this.D423=info[i].val;
							}
							if(info[i].name=='D-424'){
								this.D424=info[i].val;
							}
							if(info[i].name=='D-425'){
								this.D425=info[i].val;
							}
							if(info[i].name=='D-426'){
								this.D426=info[i].val;
							}
							if(info[i].name=='D-427'){
								this.D427=info[i].val;
							}
							if(info[i].name=='D-428'){
								this.D428=info[i].val;
							}
							if(info[i].name=='D-429'){
								this.D429=info[i].val;
							}
							if(info[i].name=='D-430'){
								this.D430=info[i].val;
							}
							if(info[i].name=='D-431'){
								this.D431=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 {
		background-color: #FFFFFF;
		width: 600upx;
		padding: 10upx 10upx 10upx 10upx;
		display: flex;
		flex-direction: row;
		justify-content: flex-start;
		font-size: 32upx;
	}

	.p {
		width: 200upx;
		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>
