Эх сурвалжийг харах

未完全解决微信消防站新增人员问题

liyangzheng 1 жил өмнө
parent
commit
e277572b7c

+ 1 - 0
pagesA/fire/fire_station/add_fireStation/add_fireStation.vue

@@ -224,6 +224,7 @@
 								})
 							}, 0);
 						});
+						localStorage.removeItem('empList')
 					})
 					.catch(err => {
 						// console.log('err错误信息为:', err);

+ 64 - 26
pagesA/fire/fire_station/people_fireStation/people_fireStation.vue

@@ -80,7 +80,7 @@
 					</u--form>
 					<div class="useBox">
 						<button class="antherBtn" @click="makeSureEdit">确认修改</button>
-						
+
 						<button class="antherBtn" @click="showModal = false">取消</button>
 					</div>
 				</view>
@@ -196,37 +196,65 @@
 				})
 			},
 			addNewPeople() {
-				const MAX_LENGTH = 1; // 假设你想限制数组最大长度为6
-				if (this.membersList.length < MAX_LENGTH) {
-					const newPerson = {
-						name: '',
-						userNum: '',
-						phone: '',
-						worker: '',
-						// 其他字段
-					};
-					this.membersList.push(newPerson);
-				} else {
-					// 达到最大数量,给出提示或执行其他操作
-					uni.showToast({
-						title: '只支持一位添加',
-						icon: 'none', // 图标类型,可选值:'success', 'loading', 'none'
-						duration: 2000, // 持续时间,单位为毫秒,默认值为 1500
-						mask: false, // 是否显示透明蒙层,防止触摸穿透,默认值为 false
-						success() {
-							// console.log('toast消息提示显示成功');
-						},
-						fail(err) {
-							// console.error('toast消息提示显示失败', err);
-						}
-					});
+				if (this.$route.query.addId) {
+					const MAX_LENGTH = 1; // 假设你想限制数组最大长度为6
+					if (this.membersList.length < MAX_LENGTH) {
+						const newPerson = {
+							name: '',
+							userNum: '',
+							phone: '',
+							worker: '',
+							// 其他字段
+						};
+						this.membersList.push(newPerson);
+					} else {
+						// 达到最大数量,给出提示或执行其他操作
+						uni.showToast({
+							title: '只支持一位添加',
+							icon: 'none', // 图标类型,可选值:'success', 'loading', 'none'
+							duration: 2000, // 持续时间,单位为毫秒,默认值为 1500
+							mask: false, // 是否显示透明蒙层,防止触摸穿透,默认值为 false
+							success() {
+								// console.log('toast消息提示显示成功');
+							},
+							fail(err) {
+								// console.error('toast消息提示显示失败', err);
+							}
+						});
+					}
+				}else{
+					const MAX_LENGTH = 1; // 假设你想限制数组最大长度为6
+					if (this.membersList.length < MAX_LENGTH) {
+						const newPerson = {
+							name: '',
+							userNum: '',
+							phone: '',
+							worker: '',
+							// 其他字段
+						};
+						this.membersList.push(newPerson);
+					} else {
+						// 达到最大数量,给出提示或执行其他操作
+						uni.showToast({
+							title: '超出限制',
+							icon: 'none', // 图标类型,可选值:'success', 'loading', 'none'
+							duration: 2000, // 持续时间,单位为毫秒,默认值为 1500
+							mask: false, // 是否显示透明蒙层,防止触摸穿透,默认值为 false
+							success() {
+								// console.log('toast消息提示显示成功');
+							},
+							fail(err) {
+								// console.error('toast消息提示显示失败', err);
+							}
+						});
+					}
 				}
 			},
 
 			addSure() {
 				if (this.$route.query.addId) {
 					if (!this.userRules && !this.phoneRules && !this.nameRules) {
-						console.log(this.membersList[0].worker,'988');
+						// console.log(this.membersList[0].worker,'988');
 						creatFirePeople({
 							empName: this.membersList[0].name,
 							empType: this.membersList[0].worker,
@@ -266,6 +294,16 @@
 						});
 					}
 				} else {
+					// let ground = localStorage.getItem('empList')
+					// if (ground) {
+					// 	ground = JSON.parse(ground)
+					// 	ground.push({
+					// 		...this.membersList[0]
+					// 	})
+					// 	localStorage.setItem('empList', JSON.stringify(ground))
+					// } else {
+					// 	localStorage.setItem("empList", JSON.stringify(this.membersList))
+					// }
 					localStorage.setItem("empList", JSON.stringify(this.membersList))
 					uni.navigateBack({
 						delta: 1