heyang 1 ano atrás
pai
commit
cd9faae860
2 arquivos alterados com 51 adições e 10 exclusões
  1. 50 9
      pages/gasBottle/gasUse/gasUse.vue
  2. 1 1
      pages/manageWorkbench.vue

+ 50 - 9
pages/gasBottle/gasUse/gasUse.vue

@@ -107,9 +107,11 @@
 				endYear: 0,
 				timeStr:'',
 				usageTimeUnit:'分钟',
+				currentDate:'',//开始时间默认当前时间
             }
         },
         onLoad(option) {
+			this.currentDateStartFun()
 			this.currentDateFun()
 			this.initTime()
 			if(option.beaconTag){
@@ -122,6 +124,7 @@
         },
 		mounted(){
 		  this.getInfo()
+		  
 		 
 		},
         methods: {
@@ -130,6 +133,17 @@
 				this.startYear= date.getFullYear(); //获取完整的年份(4位)
 				this.endYear= date.getFullYear()+70; 
 			},
+			//当前时间年月日时分
+			currentDateStartFun(){
+				var self = this;
+				let yy = new Date().getFullYear();
+				let mm = new Date().getMonth()+1;
+				let dd = new Date().getDate();
+				let hh = new Date().getHours();
+				let mf = new Date().getMinutes()<10 ? '0'+new Date().getMinutes() : new Date().getMinutes();
+				let ss = new Date().getSeconds()<10 ? '0'+new Date().getSeconds() : new Date().getSeconds();
+				self.currentDate=yy+'-'+mm+'-'+dd+' '+hh+':'+mf;
+			},
 			initTime(){
 				let date = new Date();
 				let endYear = date.getFullYear();
@@ -150,16 +164,40 @@
 			},
 			//开始时间
 			changeDateTime(e) {
-			    this.dateTime = e.detail.value;
-			    this.form.usageStartTime= this.createTimeStr(this.dateTimeArray,this.dateTime);
+				this.dateTime = e.detail.value;
+				let start= this.createTimeStr(this.dateTimeArray,this.dateTime);
+				if(new Date(start).getTime()>new Date(this.form.usageEndTime).getTime()){
+					 uni.showToast({
+						title: '结束时间不能小于开始时间',
+						icon:"none",
+						mask:true,
+						duration: 2000
+					});
+				}else{
+					this.form.usageStartTime= start;
+				}
+			   
 			    //ios时间不能用'-'解析成时间戳
 			 },
 			 //结束时间
 			 changeDateTime2(e) {
-			     this.dateTime = e.detail.value;
-			     this.form.usageEndTime= this.createTimeStr(this.dateTimeArray,this.dateTime);
-			     //ios时间不能用'-'解析成时间戳
-				 this.durationFun();//使用时长
+				 this.dateTime = e.detail.value;
+				 let end= this.createTimeStr(this.dateTimeArray,this.dateTime);
+				 
+				 if(new Date(this.form.usageStartTime).getTime()>new Date(end).getTime()){
+					 uni.showToast({
+						title: '结束时间不能小于开始时间',
+						icon:"none",
+						mask:true,
+						duration: 2000
+					});
+				}else{
+					this.form.usageEndTime= end
+					//ios时间不能用'-'解析成时间戳
+					this.durationFun();//使用时长
+				}
+				 
+			     
 			  },
 			/*年,月切换时重新更新计算*/
 			changeDateTimeColumn(e) {
@@ -288,8 +326,8 @@
 			    this.imgList.splice(index,1);
 			},
 			async getInfo(){
-				let _this=this;
-				const {data} = await airbottleStockFindByBeaconTag({BeaconTag:_this.beaconTag});
+				let self=this;
+				const {data} = await airbottleStockFindByBeaconTag({BeaconTag:self.beaconTag});
 				if(data.code==200){
 					for(let b=0;b<this.gasBottleSpecification.length;b++){
 						if(this.gasBottleSpecification[b].dictValue==data.data.size){
@@ -301,7 +339,10 @@
 							data.data.levelName=this.gasBottleLevel[t].dictLabel
 						}
 					}
-					_this.form=data.data;
+					self.form=data.data;
+					this.$set(this.form,'usageStartTime',self.currentDate);
+					
+					console.log(self.currentDate)
 					
 				}
 			},

+ 1 - 1
pages/manageWorkbench.vue

@@ -40,7 +40,7 @@
     </view> -->
     <view class=big-icon-button-box>
 		<!-- 气瓶管理 -->
-		<view class="big-icon-button-box_l">
+		<view class="big-icon-button-box_l" @click="goPage('gasManage')">
 			<!-- <img  class="big-icon-button-box_bg" src="@/images/img_bg_qpgl.png" @click="goPage('gasManage')"> -->
 			<view class="big-icon-button-box_t1">气瓶管理</view>
 			<view class="big-icon-button-box_t2">安全第一   预防为主</view>