Kaynağa Gözat

优化器状态列表和修改设备名称

soobin 2 yıl önce
ebeveyn
işleme
b6ed9b73fb

+ 91 - 22
packageA/pages/user/equipmentName.vue

@@ -3,9 +3,9 @@
 		<view class="xiugai">
 			{{$t('equipmentname.title')}}
 		</view>
-		<view v-for="(list,index) in listName" :key="index" class="body">
+		<view v-for="(list,index) in equipmentList" :key="index" class="body">
 			<view class="input-two">
-				<input :id=list.id type="text" class="input" @focus="setStyle()" @blur="setStyle2()" :value=list.name @input="getValue" />
+				<input :id=list.id type="text" class="input" @focus="setStyle()" @blur="setStyle2()" :value="list.name==null? list.clientId:list.name" @input="getValue" />
 				<p id="p2" class="p2" :style="{display:showOrNo}">如:粤A张先生1</p>
 			</view>
 			<view class="button2">
@@ -15,6 +15,10 @@
 			</view>
 		
 		</view>
+		<view v-if="btnShow" class="button-container">
+			<button v-if="upBtn" class="left-button" :disabled="isLoading" @click="previousPage">{{$t('equipmentStatusList.previousPage')}}</button>
+			<button v-if="nextBtn" class="right-button" :disabled="isLoading" @click="nextPage">{{$t('equipmentStatusList.nextPage')}}</button>
+		</view>
 	</view>
 </template>
 
@@ -32,6 +36,7 @@
 				name: '',
 				show: false,
 				listName: [],
+				equipmentList: [],
 				value: null,
 				id: null,
 				parm: {
@@ -41,7 +46,12 @@
 				showOrNo: null,
 				avatarUrl: null,
 				weixinUp: false,
-				weixinDown: true
+				weixinDown: true,
+				btnShow:false, // 按钮显示
+				upBtn:false, // 上一页按钮
+				nextBtn:true, // 下一页按钮
+				equipmentTotal:0, // 设备总数
+				isLoading: false, //是否加载中
 			};
 		},
 		onPullDownRefresh() {
@@ -52,25 +62,38 @@
 		onShow() {
 			uni.setNavigationBarTitle({title: this.$t('equipmentname.title')});
 			// uni.startPullDownRefresh();
-			var me = this;
-			var name = uni.getStorageSync("name");
-			me.name = name;
-			var listName = uni.getStorageSync("listName");
-			me.listName = listName;
-			if (listName != '' && listName != null) {
-				var adminId = listName[0].adminId;
-				if (adminId != '1' && adminId != null) {
-					me.show = true;
-				}
-			}
-			var newparm = uni.getStorageSync("newparm");
-			if (newparm.toString().length > 1) {
-				if (newparm.avatarUrl.length > 1) {
-					this.avatarUrl = newparm.avatarUrl;
-					this.weixinUp = true;
-					this.weixinDown = false;
-				}
+			this.globalUser = uni.getStorageSync("globalUser");
+			this.globalUser.offset = 0;
+			this.globalUser.limit = 10;
+			var token = uni.getStorageSync("token");
+			if (token.length > 1) {
+				this.getEquipmentListData();
+				this.upBtn = false;
+				this.nextBtn = true;
+			} else {
+				uni.reLaunch({
+					url: '../Login/Login',
+				});
 			}
+			// var me = this;
+			// var name = uni.getStorageSync("name");
+			// me.name = name;
+			// var listName = uni.getStorageSync("listName");
+			// me.listName = listName;
+			// if (listName != '' && listName != null) {
+			// 	var adminId = listName[0].adminId;
+			// 	if (adminId != '1' && adminId != null) {
+			// 		me.show = true;
+			// 	}
+			// }
+			// var newparm = uni.getStorageSync("newparm");
+			// if (newparm.toString().length > 1) {
+			// 	if (newparm.avatarUrl.length > 1) {
+			// 		this.avatarUrl = newparm.avatarUrl;
+			// 		this.weixinUp = true;
+			// 		this.weixinDown = false;
+			// 	}
+			// }
 	
 		},
 		onLoad() {
@@ -92,7 +115,45 @@
 				this.parm.name = value;
 				this.parm.id = id;
 			},
-			...mapActions('chart', ['updata']),
+			getEquipmentListData() {
+				this.isLoading = true;
+				this.getEquipmentListByUser(this.globalUser)
+					.then(data => {
+						this.equipmentList = data[0].equipmentList;
+						this.equipmentTotal = data[0].equipmentTotal;
+						if(this.equipmentTotal > this.globalUser.limit) {
+							this.btnShow = true;
+						}
+						console.log(this.equipmentList);
+						this.isLoading = false;
+					}, _ => void uni.stopPullDownRefresh());
+			},
+			// 更改按钮显示状态
+			changeBtnshow() {
+				if(this.globalUser.offset != 0) {
+					this.upBtn = true;
+				} else {
+					this.upBtn = false;
+				}
+				if(this.globalUser.offset + this.globalUser.limit < this.equipmentTotal) {
+					this.nextBtn = true;
+				} else {
+					this.nextBtn = false;
+				}
+			},
+			// 点击上一页
+			previousPage() {
+				this.globalUser.offset = this.globalUser.offset - this.globalUser.limit;
+				this.getEquipmentListData();
+				this.changeBtnshow();
+			},
+			// 点击下一页
+			nextPage() {
+				this.globalUser.offset = this.globalUser.offset + this.globalUser.limit;
+				this.getEquipmentListData();
+				this.changeBtnshow();
+			},
+			...mapActions('chart', ['updata', 'getEquipmentListByUser']),
 			updata1() {
 				if (this.parm.id != null) {
 					this.updata(this.parm)
@@ -248,4 +309,12 @@
 		height: 50upx;
 		border: 1px;
 	}
+	.button-container {
+	  display: flex;
+	}
+	
+	.left-button,
+	.right-button {
+	  flex: 1;
+	}
 </style>

+ 23 - 6
pages/User/equipmentStatusList.vue

@@ -308,15 +308,13 @@
 					</view>
 				</uni-collapse-item>
 			</view>
-			<view v-show="btnShow" class="button-container">
-				<button v-show="globalUser.offset != 0" class="left-button" :disabled="isLoading" @click="previousPage">{{$t('equipmentStatusList.previousPage')}}</button>
-				<button v-show="this.globalUser.offset + this.globalUser.limit < this.equipmentTotal" class="right-button" :disabled="isLoading" @click="nextPage">{{$t('equipmentStatusList.nextPage')}}</button>
+			<view v-if="btnShow" class="button-container">
+				<button v-if="upBtn" class="left-button" :disabled="isLoading" @click="previousPage">{{$t('equipmentStatusList.previousPage')}}</button>
+				<button v-if="nextBtn" class="right-button" :disabled="isLoading" @click="nextPage">{{$t('equipmentStatusList.nextPage')}}</button>
 			</view>
 		</uni-collapse>
 	</view>
-
 </template>
-
 <script>
 	import {
 		mapState,
@@ -363,6 +361,8 @@
 				sleepDesc:null,
 				descShow:false,
 				btnShow:false, // 按钮显示
+				upBtn:false, // 上一页按钮
+				nextBtn:true, // 下一页按钮
 				equipmentTotal:0, // 设备总数
 				isLoading: false, //是否加载中
 			}
@@ -388,6 +388,8 @@
 			var token = uni.getStorageSync("token");
 			if (token.length > 1) {
 				this.getEquipmentListData();
+				this.upBtn = false;
+				this.nextBtn = true;
 			} else {
 				uni.reLaunch({
 					url: '../Login/Login',
@@ -401,7 +403,7 @@
 				return merchant.name ? merchant.name : merchant.username;
 			},
 			getEquipmentTitle(equipment) {
-				return equipment.name ? equipment.name : '暂无名称';
+				return equipment.name ? equipment.name : equipment.clientId;
 			},
 			getEquipmentListData() {
 				this.isLoading = true;
@@ -432,15 +434,30 @@
 						uni.stopPullDownRefresh();
 					}, _ => void uni.stopPullDownRefresh());
 			},
+			// 更改按钮显示状态
+			changeBtnshow() {
+				if(this.globalUser.offset != 0) {
+					this.upBtn = true;
+				} else {
+					this.upBtn = false;
+				}
+				if(this.globalUser.offset + this.globalUser.limit < this.equipmentTotal) {
+					this.nextBtn = true;
+				} else {
+					this.nextBtn = false;
+				}
+			},
 			// 点击上一页
 			previousPage() {
 				this.globalUser.offset = this.globalUser.offset - this.globalUser.limit;
 				this.getEquipmentListData();
+				this.changeBtnshow();
 			},
 			// 点击下一页
 			nextPage() {
 				this.globalUser.offset = this.globalUser.offset + this.globalUser.limit;
 				this.getEquipmentListData();
+				this.changeBtnshow();
 			},
 			
 			getValue: function(event) {

+ 23 - 10
pages/User/merchantList.vue

@@ -10,9 +10,9 @@
 							<uni-list-item :title="getEquipmentTitle(equipment)" @click="openByEquipment(merchantList[0].name,equipment.id)" />
 						</view>
 					</uni-list>
-					<view v-show="btnShow" class="button-container">
-						<button v-show="globalUser.offset != 0" class="left-button" :disabled="isLoading" @click="previousPage">{{$t('equipmentStatusList.previousPage')}}</button>
-						<button v-show="this.globalUser.offset + this.globalUser.limit < this.equipmentTotal" class="right-button" :disabled="isLoading" @click="nextPage">{{$t('equipmentStatusList.nextPage')}}</button>
+					<view v-if="btnShow" class="button-container">
+						<button v-if="upBtn" class="left-button" :disabled="isLoading" @click="previousPage">{{$t('equipmentStatusList.previousPage')}}</button>
+						<button v-if="nextBtn" class="right-button" :disabled="isLoading" @click="nextPage">{{$t('equipmentStatusList.nextPage')}}</button>
 					</view>
 				</uni-collapse>
 			</view>
@@ -59,6 +59,8 @@
 				pname:null,
 				list: [],
 				btnShow:false, // 按钮显示
+				upBtn:false, // 上一页按钮
+				nextBtn:true, // 下一页按钮
 				equipmentTotal:0, // 设备总数
 				isLoading: false, //是否加载中
 			}
@@ -66,12 +68,6 @@
 		computed: {
 			...mapState(['loginUser']),
 		},
-		// onReachBottom() {
-		// 	if(this.onReach) {
-		// 		this.globalUser.offset = this.globalUser.offset + this.globalUser.limit;
-		// 		this.getEquipmentListData();
-		// 	}
-		// },
 		onShow() {
 			uni.setNavigationBarTitle({title: this.$t('merchantList.title')});
 			uni.setTabBarItem({ index: 1,text: this.$t('tabs.tab2')});
@@ -81,7 +77,9 @@
 			this.globalUser.limit = 20;
 			var token = uni.getStorageSync("token");
 			if (token.length>1) {
-				this.getEquipmentListData();						
+				this.getEquipmentListData();
+				this.upBtn = false;
+				this.nextBtn = true;
 			}else{
 				uni.reLaunch({
 					url: '../Login/Login',
@@ -184,15 +182,30 @@
 				}
 				
 			},
+			// 更改按钮显示状态
+			changeBtnshow() {
+				if(this.globalUser.offset != 0) {
+					this.upBtn = true;
+				} else {
+					this.upBtn = false;
+				}
+				if(this.globalUser.offset + this.globalUser.limit < this.equipmentTotal) {
+					this.nextBtn = true;
+				} else {
+					this.nextBtn = false;
+				}
+			},
 			// 点击上一页
 			previousPage() {
 				this.globalUser.offset = this.globalUser.offset - this.globalUser.limit;
 				this.getEquipmentListData();
+				this.changeBtnshow();
 			},
 			// 点击下一页
 			nextPage() {
 				this.globalUser.offset = this.globalUser.offset + this.globalUser.limit;
 				this.getEquipmentListData();
+				this.changeBtnshow();
 			},
 		}
 	}