Ver código fonte

添加睡眠描述功能

soobin 2 anos atrás
pai
commit
51215bbfbc
3 arquivos alterados com 154 adições e 7 exclusões
  1. 9 1
      common/lang/en.js
  2. 9 1
      common/lang/zh.js
  3. 136 5
      pages/User/equipmentStatusList.vue

+ 9 - 1
common/lang/en.js

@@ -65,6 +65,8 @@ export default {
 		inDoor:'inner door',
 		open:'open',
 		close:'close',
+		confirm:'confirm',
+		cancel:'cancel',
 		openStatus:'Door opening',
 		closeStatus:'Door closing',
 		opensuccess:'open success',
@@ -73,6 +75,7 @@ export default {
 		green:'Green means the machine is normal',
 		sleep:'sleep state:machine sleep',
 		unsleep:'sleep state:did not sleep',
+		sleepDesc:'sleep desc',
 		on:'switch:the machine is turning on',
 		off:'switch:machine shut down',
 		equipmentNo:'equipmentNo',
@@ -84,9 +87,12 @@ export default {
 		tip:'prompt',
 		successReturn:'Sending succeeded',
 		errorReturn:'fail in send',
+		modifiedSuccessfully:'Modified Successfully',
+		modificationFailure:'Modification Failure',
 		rebootTip:'whether or not to reboot?',
 		updateTip:'Execute or not?',
 		sleepTip:'whether or not to sleep?',
+		sleepDescTip:'whether or not to change?',
 		onoffTip:'whether to turn it off?',
 		wuliaoTip:'Are you sure?',
 		onoff:'boot/shut down....',
@@ -104,6 +110,7 @@ export default {
 		look:'look',
 		kaiqi:'on',
 		guanbi:'off',
+		edit:'edit',
 		refreshTime:'last refresh time',
 		volume:'volume',
 		whiteSugar:'whiteSugar',
@@ -114,7 +121,8 @@ export default {
 		water:'water',
 		wasteWater:'wasteWater',
 		buliao:'one click to complete materials',
-		buliaoT:'implement'
+		buliaoT:'implement',
+		suspendBusiness:'Suspend Business'
 	},
 	equipmentStatics:{
 		title:'Machine Sales Ranking',

+ 9 - 1
common/lang/zh.js

@@ -65,12 +65,15 @@ export default {
 		closeStatus:'关闭状态',
 		open:'开门',
 		close:'关门',
+		confirm:'确认',
+		cancel:'取消',
 		opensuccess:'开门成功',
 		title:'机器状态',
 		red:'红色代表机器报警',
 		green:'绿色代表机器正常',
 		sleep:'睡眠状态:已开启睡眠模式',
 		unsleep:'睡眠状态:已关闭睡眠模式',
+		sleepDesc:'睡眠描述',
 		on:'开/关炉头:已开启',
 		off:'开/关炉头:已关闭',
 		equipmentNo:'机器唯一码',
@@ -82,9 +85,12 @@ export default {
 		tip:'提示',
 		successReturn:'发送成功',
 		errorReturn:'发送失败',
+		modifiedSuccessfully:'修改成功',
+		modificationFailure:'修改失败',
 		updateTip:'是否执行操作?',
 		rebootTip:'是否重启?',
 		sleepTip:'是否休眠?',
+		sleepDescTip:'是否确认更改?',
 		onoffTip:'是否关机?',
 		wuliaoTip:'是否补料?',
 		onoff:'开/关机中',
@@ -102,6 +108,7 @@ export default {
 		look:'查看',
 		kaiqi:'开启',
 		guanbi:'关闭',
+		edit:'更改',
 		refreshTime:'最近刷新时间',
 		volume:'音量',
 		whiteSugar:'白糖',
@@ -112,7 +119,8 @@ export default {
 		water:'清水',
 		wasteWater:'废水',
 		buliao:'一键补料',
-		buliaoT:'补料'
+		buliaoT:'补料',
+		suspendBusiness:'暂停营业'
 	},
 	equipmentStatics:{
 		title:'机器销售排行',

+ 136 - 5
pages/User/equipmentStatusList.vue

@@ -122,6 +122,26 @@
 							</view>
 						</view>
 						<view class="line1"></view>
+						<view class="swithBox" v-if="equipment.isSleep">
+							<view class="swichFont2">{{$t('equipmentStatusList.sleepDesc')}}:</view>
+							<input v-if="descShow" class="swichFont3" :value=equipment.sleepDesc @input="getValue" 
+							style="background: #fff" />
+							<span v-else class="swichFont4">{{equipment.sleepDesc==null?"暂停营业":equipment.sleepDesc}}</span>
+							<view v-if="editBtn" class="switch3">
+								<button type="primary" @click="toggleReadOnly" class="button">
+									<p class="p">{{$t('equipmentStatusList.edit')}}</p>
+								</button>
+							</view>
+							<view v-else class="switch2">
+								<button type="primary" @click="confirmDesc(equipment.sleepDesc,equipment.id)" class="button">
+									<p class="p">{{$t('equipmentStatusList.confirm')}}</p>
+								</button>
+								<button style="color:#BEBEBE;" @click="cancelDesc" class="button">
+									<p class="p">{{$t('equipmentStatusList.cancel')}}</p>
+								</button>
+							</view>
+						</view>
+						<view v-if="equipment.isSleep" class="line1"></view>
 						<!-- 一键重启 -->
 						<view class="opendoor"><span>{{$t('equipmentStatusList.reboot')}}:</span>
 							<view class="">
@@ -136,7 +156,7 @@
 							<!-- 已关机 -->
 							<view class="swithBox" v-if="equipment.eqeStatus==0">
 								<view class="swichFont1">{{$t('equipmentStatusList.off')}}</view>
-								<view class="switch1">
+								<view class="switch2">
 									<!-- <switch style="transform:scale(0.65)" checked @change="OnOff(equipment.id,1)" /> -->
 									<button style="color:#BEBEBE;" @click="OnOff(equipment.id,1)" class="button">
 										<p class="p">{{$t('equipmentStatusList.kaiqi')}}</p>
@@ -149,7 +169,7 @@
 							<!-- 已开机 -->
 							<view class="swithBox" v-else>
 								<view class="swichFont1">{{$t('equipmentStatusList.on')}}</view>
-								<view class="switch1">
+								<view class="switch2">
 									<!-- <switch style="transform:scale(0.65)" :checked="onffChecked" @change="OnOff(equipment.id,0)" /> -->
 									<button type="primary" @click="OnOff(equipment.id,1)" class="button">
 										<p class="p">{{$t('equipmentStatusList.kaiqi')}}</p>
@@ -333,6 +353,10 @@
 
 				},
 				input: 0,
+				isReadOnly: true,
+				editBtn:true,
+				sleepDesc:null,
+				descShow:false,
 			}
 		},
 		computed: {
@@ -389,6 +413,79 @@
 						uni.stopPullDownRefresh();
 					}, _ => void uni.stopPullDownRefresh());
 			},
+			
+			getValue: function(event) {
+				// 绕过v-model 获取input输入框的值
+				var value = event.target.value;
+				this.sleepDesc = value;
+			},
+			
+			// 点击更改
+			toggleReadOnly() {
+				this.descShow = true;
+				this.editBtn = false;
+			},
+			
+			// 取消更改
+			cancelDesc() {
+				this.descShow = false;
+				this.editBtn = true;
+			},
+			
+			// 更改睡眠描述
+			confirmDesc(sleepDesc,id) {
+				var that = this;
+				uni.showModal({
+					title: that.$t('equipmentStatusList.tip'),
+					content: that.$t('equipmentStatusList.sleepDescTip'),
+					success: function(res) {
+						if (res.confirm) {
+							var serverurl = that.serverurl;
+							var sleepDescNew = that.sleepDesc;
+							if(sleepDescNew == null||sleepDescNew == '') {
+								if(sleepDesc!=null) {
+									sleepDescNew = sleepDesc;
+								} else {
+									sleepDescNew = that.$t('equipmentStatusList.suspendBusiness');
+								}
+							}
+							var token = uni.getStorageSync("token");
+							uni.request({
+								url: serverurl + '/TEquipmentDesc/updateSleepDesc',
+								data: {
+									"sleepDesc": sleepDescNew,
+									"equipmentId": id
+								},
+								method: "POST",
+								header: {
+									'token': token
+								},
+								success: (res) => {
+									console.log(res.data.code);
+									if (res.data.code) {
+										uni.showModal({
+											title: that.$t('equipmentStatusList.tip'),
+											content: that.$t('equipmentStatusList.modifiedSuccessfully'),
+										})
+										that.descShow = false;
+										that.editBtn = true;
+										that.getEquipmentListData();
+									} else {
+										uni.showModal({
+											title: that.$t('equipmentStatusList.tip'),
+											content: that.$t('equipmentStatusList.modificationFailure'),
+										})
+										that.descShow = false;
+										that.editBtn = true;
+										that.getEquipmentListData();
+									}
+								}
+							});
+						}
+					}
+				})
+			},
+			
 			//查看经纬度
 			lookMap(id, longitude, latitude) {
 				var item = {};
@@ -773,6 +870,8 @@
 						}
 					});
 				} else {
+					that.descShow = false;
+					that.editBtn = true;
 					var serverurl = that.serverurl;
 					var code = code;
 					var equipmentId = id;
@@ -834,7 +933,7 @@
 	}
 
 	.opendoor {
-		/* #ifdef H5 */
+		/* #ifdef H5
 
 		/* #endif */
 		padding-top: 10upx;
@@ -909,20 +1008,52 @@
 
 	.switch1 {
 		display: flex;
+		/* flex-direction: row; */
+		width: 35%;
+		height: 42upx;
+		/* padding-top: 13upx; */
+/* 		padding-left: 132px; */
+		margin-left: auto;
+	}
+	
+	.switch2 {
+		display: flex;
 		flex-direction: row;
+		padding-top: 13upx;
 		width: 35%;
 		height: 42upx;
+		margin-left: auto;
+	}
+	
+	.switch3 {
+		height: 42upx;
 		padding-top: 13upx;
-		padding-left: 72upx;
+		margin-left: auto;
 	}
 
 	.swichFont {
 		width: 85%;
 		padding-top: 12upx;
 	}
+	
+	.swichFont2{
+		width: auto;
+		padding-top: 12upx;
+	}
+	
+	.swichFont3{
+		width: 40%;
+		margin-top: 8px;
+		font-size: 14px;
+	}
+	
+	.swichFont4 {
+		width: auto;
+		padding-top: 12upx;
+	}
 
 	.swichFont1 {
-		width: 55%;
+		width: 60%;
 		padding-top: 12upx;
 	}