perf(权限模块): 优化代码,修改bug
1.修改api路径 2.优化事务代码 3.逐步去除英文展示
This commit is contained in:
parent
6f08eda851
commit
92f4189810
@ -21,7 +21,7 @@ export interface AuthRecord extends AuthCreateRecord {
|
|||||||
// 查询所有的权限列表
|
// 查询所有的权限列表
|
||||||
export function queryAuthList(data: any) {
|
export function queryAuthList(data: any) {
|
||||||
return axios({
|
return axios({
|
||||||
url: '/api/rest/auth', // 路径
|
url: '/api/rest/authority', // 路径
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params: data, // 参数
|
params: data, // 参数
|
||||||
})
|
})
|
||||||
@ -29,27 +29,27 @@ export function queryAuthList(data: any) {
|
|||||||
|
|
||||||
// 切换启用状态
|
// 切换启用状态
|
||||||
export function enabled(id: string) {
|
export function enabled(id: string) {
|
||||||
return axios.patch(`/api/rest/auth/toggle/${id}`);
|
return axios.patch(`/api/rest/authority/toggle/${id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除
|
// 删除
|
||||||
export function remove(id: string) {
|
export function remove(id: string) {
|
||||||
return axios.delete(`/api/rest/auth/${id}`);
|
return axios.delete(`/api/rest/authority/${id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 添加
|
// 添加
|
||||||
export function create(data: AuthCreateRecord) {
|
export function create(data: AuthCreateRecord) {
|
||||||
return axios.post(`/api/rest/auth`, data);
|
return axios.post(`/api/rest/authority`, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新
|
// 更新
|
||||||
export function update(data: AuthRecord) {
|
export function update(data: AuthRecord) {
|
||||||
return axios.patch(`/api/rest/auth/${data.id}`, data);
|
return axios.patch(`/api/rest/authority/${data.id}`, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取详情
|
// 获取详情
|
||||||
export function getDetail(id: string) {
|
export function getDetail(id: string) {
|
||||||
return axios.get<AuthRecord>(`/api/rest/auth/${id}`);
|
return axios.get<AuthRecord>(`/api/rest/authority/${id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// export function queryRoles(params?: ListParams<Partial<RoleRecord>>) {
|
// export function queryRoles(params?: ListParams<Partial<RoleRecord>>) {
|
||||||
|
@ -62,7 +62,7 @@
|
|||||||
});
|
});
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const modalTitle = computed(() => {
|
const modalTitle = computed(() => {
|
||||||
return props.isCreate ? t('Create Auth Info') : t('Edit Auth Info');
|
return props.isCreate ? '创建权限' : '编辑权限';
|
||||||
});
|
});
|
||||||
const { visible, setVisible } = useVisible(false);
|
const { visible, setVisible } = useVisible(false);
|
||||||
const createEditRef = ref<FormInstance>();
|
const createEditRef = ref<FormInstance>();
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<Breadcrumb :items="['menu.system', '权限管理']" />
|
<Breadcrumb :items="['系统管理', '权限管理']" />
|
||||||
<a-card class="general-card" title=" ">
|
<a-card class="general-card" title=" ">
|
||||||
<a-row>
|
<a-row>
|
||||||
<a-col :flex="1">
|
<a-col :flex="1">
|
||||||
@ -21,13 +21,13 @@
|
|||||||
<template #icon>
|
<template #icon>
|
||||||
<icon-search />
|
<icon-search />
|
||||||
</template>
|
</template>
|
||||||
{{ $t('searchTable.form.search') }}
|
查询
|
||||||
</a-button>
|
</a-button>
|
||||||
<a-button @click="reset">
|
<a-button @click="reset">
|
||||||
<template #icon>
|
<template #icon>
|
||||||
<icon-refresh />
|
<icon-refresh />
|
||||||
</template>
|
</template>
|
||||||
{{ $t('searchTable.form.reset') }}
|
重置
|
||||||
</a-button>
|
</a-button>
|
||||||
</a-space>
|
</a-space>
|
||||||
</a-col>
|
</a-col>
|
||||||
@ -40,13 +40,13 @@
|
|||||||
</a-space>
|
</a-space>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="12" style="display: flex; align-items: center; justify-content: end">
|
<a-col :span="12" style="display: flex; align-items: center; justify-content: end">
|
||||||
<a-tooltip :content="$t('searchTable.actions.refresh')">
|
<a-tooltip content='刷新'>
|
||||||
<div class="action-icon" @click="fetchData">
|
<div class="action-icon" @click="fetchData">
|
||||||
<icon-refresh size="18" />
|
<icon-refresh size="18" />
|
||||||
</div>
|
</div>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
<a-dropdown @select="handleSelectDensity">
|
<a-dropdown @select="handleSelectDensity">
|
||||||
<a-tooltip :content="$t('searchTable.actions.density')">
|
<a-tooltip content='密度'>
|
||||||
<div class="action-icon"><icon-line-height size="18" /></div>
|
<div class="action-icon"><icon-line-height size="18" /></div>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
<template #content>
|
<template #content>
|
||||||
@ -56,7 +56,7 @@
|
|||||||
</a-doption>
|
</a-doption>
|
||||||
</template>
|
</template>
|
||||||
</a-dropdown>
|
</a-dropdown>
|
||||||
<a-tooltip :content="$t('searchTable.actions.columnSetting')">
|
<a-tooltip content='列设置'>
|
||||||
<a-popover trigger="click" position="bl" @popup-visible-change="popupVisibleChange">
|
<a-popover trigger="click" position="bl" @popup-visible-change="popupVisibleChange">
|
||||||
<div class="action-icon"><icon-settings size="18" /></div>
|
<div class="action-icon"><icon-settings size="18" /></div>
|
||||||
<template #content>
|
<template #content>
|
||||||
@ -81,8 +81,26 @@
|
|||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
</a-col>
|
</a-col>
|
||||||
</a-row>
|
</a-row>
|
||||||
<AuthTable :data="renderData" :pagination="pagination" :loading="loading" @pageChange="onPageChange"
|
<a-table row-key="id" :loading="loading" :pagination="false" :columns="(cloneColumns as TableColumnData[])" :data="renderData" :bordered="false"
|
||||||
:columns="(cloneColumns as TableColumnData[])" @search="search" />
|
:size="sizeof" style="margin-bottom: 40px" @pageChange="onPageChange">
|
||||||
|
<template #index="{ rowIndex }">
|
||||||
|
{{ rowIndex + 1 }}
|
||||||
|
</template>
|
||||||
|
<template #enabled="{ record }">
|
||||||
|
<a-switch :model-value="record.enabled" :checked-value="true" :unchecked-value="false"
|
||||||
|
@change="enabledStatus(record)" />
|
||||||
|
</template>
|
||||||
|
<template #operations="{ record }">
|
||||||
|
<!-- 编辑 -->
|
||||||
|
<AuthEdit ref="editRef" :prem="record" :is-create="false" @refresh="fetchData" />
|
||||||
|
<a-popconfirm content='确认删除此权限?' type="error" @ok="handleDelete(record)">
|
||||||
|
<a-button type="outline" size="small" status="danger" style="padding: 7px">
|
||||||
|
<template #icon><icon-delete /></template>
|
||||||
|
删除
|
||||||
|
</a-button>
|
||||||
|
</a-popconfirm>
|
||||||
|
</template>
|
||||||
|
</a-table>
|
||||||
<a-pagination style="float: right; position: relative; right: 1px; bottom: 25px" :total="pagination.total"
|
<a-pagination style="float: right; position: relative; right: 1px; bottom: 25px" :total="pagination.total"
|
||||||
show-total show-jumper show-page-size @page-size-change="onSizeChange" @change="onPageChange" />
|
show-total show-jumper show-page-size @page-size-change="onSizeChange" @change="onPageChange" />
|
||||||
</a-card>
|
</a-card>
|
||||||
@ -90,8 +108,9 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref, watch, computed } from 'vue';
|
import { ref, watch, computed, onMounted } from 'vue';
|
||||||
// import { useI18n } from 'vue-i18n';
|
import dayjs from 'dayjs';
|
||||||
|
import { Message } from '@arco-design/web-vue';
|
||||||
import useLoading from '@/hooks/loading';
|
import useLoading from '@/hooks/loading';
|
||||||
import { useAuthStore } from '@/store';
|
import { useAuthStore } from '@/store';
|
||||||
import { AuthRecord } from '@/api/authority';
|
import { AuthRecord } from '@/api/authority';
|
||||||
@ -99,9 +118,7 @@ import { Pagination } from '@/types/global';
|
|||||||
import useTableOption from '@/hooks/table-option';
|
import useTableOption from '@/hooks/table-option';
|
||||||
import type { TableColumnData } from '@arco-design/web-vue/es/table/interface';
|
import type { TableColumnData } from '@arco-design/web-vue/es/table/interface';
|
||||||
import AuthEdit from './components/auth-edit.vue';
|
import AuthEdit from './components/auth-edit.vue';
|
||||||
import AuthTable from './components/auth-table.vue';
|
|
||||||
|
|
||||||
// const { t } = useI18n();
|
|
||||||
const {loading, setLoading} = useLoading();
|
const {loading, setLoading} = useLoading();
|
||||||
const authStore = useAuthStore();
|
const authStore = useAuthStore();
|
||||||
const renderData = ref<AuthRecord[]>([]);
|
const renderData = ref<AuthRecord[]>([]);
|
||||||
@ -145,14 +162,6 @@ const columns = computed<TableColumnData[]>(() => [
|
|||||||
title: "备注",
|
title: "备注",
|
||||||
dataIndex: 'remark',
|
dataIndex: 'remark',
|
||||||
},
|
},
|
||||||
{
|
|
||||||
title: "创建时间",
|
|
||||||
dataIndex: 'createTime',
|
|
||||||
slotName: 'createTime',
|
|
||||||
sortable: {
|
|
||||||
sortDirections: ['ascend', 'descend'],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
title: "状态",
|
title: "状态",
|
||||||
dataIndex: 'enabled',
|
dataIndex: 'enabled',
|
||||||
@ -175,7 +184,6 @@ const fetchData = async (params: any) => {
|
|||||||
pagination.total = res.data.total;
|
pagination.total = res.data.total;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// you can report use errorHandler or other
|
// you can report use errorHandler or other
|
||||||
console.log(err);
|
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
@ -188,7 +196,10 @@ const search = () => {
|
|||||||
...formModel.value,
|
...formModel.value,
|
||||||
} as unknown as any);
|
} as unknown as any);
|
||||||
};
|
};
|
||||||
search();
|
|
||||||
|
onMounted(() => {
|
||||||
|
search();
|
||||||
|
})
|
||||||
// 分页发生改变
|
// 分页发生改变
|
||||||
const onPageChange = (current: number) => {
|
const onPageChange = (current: number) => {
|
||||||
pagination.page = current;
|
pagination.page = current;
|
||||||
@ -207,6 +218,41 @@ const reset = () => {
|
|||||||
formModel.value = generateFormModel();
|
formModel.value = generateFormModel();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 是否启用
|
||||||
|
const enabledStatus = async (record: any) => {
|
||||||
|
record.enabled = !record.enabled;
|
||||||
|
const res = await authStore.enabledAuth(record.id);
|
||||||
|
if (res.status === 200) {
|
||||||
|
Message.success({
|
||||||
|
content: '修改成功',
|
||||||
|
duration: 3 * 1000,
|
||||||
|
});
|
||||||
|
search();
|
||||||
|
} else {
|
||||||
|
Message.error({
|
||||||
|
content: '修改失败',
|
||||||
|
duration: 3 * 1000,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 删除
|
||||||
|
const handleDelete = async (record: AuthRecord) => {
|
||||||
|
const res = await authStore.removeAuth(record.id);
|
||||||
|
if (res.status === 200) {
|
||||||
|
Message.success({
|
||||||
|
content: '删除成功',
|
||||||
|
duration: 5 * 1000,
|
||||||
|
});
|
||||||
|
search();
|
||||||
|
} else {
|
||||||
|
Message.error({
|
||||||
|
content: '删除失败',
|
||||||
|
duration: 3 * 1000,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
watch(() => columns.value, deepClone, { deep: true, immediate: true });
|
watch(() => columns.value, deepClone, { deep: true, immediate: true });
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user