From 920ad7c1062549f8ff6e5034f84a90c725dc89dd Mon Sep 17 00:00:00 2001
From: doum <doum>
Date: 星期二, 23 九月 2025 16:40:27 +0800
Subject: [PATCH] H5静态化
---
admin/src/components/system/user/ResetPwdWindow.vue | 119 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 119 insertions(+), 0 deletions(-)
diff --git a/admin/src/components/system/user/ResetPwdWindow.vue b/admin/src/components/system/user/ResetPwdWindow.vue
new file mode 100644
index 0000000..48c7080
--- /dev/null
+++ b/admin/src/components/system/user/ResetPwdWindow.vue
@@ -0,0 +1,119 @@
+<template>
+ <GlobalWindow
+ :visible.sync="visible"
+ :confirm-working="isWorking"
+ width="576px"
+ title="閲嶇疆瀵嗙爜"
+ @confirm="confirm"
+ >
+ <p class="tip" v-if="user != null">涓虹敤鎴� <em>{{user.realname}}</em> 閲嶇疆瀵嗙爜</p>
+ <el-form :model="form" ref="form" :rules="rules">
+ <el-form-item label="鏂板瘑鐮�" prop="password" required>
+ <el-input v-model="form.password" type="password" placeholder="璇疯緭鍏ユ柊瀵嗙爜" maxlength="30" show-password></el-input>
+ </el-form-item>
+ </el-form>
+ </GlobalWindow>
+</template>
+
+<script>
+import GlobalWindow from '@/components/common/GlobalWindow'
+import { resetPwd } from '@/api/system/user'
+export default {
+ name: 'ResetPwdWindow',
+ components: { GlobalWindow },
+ data () {
+ return {
+ isWorking: false,
+ visible: false,
+ user: null,
+ form: {
+ password: ''
+ },
+ rules: {
+ password: [
+ { required: true, message: '璇疯緭鍏ュ瘑鐮�', trigger: 'blur' },
+ { validator: this.validatePassword, trigger: 'blur' }
+ ]
+ }
+ }
+ },
+ methods: {
+ validatePassword (rule, value, callback) {
+ if (!value) {
+ callback(new Error('璇疯緭鍏ュ瘑鐮�'))
+ } else {
+ const lengthValid = /^.{6,20}$/.test(value)
+ const hasLetter = /[a-zA-Z]/.test(value)
+ const hasNumber = /[0-9]/.test(value)
+ const hasSpecial = /[!@#$%^&*(),.?":{}|<>]/.test(value)
+
+ const typesCount = [hasLetter, hasNumber, hasSpecial].filter(Boolean).length
+
+ if (!lengthValid) {
+ callback(new Error('瀵嗙爜闀垮害闇�涓�6鍒�20涓瓧绗�'))
+ } else if (typesCount < 2) {
+ callback(new Error('瀵嗙爜闇�鍖呭惈瀛楁瘝銆佹暟瀛楀強鐗规畩瀛楃涓殑鑷冲皯涓ょ'))
+ } else {
+ callback() // 楠岃瘉閫氳繃
+ }
+ }
+ },
+ /**
+ * 鎵撳紑绐楀彛
+ *
+ * @param user 鐩爣鐢ㄦ埛
+ */
+ open (user) {
+ this.user = user
+ this.visible = true
+ this.$nextTick(() => {
+ this.$refs.form.resetFields()
+ })
+ },
+ /**
+ * 纭閲嶇疆瀵嗙爜
+ */
+ confirm () {
+ if (this.isWorking) {
+ return
+ }
+ this.$refs.form.validate((valid) => {
+ if (!valid) {
+ return
+ }
+ this.isWorking = true
+ resetPwd({
+ id: this.user.id,
+ password: this.form.password
+ })
+ .then(() => {
+ this.$tip.apiSuccess('瀵嗙爜閲嶇疆鎴愬姛')
+ this.visible = false
+ this.$emit('success')
+ })
+ .catch(e => {
+ this.$tip.apiFailed(e)
+ })
+ .finally(() => {
+ this.isWorking = false
+ })
+ })
+ }
+ }
+}
+</script>
+
+<style scoped lang="scss">
+@import "@/assets/style/variables.scss";
+// 瑙掕壊閰嶇疆
+.global-window {
+ .tip {
+ margin-bottom: 12px;
+ em {
+ font-style: normal;
+ color: $primary-color;
+ font-weight: bold;
+ }
+ }
+}
+</style>
--
Gitblit v1.9.3