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) {
|
||||
return axios({
|
||||
url: '/api/rest/auth', // 路径
|
||||
url: '/api/rest/authority', // 路径
|
||||
method: 'get',
|
||||
params: data, // 参数
|
||||
})
|
||||
@ -29,27 +29,27 @@ export function queryAuthList(data: any) {
|
||||
|
||||
// 切换启用状态
|
||||
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) {
|
||||
return axios.delete(`/api/rest/auth/${id}`);
|
||||
return axios.delete(`/api/rest/authority/${id}`);
|
||||
}
|
||||
|
||||
// 添加
|
||||
export function create(data: AuthCreateRecord) {
|
||||
return axios.post(`/api/rest/auth`, data);
|
||||
return axios.post(`/api/rest/authority`, data);
|
||||
}
|
||||
|
||||
// 更新
|
||||
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) {
|
||||
return axios.get<AuthRecord>(`/api/rest/auth/${id}`);
|
||||
return axios.get<AuthRecord>(`/api/rest/authority/${id}`);
|
||||
}
|
||||
|
||||
// export function queryRoles(params?: ListParams<Partial<RoleRecord>>) {
|
||||
|
@ -62,7 +62,7 @@
|
||||
});
|
||||
const { t } = useI18n();
|
||||
const modalTitle = computed(() => {
|
||||
return props.isCreate ? t('Create Auth Info') : t('Edit Auth Info');
|
||||
return props.isCreate ? '创建权限' : '编辑权限';
|
||||
});
|
||||
const { visible, setVisible } = useVisible(false);
|
||||
const createEditRef = ref<FormInstance>();
|
||||
|
@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div class="container">
|
||||
<Breadcrumb :items="['menu.system', '权限管理']" />
|
||||
<Breadcrumb :items="['系统管理', '权限管理']" />
|
||||
<a-card class="general-card" title=" ">
|
||||
<a-row>
|
||||
<a-col :flex="1">
|
||||
@ -21,13 +21,13 @@
|
||||
<template #icon>
|
||||
<icon-search />
|
||||
</template>
|
||||
{{ $t('searchTable.form.search') }}
|
||||
查询
|
||||
</a-button>
|
||||
<a-button @click="reset">
|
||||
<template #icon>
|
||||
<icon-refresh />
|
||||
</template>
|
||||
{{ $t('searchTable.form.reset') }}
|
||||
重置
|
||||
</a-button>
|
||||
</a-space>
|
||||
</a-col>
|
||||
@ -40,13 +40,13 @@
|
||||
</a-space>
|
||||
</a-col>
|
||||
<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">
|
||||
<icon-refresh size="18" />
|
||||
</div>
|
||||
</a-tooltip>
|
||||
<a-dropdown @select="handleSelectDensity">
|
||||
<a-tooltip :content="$t('searchTable.actions.density')">
|
||||
<a-tooltip content='密度'>
|
||||
<div class="action-icon"><icon-line-height size="18" /></div>
|
||||
</a-tooltip>
|
||||
<template #content>
|
||||
@ -56,7 +56,7 @@
|
||||
</a-doption>
|
||||
</template>
|
||||
</a-dropdown>
|
||||
<a-tooltip :content="$t('searchTable.actions.columnSetting')">
|
||||
<a-tooltip content='列设置'>
|
||||
<a-popover trigger="click" position="bl" @popup-visible-change="popupVisibleChange">
|
||||
<div class="action-icon"><icon-settings size="18" /></div>
|
||||
<template #content>
|
||||
@ -81,8 +81,26 @@
|
||||
</a-tooltip>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<AuthTable :data="renderData" :pagination="pagination" :loading="loading" @pageChange="onPageChange"
|
||||
:columns="(cloneColumns as TableColumnData[])" @search="search" />
|
||||
<a-table row-key="id" :loading="loading" :pagination="false" :columns="(cloneColumns as TableColumnData[])" :data="renderData" :bordered="false"
|
||||
: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"
|
||||
show-total show-jumper show-page-size @page-size-change="onSizeChange" @change="onPageChange" />
|
||||
</a-card>
|
||||
@ -90,8 +108,9 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, watch, computed } from 'vue';
|
||||
// import { useI18n } from 'vue-i18n';
|
||||
import { ref, watch, computed, onMounted } from 'vue';
|
||||
import dayjs from 'dayjs';
|
||||
import { Message } from '@arco-design/web-vue';
|
||||
import useLoading from '@/hooks/loading';
|
||||
import { useAuthStore } from '@/store';
|
||||
import { AuthRecord } from '@/api/authority';
|
||||
@ -99,9 +118,7 @@ import { Pagination } from '@/types/global';
|
||||
import useTableOption from '@/hooks/table-option';
|
||||
import type { TableColumnData } from '@arco-design/web-vue/es/table/interface';
|
||||
import AuthEdit from './components/auth-edit.vue';
|
||||
import AuthTable from './components/auth-table.vue';
|
||||
|
||||
// const { t } = useI18n();
|
||||
const {loading, setLoading} = useLoading();
|
||||
const authStore = useAuthStore();
|
||||
const renderData = ref<AuthRecord[]>([]);
|
||||
@ -145,14 +162,6 @@ const columns = computed<TableColumnData[]>(() => [
|
||||
title: "备注",
|
||||
dataIndex: 'remark',
|
||||
},
|
||||
{
|
||||
title: "创建时间",
|
||||
dataIndex: 'createTime',
|
||||
slotName: 'createTime',
|
||||
sortable: {
|
||||
sortDirections: ['ascend', 'descend'],
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "状态",
|
||||
dataIndex: 'enabled',
|
||||
@ -175,7 +184,6 @@ const fetchData = async (params: any) => {
|
||||
pagination.total = res.data.total;
|
||||
} catch (err) {
|
||||
// you can report use errorHandler or other
|
||||
console.log(err);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@ -188,7 +196,10 @@ const search = () => {
|
||||
...formModel.value,
|
||||
} as unknown as any);
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
search();
|
||||
})
|
||||
// 分页发生改变
|
||||
const onPageChange = (current: number) => {
|
||||
pagination.page = current;
|
||||
@ -207,6 +218,41 @@ const reset = () => {
|
||||
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 });
|
||||
</script>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user