Files
mp-vue/src/views/cms/cmsWebsiteField/components/Import.vue
赵忠林 addd4bbe01 feat(system): 实现菜单备份与恢复功能- 新增菜单数据导入组件 (Import.vue)
- 修改菜单搜索组件,添加备份与恢复按钮
- 调整主页面组件属性绑定
- 实现 Excel 格式菜单数据的导出与导入
- 添加文件类型与大小验证
- 支持拖拽上传与点击上传两种方式
- 提供操作成功/失败的消息反馈
-限制功能仅超级管理员可用
- 更新相关 API 接口调用 (importSystemMenu)- 优化用户体验与界面交互
2025-09-30 22:47:31 +08:00

83 lines
2.0 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!-- 用户导入弹窗 -->
<template>
<ele-modal
:width="520"
:footer="null"
title="导入备份"
:visible="visible"
@update:visible="updateVisible"
>
<a-spin :spinning="loading">
<a-upload-dragger
accept=".xls,.xlsx"
:show-upload-list="false"
:customRequest="doUpload"
style="padding: 24px 0; margin-bottom: 16px"
>
<p class="ant-upload-drag-icon">
<cloud-upload-outlined />
</p>
<p class="ant-upload-hint">将文件拖到此处或点击上传</p>
</a-upload-dragger>
</a-spin>
<!-- <div class="ele-text-center">-->
<!-- <span>导入备份文件</span>-->
<!-- </div>-->
</ele-modal>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import { message } from 'ant-design-vue/es';
import { CloudUploadOutlined } from '@ant-design/icons-vue';
import {importWebsiteField} from "@/api/cms/cmsWebsiteField";
const emit = defineEmits<{
(e: 'done'): void;
(e: 'update:visible', visible: boolean): void;
}>();
defineProps<{
// 是否打开弹窗
visible: boolean;
}>();
// 导入请求状态
const loading = ref(false);
/* 上传 */
const doUpload = ({ file }) => {
if (
![
'application/vnd.ms-excel',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
].includes(file.type)
) {
message.error('只能选择 excel 文件');
return false;
}
if (file.size / 1024 / 1024 > 10) {
message.error('大小不能超过 10MB');
return false;
}
loading.value = true;
importWebsiteField(file)
.then((msg) => {
loading.value = false;
message.success(msg);
updateVisible(false);
emit('done');
})
.catch((e) => {
loading.value = false;
message.error(e.message);
});
return false;
};
/* 更新 visible */
const updateVisible = (value: boolean) => {
emit('update:visible', value);
};
</script>