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