feat: 使用json或excel导入导出权限
This commit is contained in:
parent
a0a6165ee3
commit
6d8e3d2cf0
|
@ -24,8 +24,8 @@ export const deletePermission = (data: any) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 权限---导出权限 */
|
/** 权限---导出权限 */
|
||||||
export const exportPermission = () => {
|
export const exportPermission = (data: any) => {
|
||||||
return http.request<any>('get', 'permission/file/export', { responseType: 'blob' });
|
return http.request<any>('get', 'permission/file/export', { params: data }, { responseType: 'blob' });
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 权限---导入权限权限 */
|
/** 权限---导入权限权限 */
|
||||||
|
|
|
@ -83,8 +83,8 @@ export const usePermissionStore = defineStore('PermissionStore', {
|
||||||
},
|
},
|
||||||
|
|
||||||
/* 使用Excel导出权限 */
|
/* 使用Excel导出权限 */
|
||||||
async downloadPermissionByFile() {
|
async downloadPermissionByFile(data: any) {
|
||||||
const result = await exportPermission();
|
const result = await exportPermission(data);
|
||||||
|
|
||||||
downloadBlob(result, 'role.zip');
|
downloadBlob(result, 'role.zip');
|
||||||
},
|
},
|
||||||
|
|
|
@ -55,12 +55,12 @@ const resetForm = async (formEl: FormInstance) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
/* 导出权限 */
|
/* 导出权限 */
|
||||||
const downloadPermission = () => {
|
const downloadPermission = (type: string) => {
|
||||||
powerStore.downloadPermissionByFile();
|
powerStore.downloadPermissionByFile({ type });
|
||||||
};
|
};
|
||||||
|
|
||||||
/* 导入权限 */
|
/* 导入权限 */
|
||||||
const uploadPermission = async () => {
|
const uploadPermission = async (type: string) => {
|
||||||
addDialog({
|
addDialog({
|
||||||
title: `${$t('modify')}${$t('role')}`,
|
title: `${$t('modify')}${$t('role')}`,
|
||||||
width: '30%',
|
width: '30%',
|
||||||
|
@ -74,7 +74,7 @@ const uploadPermission = async () => {
|
||||||
formRef.value.formRef.validate(async (valid: any) => {
|
formRef.value.formRef.validate(async (valid: any) => {
|
||||||
if (!valid) return;
|
if (!valid) return;
|
||||||
// 更新文件 data
|
// 更新文件 data
|
||||||
const data = { file: form.file[0].raw };
|
const data = { file: form.file[0].raw, type };
|
||||||
|
|
||||||
const result = await powerStore.uploadPermissionByFile(data);
|
const result = await powerStore.uploadPermissionByFile(data);
|
||||||
if (!result) return;
|
if (!result) return;
|
||||||
|
@ -125,14 +125,29 @@ onMounted(() => {
|
||||||
@refresh="onSearch"
|
@refresh="onSearch"
|
||||||
>
|
>
|
||||||
<template #buttons>
|
<template #buttons>
|
||||||
<!-- 添加权限按钮 -->
|
<!-- 下载配置 -->
|
||||||
<el-button v-if="hasAuth(auth.update)" :icon="useRenderIcon(Download)" plain type="primary" @click="downloadPermission()">
|
<el-dropdown v-if="hasAuth(auth.update)" class="mr-1" type="primary">
|
||||||
{{ $t('download_configuration') }}
|
<el-button :icon="useRenderIcon(Download)" plain type="primary">
|
||||||
</el-button>
|
{{ $t('download_configuration') }}
|
||||||
<!-- 文件更新 -->
|
</el-button>
|
||||||
<el-button v-if="hasAuth(auth.update)" :icon="useRenderIcon(Upload)" plain type="primary" @click="uploadPermission">
|
<template #dropdown>
|
||||||
{{ $t('file_import') }}
|
<el-dropdown-menu>
|
||||||
</el-button>
|
<el-dropdown-item @click="downloadPermission('json')">{{ $t('download_json') }}</el-dropdown-item>
|
||||||
|
<el-dropdown-item @click="downloadPermission('excel')">{{ $t('download_excel') }}</el-dropdown-item>
|
||||||
|
</el-dropdown-menu>
|
||||||
|
</template>
|
||||||
|
</el-dropdown>
|
||||||
|
|
||||||
|
<!-- 更新配置 -->
|
||||||
|
<el-dropdown v-if="hasAuth(auth.update)" class="mr-1" type="primary">
|
||||||
|
<el-button :icon="useRenderIcon(Upload)" plain type="primary">{{ $t('file_import') }}</el-button>
|
||||||
|
<template #dropdown>
|
||||||
|
<el-dropdown-menu>
|
||||||
|
<el-dropdown-item @click="uploadPermission('json')">{{ $t('use_json_update') }}</el-dropdown-item>
|
||||||
|
<el-dropdown-item @click="uploadPermission('excel')">{{ $t('use_excel_update') }}</el-dropdown-item>
|
||||||
|
</el-dropdown-menu>
|
||||||
|
</template>
|
||||||
|
</el-dropdown>
|
||||||
|
|
||||||
<!-- 添加权限按钮 -->
|
<!-- 添加权限按钮 -->
|
||||||
<el-button v-if="hasAuth(auth.add)" :icon="useRenderIcon(AddFill)" plain type="primary" @click="onAdd()">
|
<el-button v-if="hasAuth(auth.add)" :icon="useRenderIcon(AddFill)" plain type="primary" @click="onAdd()">
|
||||||
|
|
Loading…
Reference in New Issue