refactor: 取消用户默认密码,改为表单填写密码
This commit is contained in:
24
README.md
24
README.md
@@ -6,6 +6,18 @@
|
|||||||
<a href="https://github.com/Charles7c/continew-admin-ui" target="_blank">
|
<a href="https://github.com/Charles7c/continew-admin-ui" target="_blank">
|
||||||
<img src="https://img.shields.io/badge/SNAPSHOT-v2.4.0-%23ff3f59.svg" alt="Release" />
|
<img src="https://img.shields.io/badge/SNAPSHOT-v2.4.0-%23ff3f59.svg" alt="Release" />
|
||||||
</a>
|
</a>
|
||||||
|
<a href="https://cn.vuejs.org/" target="_blank">
|
||||||
|
<img src="https://img.shields.io/badge/Vue-3.3.7-%236CB52D.svg?logo=Vue.js" alt="Release" />
|
||||||
|
</a>
|
||||||
|
<a href="https://arco.design/vue/docs/start" target="_blank">
|
||||||
|
<img src="https://img.shields.io/badge/Arco Design-2.53.3-%236CB52D.svg" alt="Release" />
|
||||||
|
</a>
|
||||||
|
<a href="https://ts.nodejs.cn/" target="_blank">
|
||||||
|
<img src="https://img.shields.io/badge/TypeScript-5.3.3-%236CB52D.svg?logo=TypeScript&logoColor=FFF" alt="Release" />
|
||||||
|
</a>
|
||||||
|
<a href="https://cn.vitejs.dev/" target="_blank">
|
||||||
|
<img src="https://img.shields.io/badge/Vite-4.5.1-%236CB52D.svg?logo=Vite&logoColor=FFF" alt="Release" />
|
||||||
|
</a>
|
||||||
<a href="https://github.com/Charles7c/continew-admin" target="_blank">
|
<a href="https://github.com/Charles7c/continew-admin" target="_blank">
|
||||||
<img src="https://img.shields.io/github/stars/Charles7c/continew-admin?style=social" alt="GitHub stars" />
|
<img src="https://img.shields.io/github/stars/Charles7c/continew-admin?style=social" alt="GitHub stars" />
|
||||||
</a>
|
</a>
|
||||||
@@ -18,18 +30,6 @@
|
|||||||
<a href="https://gitee.com/Charles7c/continew-admin" target="_blank">
|
<a href="https://gitee.com/Charles7c/continew-admin" target="_blank">
|
||||||
<img src="https://gitee.com/Charles7c/continew-admin/badge/fork.svg?theme=white" alt="Gitee forks" />
|
<img src="https://gitee.com/Charles7c/continew-admin/badge/fork.svg?theme=white" alt="Gitee forks" />
|
||||||
</a>
|
</a>
|
||||||
<a href="https://github.com/Charles7c/continew-admin-ui" target="_blank">
|
|
||||||
<img src="https://img.shields.io/badge/Vue-3.3.7-%236CB52D.svg" alt="Release" />
|
|
||||||
</a>
|
|
||||||
<a href="https://github.com/Charles7c/continew-admin-ui" target="_blank">
|
|
||||||
<img src="https://img.shields.io/badge/Arco Design Vue-2.53.3-%236CB52D.svg" alt="Release" />
|
|
||||||
</a>
|
|
||||||
<a href="https://github.com/Charles7c/continew-admin-ui" target="_blank">
|
|
||||||
<img src="https://img.shields.io/badge/TypeScript-5.3.3-%236CB52D.svg" alt="Release" />
|
|
||||||
</a>
|
|
||||||
<a href="https://github.com/Charles7c/continew-admin-ui" target="_blank">
|
|
||||||
<img src="https://img.shields.io/badge/Vite-4.5.1-%236CB52D.svg" alt="Release" />
|
|
||||||
</a>
|
|
||||||
|
|
||||||
📚 [在线文档](https://doc.charles7c.top) | 🚀 [演示地址](https://cnadmin.charles7c.top)(账号/密码:admin/admin123)
|
📚 [在线文档](https://doc.charles7c.top) | 🚀 [演示地址](https://cnadmin.charles7c.top)(账号/密码:admin/admin123)
|
||||||
|
|
||||||
|
@@ -7,6 +7,7 @@ export interface DataRecord {
|
|||||||
id?: number;
|
id?: number;
|
||||||
username?: string;
|
username?: string;
|
||||||
nickname?: string;
|
nickname?: string;
|
||||||
|
password?: string;
|
||||||
gender?: number;
|
gender?: number;
|
||||||
email?: string;
|
email?: string;
|
||||||
phone?: string;
|
phone?: string;
|
||||||
@@ -25,6 +26,10 @@ export interface DataRecord {
|
|||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface UserResetReq {
|
||||||
|
newPassword: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface ListParam {
|
export interface ListParam {
|
||||||
username?: string;
|
username?: string;
|
||||||
status?: number;
|
status?: number;
|
||||||
@@ -64,8 +69,8 @@ export function del(ids: number | Array<number>) {
|
|||||||
return axios.delete(`${BASE_URL}/${ids}`);
|
return axios.delete(`${BASE_URL}/${ids}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function resetPassword(id: number) {
|
export function resetPassword(req: UserResetReq, id: number) {
|
||||||
return axios.patch(`${BASE_URL}/${id}/password`);
|
return axios.patch(`${BASE_URL}/${id}/password`, req);
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UpdateUserRoleReq {
|
export interface UpdateUserRoleReq {
|
||||||
|
@@ -68,7 +68,7 @@
|
|||||||
callback(
|
callback(
|
||||||
t(
|
t(
|
||||||
'userCenter.securitySettings.updatePwd.form.error.validator.rePassword'
|
'userCenter.securitySettings.updatePwd.form.error.validator.rePassword'
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
callback();
|
callback();
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
import { LabelValueState } from '@/store/modules/dict/types';
|
import { LabelValueState } from '@/store/modules/dict/types';
|
||||||
import getAvatar from '@/utils/avatar';
|
import getAvatar from '@/utils/avatar';
|
||||||
import checkPermission from '@/utils/permission';
|
import checkPermission from '@/utils/permission';
|
||||||
|
import { encryptByRsa } from '@/utils/encrypt';
|
||||||
|
|
||||||
const { proxy } = getCurrentInstance() as any;
|
const { proxy } = getCurrentInstance() as any;
|
||||||
const { dis_enable_status_enum } = proxy.useDict('dis_enable_status_enum');
|
const { dis_enable_status_enum } = proxy.useDict('dis_enable_status_enum');
|
||||||
@@ -31,6 +32,7 @@
|
|||||||
const detailLoading = ref(false);
|
const detailLoading = ref(false);
|
||||||
const exportLoading = ref(false);
|
const exportLoading = ref(false);
|
||||||
const visible = ref(false);
|
const visible = ref(false);
|
||||||
|
const resetPasswordVisible = ref(false);
|
||||||
const userRoleVisible = ref(false);
|
const userRoleVisible = ref(false);
|
||||||
const detailVisible = ref(false);
|
const detailVisible = ref(false);
|
||||||
const deptLoading = ref(false);
|
const deptLoading = ref(false);
|
||||||
@@ -57,6 +59,7 @@
|
|||||||
rules: {
|
rules: {
|
||||||
username: [{ required: true, message: '请输入用户名' }],
|
username: [{ required: true, message: '请输入用户名' }],
|
||||||
nickname: [{ required: true, message: '请输入昵称' }],
|
nickname: [{ required: true, message: '请输入昵称' }],
|
||||||
|
password: [{ required: true, message: '请输入密码' }],
|
||||||
deptId: [{ required: true, message: '请选择所属部门' }],
|
deptId: [{ required: true, message: '请选择所属部门' }],
|
||||||
roleIds: [{ required: true, message: '请选择所属角色' }],
|
roleIds: [{ required: true, message: '请选择所属角色' }],
|
||||||
},
|
},
|
||||||
@@ -126,6 +129,17 @@
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打开重置密码对话框
|
||||||
|
*
|
||||||
|
* @param id ID
|
||||||
|
*/
|
||||||
|
const toResetPassword = (id: number) => {
|
||||||
|
reset();
|
||||||
|
form.value.id = id;
|
||||||
|
resetPasswordVisible.value = true;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 打开分配角色对话框
|
* 打开分配角色对话框
|
||||||
*
|
*
|
||||||
@@ -183,8 +197,10 @@
|
|||||||
*/
|
*/
|
||||||
const handleCancel = () => {
|
const handleCancel = () => {
|
||||||
visible.value = false;
|
visible.value = false;
|
||||||
|
resetPasswordVisible.value = false;
|
||||||
userRoleVisible.value = false;
|
userRoleVisible.value = false;
|
||||||
proxy.$refs.formRef?.resetFields();
|
proxy.$refs.formRef?.resetFields();
|
||||||
|
proxy.$refs.resetPasswordFormRef?.resetFields();
|
||||||
proxy.$refs.userRoleFormRef?.resetFields();
|
proxy.$refs.userRoleFormRef?.resetFields();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -201,12 +217,38 @@
|
|||||||
proxy.$message.success(res.msg);
|
proxy.$message.success(res.msg);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
add(form.value).then((res) => {
|
const rawPassword = form.value.password;
|
||||||
|
if (rawPassword) {
|
||||||
|
form.value.password = encryptByRsa(rawPassword) || '';
|
||||||
|
}
|
||||||
|
add(form.value)
|
||||||
|
.then((res) => {
|
||||||
|
handleCancel();
|
||||||
|
getList();
|
||||||
|
proxy.$message.success(res.msg);
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
form.value.password = rawPassword;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重置密码
|
||||||
|
*/
|
||||||
|
const handleResetPassword = () => {
|
||||||
|
proxy.$refs.resetPasswordFormRef.validate((valid: any) => {
|
||||||
|
if (!valid && form.value.id !== undefined) {
|
||||||
|
const newPassword = form.value.password;
|
||||||
|
resetPassword({ newPassword: encryptByRsa(newPassword) }, form.value.id)
|
||||||
|
.then((res) => {
|
||||||
handleCancel();
|
handleCancel();
|
||||||
getList();
|
getList();
|
||||||
proxy.$message.success(res.msg);
|
proxy.$message.success(res.msg);
|
||||||
});
|
})
|
||||||
}
|
.catch();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -285,17 +327,6 @@
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* 重置密码
|
|
||||||
*
|
|
||||||
* @param id ID
|
|
||||||
*/
|
|
||||||
const handleResetPassword = (id: number) => {
|
|
||||||
resetPassword(id).then((res) => {
|
|
||||||
proxy.$message.success(res.msg);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 已选择的数据行发生改变时触发
|
* 已选择的数据行发生改变时触发
|
||||||
*
|
*
|
||||||
@@ -578,7 +609,13 @@
|
|||||||
}}</a-link>
|
}}</a-link>
|
||||||
</template>
|
</template>
|
||||||
</a-table-column>
|
</a-table-column>
|
||||||
<a-table-column title="昵称" data-index="nickname" :width="115" ellipsis tooltip />
|
<a-table-column
|
||||||
|
title="昵称"
|
||||||
|
data-index="nickname"
|
||||||
|
:width="115"
|
||||||
|
ellipsis
|
||||||
|
tooltip
|
||||||
|
/>
|
||||||
<a-table-column title="性别" align="center">
|
<a-table-column title="性别" align="center">
|
||||||
<template #cell="{ record }">
|
<template #cell="{ record }">
|
||||||
<span v-if="record.gender === 1">男</span>
|
<span v-if="record.gender === 1">男</span>
|
||||||
@@ -622,7 +659,12 @@
|
|||||||
<a-tag v-else color="arcoblue">否</a-tag>
|
<a-tag v-else color="arcoblue">否</a-tag>
|
||||||
</template>
|
</template>
|
||||||
</a-table-column>
|
</a-table-column>
|
||||||
<a-table-column title="描述" data-index="description" ellipsis tooltip />
|
<a-table-column
|
||||||
|
title="描述"
|
||||||
|
data-index="description"
|
||||||
|
ellipsis
|
||||||
|
tooltip
|
||||||
|
/>
|
||||||
<a-table-column title="创建人/创建时间" :width="175">
|
<a-table-column title="创建人/创建时间" :width="175">
|
||||||
<template #cell="{ record }">
|
<template #cell="{ record }">
|
||||||
{{ record.createUserString }}<br />
|
{{ record.createUserString }}<br />
|
||||||
@@ -668,22 +710,15 @@
|
|||||||
<template #icon><icon-delete /></template>
|
<template #icon><icon-delete /></template>
|
||||||
</a-button>
|
</a-button>
|
||||||
</a-popconfirm>
|
</a-popconfirm>
|
||||||
<a-popconfirm
|
<a-button
|
||||||
content="是否确定重置当前用户的密码?"
|
v-permission="['system:user:password:reset']"
|
||||||
type="warning"
|
type="text"
|
||||||
@ok="handleResetPassword(record.id)"
|
size="small"
|
||||||
|
title="重置密码"
|
||||||
|
@click="toResetPassword(record.id)"
|
||||||
>
|
>
|
||||||
<a-button
|
<template #icon><svg-icon icon-class="privacy" /></template>
|
||||||
v-permission="['system:user:password:reset']"
|
</a-button>
|
||||||
type="text"
|
|
||||||
size="small"
|
|
||||||
title="重置密码"
|
|
||||||
>
|
|
||||||
<template #icon
|
|
||||||
><svg-icon icon-class="privacy"
|
|
||||||
/></template>
|
|
||||||
</a-button>
|
|
||||||
</a-popconfirm>
|
|
||||||
<a-button
|
<a-button
|
||||||
v-permission="['system:user:role:update']"
|
v-permission="['system:user:role:update']"
|
||||||
type="text"
|
type="text"
|
||||||
@@ -715,19 +750,11 @@
|
|||||||
@ok="handleOk"
|
@ok="handleOk"
|
||||||
@cancel="handleCancel"
|
@cancel="handleCancel"
|
||||||
>
|
>
|
||||||
<a-form
|
<a-form ref="formRef" :model="form" :rules="rules" size="large">
|
||||||
ref="formRef"
|
|
||||||
:model="form"
|
|
||||||
:rules="rules"
|
|
||||||
:label-col-style="{ width: '84px' }"
|
|
||||||
size="large"
|
|
||||||
layout="inline"
|
|
||||||
>
|
|
||||||
<a-form-item label="用户名" field="username">
|
<a-form-item label="用户名" field="username">
|
||||||
<a-input
|
<a-input
|
||||||
v-model="form.username"
|
v-model="form.username"
|
||||||
placeholder="请输入用户名"
|
placeholder="请输入用户名"
|
||||||
style="width: 162px"
|
|
||||||
:max-length="64"
|
:max-length="64"
|
||||||
/>
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
@@ -736,7 +763,13 @@
|
|||||||
v-model="form.nickname"
|
v-model="form.nickname"
|
||||||
placeholder="请输入昵称"
|
placeholder="请输入昵称"
|
||||||
:max-length="30"
|
:max-length="30"
|
||||||
style="width: 162px"
|
/>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item v-if="!form.id" label="密码" field="password">
|
||||||
|
<a-input-password
|
||||||
|
v-model="form.password"
|
||||||
|
placeholder="请输入密码"
|
||||||
|
:max-length="32"
|
||||||
/>
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item label="邮箱" field="email">
|
<a-form-item label="邮箱" field="email">
|
||||||
@@ -744,7 +777,6 @@
|
|||||||
v-model="form.email"
|
v-model="form.email"
|
||||||
placeholder="请输入邮箱"
|
placeholder="请输入邮箱"
|
||||||
:max-length="255"
|
:max-length="255"
|
||||||
style="width: 162px"
|
|
||||||
/>
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item label="手机号码" field="phone">
|
<a-form-item label="手机号码" field="phone">
|
||||||
@@ -752,11 +784,10 @@
|
|||||||
v-model="form.phone"
|
v-model="form.phone"
|
||||||
placeholder="请输入手机号码"
|
placeholder="请输入手机号码"
|
||||||
:max-length="15"
|
:max-length="15"
|
||||||
style="width: 162px"
|
|
||||||
/>
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item label="性别" field="gender">
|
<a-form-item label="性别" field="gender">
|
||||||
<a-radio-group v-model="form.gender">
|
<a-radio-group v-model="form.gender" style="width: 197px">
|
||||||
<a-radio :value="1">男</a-radio>
|
<a-radio :value="1">男</a-radio>
|
||||||
<a-radio :value="2">女</a-radio>
|
<a-radio :value="2">女</a-radio>
|
||||||
<a-radio :value="0" disabled>未知</a-radio>
|
<a-radio :value="0" disabled>未知</a-radio>
|
||||||
@@ -770,7 +801,6 @@
|
|||||||
allow-clear
|
allow-clear
|
||||||
allow-search
|
allow-search
|
||||||
:filter-tree-node="filterDeptOptions"
|
:filter-tree-node="filterDeptOptions"
|
||||||
style="width: 431px"
|
|
||||||
/>
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item
|
<a-form-item
|
||||||
@@ -786,7 +816,6 @@
|
|||||||
multiple
|
multiple
|
||||||
allow-clear
|
allow-clear
|
||||||
:allow-search="{ retainInputValue: true }"
|
:allow-search="{ retainInputValue: true }"
|
||||||
style="width: 431px"
|
|
||||||
/>
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item label="描述" field="description">
|
<a-form-item label="描述" field="description">
|
||||||
@@ -798,7 +827,32 @@
|
|||||||
minRows: 3,
|
minRows: 3,
|
||||||
}"
|
}"
|
||||||
show-word-limit
|
show-word-limit
|
||||||
style="width: 431px"
|
/>
|
||||||
|
</a-form-item>
|
||||||
|
</a-form>
|
||||||
|
</a-modal>
|
||||||
|
|
||||||
|
<a-modal
|
||||||
|
title="重置密码"
|
||||||
|
:visible="resetPasswordVisible"
|
||||||
|
:mask-closable="false"
|
||||||
|
:esc-to-close="false"
|
||||||
|
unmount-on-close
|
||||||
|
render-to-body
|
||||||
|
@ok="handleResetPassword"
|
||||||
|
@cancel="handleCancel"
|
||||||
|
>
|
||||||
|
<a-form
|
||||||
|
ref="resetPasswordFormRef"
|
||||||
|
:model="form"
|
||||||
|
:rules="rules"
|
||||||
|
size="large"
|
||||||
|
>
|
||||||
|
<a-form-item label="密码" field="password">
|
||||||
|
<a-input-password
|
||||||
|
v-model="form.password"
|
||||||
|
placeholder="请输入密码"
|
||||||
|
:max-length="32"
|
||||||
/>
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-form>
|
</a-form>
|
||||||
|
Reference in New Issue
Block a user