7 changed files with 308 additions and 228 deletions
@ -0,0 +1,31 @@
@@ -0,0 +1,31 @@
|
||||
/** |
||||
* 提供api模板规范代码参考,请尽量保证编写代码风格跟模板规范代码一致 |
||||
* Copyright © 2023-2023 <a href="https://godolphinx.org">海豚生态开源社区</a> All rights reserved. |
||||
* author wangxiang4 |
||||
*/ |
||||
import type { SsoUserParams, SsoUser ,SsoUserResult } from '/@/api/platform/system/entity/ssoUser'; |
||||
import { defHttp } from '/@/utils/http/axios'; |
||||
|
||||
enum Api { |
||||
list = '/system_proxy/system/ssoUser/list', |
||||
add = '/system_proxy/system/ssoUser/save', |
||||
get = '/system_proxy/system/ssoUser', |
||||
edit = '/system_proxy/system/ssoUser/update', |
||||
del = '/system_proxy/system/ssoUser/remove', |
||||
updatePwd = '/system_proxy/system/ssoUser/updatePwd', |
||||
resetPwd='/system_proxy/system/ssoUser/resetPwd', |
||||
} |
||||
|
||||
export const listSsoUser = (params?: Partial<SsoUserParams>) => defHttp.get<SsoUserResult>({ url: Api.list, params }, { isReturnResultResponse: true }); |
||||
|
||||
export const addSsoUser = (params: Partial<SsoUser>) => defHttp.post({ url: Api.add, data: params }); |
||||
|
||||
export const editSsoUser = (params: Partial<SsoUser>) => defHttp.put({ url: Api.edit, data: params }); |
||||
|
||||
export const getSsoUser = (id: string) => defHttp.get<SsoUser>({ url: `${Api.get}/${id}` }); |
||||
|
||||
export const delSsoUser = (ids: string) => defHttp.delete({ url: `${Api.del}/${ids}` }); |
||||
|
||||
export const updatePwd = (params: Partial<SsoUser>) => defHttp.put({ url: Api.updatePwd, params }); |
||||
|
||||
export const resetPwd = (params: Partial<SsoUser>) => defHttp.put({ url: Api.resetPwd, data: params }); |
@ -0,0 +1,37 @@
@@ -0,0 +1,37 @@
|
||||
/** |
||||
* @program: kicc-ui |
||||
* @description: SSO用户统一实体类 |
||||
* 类型定义 |
||||
* @author: wangxiang4 |
||||
* @create: 2022/4/8 |
||||
*/ |
||||
import type { R } from '/#/axios'; |
||||
import type { Page } from '/@/api/common/data/entity'; |
||||
import { CommonEntity } from '/@/api/common/data/entity'; |
||||
export type SsoUserParams = Page & SsoUser; |
||||
|
||||
export interface SsoUser extends CommonEntity { |
||||
// 用户id
|
||||
id: string; |
||||
// 用户名
|
||||
userName: string; |
||||
// 昵称
|
||||
nickName: string; |
||||
// 头像
|
||||
avatar: string; |
||||
// 邮箱
|
||||
email: string; |
||||
// 手机号
|
||||
phone: string; |
||||
// 用户密码
|
||||
password: string; |
||||
// 用户性别
|
||||
sex: string; |
||||
// 最后登陆IP
|
||||
loginIp: string; |
||||
// 最后登陆时间
|
||||
loginTime: string; |
||||
[key: string]: any; |
||||
} |
||||
|
||||
export type SsoUserResult = R<SsoUser[]>; |
@ -0,0 +1,96 @@
@@ -0,0 +1,96 @@
|
||||
<template> |
||||
<BasicModal |
||||
v-bind="$attrs" |
||||
centered |
||||
title="重置密码" |
||||
minHeight="100px" |
||||
@ok="handleSubmit" |
||||
@register="registerModal" |
||||
> |
||||
<Form :model="modelRef" :rules="rulesRef"> |
||||
<FormItem name="newPassword" v-bind="validateInfos.newPassword"> |
||||
<StrengthMeter v-model:value="modelRef.newPassword" placeholder="请输入重置密码"/> |
||||
</FormItem> |
||||
</Form> |
||||
</BasicModal> |
||||
</template> |
||||
|
||||
<script lang="ts" setup> |
||||
/** |
||||
* 提供模板规范代码参考,请尽量保证编写代码风格跟模板规范代码一致 |
||||
* 采用ant-design-vue原生组件编写表单,采用 setup 写法 |
||||
* Copyright © 2023-2023 <a href="https://godolphinx.org">海豚生态开源社区</a> All rights reserved. |
||||
* author wangxiang4 |
||||
*/ |
||||
import { reactive } from 'vue'; |
||||
import { BasicModal, ModalProps, useModalInner } from '/@/components/Modal'; |
||||
import { StrengthMeter } from '/@/components/StrengthMeter'; |
||||
import { Form } from 'ant-design-vue'; |
||||
import { resetPwd } from '/@/api/platform/system/controller/ssoUser'; |
||||
import { useMessage } from '/@/hooks/web/useMessage'; |
||||
|
||||
/** 类型规范统一声明定义区域 */ |
||||
interface WindowState { |
||||
id: string; |
||||
newPassword: string; |
||||
} |
||||
|
||||
/** 通用变量统一声明区域 */ |
||||
const { createMessage } = useMessage(); |
||||
/** https://v3.cn.vuejs.org/api/options-data.html#emits */ |
||||
const emit = defineEmits(['success', 'register']); |
||||
const FormItem = Form.Item; |
||||
const useForm = Form.useForm; |
||||
const modelRef = reactive<WindowState>({ |
||||
id: '', |
||||
newPassword: '' |
||||
}); |
||||
const rulesRef = reactive<Recordable>({ |
||||
newPassword: [ |
||||
{ |
||||
required: true, |
||||
whitespace: true, |
||||
message: '请输入密码!', |
||||
}, |
||||
{ |
||||
pattern: new RegExp('[^\\u4e00-\\u9fa5]+'), |
||||
type: 'string', |
||||
message: '密码不能输入汉字!', |
||||
}, |
||||
{ |
||||
min: 6, |
||||
max: 32, |
||||
message: '长度必需在6-32之间!', |
||||
} |
||||
] |
||||
}); |
||||
const { resetFields, clearValidate, validate, validateInfos } = useForm(modelRef, rulesRef); |
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner( (data: BoxPayload) => { |
||||
// 处理清除脏数据 |
||||
resetFields(); |
||||
clearValidate(); |
||||
// 处理设置数据 |
||||
modelRef.id = data.record?.id; |
||||
const props: Partial<ModalProps> = { confirmLoading: false }; |
||||
// 尾部:设置处理后的最终配置数据 |
||||
setModalProps(props); |
||||
}); |
||||
|
||||
/** 处理模态框提交 */ |
||||
async function handleSubmit() { |
||||
try { |
||||
// 验证数据 |
||||
await validate(); |
||||
// 处理提交之前逻辑 |
||||
setModalProps({ confirmLoading: true }); |
||||
if (!modelRef.id) return createMessage.error('用户编号ID不存在,请检查!'); |
||||
await resetPwd(modelRef); |
||||
// 处理提交完成之后逻辑 |
||||
closeModal(); |
||||
emit('success'); |
||||
} finally { |
||||
setModalProps({ confirmLoading: false }); |
||||
} |
||||
} |
||||
|
||||
</script> |
Loading…
Reference in new issue