Compare commits
1 Commits
master
...
feature/au
Author | SHA1 | Date | |
---|---|---|---|
ffe50d431c |
@ -11,7 +11,7 @@ export interface AuthCreateRecord {
|
||||
|
||||
// 基础信息
|
||||
export interface AuthRecord extends AuthCreateRecord {
|
||||
id: string;
|
||||
id?: string;
|
||||
}
|
||||
|
||||
// export interface RoleListRecord extends AuthRecord {
|
||||
@ -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,29 +29,26 @@ 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>>) {
|
||||
// return queryList<RoleRecord>(`/api/rest/role/query`, params);
|
||||
// }
|
||||
|
@ -25,7 +25,7 @@
|
||||
field="name"
|
||||
label="权限名称"
|
||||
:validate-trigger="['change', 'input']"
|
||||
:rules="[{ required: true, message: t('auth.info.name.required') }]"
|
||||
:rules="[{ required: true }]"
|
||||
>
|
||||
<a-input
|
||||
v-model="formData.name"
|
||||
@ -46,7 +46,6 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import useVisible from '@/hooks/visible';
|
||||
import { computed, PropType, ref } from 'vue';
|
||||
import { FormInstance } from '@arco-design/web-vue/es/form';
|
||||
@ -60,41 +59,21 @@
|
||||
},
|
||||
isCreate: Boolean,
|
||||
});
|
||||
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>();
|
||||
const authStore = useAuthStore();
|
||||
const formData = ref<AuthRecord>({
|
||||
id: '',
|
||||
name: '',
|
||||
// dataScope: '',
|
||||
// permissionIds: [],
|
||||
enabled: true,
|
||||
remark: '',
|
||||
// authorities: [],
|
||||
const formData = ref<any>({
|
||||
...props.prem,
|
||||
});
|
||||
|
||||
const emit = defineEmits(['refresh']);
|
||||
|
||||
// 组件被点击
|
||||
const handleClick = () => {
|
||||
const authId = props.prem?.id;
|
||||
// 编辑
|
||||
if (!props.isCreate && authId) {
|
||||
authStore
|
||||
.getAuthDetail(authId)
|
||||
.then((res:any) => {
|
||||
formData.value = res.data;
|
||||
})
|
||||
.then(() => {
|
||||
setVisible(true);
|
||||
});
|
||||
} else {
|
||||
setVisible(true);
|
||||
}
|
||||
setVisible(true);
|
||||
};
|
||||
|
||||
// 提交
|
||||
@ -106,7 +85,7 @@
|
||||
const res = await authStore.createAuth(formData.value);
|
||||
if (res.status === 200) {
|
||||
Message.success({
|
||||
content: t('create.sucess'),
|
||||
content: '创建成功',
|
||||
duration: 5 * 1000,
|
||||
});
|
||||
}
|
||||
@ -116,7 +95,7 @@
|
||||
const res = await authStore.updateAuth(formData.value);
|
||||
if (res.status === 200) {
|
||||
Message.success({
|
||||
content: t('modify.sucess'),
|
||||
content: '修改成功',
|
||||
duration: 5 * 1000,
|
||||
});
|
||||
}
|
||||
|
@ -1,133 +0,0 @@
|
||||
<template>
|
||||
<a-table row-key="id" :loading="loading" :pagination="false" :columns="columns" :data="data" :bordered="false"
|
||||
:size="size" style="margin-bottom: 40px" @pageChange="onPageChange">
|
||||
<template #index="{ rowIndex }">
|
||||
{{ rowIndex + 1 }}
|
||||
</template>
|
||||
<template #createTime="{ record }">
|
||||
{{ dayjs(record.createTime).format('YYYY-MM-DD') }}
|
||||
</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="t('Confirm the deletion of this role')" 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>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { defineProps, defineEmits} from 'vue';
|
||||
import dayjs from 'dayjs';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Message } from '@arco-design/web-vue';
|
||||
import { useAuthStore } from '@/store';
|
||||
import { AuthRecord } from '@/api/authority';
|
||||
// import type { TableColumnData } from '@arco-design/web-vue/es/table/interface';
|
||||
import AuthEdit from './auth-edit.vue';
|
||||
|
||||
|
||||
const authStore = useAuthStore();
|
||||
const props = defineProps({
|
||||
loading: Boolean,
|
||||
data: Array,
|
||||
size: String,
|
||||
});
|
||||
|
||||
const { t } = useI18n();
|
||||
const emit = defineEmits(['pageChange', 'refresh','search']);
|
||||
// 表格头部
|
||||
// const columns = computed<TableColumnData[]>(() => [
|
||||
// {
|
||||
// title: t('roleTable.columns.index'),
|
||||
// dataIndex: 'index',
|
||||
// slotName: 'index',
|
||||
// },
|
||||
// {
|
||||
// title: t('roleTable.columns.name'),
|
||||
// dataIndex: 'name',
|
||||
// sortable: {
|
||||
// sortDirections: ['ascend', 'descend'],
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// title: t('roleTable.columns.remark'),
|
||||
// dataIndex: 'remark',
|
||||
// },
|
||||
// {
|
||||
// title: t('roleTable.columns.createTime'),
|
||||
// dataIndex: 'createTime',
|
||||
// slotName: 'createTime',
|
||||
// sortable: {
|
||||
// sortDirections: ['ascend', 'descend'],
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// title: t('roleTable.columns.enabled'),
|
||||
// dataIndex: 'enabled',
|
||||
// slotName: 'enabled',
|
||||
// },
|
||||
// {
|
||||
// title: t('searchTable.columns.operations'),
|
||||
// dataIndex: 'operations',
|
||||
// slotName: 'operations',
|
||||
// },
|
||||
// ]);
|
||||
|
||||
|
||||
const fetchData = () => {
|
||||
emit('refresh');
|
||||
};
|
||||
// 分页
|
||||
const onPageChange = (page: number) => {
|
||||
emit('pageChange', page);
|
||||
};
|
||||
|
||||
// 是否启用
|
||||
const enabledStatus = async (record: string) => {
|
||||
record.enabled = !record.enabled;
|
||||
const res = await authStore.enabledAuth(record.id);
|
||||
if (res.status === 200) {
|
||||
Message.success({
|
||||
content: t('modify.status.sucess'),
|
||||
duration: 3 * 1000,
|
||||
});
|
||||
} else {
|
||||
Message.error({
|
||||
content: t('modify.status.fail'),
|
||||
duration: 3 * 1000,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// 删除
|
||||
const handleDelete = async (record: AuthRecord) => {
|
||||
const res = await authStore.removeAuth(record.id);
|
||||
if (res.status === 200) {
|
||||
Message.success({
|
||||
content: t('delete.auth.sucess'),
|
||||
duration: 5 * 1000,
|
||||
});
|
||||
emit('search');
|
||||
} else {
|
||||
Message.error({
|
||||
content: t('delete.auth.fail'),
|
||||
duration: 3 * 1000,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// watch(() => columns.value, deepClone, { deep: true, immediate: true });
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
/* 添加一些样式 */
|
||||
</style>
|
Loading…
Reference in New Issue
Block a user