From 0bd15917637362c104eb157d5163f65bf9503780 Mon Sep 17 00:00:00 2001
From: wk
Date: 星期六, 14 九月 2024 16:53:14 +0800
Subject: [PATCH] feat:通行证

---
 pages/customer-page/customer-my/userMange/userManageEdit/userManageEdit.vue |  574 ++++++++++++++++++++++++++++++++++++---------------------
 1 files changed, 364 insertions(+), 210 deletions(-)

diff --git a/pages/customer-page/customer-my/userMange/userManageEdit/userManageEdit.vue b/pages/customer-page/customer-my/userMange/userManageEdit/userManageEdit.vue
index 3d56130..959cab3 100644
--- a/pages/customer-page/customer-my/userMange/userManageEdit/userManageEdit.vue
+++ b/pages/customer-page/customer-my/userMange/userManageEdit/userManageEdit.vue
@@ -1,237 +1,391 @@
 <template>
 	<view class="main">
 		<view class="main-block">
-			<u--form labelPosition="left" :model="model1" :rules="rules" ref="uForm" :errorType="errorType">
-				<u-form-item label="鏈嶅姟閮ㄩ棬" labelWidth="20%" @click="treeOpen" borderBottom prop="deptIds">
-					<u--input placeholder="璇烽�夋嫨鏈嶅姟閮ㄩ棬" v-model="model1.deptIds" class="input" type="text"></u--input>
-					<qian-tree ref="tkitree" :range="department" confirmColor="#4e8af7" :multiple="true" :selectParent="true" title="閫夋嫨閮ㄩ棬" @confirm="treeChooseValue" />
+			<u--form labelPosition="left"
+				:model="model1"
+				:rules="rules"
+				ref="uForm"
+				:errorType="errorType">
+				<u-form-item label="濮撳悕"
+					labelWidth="20%"
+					borderBottom
+					prop="name">
+					<u--input border="none"
+						v-model="model1.name"
+						placeholder="璇疯緭鍏ョ湡瀹炲鍚�"></u--input>
 				</u-form-item>
-				<u-form-item label="韬唤璇�" labelWidth="20%" borderBottom prop="idCard">
-					<u--input border="none" v-model="model1.idCard" placeholder="璇疯緭鍏ヨ韩浠借瘉"></u--input>
+				<u-form-item label="鎵嬫満鍙�"
+					labelWidth="20%"
+					borderBottom
+					prop="phone">
+					<u--input border="none"
+						v-model="model1.phone"
+						placeholder="璇疯緭鍏ユ墜鏈哄彿"></u--input>
 				</u-form-item>
-				<u-form-item label="鐪熷疄濮撳悕" labelWidth="20%" borderBottom prop="name">
-					<u--input border="none" v-model="model1.name" placeholder="璇疯緭鍏ョ湡瀹炲鍚�"></u--input>
+				<u-form-item label="瀵嗙爜"
+					labelWidth="20%"
+					borderBottom
+					prop="password">
+					<u--input border="none"
+						v-model="model1.password"
+						placeholder="璇疯緭鍏ュ瘑鐮�"></u--input>
 				</u-form-item>
-				<u-form-item label="鎵嬫満鍙�" labelWidth="20%" borderBottom prop="phone">
-					<u--input border="none" v-model="model1.phone" placeholder="璇疯緭鍏ユ墜鏈哄彿"></u--input>
-				</u-form-item>
-				<u-form-item label="瀵嗙爜" labelWidth="20%" borderBottom prop="password">
-					<u--input border="none" v-model="model1.password" placeholder="璇疯緭鍏ュ瘑鐮�"></u--input>
-				</u-form-item>
+				  <view class="intensity">
+					<view class="psdText">瀵嗙爜寮哄害</view>
+					<view
+						class="line"
+						:class="[level.includes('low') ? 'low' : '']"></view>
+					<view
+						class="line"
+						:class="[level.includes('middle') ? 'middle' : '']"></view>
+					<view
+						class="line"
+						:class="[level.includes('high') ? 'high' : '']"></view>
+					<div class="warningtext">
+					瀵嗙爜搴旂敱8-16浣嶆暟瀛椼�佸瓧姣嶃�佺鍙风粍鎴愩�傝涓嶈浣跨敤瀹规槗琚寽鍒扮殑瀵嗙爜
+					</div>
+				</view>
 			</u--form>
 		</view>
-		<view class="submit-button"><u-button :text="userId ? '纭淇敼' : '纭鎻愪氦'" type="primary" @click="submitMsg"></u-button></view>
+		<view class="submit-button"><u-button :text="userId ? '纭淇敼' : '纭鎻愪氦'"
+				type="primary"
+				@click="submitMsg"></u-button></view>
 	</view>
 </template>
 
 <script>
-let url = 'http://192.168.31.14:9999';
-import qianTree from '@/components/qian-tree/qian-tree.vue';
-export default {
-	components: {
-		qianTree
-	},
-	data() {
-		return {
-			department: [],
-			model1: {
-				departmentName: '',
-				idCard: '',
-				name: '',
-				phone: '',
-				password: '',
-				deptIds: '',
-				isHostUser: 1
-			},
-			tempdeptIds: '',
-			userId: '',
-			diffdeptId: '',
-			ismodifyDept: false,
-			rules: {
-				deptIds: {
-					type: 'string',
-					required: true,
-					message: '璇疯嚦灏戦�夋嫨涓�涓儴闂�',
-					trigger: ['blur', 'change']
-				},
-				idCard: {
-					type: 'string',
-					required: true,
-					message: '璇峰~鍐欒韩浠借瘉鍙风爜',
-					trigger: ['blur', 'change']
-				},
-				name: {
-					type: 'string',
-					required: true,
-					message: '璇峰~鍐欏鍚�',
-					trigger: ['blur', 'change']
-				},
-				phone: {
-					type: 'string',
-					required: true,
-					message: '璇峰~鍐欐墜鏈哄彿',
-					trigger: ['blur', 'change']
-				},
-				password: {
-					type: 'string',
-					required: true,
-					message: '璇峰~鍐欏瘑鐮�',
-					trigger: ['blur', 'change']
-				}
-			},
-			errorType: 'message'
-		};
-	},
-	onLoad(params) {
-		if (params.userId) {
-			this.userId = params.userId;
-		}
-	},
-	onShow() {
-		if (this.userId) {
-			this.viewInfo();
-		}
-		this.$refs.tkitree._hide();
-	},
-	onReady() {
-		this.$refs.uForm.setRules(this.rules);
-	},
-	created() {
-		this.fetchTree();
-	},
-	methods: {
-		fetchTree() {
-			uni.request({
-				url: `${url}/admin/dept/ownTree`,
-				header: {
-					Authorization: 'Bearer' + ' ' + uni.getStorageSync('token'),
-					CLIENT_TOC: 'Y'
-				},
-				success: res => {
-					this.department = res.data.data;
-				}
-			});
+	let url = 'http://192.168.31.14:9999';
+	import qianTree from '@/components/qian-tree/qian-tree.vue';
+	import { BaseUrl } from '@/api/publicInterface.js'
+	export default {
+		components: {
+			qianTree
 		},
-		viewInfo(v) {
-			uni.showLoading({
-				title: '鍔犺浇涓�'
-			});
-			this.$reqGet('getAppById', { userId: this.userId.toString() }).then(res => {
-				uni.hideLoading();
-				if (res.code == 0) {
-					this.tempdeptIds = res.data.deptIds;
-					if (res.data.deptIds == null) {
-						this.diffdeptId = '鍏ㄩ儴';
-					} else {
-						this.diffdeptId = this.findNameById(this.department, res.data.deptIds.split(',')).join();
-					}
-					this.model1 = {
-						...res.data,
-						password: '',
-						deptIds: this.diffdeptId
-					};
-				} else {
-					this.$u.toast('鍔犺浇澶辫触');
-				}
-			});
+		data() {
+			const checkPassword = (rule, value, callback) => {
+        // let roles = this.$store.getters.roles;//褰撳墠鐢ㄦ埛瑙掕壊id
+        // let passL = 8;
+        // if (roles.concat(1)){
+        //   passL = 10
+        // }
+        let passL = 8;
+        this.level = []
+        if(!value) {
+          return callback()
+        }
+        if(value.length < passL) {
+          return callback(`瀵嗙爜涓嶈兘灏戜簬${passL}浣峘)
+        }
+        if(value.length > 16) {
+          return callback('瀵嗙爜涓嶈兘澶т簬16浣�')
+        }
+        //鏍¢獙鏄暟瀛�
+        const regex1 = /^\d+$/
+        // 鏍¢獙瀛楁瘝
+        const regex2 = /^[A-Za-z]+$/
+        // 鏍¢獙绗﹀彿
+        const regex3 =
+            /^[`~!@#$%^&*()_\-+=<>?:"{}|,.\/;'\\[\]路~锛丂#锟�%鈥︹��&*锛堬級鈥斺�擻-+={}|銆娿�嬶紵锛氣�溾�濄�愩�戙�侊紱鈥�'锛屻�傘�乚+$/;
+        if(regex1.test(value)) {
+          this.level.push('low')
+          return callback('瀵嗙爜寮哄害杩囦綆')
+        }else if(regex2.test(value)) {
+          this.level.push('low')
+          return callback('瀵嗙爜寮哄害杩囦綆')
+        }else if(regex3.test(value)) {
+          this.level.push('low')
+          return callback('瀵嗙爜寮哄害杩囦綆')
+        }else if(/^[A-Za-z\d]+$/.test(value)) {
+          this.level.push('low')
+          this.level.push('middle')
+          return callback('瀵嗙爜寮哄害杩囦綆')
+        }else if(
+            /^[`~!@#$%^&*()_\-+=<>?:"{}|,.\/;'\\[\]路~锛丂#锟�%鈥︹��&*锛堬級鈥斺�擻-+={}|銆娿�嬶紵锛氣�溾�濄�愩�戙�侊紱鈥�'锛屻�傘�乗d]+$/.test(
+                value
+            )
+        ) {
+          this.level.push('low')
+          this.level.push('middle')
+          return callback('瀵嗙爜寮哄害杩囦綆')
+        }else if(
+            /^[`~!@#$%^&*()_\-+=<>?:"{}|,.\/;'\\[\]路~锛丂#锟�%鈥︹��&*锛堬級鈥斺�擻-+={}|銆娿�嬶紵锛氣�溾�濄�愩�戙�侊紱鈥�'锛屻�傘�丄-Za-z]+$/.test(
+                value
+            )
+        ) {
+          this.level.push('low')
+          this.level.push('middle')
+          return callback('瀵嗙爜寮哄害杩囦綆')
+        } else if (
+            /^[`~!@#$%^&*()_\-+=<>?:"{}|,.\/;'\\[\]路~锛丂#锟�%鈥︹��&*锛堬級鈥斺�擻-+={}|銆娿�嬶紵锛氣�溾�濄�愩�戙�侊紱鈥�'锛屻�傘�丄-Za-z\d]+$/.test(
+                value
+            )
+        ) {
+          this.level.push('low')
+          this.level.push('middle')
+          this.level.push('high')
+        }
+        return callback()
+      };
+	  const phone = (rule, value, callback) =>{
+	 		if(/^1[34578]\d{9}$/.test(value) == false){
+                    callback(new Error("璇疯緭鍏ユ纭殑鎵嬫満鍙�"));
+                }else{
+                    callback();
+                }
+	  }
+			return {
+				level:[],
+				department: [],
+				model1: {
+					departmentName: '',
+					idCard: '',
+					name: '',
+					phone: '',
+					password: '',
+					deptIds: '',
+					isHostUser: 1
+				},
+				tempdeptIds: '',
+				userId: '',
+				diffdeptId: '',
+				ismodifyDept: false,
+				rules: {
+					deptIds: {
+						type: 'string',
+						required: true,
+						message: '璇疯嚦灏戦�夋嫨涓�涓儴闂�',
+						trigger: ['blur', 'change']
+					},
+					idCard: {
+						type: 'string',
+						required: true,
+						message: '璇峰~鍐欒韩浠借瘉鍙风爜',
+						trigger: ['blur', 'change']
+					},
+					name: {
+						type: 'string',
+						required: true,
+						message: '璇峰~鍐欏鍚�',
+						trigger: ['blur', 'change']
+					},
+					phone:  [{
+							required: true,
+							message: '璇疯緭鍏ユ墜鏈哄彿',
+							trigger: ['blur', 'change']
+						},
+							{
+							validator: phone,
+							trigger: 'change'
+							}],
+								password: [{
+							required: false,
+							message: '璇疯缃瘑鐮�',
+							trigger: ['blur', 'change']
+						},
+							{
+							validator: checkPassword,
+							trigger: 'change'
+							}],
+				},
+				errorType: 'message'
+			};
 		},
-		treeOpen() {
-			this.$refs.tkitree._show();
-		},
-		treeClose() {
-			this.$refs.tkitree._hide();
-		},
-		treeChooseValue(v) {
-			this.$refs.tkitree._hide();
-			this.model1.deptIds = this.findNameById(this.department, v).join();
-			this.diffdeptId = v.join();
-			this.ismodifyDept = true;
-			this.$refs.uForm.clearValidate('deptIds');
-		},
-		findNameById(tree, idArr) {
-			let result = [];
-
-			function traverse(node, idArr) {
-				if (!node) return;
-				if (idArr.includes(node.id)) {
-					result.push(node.name);
-				}
-				if (node.children && node.children.length > 0) {
-					node.children.forEach(child => {
-						traverse(child, idArr);
-					});
-				}
+		onLoad(params) {
+			if (params.userId) {
+				this.userId = params.userId;
 			}
-
-			tree.forEach(node => {
-				traverse(node, idArr);
-			});
-
-			return result;
 		},
-		submitMsg() {
-			this.$refs.uForm
-				.validate()
-				.then(res => {
-					if (this.userId) {
-						this.model1.deptIds = this.ismodifyDept ? this.diffdeptId : this.tempdeptIds;
-						this.$reqAllJson('appUpdateById', this.model1, { method: 'PUT', 'Content-type': 'application/json' }).then(res => {
-							if (res.code == 0) {
-								this.$u.toast('淇敼鎴愬姛');
-								let timer = setTimeout(() => {
-									uni.navigateBack({
-										delta: 1
-									});
-								}, 500);
-							} else {
-								this.$u.toast('淇敼澶辫触');
-							}
-						});
-					} else {
+		onShow() {
+			if (this.userId) {
+				this.viewInfo();
+			}
+			this.$refs.tkitree._hide();
+		},
+		onReady() {
+			this.$refs.uForm.setRules(this.rules);
+		},
+		created() {
+			this.fetchTree();
+		},
+		methods: {
+			fetchTree() {
+				uni.request({
+					url: `${BaseUrl}/admin/dept/ownTree`,
+					header: {
+						Authorization: 'Bearer' + ' ' + uni.getStorageSync('token'),
+						clientToc: 'Y',
+					    'CLIENT_TOC': 'Y',
+					},
+					success: res => {
+						this.department = res.data.data;
+					}
+				});
+			},
+			viewInfo(v) {
+				uni.showLoading({
+					title: '鍔犺浇涓�'
+				});
+				this.$reqGet('getAppById', { userId: this.userId.toString() }).then(res => {
+					uni.hideLoading();
+					if (res.code == 0) {
+						this.tempdeptIds = res.data.deptIds;
+						if (res.data.deptIds == null) {
+							this.diffdeptId = '鍏ㄩ儴';
+						} else {
+							this.diffdeptId = this.findNameById(this.department, res.data.deptIds.split(','))
+							.join();
+						}
 						this.model1 = {
-							...this.model1,
+							...res.data,
+							password: '',
 							deptIds: this.diffdeptId
 						};
-						this.$reqPost('appSave', this.model1, 'json').then(result => {
-							if (result.code == 0) {
-								this.$u.toast('鎻愪氦鎴愬姛');
-								let timer = setTimeout(() => {
-									uni.navigateBack({
-										delta: 1
-									});
-								}, 500);
-							} else {
-								this.$u.toast(result.msg ? result.msg : '鎻愪氦澶辫触');
-							}
+					} else {
+						this.$u.toast('鍔犺浇澶辫触');
+					}
+				});
+			},
+			treeOpen() {
+				this.$refs.tkitree._show();
+			},
+			treeClose() {
+				this.$refs.tkitree._hide();
+			},
+			treeChooseValue(v) {
+				this.$refs.tkitree._hide();
+				this.model1.deptIds = this.findNameById(this.department, v).join();
+				this.diffdeptId = v.join();
+				this.ismodifyDept = true;
+				this.$refs.uForm.clearValidate('deptIds');
+			},
+			findNameById(tree, idArr) {
+				let result = [];
+
+				function traverse(node, idArr) {
+					if (!node) return;
+					if (idArr.includes(node.id)) {
+						result.push(node.name);
+					}
+					if (node.children && node.children.length > 0) {
+						node.children.forEach(child => {
+							traverse(child, idArr);
 						});
 					}
-				})
-				.catch(error => {
-					console.log(error);
+				}
+
+				tree.forEach(node => {
+					traverse(node, idArr);
 				});
+
+				return result;
+			},
+			submitMsg() {
+				this.$refs.uForm
+					.validate()
+					.then(res => {
+						if (this.userId) {
+							this.model1.deptIds = this.ismodifyDept ? this.diffdeptId : this.tempdeptIds;
+							this.$reqAllJson('appUpdateById', this
+						.model1, { method: 'PUT', 'Content-type': 'application/json' }).then(res => {
+								if (res.code == 0) {
+									this.$u.toast('淇敼鎴愬姛');
+									let timer = setTimeout(() => {
+										uni.navigateBack({
+											delta: 1
+										});
+									}, 500);
+								} else {
+									this.$u.toast('淇敼澶辫触');
+								}
+							});
+						} else {
+							this.model1 = {
+								...this.model1,
+								deptIds: this.diffdeptId
+							};
+							this.$reqPost('appSave', this.model1, 'json').then(result => {
+								if (result.code == 0) {
+									this.$u.toast('鎻愪氦鎴愬姛');
+									let timer = setTimeout(() => {
+										uni.navigateBack({
+											delta: 1
+										});
+									}, 500);
+								} else {
+									this.$u.toast(result.msg ? result.msg : '鎻愪氦澶辫触');
+								}
+							});
+						}
+					})
+					.catch(error => {
+						console.log(error);
+					});
+			}
 		}
-	}
-};
+	};
 </script>
 
-<style lang="scss" scoped>
-.main {
-	width: 100%;
-	&-block {
-		width: 94%;
-		margin: vww(15);
-	}
-	.submit-button {
-		position: relative;
-		bottom: vww(-20);
-		/deep/ .u-button {
-			width: 631rpx;
-			height: 74rpx;
-			border: 2px solid #3b56eb;
-			background-color: #fff;
-			color: #3b56eb;
-			border-radius: 37rpx 37rpx 37rpx 37rpx;
+<style lang="scss"
+	scoped>
+	.main {
+		width: 100%;
+
+		&-block {
+			width: 94%;
+			margin: vww(15);
+		}
+
+		.submit-button {
+			position: relative;
+			bottom: vww(-20);
+
+			/deep/ .u-button {
+				width: 631rpx;
+				height: 74rpx;
+				border: 2px solid #3b56eb;
+				background-color: #fff;
+				color: #3b56eb;
+				border-radius: 37rpx 37rpx 37rpx 37rpx;
+			}
 		}
 	}
-}
-</style>
+	.intensity {
+    width: 100%;
+    margin-top: 10rpx;
+    .psdText {
+      font-size: 14px;
+      margin-right: 10px;
+    }
+
+    .line {
+      display: inline-block;
+      width: 70rpx;
+      height: 8rpx;
+      background: #d8d8d8;
+      border-radius: 6rpx;
+      margin-right: 16rpx;
+
+      &.low {
+        background: #f4664a;
+      }
+
+      &.middle {
+        background: #ffb700;
+      }
+
+      &.high {
+        background: #2cbb79;
+      }
+    }
+
+    .level {
+      margin: 0 32rpx 0 16rpx;
+    }
+
+    .warningtext {
+      color: #5a5a5a;
+      font-size: 24rpx;
+      margin-top: 10rpx;
+    }
+  }
+</style>
\ No newline at end of file

--
Gitblit v1.9.1