feat(credit): 新增客户导入与数据导出功能

- 在信用客户模块中添加了导入客户的功能,支持通过文件上传方式导入客户数据
- 实现了多个信用相关模块的数据导出功能,包括企业、司法案件、风险关系、供应商及用户模块
- 更新了搜索组件以支持导出事件,并在各模块中实现了具体的导出逻辑
- 简化了部分表单项的标签显示并移除了冗余字段,优化了用户体验
- 修复了一些潜在的代码格式问题和不必要的注释块
This commit is contained in:
2025-12-22 10:00:49 +08:00
parent ebdc9b5933
commit ecd571c60b
11 changed files with 389 additions and 473 deletions

View File

@@ -17,6 +17,8 @@
@add="openEdit"
@remove="removeBatch"
@batchMove="openMove"
@importData="openImport"
@exportData="exportData"
/>
</template>
<template #bodyCell="{ column, record }">
@@ -45,11 +47,13 @@
<!-- 编辑弹窗 -->
<CreditSupplierEdit v-model:visible="showEdit" :data="current" @done="reload" />
<!-- 导入弹窗 -->
<CreditSupplierImport v-model:visible="showImport" @done="reload" />
</a-page-header>
</template>
<script lang="ts" setup>
import { createVNode, ref, computed } from 'vue';
import { createVNode, ref } from 'vue';
import { message, Modal } from 'ant-design-vue';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import type { EleProTable } from 'ele-admin-pro';
@@ -58,11 +62,21 @@
DatasourceFunction,
ColumnItem
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import {getPageTitle} from '@/utils/common';
import Search from '@/views/credit/components/CreditSearchToolbar.vue';
import { exportCreditData } from '../utils/export';
import { getPageTitle } from '@/utils/common';
import CreditSupplierEdit from './components/creditSupplierEdit.vue';
import { pageCreditSupplier, removeCreditSupplier, removeBatchCreditSupplier } from '@/api/credit/creditSupplier';
import type { CreditSupplier, CreditSupplierParam } from '@/api/credit/creditSupplier/model';
import CreditSupplierImport from './components/credit-supplier-import.vue';
import {
pageCreditSupplier,
listCreditSupplier,
removeCreditSupplier,
removeBatchCreditSupplier
} from '@/api/credit/creditSupplier';
import type {
CreditSupplier,
CreditSupplierParam
} from '@/api/credit/creditSupplier/model';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
@@ -73,37 +87,45 @@
const current = ref<CreditSupplier | null>(null);
// 是否显示编辑弹窗
const showEdit = ref(false);
// 是否显示导入弹窗
const showImport = ref(false);
// 是否显示批量移动弹窗
const showMove = ref(false);
// 加载状态
const loading = ref(true);
// 搜索关键词
const searchText = ref('');
// 表格数据源
const datasource: DatasourceFunction = ({
page,
limit,
where,
where = {},
orders,
filters
}) => {
const params: CreditSupplierParam = { ...where };
if (filters) {
where.status = filters.status;
(params as any).status = filters.status;
}
if (!params.keywords && searchText.value) {
params.keywords = searchText.value;
}
return pageCreditSupplier({
...where,
...params,
...orders,
page,
limit
});
};
// 完整的列配置(包含所有字段)
// 关键信息列
const columns = ref<ColumnItem[]>([
{
title: 'ID',
dataIndex: 'id',
key: 'id',
width: 90,
width: 80
},
{
title: '供应商',
@@ -135,66 +157,19 @@
key: 'dataSource',
ellipsis: true
},
{
title: '备注',
dataIndex: 'comments',
key: 'comments',
ellipsis: true
},
{
title: '是否推荐',
dataIndex: 'recommend',
key: 'recommend',
width: 120
},
{
title: '排序(数字越小越靠前)',
dataIndex: 'sortNumber',
key: 'sortNumber',
width: 120
},
{
title: '状态, 0正常, 1冻结',
dataIndex: 'status',
key: 'status',
width: 120
},
{
title: '是否删除, 0否, 1是',
dataIndex: 'deleted',
key: 'deleted',
width: 120
},
{
title: '用户ID',
dataIndex: 'userId',
key: 'userId',
width: 120
},
{
title: '创建时间',
dataIndex: 'createTime',
key: 'createTime',
width: 200,
width: 180,
align: 'center',
sorter: true,
ellipsis: true,
customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd HH:mm:ss')
},
{
title: '修改时间',
dataIndex: 'updateTime',
key: 'updateTime',
width: 200,
align: 'center',
sorter: true,
ellipsis: true,
customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd HH:mm:ss')
},
{
title: '操作',
key: 'action',
width: 180,
width: 160,
fixed: 'right',
align: 'center',
hideInSetting: true
@@ -203,8 +178,12 @@
/* 搜索 */
const reload = (where?: CreditSupplierParam) => {
if (where && Object.prototype.hasOwnProperty.call(where, 'keywords')) {
searchText.value = where.keywords ?? '';
}
const targetWhere = where ?? { keywords: searchText.value || undefined };
selection.value = [];
tableRef?.value?.reload({ where: where });
tableRef?.value?.reload({ where: targetWhere });
};
/* 打开编辑弹窗 */
@@ -218,6 +197,38 @@
showMove.value = true;
};
/* 打开导入弹窗 */
const openImport = () => {
showImport.value = true;
};
/* 导出 */
const exportData = () => {
exportCreditData<CreditSupplier>({
filename: '供应商',
columns: [
{ title: 'ID', dataIndex: 'id' },
{ title: '供应商', dataIndex: 'supplier' },
{ title: '状态', dataIndex: 'statusTxt' },
{ title: '采购金额(万元)', dataIndex: 'purchaseAmount' },
{ title: '公开日期', dataIndex: 'publicDate' },
{ title: '数据来源', dataIndex: 'dataSource' },
{
title: '创建时间',
dataIndex: 'createTime',
formatter: (record: CreditSupplier) =>
record.createTime
? toDateString(record.createTime, 'yyyy-MM-dd HH:mm:ss')
: ''
}
],
fetchData: () =>
listCreditSupplier({
keywords: searchText.value || undefined
})
});
};
/* 删除单个 */
const remove = (row: CreditSupplier) => {
const hide = message.loading('请求中..', 0);