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

@@ -103,3 +103,24 @@ export async function getCreditCustomer(id: number) {
}
return Promise.reject(new Error(res.data.message));
}
/**
* 导入客户
*/
export async function importCreditCustomer(file: File) {
const formData = new FormData();
formData.append('file', file);
const res = await request.post<ApiResult<unknown>>(
'/credit/credit-customer/import',
formData,
{
headers: {
'Content-Type': 'multipart/form-data'
}
}
);
if (res.data.code === 0) {
return res.data.message;
}
return Promise.reject(new Error(res.data.message));
}

View File

@@ -13,6 +13,12 @@
</template>
<span>导入</span>
</a-button>
<a-button class="ele-btn-icon" @click="exportData">
<template #icon>
<CloudDownloadOutlined />
</template>
<span>导出</span>
</a-button>
<a-button
danger
class="ele-btn-icon"
@@ -40,6 +46,7 @@
import {
PlusOutlined,
CloudUploadOutlined,
CloudDownloadOutlined,
DeleteOutlined
} from '@ant-design/icons-vue';
import type {
@@ -63,6 +70,7 @@
(e: 'remove'): void;
(e: 'batchMove'): void;
(e: 'importData'): void;
(e: 'exportData'): void;
}>();
const keywords = ref('');
@@ -83,6 +91,11 @@
emit('importData');
};
// 导出
const exportData = () => {
emit('exportData');
};
// 批量删除
const remove = () => {
emit('remove');

View File

@@ -19,6 +19,7 @@
@remove="removeBatch"
@batchMove="openMove"
@importData="openImport"
@exportData="exportData"
/>
</template>
<template #bodyCell="{ column, record }">
@@ -88,7 +89,7 @@
</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';
@@ -102,6 +103,7 @@
import CreditCompanyEdit from './components/creditCompanyEdit.vue';
import {
pageCreditCompany,
listCreditCompany,
removeCreditCompany,
removeBatchCreditCompany
} from '@/api/credit/creditCompany';
@@ -111,6 +113,7 @@
} from '@/api/credit/creditCompany/model';
import CreditCompanyImport from './components/credit-company-import.vue';
import CreditCompanyInfo from './components/creditCompanyInfo.vue';
import { exportCreditData } from '../utils/export';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
@@ -129,27 +132,33 @@
const showInfo = ref(false);
// 加载状态
const loading = ref(true);
// 搜索关键词
const searchText = ref('');
// 表格数据源
const datasource: DatasourceFunction = ({
page,
limit,
where,
where = {},
orders,
filters
}) => {
const params: CreditCompanyParam = { ...where };
if (filters) {
where.status = filters.status;
(params as any).status = filters.status;
}
if (!params.keywords && searchText.value) {
params.keywords = searchText.value;
}
return pageCreditCompany({
...where,
...params,
...orders,
page,
limit
});
};
// 完整的列配置(包含所有字段)
// 关键信息列
const columns = ref<ColumnItem[]>([
{
title: '操作',
@@ -158,12 +167,6 @@
fixed: 'left',
align: 'center'
},
// {
// title: 'ID',
// dataIndex: 'id',
// key: 'id',
// width: 90
// },
{
title: '原文件导入名称',
dataIndex: 'name',
@@ -185,18 +188,6 @@
ellipsis: true,
width: 200
},
// {
// title: '类型',
// dataIndex: 'type',
// key: 'type',
// width: 120
// },
// {
// title: '上级id, 0是顶级',
// dataIndex: 'parentId',
// key: 'parentId',
// width: 120
// },
{
title: '登记状态',
dataIndex: 'registrationStatus',
@@ -218,13 +209,6 @@
ellipsis: true,
width: 120
},
{
title: '实缴资本',
dataIndex: 'paidinCapital',
key: 'paidinCapital',
ellipsis: true,
width: 120
},
{
title: '成立日期',
dataIndex: 'establishDate',
@@ -232,13 +216,6 @@
ellipsis: true,
width: 120
},
{
title: '企业地址',
dataIndex: 'address',
key: 'address',
ellipsis: true,
width: 120
},
{
title: '电话',
dataIndex: 'tel',
@@ -246,27 +223,6 @@
ellipsis: true,
width: 150
},
{
title: '更多电话',
dataIndex: 'moreTel',
key: 'moreTel',
ellipsis: true,
width: 120
},
{
title: '邮箱',
dataIndex: 'email',
key: 'email',
ellipsis: true,
width: 150
},
{
title: '更多邮箱',
dataIndex: 'moreEmail',
key: 'moreEmail',
ellipsis: true,
width: 120
},
{
title: '所属省份',
dataIndex: 'province',
@@ -281,195 +237,6 @@
ellipsis: true,
width: 120
},
{
title: '所属区县',
dataIndex: 'region',
key: 'region',
ellipsis: true,
width: 120
},
{
title: '企业(机构)类型',
dataIndex: 'institutionType',
key: 'institutionType',
ellipsis: true,
width: 140
},
{
title: '纳税人识别号',
dataIndex: 'taxpayerCode',
key: 'taxpayerCode',
ellipsis: true,
width: 120
},
{
title: '注册号',
dataIndex: 'registrationNumber',
key: 'registrationNumber',
ellipsis: true,
width: 120
},
{
title: '组织机构代码',
dataIndex: 'organizationalCode',
key: 'organizationalCode',
ellipsis: true,
width: 120
},
{
title: '参保人数',
dataIndex: 'numberOfInsuredPersons',
key: 'numberOfInsuredPersons',
ellipsis: true,
width: 120
},
{
title: '参保人数所属年报',
dataIndex: 'annualReport',
key: 'annualReport',
ellipsis: true,
width: 140
},
{
title: '营业期限',
dataIndex: 'businessTerm',
key: 'businessTerm',
ellipsis: true,
width: 120
},
{
title: '国标行业门类',
dataIndex: 'nationalStandardIndustryCategories',
key: 'nationalStandardIndustryCategories',
ellipsis: true,
width: 120
},
{
title: '国标行业大类',
dataIndex: 'nationalStandardIndustryCategories2',
key: 'nationalStandardIndustryCategories2',
ellipsis: true,
width: 120
},
{
title: '国标行业中类',
dataIndex: 'nationalStandardIndustryCategories3',
key: 'nationalStandardIndustryCategories3',
ellipsis: true,
width: 120
},
{
title: '国标行业小类',
dataIndex: 'nationalStandardIndustryCategories4',
key: 'nationalStandardIndustryCategories4',
ellipsis: true,
width: 120
},
{
title: '企查查行业门类',
dataIndex: 'nationalStandardIndustryCategories5',
key: 'nationalStandardIndustryCategories5',
ellipsis: true,
width: 120
},
{
title: '企查查行业大类',
dataIndex: 'nationalStandardIndustryCategories6',
key: 'nationalStandardIndustryCategories6',
ellipsis: true,
width: 120
},
{
title: '企查查行业中类',
dataIndex: 'nationalStandardIndustryCategories7',
key: 'nationalStandardIndustryCategories7',
ellipsis: true,
width: 120
},
{
title: '企查查行业小类',
dataIndex: 'nationalStandardIndustryCategories8',
key: 'nationalStandardIndustryCategories8',
ellipsis: true,
width: 120
},
{
title: '企业规模',
dataIndex: 'companySize',
key: 'companySize',
ellipsis: true,
width: 120
},
{
title: '曾用名',
dataIndex: 'formerName',
key: 'formerName',
ellipsis: true,
width: 120
},
{
title: '英文名',
dataIndex: 'englishName',
key: 'englishName',
ellipsis: true,
width: 120
},
{
title: '官网',
dataIndex: 'domain',
key: 'domain',
ellipsis: true,
width: 240
},
{
title: '通信地址',
dataIndex: 'mailingAddress',
key: 'mailingAddress',
ellipsis: true,
width: 120
},
{
title: '企业简介',
dataIndex: 'companyProfile',
key: 'companyProfile',
ellipsis: true,
width: 120
},
{
title: '经营范围',
dataIndex: 'natureOfBusiness',
key: 'natureOfBusiness',
ellipsis: true,
width: 120
},
{
title: '登记机关',
dataIndex: 'registrationAuthority',
key: 'registrationAuthority',
ellipsis: true,
width: 120
},
{
title: '纳税人资质',
dataIndex: 'taxpayerQualification',
key: 'taxpayerQualification',
ellipsis: true,
width: 120
},
{
title: '最新年报年份',
dataIndex: 'latestAnnualReportYear',
key: 'latestAnnualReportYear',
ellipsis: true,
width: 120
},
{
title: '最新年报营业收入',
dataIndex: 'latestAnnualReportOnOperatingRevenue',
key: 'latestAnnualReportOnOperatingRevenue',
ellipsis: true,
width: 150
},
{
title: '企查分',
dataIndex: 'enterpriseScoreCheck',
@@ -484,26 +251,21 @@
ellipsis: true,
width: 120
},
{
title: '科创分',
dataIndex: 'cechnologyScore',
key: 'cechnologyScore',
ellipsis: true,
width: 120
},
{
title: '科创等级',
dataIndex: 'cechnologyLevel',
key: 'cechnologyLevel',
ellipsis: true,
width: 120
},
{
title: '是否小微企业',
dataIndex: 'smallEnterprise',
key: 'smallEnterprise',
ellipsis: true,
width: 120
},
{
title: '创建时间',
dataIndex: 'createTime',
key: 'createTime',
width: 180,
align: 'center',
ellipsis: true,
customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd HH:mm:ss')
}
// {
// title: '备注',
@@ -543,8 +305,12 @@
/* 搜索 */
const reload = (where?: CreditCompanyParam) => {
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 });
};
/* 打开编辑弹窗 */
@@ -562,6 +328,38 @@
const openImport = () => {
showImport.value = true;
};
/* 导出 */
const exportData = () => {
exportCreditData<CreditCompany>({
filename: '企业',
columns: [
{ title: '原文件导入名称', dataIndex: 'name' },
{ title: '系统匹配企业名称', dataIndex: 'matchName' },
{ title: '统一社会信用代码', dataIndex: 'code' },
{ title: '登记状态', dataIndex: 'registrationStatus' },
{ title: '法定代表人', dataIndex: 'legalPerson' },
{ title: '注册资本', dataIndex: 'registeredCapital' },
{ title: '成立日期', dataIndex: 'establishDate' },
{ title: '所属省份', dataIndex: 'province' },
{ title: '所属城市', dataIndex: 'city' },
{ title: '企查分', dataIndex: 'enterpriseScoreCheck' },
{ title: '信用等级', dataIndex: 'creditRating' },
{
title: '创建时间',
dataIndex: 'createTime',
formatter: (record: CreditCompany) =>
record.createTime
? toDateString(record.createTime, 'yyyy-MM-dd HH:mm:ss')
: ''
}
],
fetchData: () =>
listCreditCompany({
keywords: searchText.value || undefined
})
});
};
/* 打开企业详情 */
const openInfo = (row?: CreditCompany) => {
current.value = row ?? null;

View File

@@ -26,21 +26,21 @@
v-model:value="form.name"
/>
</a-form-item>
<a-form-item label="企业状态(如存续、注销等)" name="statusTxt">
<a-form-item label="状态" name="statusTxt">
<a-input
allow-clear
placeholder="请输入企业状态(如存续、注销等)"
v-model:value="form.statusTxt"
/>
</a-form-item>
<a-form-item label="法定代表人姓名" name="legalRepresentative">
<a-form-item label="法定代表人" name="legalRepresentative">
<a-input
allow-clear
placeholder="请输入法定代表人姓名"
v-model:value="form.legalRepresentative"
/>
</a-form-item>
<a-form-item label="注册资本(金额)" name="registeredCapital">
<a-form-item label="注册资本" name="registeredCapital">
<a-input
allow-clear
placeholder="请输入注册资本(金额)"
@@ -125,49 +125,12 @@
v-model:value="form.comments"
/>
</a-form-item>
<a-form-item label="是否推荐" name="recommend">
<a-input
allow-clear
placeholder="请输入是否推荐"
v-model:value="form.recommend"
/>
</a-form-item>
<a-form-item label="排序(数字越小越靠前)" name="sortNumber">
<a-input-number
:min="0"
:max="9999"
class="ele-fluid"
placeholder="请输入排序号"
v-model:value="form.sortNumber"
/>
</a-form-item>
<a-form-item label="状态, 0正常, 1冻结" name="status">
<a-radio-group v-model:value="form.status">
<a-radio :value="0">显示</a-radio>
<a-radio :value="1">隐藏</a-radio>
</a-radio-group>
</a-form-item>
<a-form-item label="是否删除, 0否, 1是" name="deleted">
<a-input
allow-clear
placeholder="请输入是否删除, 0否, 1是"
v-model:value="form.deleted"
/>
</a-form-item>
<a-form-item label="用户ID" name="userId">
<a-input
allow-clear
placeholder="请输入用户ID"
v-model:value="form.userId"
/>
</a-form-item>
<a-form-item label="修改时间" name="updateTime">
<a-input
allow-clear
placeholder="请输入修改时间"
v-model:value="form.updateTime"
/>
</a-form-item>
<!-- <a-form-item label="状态, 0正常, 1冻结" name="status">-->
<!-- <a-radio-group v-model:value="form.status">-->
<!-- <a-radio :value="0">显示</a-radio>-->
<!-- <a-radio :value="1">隐藏</a-radio>-->
<!-- </a-radio-group>-->
<!-- </a-form-item>-->
</a-form>
</ele-modal>
</template>
@@ -176,7 +139,10 @@
import { ref, reactive, watch } from 'vue';
import { Form, message } from 'ant-design-vue';
import { assignObject, uuid } from 'ele-admin-pro';
import { addCreditExternal, updateCreditExternal } from '@/api/credit/creditExternal';
import {
addCreditExternal,
updateCreditExternal
} from '@/api/credit/creditExternal';
import { CreditExternal } from '@/api/credit/creditExternal/model';
import { useThemeStore } from '@/store/modules/theme';
import { storeToRefs } from 'pinia';
@@ -289,7 +255,9 @@
const formData = {
...form
};
const saveOrUpdate = isUpdate.value ? updateCreditExternal : addCreditExternal;
const saveOrUpdate = isUpdate.value
? updateCreditExternal
: addCreditExternal;
saveOrUpdate(formData)
.then((msg) => {
loading.value = false;
@@ -317,7 +285,7 @@
uid: uuid(),
url: props.data.image,
status: 'done'
})
});
}
isUpdate.value = true;
} else {

View File

@@ -46,7 +46,11 @@
</a-card>
<!-- 编辑弹窗 -->
<CreditExternalEdit v-model:visible="showEdit" :data="current" @done="reload" />
<CreditExternalEdit
v-model:visible="showEdit"
:data="current"
@done="reload"
/>
<!-- 导入弹窗 -->
<CreditExternalImport v-model:visible="showImport" @done="reload" />
</a-page-header>
@@ -134,20 +138,20 @@
ellipsis: true
},
{
title: '企业状态(如存续、注销等)',
title: '状态',
dataIndex: 'statusTxt',
key: 'statusTxt',
ellipsis: true
},
{
title: '法定代表人姓名',
title: '法定代表人',
dataIndex: 'legalRepresentative',
key: 'legalRepresentative',
ellipsis: true,
width: 120
},
{
title: '注册资本(金额)',
title: '注册资本',
dataIndex: 'registeredCapital',
key: 'registeredCapital',
width: 120

View File

@@ -13,6 +13,12 @@
</template>
<span>导入</span>
</a-button>
<a-button class="ele-btn-icon" @click="exportData">
<template #icon>
<CloudDownloadOutlined />
</template>
<span>导出</span>
</a-button>
<a-button
danger
class="ele-btn-icon"
@@ -40,6 +46,7 @@
import {
PlusOutlined,
CloudUploadOutlined,
CloudDownloadOutlined,
DeleteOutlined
} from '@ant-design/icons-vue';
import type {
@@ -63,6 +70,7 @@
(e: 'remove'): void;
(e: 'batchMove'): void;
(e: 'importData'): void;
(e: 'exportData'): void;
}>();
const keywords = ref('');
@@ -83,6 +91,11 @@
emit('importData');
};
// 导出
const exportData = () => {
emit('exportData');
};
// 批量删除
const remove = () => {
emit('remove');

View File

@@ -19,6 +19,7 @@
@remove="removeBatch"
@batchMove="openMove"
@importData="openImport"
@exportData="exportData"
/>
</template>
<template #bodyCell="{ column, record }">
@@ -72,10 +73,12 @@
import CreditJudiciaryImport from './components/credit-judiciary-import.vue';
import {
pageCreditJudiciary,
listCreditJudiciary,
removeCreditJudiciary,
removeBatchCreditJudiciary
} from '@/api/credit/creditJudiciary';
import type { CreditJudiciary, CreditJudiciaryParam } from '@/api/credit/creditJudiciary/model';
import { exportCreditData } from '../utils/export';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
@@ -318,6 +321,29 @@
showImport.value = true;
};
/* 导出 */
const exportData = () => {
exportCreditData<CreditJudiciary>({
filename: '司法案件',
columns: [
{ title: 'ID', dataIndex: 'id' },
{ title: '案件名称', dataIndex: 'name' },
{ title: '案件类型', dataIndex: 'infoType' },
{ title: '案由', dataIndex: 'reason' },
{ title: '进程日期', dataIndex: 'processDate' },
{ title: '案件进程', dataIndex: 'caseProgress' },
{ title: '案件身份', dataIndex: 'caseIdentity' },
{ title: '案号', dataIndex: 'code' },
{ title: '法院', dataIndex: 'court' },
{ title: '案件金额(元)', dataIndex: 'caseAmount' }
],
fetchData: () =>
listCreditJudiciary({
keywords: searchText.value || undefined
})
});
};
/* 删除单个 */
const remove = (row: CreditJudiciary) => {
const hide = message.loading('请求中..', 0);

View File

@@ -17,6 +17,8 @@
@add="openEdit"
@remove="removeBatch"
@batchMove="openMove"
@importData="openImport"
@exportData="exportData"
/>
</template>
<template #bodyCell="{ column, record }">
@@ -45,11 +47,16 @@
<!-- 编辑弹窗 -->
<CreditRiskRelationEdit v-model:visible="showEdit" :data="current" @done="reload" />
<!-- 导入弹窗 -->
<CreditRiskRelationImport
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 +65,21 @@
DatasourceFunction,
ColumnItem
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import Search from '@/views/credit/components/CreditSearchToolbar.vue';
import { exportCreditData } from '../utils/export';
import { getPageTitle } from '@/utils/common';
import CreditRiskRelationEdit from './components/creditRiskRelationEdit.vue';
import { pageCreditRiskRelation, removeCreditRiskRelation, removeBatchCreditRiskRelation } from '@/api/credit/creditRiskRelation';
import type { CreditRiskRelation, CreditRiskRelationParam } from '@/api/credit/creditRiskRelation/model';
import CreditRiskRelationImport from './components/credit-risk-relation-import.vue';
import {
pageCreditRiskRelation,
listCreditRiskRelation,
removeCreditRiskRelation,
removeBatchCreditRiskRelation
} from '@/api/credit/creditRiskRelation';
import type {
CreditRiskRelation,
CreditRiskRelationParam
} from '@/api/credit/creditRiskRelation/model';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
@@ -73,37 +90,45 @@
const current = ref<CreditRiskRelation | 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: CreditRiskRelationParam = { ...where };
if (filters) {
where.status = filters.status;
(params as any).status = filters.status;
}
if (!params.keywords && searchText.value) {
params.keywords = searchText.value;
}
return pageCreditRiskRelation({
...where,
...params,
...orders,
page,
limit
});
};
// 完整的列配置(包含所有字段)
// 关键信息列
const columns = ref<ColumnItem[]>([
{
title: '序号',
dataIndex: 'id',
key: 'id',
width: 90,
width: 80
},
{
title: '主体名称',
@@ -141,49 +166,12 @@
key: 'riskRelation',
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')
},
@@ -191,16 +179,15 @@
title: '修改时间',
dataIndex: 'updateTime',
key: 'updateTime',
width: 200,
width: 180,
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
@@ -209,8 +196,12 @@
/* 搜索 */
const reload = (where?: CreditRiskRelationParam) => {
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 });
};
/* 打开编辑弹窗 */
@@ -224,6 +215,39 @@
showMove.value = true;
};
/* 打开导入弹窗 */
const openImport = () => {
showImport.value = true;
};
/* 导出 */
const exportData = () => {
exportCreditData<CreditRiskRelation>({
filename: '风险关系',
columns: [
{ title: '序号', dataIndex: 'id' },
{ title: '主体名称', dataIndex: 'mainBodyName' },
{ title: '登记状态', dataIndex: 'registrationStatus' },
{ title: '注册资本', dataIndex: 'registeredCapital' },
{ title: '省份地区', dataIndex: 'provinceRegion' },
{ title: '关联关系', dataIndex: 'associatedRelation' },
{ title: '风险关系', dataIndex: 'riskRelation' },
{
title: '创建时间',
dataIndex: 'createTime',
formatter: (record: CreditRiskRelation) =>
record.createTime
? toDateString(record.createTime, 'yyyy-MM-dd HH:mm:ss')
: ''
}
],
fetchData: () =>
listCreditRiskRelation({
keywords: searchText.value || undefined
})
});
};
/* 删除单个 */
const remove = (row: CreditRiskRelation) => {
const hide = message.loading('请求中..', 0);

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 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);

View File

@@ -13,6 +13,12 @@
</template>
<span>导入</span>
</a-button>
<a-button class="ele-btn-icon" @click="exportData">
<template #icon>
<CloudDownloadOutlined />
</template>
<span>导出</span>
</a-button>
<a-button
danger
class="ele-btn-icon"
@@ -40,6 +46,7 @@
import {
PlusOutlined,
CloudUploadOutlined,
CloudDownloadOutlined,
DeleteOutlined
} from '@ant-design/icons-vue';
import type { CreditUser, CreditUserParam } from '@/api/credit/creditUser/model';
@@ -60,6 +67,7 @@
(e: 'remove'): void;
(e: 'batchMove'): void;
(e: 'importData'): void;
(e: 'exportData'): void;
}>();
const keywords = ref('');
@@ -80,6 +88,11 @@
emit('importData');
};
// 导出
const exportData = () => {
emit('exportData');
};
// 批量删除
const remove = () => {
emit('remove');

View File

@@ -19,6 +19,7 @@
@remove="removeBatch"
@batchMove="openMove"
@importData="openImport"
@exportData="exportData"
/>
</template>
<template #bodyCell="{ column, record }">
@@ -67,6 +68,7 @@
import CreditUserImport from './components/credit-user-import.vue';
import {
pageCreditUser,
listCreditUser,
removeCreditUser,
removeBatchCreditUser
} from '@/api/credit/creditUser';
@@ -74,6 +76,7 @@
CreditUser,
CreditUserParam
} from '@/api/credit/creditUser/model';
import { exportCreditData } from '../utils/export';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
@@ -258,6 +261,28 @@
showMove.value = true;
};
/* 导出 */
const exportData = () => {
exportCreditData<CreditUser>({
filename: '招投标结果',
columns: [
{ title: 'ID', dataIndex: 'id' },
{ title: '项目名称', dataIndex: 'name' },
{ title: '发布日期', dataIndex: 'releaseDate' },
{ title: '企业角色', dataIndex: 'role' },
{ title: '信息类型', dataIndex: 'infoType' },
{ title: '省份地区', dataIndex: 'province' },
{ title: '招采单位', dataIndex: 'procurementName' },
{ title: '中标单位', dataIndex: 'winningName' },
{ title: '中标金额', dataIndex: 'winningPrice' }
],
fetchData: () =>
listCreditUser({
keywords: searchText.value || undefined
})
});
};
/* 删除单个 */
const remove = (row: CreditUser) => {
const hide = message.loading('请求中..', 0);