fix: 角色管理调整

This commit is contained in:
TsMask
2023-09-05 17:11:45 +08:00
parent 1ab5c4f3c6
commit 520d1ffcf9
4 changed files with 51 additions and 61 deletions

View File

@@ -21,7 +21,7 @@ export function exportRole(query: Record<string, any>) {
*/
export function listRole(query: Record<string, any>) {
return request({
url: '/system/role/list',
url: '/roleManage/v1/roles',
method: 'get',
params: query,
});
@@ -34,7 +34,7 @@ export function listRole(query: Record<string, any>) {
*/
export function getRole(roleId: string | number) {
return request({
url: `/system/role/${roleId}`,
url: `/roleManage/v1/role/${roleId}`,
method: 'get',
});
}
@@ -46,7 +46,7 @@ export function getRole(roleId: string | number) {
*/
export function addRole(data: Record<string, any>) {
return request({
url: '/system/role',
url: '/roleManage/v1/role',
method: 'post',
data: data,
});
@@ -59,7 +59,7 @@ export function addRole(data: Record<string, any>) {
*/
export function updateRole(data: Record<string, any>) {
return request({
url: '/system/role',
url: '/roleManage/v1/role',
method: 'put',
data: data,
});
@@ -72,7 +72,7 @@ export function updateRole(data: Record<string, any>) {
*/
export function delRole(roleId: string | number) {
return request({
url: `/system/role/${roleId}`,
url: `/roleManage/v1/role/${roleId}`,
method: 'delete',
});
}
@@ -85,7 +85,7 @@ export function delRole(roleId: string | number) {
*/
export function changeRoleStatus(roleId: string, status: string | number) {
return request({
url: '/system/role/changeStatus',
url: '/roleManage/v1/role/changeStatus',
method: 'put',
data: {
roleId,
@@ -101,7 +101,7 @@ export function changeRoleStatus(roleId: string, status: string | number) {
*/
export function dataScope(data: Record<string, any>) {
return request({
url: '/system/role/dataScope',
url: '/roleManage/v1/role/dataScope',
method: 'put',
data: data,
});
@@ -114,7 +114,7 @@ export function dataScope(data: Record<string, any>) {
*/
export function authUserAllocatedList(query: Record<string, any>) {
return request({
url: '/system/role/authUser/allocatedList',
url: '/roleManage/v1/role/authUser/allocatedList',
method: 'get',
params: query,
});
@@ -127,7 +127,7 @@ export function authUserAllocatedList(query: Record<string, any>) {
*/
export function authUserChecked(data: Record<string, any>) {
return request({
url: '/system/role/authUser/checked',
url: '/roleManage/v1/role/authUser/checked',
method: 'put',
data: data,
});

View File

@@ -90,22 +90,22 @@ let tableState: TabeStateType = reactive({
let tableColumns: ColumnsType = [
{
title: '用户编号',
dataIndex: 'userId',
dataIndex: 'id',
align: 'center',
},
{
title: '登录账号',
dataIndex: 'userName',
dataIndex: 'accountId',
align: 'center',
},
{
title: '用户昵称',
dataIndex: 'nickName',
title: '用户',
dataIndex: 'name',
align: 'center',
},
{
title: '手机号码',
dataIndex: 'phonenumber',
dataIndex: 'phone',
align: 'center',
},
{
@@ -124,13 +124,13 @@ let tableColumns: ColumnsType = [
dataIndex: 'createTime',
align: 'center',
customRender(opt) {
if (+opt.value <= 0) return '';
return parseDateToStr(+opt.value);
if (!opt.value) return '';
return parseDateToStr(opt.value);
},
},
{
title: '操作',
key: 'userId',
key: 'id',
align: 'center',
},
];
@@ -215,7 +215,7 @@ function fnModalOk(userIds: string[] | number[]) {
roleId: roleId,
}).then(res => {
hide();
if (res.code === 200) {
if (res.code === 1) {
modalState.visibleBySelectUser = false;
message.success({
content: `授权用户添加成功`,
@@ -247,7 +247,7 @@ function fnRecordDelete(userId: string | number) {
authUserChecked({ checked: false, userIds: userId, roleId: roleId }).then(
res => {
hide();
if (res.code === 200) {
if (res.code === 1) {
message.success({
content: `取消授权成功`,
duration: 3,
@@ -280,7 +280,7 @@ function fnGetList() {
if (tableState.loading) return;
tableState.loading = true;
authUserAllocatedList(toRaw(queryParams)).then(res => {
if (res.code === 200 && Array.isArray(res.rows)) {
if (res.code === 1 && Array.isArray(res.rows)) {
// 取消勾选
if (tableState.selectedRowKeys.length > 0) {
tableState.selectedRowKeys = [];
@@ -333,7 +333,7 @@ onMounted(() => {
></a-input>
</a-form-item>
</a-col>
<a-col :lg="6" :md="12" :xs="24">
<!-- <a-col :lg="6" :md="12" :xs="24">
<a-form-item label="手机号码" name="phonenumber">
<a-input
v-model:value="queryParams.phonenumber"
@@ -342,7 +342,7 @@ onMounted(() => {
placeholder="请输入手机号码"
></a-input>
</a-form-item>
</a-col>
</a-col> -->
<a-col :lg="6" :md="12" :xs="24">
<a-form-item label="用户状态" name="status">
<a-select
@@ -452,7 +452,7 @@ onMounted(() => {
<!-- 表格列表 -->
<a-table
class="table"
row-key="userId"
row-key="id"
:columns="tableColumns"
:loading="tableState.loading"
:data-source="tableState.data"
@@ -469,13 +469,13 @@ onMounted(() => {
<template v-if="column.key === 'status'">
<DictTag :options="dict.sysNormalDisable" :value="record.status" />
</template>
<template v-if="column.key === 'userId'">
<template v-if="column.key === 'id'">
<a-space :size="8" align="center">
<a-tooltip>
<template #title>取消授权</template>
<a-button
type="link"
@click.prevent="fnRecordDelete(record.userId)"
@click.prevent="fnRecordDelete(record.id)"
v-perms:has="['system:role:remove']"
>
<template #icon><UserDeleteOutlined /></template>

View File

@@ -87,24 +87,14 @@ let tableState: TabeStateType = reactive({
let tableColumns: ColumnsType = [
{
title: '用户编号',
dataIndex: 'userId',
dataIndex: 'id',
align: 'center',
},
{
title: '登录账号',
dataIndex: 'userName',
dataIndex: 'accountId',
align: 'center',
},
{
title: '用户昵称',
dataIndex: 'nickName',
align: 'center',
},
{
title: '手机号码',
dataIndex: 'phonenumber',
align: 'center',
},
},
{
title: '用户状态',
dataIndex: 'status',
@@ -116,8 +106,8 @@ let tableColumns: ColumnsType = [
dataIndex: 'createTime',
align: 'center',
customRender(opt) {
if (+opt.value <= 0) return '';
return parseDateToStr(+opt.value);
if (!opt.value) return '';
return parseDateToStr(opt.value);
},
},
];
@@ -160,7 +150,7 @@ function fnGetList() {
if (tableState.loading) return;
tableState.loading = true;
authUserAllocatedList(toRaw(queryParams)).then(res => {
if (res.code === 200 && Array.isArray(res.rows)) {
if (res.code === 1 && Array.isArray(res.rows)) {
// 取消勾选
if (tableState.selectedRowKeys.length > 0) {
tableState.selectedRowKeys = [];
@@ -233,7 +223,7 @@ watch(
></a-input>
</a-form-item>
</a-col>
<a-col :lg="8" :md="12" :xs="24">
<!-- <a-col :lg="8" :md="12" :xs="24">
<a-form-item label="手机号码" name="phonenumber">
<a-input
v-model:value="queryParams.phonenumber"
@@ -242,7 +232,7 @@ watch(
placeholder="请输入手机号码"
></a-input>
</a-form-item>
</a-col>
</a-col> -->
<a-col :lg="8" :md="12" :xs="24">
<a-form-item label="用户状态" name="status">
<a-select
@@ -273,7 +263,7 @@ watch(
<a-table
class="table"
row-key="userId"
row-key="id"
:columns="tableColumns"
:loading="tableState.loading"
:data-source="tableState.data"
@@ -285,11 +275,11 @@ watch(
onChange: fnTableSelectedRowKeys,
}"
>
<template #bodyCell="{ column, record }">
<!-- <template #bodyCell="{ column, record }">
<template v-if="column.key === 'status'">
<DictTag :options="dict.sysNormalDisable" :value="record.status" />
</template>
</template>
</template> -->
</a-table>
</a-modal>
</template>

View File

@@ -305,9 +305,9 @@ function fnModalVisibleByVive(roleId: string | number) {
Promise.all([getRole(roleId), roleMenuTreeSelect(roleId)]).then(resArr => {
modalState.confirmLoading = false;
hide();
if (resArr[0].code === 200 && resArr[0].data) {
if (resArr[0].code === 1 && resArr[0].data) {
modalState.from = Object.assign(modalState.from, resArr[0].data);
if (resArr[1].code === 200 && resArr[1].data) {
if (resArr[1].code === 1 && resArr[1].data) {
const { menus, checkedKeys } = resArr[1].data;
menuTree.checkedKeys = parseTreeKeys(menus, 'id');
menuTree.expandedKeys = parseTreeNodeKeys(menus, 'id');
@@ -343,7 +343,7 @@ function fnModalVisibleByEdit(roleId?: string | number) {
menuTreeSelect().then(res => {
modalState.confirmLoading = false;
hide();
if (res.code === 200 && Array.isArray(res.data)) {
if (res.code === 1 && Array.isArray(res.data)) {
menuTree.checkedKeys = parseTreeKeys(res.data, 'id');
menuTree.expandedKeys = parseTreeNodeKeys(res.data, 'id');
menuTree.treeData = res.data;
@@ -361,9 +361,9 @@ function fnModalVisibleByEdit(roleId?: string | number) {
Promise.all([getRole(roleId), roleMenuTreeSelect(roleId)]).then(resArr => {
modalState.confirmLoading = false;
hide();
if (resArr[0].code === 200 && resArr[0].data) {
if (resArr[0].code === 1 && resArr[0].data) {
modalState.from = Object.assign(modalState.from, resArr[0].data);
if (resArr[1].code === 200 && resArr[1].data) {
if (resArr[1].code === 1 && resArr[1].data) {
const { menus, checkedKeys } = resArr[1].data;
menuTree.checkedKeys = parseTreeKeys(menus, 'id');
menuTree.expandedKeys = parseTreeNodeKeys(menus, 'id');
@@ -396,7 +396,7 @@ function fnModalOk() {
message.loading({ content: '请稍等...', key });
role
.then(res => {
if (res.code === 200) {
if (res.code === 1) {
message.success({
content: `${modalState.title}成功`,
key,
@@ -507,7 +507,7 @@ function fnModalOkDataScope() {
}
dataScope(fromInfo)
.then(res => {
if (res.code === 200) {
if (res.code === 1) {
message.success({
content: `${modalState.title}成功`,
duration: 2,
@@ -542,9 +542,9 @@ function fnRecordDataScope(roleId: string | number) {
// 查询角色详细同时根据角色ID查询部门树结构
Promise.all([getRole(roleId), roleDeptTreeSelect(roleId)])
.then(resArr => {
if (resArr[0].code === 200 && resArr[0].data) {
if (resArr[0].code === 1 && resArr[0].data) {
modalState.from = Object.assign(modalState.from, resArr[0].data);
if (resArr[1].code === 200 && resArr[1].data) {
if (resArr[1].code === 1 && resArr[1].data) {
const { depts, checkedKeys } = resArr[1].data;
deptTree.checkedKeys = parseTreeKeys(depts, 'id');
deptTree.expandedKeys = parseTreeNodeKeys(depts, 'id');
@@ -591,7 +591,7 @@ function fnRecordStatus(row: Record<string, string>) {
const hide = message.loading('请稍等...', 0);
changeRoleStatus(row.roleId, row.status).then(res => {
hide();
if (res.code === 200) {
if (res.code === 1) {
message.success({
content: `${row.roleName} ${text}成功`,
duration: 2,
@@ -626,7 +626,7 @@ function fnRecordDelete(roleId: string = '0') {
const hide = message.loading('请稍等...', 0);
delRole(roleId).then(res => {
hide();
if (res.code === 200) {
if (res.code === 1) {
message.success({
content: `删除成功`,
duration: 2,
@@ -651,7 +651,7 @@ function fnExportList() {
onOk() {
const hide = message.loading('请稍等...', 0);
exportRole(toRaw(queryParams)).then(res => {
if (res.code === 200) {
if (res.code === 1) {
message.success({
content: `已完成导出`,
duration: 2,
@@ -675,7 +675,7 @@ function fnGetList() {
queryParams.beginTime = queryRangePicker.value[0];
queryParams.endTime = queryRangePicker.value[1];
listRole(toRaw(queryParams)).then(res => {
if (res.code === 200 && Array.isArray(res.rows)) {
if (res.code === 1 && Array.isArray(res.rows)) {
// 取消勾选
if (tableState.selectedRowKeys.length > 0) {
tableState.selectedRowKeys = [];
@@ -923,7 +923,7 @@ onMounted(() => {
<template #icon><DeleteOutlined /></template>
</a-button>
</a-tooltip>
<a-tooltip v-if="record.roleId !== '1'">
<!-- <a-tooltip v-if="record.roleId !== '1'">
<template #title>分配数据权限</template>
<a-button
type="link"
@@ -932,7 +932,7 @@ onMounted(() => {
>
<template #icon><SecurityScanOutlined /></template>
</a-button>
</a-tooltip>
</a-tooltip> -->
<a-tooltip v-if="record.roleId !== '1'">
<template #title>分配用户</template>
<a-button