Files
mp-10579/src/views/credit/creditBankruptcy/components/credit-bankruptcy-history-import.vue
赵忠林 a36cafa77a feat(credit): 在企业详情页面添加历史破产重整导入功能
- 在企业详情的破产重整标签页中增加导入历史破产重整按钮
- 修改credit-bankruptcy-history-import组件以支持传入企业ID参数
- 将历史破产重整导入功能集成到企业详情页面的抽屉组件中
- 移除原破产重整主页面的历史导入相关代码和按钮
- 添加企业ID验证逻辑确保导入操作的安全性
- 实现导入完成后的数据重新加载和分页重置功能
2026-01-20 20:45:33 +08:00

98 lines
2.6 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>只能上传xlsxlsx文件</span>
<a :href="templateUrl" download="历史破产重整导入模板.xlsx">
下载导入模板
</a>
</div>
</ele-modal>
</template>
<script lang="ts" setup>
import { computed, ref } from 'vue';
import { message } from 'ant-design-vue/es';
import { CloudUploadOutlined } from '@ant-design/icons-vue';
import { importCreditBankruptcyHistory } from '@/api/credit/creditBankruptcy';
import { API_BASE_URL } from '@/config/setting';
const emit = defineEmits<{
(e: 'done'): void;
(e: 'update:visible', visible: boolean): void;
}>();
const props = defineProps<{
// 是否打开弹窗
visible: boolean;
// 关联企业ID企业详情下导入时需要
companyId?: number;
}>();
// 导入请求状态
const loading = ref(false);
// 模板下载地址,保持与当前接口域名一致
const templateUrl = computed(() => {
const base = (localStorage.getItem('ApiUrl') || API_BASE_URL || '').replace(
/\/$/,
''
);
return `${base}/credit/credit-bankruptcy/import/history/template`;
});
/* 上传 */
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;
importCreditBankruptcyHistory(file, props.companyId)
.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>