fix: 用户管理自测及优化
This commit is contained in:
parent
0c80efe6d2
commit
8e92b62c5c
|
@ -15,7 +15,7 @@ export const unBind_api = (appId: string) => server.post(`/application/sso/${app
|
|||
* @param type 类型
|
||||
* @param name 值
|
||||
*/
|
||||
export const validateField_api = (type: 'username' | 'password', name: string) => server.post(`/user/${type}/_validate`,name,{
|
||||
export const validateField_api = (type: 'username' | 'password', name: string) => server.post(`/user/${type}/_validate`,name,{},{
|
||||
headers: {
|
||||
'Content-Type': 'text/plain'
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ export const validateField_api = (type: 'username' | 'password', name: string)
|
|||
* 校验旧密码是否正确
|
||||
* @param password 旧密码
|
||||
*/
|
||||
export const checkOldPassword_api = (password:string) => server.post(`/user/me/password/_validate`,password,{
|
||||
export const checkOldPassword_api = (password:string) => server.post(`/user/me/password/_validate`,password,{},{
|
||||
headers: {
|
||||
'Content-Type': 'text/plain'
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ export const getUserType_api = () => server.get(`/user/detail/types`);
|
|||
export const getUserList_api = (data: object) => server.post(`/user/detail/_query`, data);
|
||||
|
||||
// 校验字段合法性
|
||||
export const validateField_api = (type: 'username' | 'password', name: string) => server.post(`/user/${type}/_validate`, name, {
|
||||
export const validateField_api = (type: 'username' | 'password', name: string) => server.post(`/user/${type}/_validate`, name,{}, {
|
||||
headers: {
|
||||
'Content-Type': 'text/plain'
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ export const addUser_api = (data: object) => server.post(`/user/detail/_create`,
|
|||
// 更新用户
|
||||
export const updateUser_api = (data: any) => server.put(`/user/detail/${data.id}/_update`, data);
|
||||
// 更新密码
|
||||
export const updatePassword_api = (data: { id: string, password: string }) => server.post(`/user/${data.id}/password/_reset`, data.password, {
|
||||
export const updatePassword_api = (data: { id: string, password: string }) => server.post(`/user/${data.id}/password/_reset`, data.password,{}, {
|
||||
headers: {
|
||||
'Content-Type': 'text/plain'
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
<PermissionButton
|
||||
type="primary"
|
||||
class="add-btn"
|
||||
:uhasPermission="`${permission}:add`"
|
||||
:hasPermission="`${permission}:add`"
|
||||
@click="openDialog()"
|
||||
>
|
||||
新增
|
||||
|
@ -31,7 +31,7 @@
|
|||
<span>{{ name }}</span>
|
||||
<span class="func-btns" @click="(e) => e.stopPropagation()">
|
||||
<PermissionButton
|
||||
:uhasPermission="`${permission}:update`"
|
||||
:hasPermission="`${permission}:update`"
|
||||
type="link"
|
||||
:tooltip="{
|
||||
title: '编辑',
|
||||
|
@ -41,7 +41,7 @@
|
|||
<AIcon type="EditOutlined" />
|
||||
</PermissionButton>
|
||||
<PermissionButton
|
||||
:uhasPermission="`${permission}:add`"
|
||||
:hasPermission="`${permission}:add`"
|
||||
type="link"
|
||||
:tooltip="{
|
||||
title: '新增子组织',
|
||||
|
@ -58,7 +58,7 @@
|
|||
</PermissionButton>
|
||||
<PermissionButton
|
||||
type="link"
|
||||
:uhasPermission="`${permission}:delete`"
|
||||
:hasPermission="`${permission}:delete`"
|
||||
:tooltip="{ title: '删除' }"
|
||||
:popConfirm="{
|
||||
title: `确定要删除吗`,
|
||||
|
@ -103,7 +103,7 @@ const treeMap = new Map(); // 数据的map版本
|
|||
const treeData = ref<any[]>([]); // 展示的数据
|
||||
const selectedKeys = ref<string[]>([]); // 当前选中的项
|
||||
|
||||
function getTree() {
|
||||
function getTree(cb?: Function) {
|
||||
loading.value = true;
|
||||
const params = {
|
||||
paging: false,
|
||||
|
@ -121,6 +121,7 @@ function getTree() {
|
|||
sourceTree.value = resp.result; // 报存源数据
|
||||
handleTreeMap(resp.result); // 将树形结构转换为map结构
|
||||
treeData.value = resp.result; // 第一次不用进行过滤
|
||||
cb && cb();
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false;
|
||||
|
@ -202,15 +203,10 @@ const openDialog = (row: any = {}) => {
|
|||
};
|
||||
init();
|
||||
function init() {
|
||||
getTree();
|
||||
getTree(save ? openDialog : undefined);
|
||||
watch(selectedKeys, (n) => {
|
||||
emits('change', n[0]);
|
||||
});
|
||||
if (save) {
|
||||
nextTick(() => {
|
||||
openDialog();
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
@ -16,13 +16,7 @@
|
|||
<j-form-item
|
||||
name="name"
|
||||
label="姓名"
|
||||
:rules="[
|
||||
{ required: true, message: '请输入姓名' },
|
||||
{
|
||||
max: 64,
|
||||
message: '最多可输入64个字符',
|
||||
},
|
||||
]"
|
||||
:rules="[{ required: true, message: '请输入姓名' }]"
|
||||
>
|
||||
<j-input
|
||||
v-model:value="form.data.name"
|
||||
|
@ -35,7 +29,7 @@
|
|||
name="username"
|
||||
label="用户名"
|
||||
:rules="[
|
||||
{ required: true },
|
||||
{ required: true, message: '' },
|
||||
{
|
||||
validator: form.rules.checkUserName,
|
||||
trigger: 'blur',
|
||||
|
@ -56,7 +50,7 @@
|
|||
name="password"
|
||||
label="密码"
|
||||
:rules="[
|
||||
{ required: true },
|
||||
{ required: true, message: '' },
|
||||
{
|
||||
validator: form.rules.checkPassword,
|
||||
trigger: 'blur',
|
||||
|
@ -76,10 +70,10 @@
|
|||
name="confirmPassword"
|
||||
label="确认密码"
|
||||
:rules="[
|
||||
{ required: true, message: '请输入8~64位的密码' },
|
||||
{ required: true, message: '' },
|
||||
{
|
||||
validator: form.rules.checkAgainPassword,
|
||||
trigger: 'change',
|
||||
trigger: 'blur',
|
||||
},
|
||||
]"
|
||||
>
|
||||
|
@ -91,7 +85,6 @@
|
|||
</j-form-item>
|
||||
</j-col>
|
||||
</j-row>
|
||||
<!-- 还差页面权限 -->
|
||||
<j-row :gutter="24" v-if="form.IsShow('add', 'edit')">
|
||||
<j-col :span="12">
|
||||
<j-form-item name="roleIdList" label="角色" class="flex">
|
||||
|
@ -104,9 +97,8 @@
|
|||
></j-select>
|
||||
|
||||
<PermissionButton
|
||||
:uhasPermission="`${rolePermission}:update`"
|
||||
:hasPermission="`${rolePermission}:add`"
|
||||
@click="form.clickAddItem('roleIdList', 'Role')"
|
||||
class="add-item"
|
||||
>
|
||||
<AIcon type="PlusOutlined" />
|
||||
</PermissionButton>
|
||||
|
@ -128,9 +120,10 @@
|
|||
</template>
|
||||
</j-tree-select>
|
||||
<PermissionButton
|
||||
:uhasPermission="`${deptPermission}:update`"
|
||||
@click="form.clickAddItem('roleIdList', 'Role')"
|
||||
class="add-item"
|
||||
:hasPermission="`${deptPermission}:add`"
|
||||
@click="
|
||||
form.clickAddItem('orgIdList', 'Department')
|
||||
"
|
||||
>
|
||||
<AIcon type="PlusOutlined" />
|
||||
</PermissionButton>
|
||||
|
@ -235,7 +228,6 @@ const form = reactive({
|
|||
rules: {
|
||||
checkUserName: (_rule: Rule, value: string): Promise<any> =>
|
||||
new Promise((resolve, reject) => {
|
||||
console.log(_rule);
|
||||
if (props.type === 'edit') return resolve('');
|
||||
|
||||
if (!value) return reject('请输入用户名');
|
||||
|
@ -248,7 +240,7 @@ const form = reactive({
|
|||
}),
|
||||
checkPassword: (_rule: Rule, value: string): Promise<any> =>
|
||||
new Promise((resolve, reject) => {
|
||||
if (!value) return reject('请输入8~64位的密码');
|
||||
if (!value) return reject('请输入密码');
|
||||
else if (value.length > 64) return reject('最多可输入64个字符');
|
||||
else if (value.length < 8) return reject('密码不能少于8位');
|
||||
validateField_api('password', value).then((resp: any) => {
|
||||
|
@ -258,7 +250,7 @@ const form = reactive({
|
|||
});
|
||||
}),
|
||||
checkAgainPassword: (_rule: Rule, value: string): Promise<any> => {
|
||||
if (!value) return Promise.reject('');
|
||||
if (!value) return Promise.reject('请输入8~64位的密码');
|
||||
return value === form.data.password
|
||||
? Promise.resolve()
|
||||
: Promise.reject('两次密码输入不一致');
|
||||
|
@ -386,6 +378,15 @@ type optionType = {
|
|||
.ant-select {
|
||||
flex: 1;
|
||||
}
|
||||
.ant-tooltip-disabled-compatible-wrapper {
|
||||
.ant-btn {
|
||||
color: rgba(0, 0, 0, 0.25);
|
||||
border-color: #d9d9d9;
|
||||
background: #f5f5f5;
|
||||
text-shadow: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
}
|
||||
.ant-btn {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
<template>
|
||||
<page-container>
|
||||
<div class="user-container">
|
||||
<j-advanced-search :columns="columns" @search="(params:any)=>queryParams = {...params}" />
|
||||
<j-advanced-search
|
||||
:columns="columns"
|
||||
@search="(params:any)=>queryParams = {...params}"
|
||||
/>
|
||||
|
||||
<j-pro-table
|
||||
ref="tableRef"
|
||||
|
@ -15,7 +18,7 @@
|
|||
>
|
||||
<template #headerTitle>
|
||||
<PermissionButton
|
||||
:uhasPermission="`${permission}:add`"
|
||||
:hasPermission="`${permission}:add`"
|
||||
type="primary"
|
||||
@click="table.openDialog('add')"
|
||||
>
|
||||
|
@ -38,7 +41,7 @@
|
|||
<template #action="slotProps">
|
||||
<j-space :size="16">
|
||||
<PermissionButton
|
||||
:uhasPermission="`${permission}:update`"
|
||||
:hasPermission="`${permission}:update`"
|
||||
type="link"
|
||||
:tooltip="{
|
||||
title: '编辑',
|
||||
|
@ -48,7 +51,7 @@
|
|||
<AIcon type="EditOutlined" />
|
||||
</PermissionButton>
|
||||
<PermissionButton
|
||||
:uhasPermission="`${permission}:action`"
|
||||
:hasPermission="`${permission}:action`"
|
||||
type="link"
|
||||
:tooltip="{
|
||||
title: `${slotProps.status ? '禁用' : '启用'}`,
|
||||
|
@ -64,7 +67,7 @@
|
|||
<play-circle-outlined v-else />
|
||||
</PermissionButton>
|
||||
<PermissionButton
|
||||
:uhasPermission="`${permission}:update`"
|
||||
:hasPermission="`${permission}:update`"
|
||||
type="link"
|
||||
:tooltip="{
|
||||
title: '重置密码',
|
||||
|
@ -75,7 +78,7 @@
|
|||
</PermissionButton>
|
||||
<PermissionButton
|
||||
type="link"
|
||||
:uhasPermission="`${permission}:delete`"
|
||||
:hasPermission="`${permission}:delete`"
|
||||
:tooltip="{
|
||||
title: slotProps.status
|
||||
? '请先禁用,再删除'
|
||||
|
@ -133,7 +136,6 @@ const columns = [
|
|||
dataIndex: 'username',
|
||||
key: 'username',
|
||||
ellipsis: true,
|
||||
fixed: 'left',
|
||||
search: {
|
||||
type: 'string',
|
||||
},
|
||||
|
@ -143,7 +145,6 @@ const columns = [
|
|||
dataIndex: 'type',
|
||||
key: 'type',
|
||||
ellipsis: true,
|
||||
fixed: 'left',
|
||||
search: {
|
||||
type: 'select',
|
||||
options: () =>
|
||||
|
@ -186,7 +187,6 @@ const columns = [
|
|||
dataIndex: 'telephone',
|
||||
key: 'telephone',
|
||||
ellipsis: true,
|
||||
fixed: 'left',
|
||||
search: {
|
||||
type: 'string',
|
||||
},
|
||||
|
@ -196,7 +196,6 @@ const columns = [
|
|||
dataIndex: 'email',
|
||||
key: 'email',
|
||||
ellipsis: true,
|
||||
fixed: 'left',
|
||||
search: {
|
||||
type: 'string',
|
||||
},
|
||||
|
@ -205,10 +204,11 @@ const columns = [
|
|||
title: '操作',
|
||||
dataIndex: 'action',
|
||||
key: 'action',
|
||||
fixed: 'right',
|
||||
scopedSlots: true,
|
||||
},
|
||||
];
|
||||
const queryParams = ({});
|
||||
const queryParams = ref({});
|
||||
|
||||
const tableRef = ref<Record<string, any>>({}); // 表格实例
|
||||
const table = {
|
||||
|
|
Loading…
Reference in New Issue