Compare commits
1 Commits
master
...
feature/au
Author | SHA1 | Date | |
---|---|---|---|
ffe50d431c |
@ -11,7 +11,7 @@ export interface AuthCreateRecord {
|
|||||||
|
|
||||||
// 基础信息
|
// 基础信息
|
||||||
export interface AuthRecord extends AuthCreateRecord {
|
export interface AuthRecord extends AuthCreateRecord {
|
||||||
id: string;
|
id?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
// export interface RoleListRecord extends AuthRecord {
|
// export interface RoleListRecord extends AuthRecord {
|
||||||
@ -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,29 +29,26 @@ 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>>) {
|
|
||||||
// return queryList<RoleRecord>(`/api/rest/role/query`, params);
|
|
||||||
// }
|
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
field="name"
|
field="name"
|
||||||
label="权限名称"
|
label="权限名称"
|
||||||
:validate-trigger="['change', 'input']"
|
:validate-trigger="['change', 'input']"
|
||||||
:rules="[{ required: true, message: t('auth.info.name.required') }]"
|
:rules="[{ required: true }]"
|
||||||
>
|
>
|
||||||
<a-input
|
<a-input
|
||||||
v-model="formData.name"
|
v-model="formData.name"
|
||||||
@ -46,7 +46,6 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { useI18n } from 'vue-i18n';
|
|
||||||
import useVisible from '@/hooks/visible';
|
import useVisible from '@/hooks/visible';
|
||||||
import { computed, PropType, ref } from 'vue';
|
import { computed, PropType, ref } from 'vue';
|
||||||
import { FormInstance } from '@arco-design/web-vue/es/form';
|
import { FormInstance } from '@arco-design/web-vue/es/form';
|
||||||
@ -60,41 +59,21 @@
|
|||||||
},
|
},
|
||||||
isCreate: Boolean,
|
isCreate: Boolean,
|
||||||
});
|
});
|
||||||
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>();
|
||||||
const authStore = useAuthStore();
|
const authStore = useAuthStore();
|
||||||
const formData = ref<AuthRecord>({
|
const formData = ref<any>({
|
||||||
id: '',
|
...props.prem,
|
||||||
name: '',
|
|
||||||
// dataScope: '',
|
|
||||||
// permissionIds: [],
|
|
||||||
enabled: true,
|
|
||||||
remark: '',
|
|
||||||
// authorities: [],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const emit = defineEmits(['refresh']);
|
const emit = defineEmits(['refresh']);
|
||||||
|
|
||||||
// 组件被点击
|
// 组件被点击
|
||||||
const handleClick = () => {
|
const handleClick = () => {
|
||||||
const authId = props.prem?.id;
|
|
||||||
// 编辑
|
|
||||||
if (!props.isCreate && authId) {
|
|
||||||
authStore
|
|
||||||
.getAuthDetail(authId)
|
|
||||||
.then((res:any) => {
|
|
||||||
formData.value = res.data;
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
});
|
|
||||||
} else {
|
|
||||||
setVisible(true);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// 提交
|
// 提交
|
||||||
@ -106,7 +85,7 @@
|
|||||||
const res = await authStore.createAuth(formData.value);
|
const res = await authStore.createAuth(formData.value);
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
Message.success({
|
Message.success({
|
||||||
content: t('create.sucess'),
|
content: '创建成功',
|
||||||
duration: 5 * 1000,
|
duration: 5 * 1000,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -116,7 +95,7 @@
|
|||||||
const res = await authStore.updateAuth(formData.value);
|
const res = await authStore.updateAuth(formData.value);
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
Message.success({
|
Message.success({
|
||||||
content: t('modify.sucess'),
|
content: '修改成功',
|
||||||
duration: 5 * 1000,
|
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