|
@@ -0,0 +1,119 @@
|
|
|
+<template>
|
|
|
+ <div>
|
|
|
+ <v-form ref="passwordRef" style="width: 370px;">
|
|
|
+ <v-text-field
|
|
|
+ v-model="query.email"
|
|
|
+ placeholder="请输入企业邮箱"
|
|
|
+ variant="outlined"
|
|
|
+ density="compact"
|
|
|
+ color="primary"
|
|
|
+ prepend-inner-icon="mdi-email-outline"
|
|
|
+ :rules="[v=> !!v || '请输入企业邮箱', v=> checkEmail(v)]"
|
|
|
+ ></v-text-field>
|
|
|
+ <v-text-field
|
|
|
+ v-model="query.password"
|
|
|
+ placeholder="请输入新密码"
|
|
|
+ variant="outlined"
|
|
|
+ density="compact"
|
|
|
+ color="primary"
|
|
|
+ prepend-inner-icon="mdi-lock-outline"
|
|
|
+ :append-inner-icon="passwordType ? 'mdi-eye-outline' : 'mdi-eye-off-outline'"
|
|
|
+ :type="passwordType ? 'text' : 'password'"
|
|
|
+ :rules="[v=> !!v || '请填写新密码', validPassword]"
|
|
|
+ @click:append-inner="passwordType = !passwordType"
|
|
|
+ ></v-text-field>
|
|
|
+ <v-text-field
|
|
|
+ v-model="query.checkPassword"
|
|
|
+ placeholder="请再次输入新密码"
|
|
|
+ variant="outlined"
|
|
|
+ density="compact"
|
|
|
+ color="primary"
|
|
|
+ prepend-inner-icon="mdi-lock-outline"
|
|
|
+ :append-inner-icon="show ? 'mdi-eye-outline' : 'mdi-eye-off-outline'"
|
|
|
+ :type="show ? 'text' : 'password'"
|
|
|
+ :rules="[v=> !!v || '请再次输入密码', confirmPassword]"
|
|
|
+ @click:append-inner="show = !show"
|
|
|
+ ></v-text-field>
|
|
|
+ </v-form>
|
|
|
+ <div class="text-center mt-5">
|
|
|
+ <v-btn v-if="showCancelBtn" class="mr-5" color="primary" variant="outlined" @click="handleClose">取 消</v-btn>
|
|
|
+ <v-btn color="primary" :max-width="showCancelBtn ? 370 : 95" :min-width="showCancelBtn ? 95 : 370" @click="handleSubmit" :loading="loading">确认修改</v-btn>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup>
|
|
|
+defineOptions({ name: 'editPasswordEnt'})
|
|
|
+import { ref, reactive, computed } from 'vue'
|
|
|
+import { updatePassword, resetPassword } from '@/api/common/index'
|
|
|
+import Snackbar from '@/plugins/snackbar'
|
|
|
+import { checkEmail } from '@/utils/validate'
|
|
|
+
|
|
|
+const emit = defineEmits(['cancel'])
|
|
|
+const props = defineProps({
|
|
|
+ phone: {
|
|
|
+ type: String,
|
|
|
+ default: ''
|
|
|
+ },
|
|
|
+ showCancelBtn: {
|
|
|
+ type: Boolean,
|
|
|
+ default: true
|
|
|
+ },
|
|
|
+ isReset: {
|
|
|
+ type: Boolean,
|
|
|
+ default: false
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
+let query = reactive({
|
|
|
+ email: '',
|
|
|
+ password: '',
|
|
|
+ checkPassword: ''
|
|
|
+})
|
|
|
+const passwordRef = ref(false)
|
|
|
+const show = ref(false)
|
|
|
+const loading = ref(false)
|
|
|
+const passwordType = ref(false)
|
|
|
+
|
|
|
+// 密码效验
|
|
|
+const regex = /^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z]).{8,16}$/
|
|
|
+const validPassword = computed(() => {
|
|
|
+ return regex.test(query.password) || '请输入8-16位数由数字、大小写字母组成的密码'
|
|
|
+})
|
|
|
+
|
|
|
+const confirmPassword = computed(() => {
|
|
|
+ return query.checkPassword === query.password || '两次输入密码不一致'
|
|
|
+})
|
|
|
+
|
|
|
+
|
|
|
+const handleClose = () => {
|
|
|
+ query = {
|
|
|
+ password: '',
|
|
|
+ checkPassword: ''
|
|
|
+ }
|
|
|
+ passwordType.value = false
|
|
|
+ loading.value = false
|
|
|
+ emit('cancel')
|
|
|
+}
|
|
|
+
|
|
|
+// 修改
|
|
|
+const handleSubmit = async () => {
|
|
|
+ const passwordValid = await passwordRef.value.validate()
|
|
|
+ if (!passwordValid.valid) return
|
|
|
+ const data = {
|
|
|
+ password: query.password,
|
|
|
+ }
|
|
|
+ loading.value = true
|
|
|
+ const api = props.isReset ? resetPassword : updatePassword
|
|
|
+ try {
|
|
|
+ await api(data)
|
|
|
+ Snackbar.success('修改成功')
|
|
|
+ } finally {
|
|
|
+ loading.value = false
|
|
|
+ handleClose()
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped lang="scss">
|
|
|
+</style>
|