refactor: 优化部分前端代码

1.前端部分 id 类型调整为 number(去除 Jackson 针对 Long 等类型的全局转换后,需要调整下前端部分 id 的类)
2.前端部分表格列去除 data-index(部分表格列,使用了 slot,则无需再使用 data-index 属性)
3.部分字典状态遗漏更改
This commit is contained in:
Charles7c 2023-09-17 20:38:56 +08:00
parent 1f73aa732d
commit 2755bc8479
19 changed files with 84 additions and 104 deletions

View File

@ -20,6 +20,7 @@ import lombok.Getter;
import lombok.RequiredArgsConstructor;
import top.charles7c.cnadmin.common.base.BaseEnum;
import top.charles7c.cnadmin.common.constant.UIConsts;
/**
* 启用/禁用状态枚举
@ -32,11 +33,12 @@ import top.charles7c.cnadmin.common.base.BaseEnum;
public enum DisEnableStatusEnum implements BaseEnum<Integer> {
/** 启用 */
ENABLE(1, "启用"),
ENABLE(1, "启用", UIConsts.COLOR_SUCCESS),
/** 禁用 */
DISABLE(2, "禁用"),;
DISABLE(2, "禁用", UIConsts.COLOR_ERROR),;
private final Integer value;
private final String description;
private final String color;
}

View File

@ -261,7 +261,7 @@
import checkPermission from '@/utils/permission';
const { proxy } = getCurrentInstance() as any;
// const { DisEnableStatusEnum } = proxy.useDict('DisEnableStatusEnum');
// const { dis_enable_status_enum } = proxy.useDict('dis_enable_status_enum');
const dataList = ref<DataRecord[]>([]);
const dataDetail = ref<DataRecord>({

View File

@ -27,7 +27,7 @@ export interface DashboardGeoDistributionRecord {
}
export interface DashboardAnnouncementRecord {
id: string;
id: number;
title: string;
type: number;
}

View File

@ -4,7 +4,7 @@ import qs from 'query-string';
const BASE_URL = '/monitor/log';
export interface LogRecord {
id?: string;
id?: number;
clientIp: string;
location: string;
browser: string;
@ -102,6 +102,6 @@ export function listSystemLog(params: SystemLogParam) {
});
}
export function getSystemLog(id: string) {
export function getSystemLog(id: number) {
return axios.get<SystemLogDetailRecord>(`${BASE_URL}/system/${id}`);
}

View File

@ -4,7 +4,7 @@ import qs from 'query-string';
const BASE_URL = '/system/announcement';
export interface DataRecord {
id?: string;
id?: number;
title?: string;
content?: string;
status?: number;
@ -42,7 +42,7 @@ export function list(params: ListParam) {
});
}
export function get(id: string) {
export function get(id: number) {
return axios.get<DataRecord>(`${BASE_URL}/${id}`);
}
@ -50,10 +50,10 @@ export function add(req: DataRecord) {
return axios.post(BASE_URL, req);
}
export function update(req: DataRecord, id: string) {
export function update(req: DataRecord, id: number) {
return axios.put(`${BASE_URL}/${id}`, req);
}
export function del(ids: string | Array<string>) {
export function del(ids: number | Array<number>) {
return axios.delete(`${BASE_URL}/${ids}`);
}

View File

@ -4,9 +4,9 @@ import qs from 'query-string';
const BASE_URL = '/system/dept';
export interface DataRecord {
id?: string;
id?: number;
name: string;
parentId?: string;
parentId?: number;
description?: string;
sort: number;
status?: number;
@ -34,7 +34,7 @@ export function list(params: ListParam) {
});
}
export function get(id: string) {
export function get(id: number) {
return axios.get<DataRecord>(`${BASE_URL}/${id}`);
}
@ -42,10 +42,10 @@ export function add(req: DataRecord) {
return axios.post(BASE_URL, req);
}
export function update(req: DataRecord, id: string) {
export function update(req: DataRecord, id: number) {
return axios.put(`${BASE_URL}/${id}`, req);
}
export function del(ids: string | Array<string>) {
export function del(ids: number | Array<number>) {
return axios.delete(`${BASE_URL}/${ids}`);
}

View File

@ -4,9 +4,9 @@ import qs from 'query-string';
const BASE_URL = '/system/menu';
export interface DataRecord {
id?: string;
id?: number;
title: string;
parentId?: string;
parentId?: number;
type: number;
path?: string;
name?: string;
@ -40,7 +40,7 @@ export function list(params: ListParam) {
});
}
export function get(id: string) {
export function get(id: number) {
return axios.get<DataRecord>(`${BASE_URL}/${id}`);
}
@ -48,10 +48,10 @@ export function add(req: DataRecord) {
return axios.post(BASE_URL, req);
}
export function update(req: DataRecord, id: string) {
export function update(req: DataRecord, id: number) {
return axios.put(`${BASE_URL}/${id}`, req);
}
export function del(ids: string | Array<string>) {
export function del(ids: number | Array<number>) {
return axios.delete(`${BASE_URL}/${ids}`);
}

View File

@ -4,14 +4,14 @@ import qs from 'query-string';
const BASE_URL = '/system/role';
export interface DataRecord {
id?: string;
id?: number;
name: string;
code?: string;
sort?: number;
description?: string;
menuIds?: Array<string>;
menuIds?: Array<number>;
dataScope: number;
deptIds?: Array<string>;
deptIds?: Array<number>;
status?: number;
type?: number;
createUserString?: string;
@ -43,7 +43,7 @@ export function list(params: ListParam) {
});
}
export function get(id: string) {
export function get(id: number) {
return axios.get<DataRecord>(`${BASE_URL}/${id}`);
}
@ -51,10 +51,10 @@ export function add(req: DataRecord) {
return axios.post(BASE_URL, req);
}
export function update(req: DataRecord, id: string) {
export function update(req: DataRecord, id: number) {
return axios.put(`${BASE_URL}/${id}`, req);
}
export function del(ids: string | Array<string>) {
export function del(ids: number | Array<number>) {
return axios.delete(`${BASE_URL}/${ids}`);
}

View File

@ -4,7 +4,7 @@ import qs from 'query-string';
const BASE_URL = '/system/user';
export interface DataRecord {
id?: string;
id?: number;
username: string;
nickname: string;
gender: number;
@ -18,9 +18,9 @@ export interface DataRecord {
createTime?: string;
updateUserString?: string;
updateTime?: string;
deptId?: string;
deptId?: number;
deptName?: string;
roleIds?: Array<string>;
roleIds?: Array<number>;
roleNames?: Array<string>;
disabled?: boolean;
}
@ -48,7 +48,7 @@ export function list(params: ListParam) {
});
}
export function get(id: string) {
export function get(id: number) {
return axios.get<DataRecord>(`${BASE_URL}/${id}`);
}
@ -56,22 +56,22 @@ export function add(req: DataRecord) {
return axios.post(BASE_URL, req);
}
export function update(req: DataRecord, id: string) {
export function update(req: DataRecord, id: number) {
return axios.put(`${BASE_URL}/${id}`, req);
}
export function del(ids: string | Array<string>) {
export function del(ids: number | Array<number>) {
return axios.delete(`${BASE_URL}/${ids}`);
}
export function resetPassword(id: string) {
export function resetPassword(id: number) {
return axios.patch(`${BASE_URL}/${id}/password`);
}
export interface UpdateUserRoleReq {
roleIds?: Array<string>;
roleIds?: Array<number>;
}
export function updateUserRole(req: UpdateUserRoleReq, id: string) {
export function updateUserRole(req: UpdateUserRoleReq, id: number) {
return axios.patch(`${BASE_URL}/${id}/role`, req);
}

View File

@ -110,7 +110,7 @@
*
* @param id ID
*/
const toDetail = async (id: string) => {
const toDetail = async (id: number) => {
if (detailLoading.value) return;
detailLoading.value = true;
detailVisible.value = true;

View File

@ -21,7 +21,7 @@
{{ rowIndex + 1 }}
</template>
</a-table-column>
<a-table-column title="模块" data-index="module">
<a-table-column title="模块">
<template #cell="{ record }">
<a-typography-paragraph
:ellipsis="{
@ -35,7 +35,6 @@
<a-table-column title="总浏览量" data-index="pvCount" />
<a-table-column
title="日涨幅"
data-index="newPvFromYesterday"
:sortable="{
sortDirections: ['ascend', 'descend'],
}"

View File

@ -14,10 +14,7 @@
:title="$t('basicProfile.column.updateContent')"
data-index="updateContent"
/>
<a-table-column
:title="$t('basicProfile.column.status')"
data-index="status"
>
<a-table-column :title="$t('basicProfile.column.status')">
<template #cell="{ record }">
<p v-if="record.status === 0">
<span class="circle"></span>

View File

@ -343,7 +343,7 @@
*
* @param id ID
*/
const toDetail = async (id: string) => {
const toDetail = async (id: number) => {
visible.value = true;
loading.value = true;
getSystemLog(id)

View File

@ -363,7 +363,7 @@
// TODO
});
const total = ref(0);
const ids = ref<Array<string>>([]);
const ids = ref<Array<number>>([]);
const title = ref('');
const single = ref(true);
const multiple = ref(true);
@ -427,7 +427,7 @@
*
* @param id ID
*/
const toUpdate = (id: string) => {
const toUpdate = (id: number) => {
reset();
get(id).then((res) => {
form.value = res.data;
@ -482,7 +482,7 @@
*
* @param id ID
*/
const toDetail = async (id: string) => {
const toDetail = async (id: number) => {
if (detailLoading.value) return;
detailLoading.value = true;
detailVisible.value = true;
@ -527,7 +527,7 @@
*
* @param ids ID 列表
*/
const handleDelete = (ids: Array<string>) => {
const handleDelete = (ids: Array<number>) => {
del(ids).then((res) => {
proxy.$message.success(res.msg);
getList();

View File

@ -254,8 +254,10 @@
<a-skeleton-line :rows="1" />
</a-skeleton>
<span v-else>
<a-tag v-if="dataDetail.status === 1" color="green">启用</a-tag>
<a-tag v-else color="red">禁用</a-tag>
<dict-tag
:value="dataDetail.status"
:dict="dis_enable_status_enum"
/>
</span>
</a-descriptions-item>
<a-descriptions-item label="部门排序">
@ -330,7 +332,7 @@
updateTime: '',
parentName: '',
});
const ids = ref<Array<string>>([]);
const ids = ref<Array<number>>([]);
const title = ref('');
const single = ref(true);
const multiple = ref(true);
@ -397,7 +399,7 @@
*
* @param id ID
*/
const toUpdate = (id: string) => {
const toUpdate = (id: number) => {
reset();
listDeptTree({}).then((res) => {
treeData.value = res.data;
@ -462,7 +464,7 @@
*
* @param id ID
*/
const toDetail = async (id: string) => {
const toDetail = async (id: number) => {
if (detailLoading.value) return;
detailLoading.value = true;
detailVisible.value = true;
@ -506,7 +508,7 @@
*
* @param ids ID 列表
*/
const handleDelete = (ids: Array<string>) => {
const handleDelete = (ids: Array<number>) => {
del(ids).then((res) => {
proxy.$message.success(res.msg);
getList();

View File

@ -358,7 +358,7 @@
const { dis_enable_status_enum } = proxy.useDict('dis_enable_status_enum');
const dataList = ref<DataRecord[]>([]);
const ids = ref<Array<string>>([]);
const ids = ref<Array<number>>([]);
const title = ref('');
const single = ref(true);
const multiple = ref(true);
@ -425,7 +425,7 @@
*
* @param id ID
*/
const toUpdate = (id: string) => {
const toUpdate = (id: number) => {
reset();
listMenuTree({}).then((res) => {
treeData.value = res.data;
@ -517,7 +517,7 @@
*
* @param ids ID 列表
*/
const handleDelete = (ids: Array<string>) => {
const handleDelete = (ids: Array<number>) => {
del(ids).then((res) => {
proxy.$message.success(res.msg);
getList();

View File

@ -117,7 +117,7 @@
>
<template #columns>
<a-table-column title="ID" data-index="id" />
<a-table-column title="角色名称" data-index="name" :width="130">
<a-table-column title="角色名称" :width="130">
<template #cell="{ record }">
<a-link @click="toDetail(record.id)">{{ record.name }}</a-link>
</template>
@ -129,7 +129,7 @@
</template>
</a-table-column>
<a-table-column title="角色排序" align="center" data-index="sort" />
<a-table-column title="状态" align="center" data-index="status">
<a-table-column title="状态" align="center">
<template #cell="{ record }">
<a-switch
v-model="record.status"
@ -344,8 +344,10 @@
<a-skeleton-line :rows="1" />
</a-skeleton>
<span v-else>
<a-tag v-if="dataDetail.status === 1" color="green">启用</a-tag>
<a-tag v-else color="red">禁用</a-tag>
<dict-tag
:value="dataDetail.status"
:dict="dis_enable_status_enum"
/>
</span>
</a-descriptions-item>
<a-descriptions-item label="数据权限">
@ -455,7 +457,7 @@
deptIds: undefined,
});
const total = ref(0);
const ids = ref<Array<string>>([]);
const ids = ref<Array<number>>([]);
const title = ref('');
const single = ref(true);
const multiple = ref(true);
@ -544,7 +546,7 @@
*
* @param id ID
*/
const toUpdate = (id: string) => {
const toUpdate = (id: number) => {
reset();
menuCheckStrictly.value = false;
deptCheckStrictly.value = false;
@ -695,7 +697,7 @@
*
* @param id ID
*/
const toDetail = async (id: string) => {
const toDetail = async (id: number) => {
if (detailLoading.value) return;
getMenuTree();
getDeptTree();
@ -741,7 +743,7 @@
*
* @param ids ID 列表
*/
const handleDelete = (ids: Array<string>) => {
const handleDelete = (ids: Array<number>) => {
del(ids).then((res) => {
proxy.$message.success(res.msg);
getList();

View File

@ -439,8 +439,10 @@
<a-skeleton-line :rows="1" />
</a-skeleton>
<span v-else>
<a-tag v-if="dataDetail.status === 1" color="green">启用</a-tag>
<a-tag v-else color="red">禁用</a-tag>
<dict-tag
:value="dataDetail.status"
:dict="dis_enable_status_enum"
/>
</span>
</a-descriptions-item>
<a-descriptions-item label="邮箱">
@ -543,7 +545,7 @@
deptId: undefined,
});
const total = ref(0);
const ids = ref<Array<string>>([]);
const ids = ref<Array<number>>([]);
const title = ref('');
const single = ref(true);
const multiple = ref(true);
@ -636,7 +638,7 @@
*
* @param id ID
*/
const toUpdate = (id: string) => {
const toUpdate = (id: number) => {
reset();
getDeptOptions();
getRoleOptions();
@ -652,7 +654,7 @@
*
* @param id ID
*/
const toUpdateRole = (id: string) => {
const toUpdateRole = (id: number) => {
reset();
getRoleOptions();
get(id).then((res) => {
@ -703,7 +705,7 @@
description: '',
status: 1,
deptId: undefined,
roleIds: [] as Array<string>,
roleIds: [] as Array<number>,
disabled: false,
};
proxy.$refs.formRef?.resetFields();
@ -764,7 +766,7 @@
*
* @param id ID
*/
const toDetail = async (id: string) => {
const toDetail = async (id: number) => {
if (detailLoading.value) return;
detailLoading.value = true;
detailVisible.value = true;
@ -808,7 +810,7 @@
*
* @param ids ID 列表
*/
const handleDelete = (ids: Array<string>) => {
const handleDelete = (ids: Array<number>) => {
del(ids).then((res) => {
proxy.$message.success(res.msg);
getList();
@ -820,7 +822,7 @@
*
* @param id ID
*/
const handleResetPassword = (id: string) => {
const handleResetPassword = (id: number) => {
resetPassword(id).then((res) => {
proxy.$message.success(res.msg);
});

View File

@ -152,37 +152,22 @@
ellipsis
tooltip
/>
<a-table-column title="描述" data-index="comment" :width="170">
<a-table-column title="描述" :width="170">
<template #cell="{ record }">
<a-input v-model="record.comment" />
</template>
</a-table-column>
<a-table-column
title="列表"
data-index="showInList"
:width="60"
align="center"
>
<a-table-column title="列表" :width="60" align="center">
<template #cell="{ record }">
<a-checkbox v-model="record.showInList" value="true" />
</template>
</a-table-column>
<a-table-column
title="表单"
data-index="showInForm"
:width="60"
align="center"
>
<a-table-column title="表单" :width="60" align="center">
<template #cell="{ record }">
<a-checkbox v-model="record.showInForm" value="true" />
</template>
</a-table-column>
<a-table-column
title="必填"
data-index="isRequired"
:width="60"
align="center"
>
<a-table-column title="必填" :width="60" align="center">
<template #cell="{ record }">
<a-checkbox
v-if="record.showInForm"
@ -192,21 +177,12 @@
<a-checkbox v-else disabled />
</template>
</a-table-column>
<a-table-column
title="查询"
data-index="showInQuery"
:width="60"
align="center"
>
<a-table-column title="查询" :width="60" align="center">
<template #cell="{ record }">
<a-checkbox v-model="record.showInQuery" value="true" />
</template>
</a-table-column>
<a-table-column
title="表单类型"
data-index="formType"
:width="150"
>
<a-table-column title="表单类型" :width="150">
<template #cell="{ record }">
<a-select
v-if="record.showInForm || record.showInQuery"
@ -217,7 +193,7 @@
<span v-else>无需设置</span>
</template>
</a-table-column>
<a-table-column title="查询方式" data-index="queryType">
<a-table-column title="查询方式">
<template #cell="{ record }">
<a-select
v-if="record.showInQuery"