|
@@ -6,7 +6,8 @@
|
|
|
</el-form-item>
|
|
|
<el-form-item label="验证码" prop="msgAuthCode" required>
|
|
|
<el-input v-model="data.msgAuthCode" style="width: 190px" :maxlength="500" placeholder="请输入" />
|
|
|
- <el-button type="danger" style="margin-left: 10px" @click="getMsgCode">获取验证码</el-button>
|
|
|
+ <el-button :loading="checkCodeBtn.loading" :disabled="checkCodeBtn.disabled" type="danger"
|
|
|
+ style="margin-left: 10px" @click="getCheckCode"> {{ checkCodeBtn.text }}</el-button>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="密码" prop="password" required>
|
|
|
<el-input autocomplete="off" readonly onfocus="this.removeAttribute('readonly');" v-model="data.password"
|
|
@@ -49,48 +50,23 @@
|
|
|
import { QuiskExpose } from "@/helper/mount";
|
|
|
import { ElMessage, type FormInstance, type FormRules } from "element-plus";
|
|
|
import { View, Hide } from '@element-plus/icons-vue';
|
|
|
-import type { OrganizationType } from '@/request/organization'
|
|
|
+// import type { OrganizationType } from '@/request/organization'
|
|
|
import {
|
|
|
- getOrgListFetch,
|
|
|
+ // getOrgListFetch,
|
|
|
getMsgAuthCode,
|
|
|
- UserType
|
|
|
+ UserType,
|
|
|
+ ChangePasswordParam
|
|
|
} from "@/request";
|
|
|
|
|
|
import { ref, reactive, unref, onMounted, watchEffect } from "vue";
|
|
|
+import { onUnmounted } from "vue";
|
|
|
const addPassFlag = ref(false)//图标显示标识
|
|
|
|
|
|
const baseFormRef = ref<FormInstance>();
|
|
|
|
|
|
-type SelectType = {
|
|
|
- value: string, id: number
|
|
|
-}
|
|
|
-
|
|
|
-const allOrgs = ref<SelectType[]>([]);
|
|
|
-
|
|
|
-
|
|
|
-const rules = reactive<FormRules>({
|
|
|
-
|
|
|
-
|
|
|
- userName: [
|
|
|
- { required: true, message: "请输入账号", trigger: "blur" },
|
|
|
- ],
|
|
|
- msgAuthCode: [
|
|
|
- { required: true, message: "请输入验证码", trigger: "change" },
|
|
|
- ],
|
|
|
-
|
|
|
- password: [
|
|
|
- { required: true, pattern: /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,16}$/, message: "请输入8-16位数字、字母大小写组合", trigger: "blur" },
|
|
|
- { required: true, min: 8, message: '密码太短!', trigger: "blur" },
|
|
|
- ],
|
|
|
- confirmPwd: [
|
|
|
- { required: true, pattern: /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,16}$/, message: "请输入8-16位数字、字母大小写组合", trigger: "blur" },
|
|
|
- { required: true, min: 8, message: '密码太短!', trigger: "blur" },
|
|
|
- ]
|
|
|
-},)
|
|
|
-
|
|
|
const props = defineProps<{
|
|
|
user: UserType,
|
|
|
- submit: (data: UserType) => Promise<any>;
|
|
|
+ submit: (data: ChangePasswordParam) => Promise<any>;
|
|
|
}>();
|
|
|
const data = ref<UserType>({
|
|
|
nickName: "",
|
|
@@ -111,20 +87,64 @@ const data = ref<UserType>({
|
|
|
userId: 0,
|
|
|
roleNames: ""
|
|
|
});
|
|
|
-const isDisableMsg = ref(false)
|
|
|
+
|
|
|
+
|
|
|
+const equalToPassword = (_, value: any, callback: any) => {
|
|
|
+ if (data.value.password !== value) {
|
|
|
+ callback(new Error("两次输入的密码不一致"));
|
|
|
+ } else {
|
|
|
+ callback();
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+const rules = reactive<FormRules>({
|
|
|
+
|
|
|
+
|
|
|
+ userName: [
|
|
|
+ { required: true, message: "请输入账号", trigger: "blur" },
|
|
|
+ ],
|
|
|
+ msgAuthCode: [
|
|
|
+ { required: true, message: "请输入验证码", trigger: "change" },
|
|
|
+ ],
|
|
|
+
|
|
|
+ password: [
|
|
|
+ { required: true, pattern: /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[\s\S]{8,16}$/, message: "请输入8-16位数字、字母大小写组合", trigger: "blur" },
|
|
|
+ { required: true, min: 8, message: '密码太短!', trigger: "blur" },
|
|
|
+ ],
|
|
|
+ confirmPwd: [
|
|
|
+ { required: true, pattern: /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[\s\S]{8,16}$/, message: "请输入8-16位数字、字母大小写组合", trigger: "blur" },
|
|
|
+ { required: true, min: 8, message: '密码太短!', trigger: "blur" },
|
|
|
+ { required: true, validator: equalToPassword, trigger: "blur" }
|
|
|
+
|
|
|
+ ]
|
|
|
+},)
|
|
|
+
|
|
|
+
|
|
|
+let checkCodeBtn = reactive<any>({
|
|
|
+ text: '获取验证码',
|
|
|
+ loading: false,
|
|
|
+ disabled: false,
|
|
|
+ duration: 60,
|
|
|
+ timer: null
|
|
|
+})
|
|
|
|
|
|
onMounted(async () => {
|
|
|
- const data = await getOrgListFetch({
|
|
|
- pageNum: 1,
|
|
|
- pageSize: 10000,
|
|
|
- })
|
|
|
- // console.log('allOrgs', data.records);
|
|
|
- allOrgs.value = Array.from(data.records).map((item: OrganizationType) => {
|
|
|
- const i: SelectType = { value: item['orgName'], id: item['orgId'] }
|
|
|
- return i
|
|
|
- });
|
|
|
+ // const data = await getOrgListFetch({
|
|
|
+ // pageNum: 1,
|
|
|
+ // pageSize: 10000,
|
|
|
+ // })
|
|
|
+ // // console.log('allOrgs', data.records);
|
|
|
+ // allOrgs.value = Array.from(data.records).map((item: OrganizationType) => {
|
|
|
+ // const i: SelectType = { value: item['orgName'], id: item['orgId'] }
|
|
|
+ // return i
|
|
|
+ // });
|
|
|
|
|
|
})
|
|
|
+onUnmounted(() => {
|
|
|
+ // 清除掉定时器
|
|
|
+ checkCodeBtn.timer && clearInterval(checkCodeBtn.timer)
|
|
|
+})
|
|
|
+
|
|
|
|
|
|
// const setParentId = () => {
|
|
|
// if (user.value) {
|
|
@@ -135,23 +155,40 @@ onMounted(async () => {
|
|
|
watchEffect(() => {
|
|
|
if (props.user) {
|
|
|
data.value = { ...props.user }
|
|
|
+ console.log('data', data)
|
|
|
}
|
|
|
})
|
|
|
-
|
|
|
-const getMsgCode = async () => {
|
|
|
- const res = await getMsgAuthCode('+86', "13750087092")
|
|
|
- console.log('res', res)
|
|
|
- let timer = null
|
|
|
+const getCheckCode = async () => {
|
|
|
+ // 倒计时期间按钮不能单击
|
|
|
+ const phoneNum = data.value.userName
|
|
|
+ console.log('getMsgCode', phoneNum)
|
|
|
+ const res = await getMsgAuthCode('+86', phoneNum)
|
|
|
if (res.success) {
|
|
|
- timer && clearTimeout(timer)
|
|
|
- isDisableMsg.value = true
|
|
|
- timer = setTimeout(() => {
|
|
|
- isDisableMsg.value = false
|
|
|
- }, 60 * 1000)
|
|
|
+ ElMessage.success(res.data);
|
|
|
}
|
|
|
-
|
|
|
+ if (checkCodeBtn.duration == 60) {
|
|
|
+ checkCodeBtn.disabled = true
|
|
|
+ }
|
|
|
+ // 清除掉定时器
|
|
|
+ checkCodeBtn.timer && clearInterval(checkCodeBtn.timer)
|
|
|
+ // 开启定时器
|
|
|
+ checkCodeBtn.timer = setInterval(() => {
|
|
|
+ const tmp = checkCodeBtn.duration--
|
|
|
+ checkCodeBtn.text = `${tmp}秒`
|
|
|
+ if (tmp <= 0) {
|
|
|
+ // 清除掉定时器
|
|
|
+ clearInterval(checkCodeBtn.timer)
|
|
|
+ checkCodeBtn.duration = 60
|
|
|
+ checkCodeBtn.text = '重新获取'
|
|
|
+ // 设置按钮可以单击
|
|
|
+ checkCodeBtn.disabled = false
|
|
|
+ }
|
|
|
+ console.info(checkCodeBtn.duration)
|
|
|
+ }, 1000)
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
// const handleSelect = (orgId: number) => {
|
|
|
// const item = Array.from(allOrgs.value).find(i => i.id === orgId)
|
|
|
// if (item) {
|