- 在信用客户模块中添加了导入客户的功能,支持通过文件上传方式导入客户数据 - 实现了多个信用相关模块的数据导出功能,包括企业、司法案件、风险关系、供应商及用户模块 - 更新了搜索组件以支持导出事件,并在各模块中实现了具体的导出逻辑 - 简化了部分表单项的标签显示并移除了冗余字段,优化了用户体验 - 修复了一些潜在的代码格式问题和不必要的注释块
127 lines
2.8 KiB
TypeScript
127 lines
2.8 KiB
TypeScript
import request from '@/utils/request';
|
|
import type { ApiResult, PageResult } from '@/api';
|
|
import type { CreditCustomer, CreditCustomerParam } from './model';
|
|
|
|
/**
|
|
* 分页查询客户
|
|
*/
|
|
export async function pageCreditCustomer(params: CreditCustomerParam) {
|
|
const res = await request.get<ApiResult<PageResult<CreditCustomer>>>(
|
|
'/credit/credit-customer/page',
|
|
{
|
|
params
|
|
}
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.data;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 查询客户列表
|
|
*/
|
|
export async function listCreditCustomer(params?: CreditCustomerParam) {
|
|
const res = await request.get<ApiResult<CreditCustomer[]>>(
|
|
'/credit/credit-customer',
|
|
{
|
|
params
|
|
}
|
|
);
|
|
if (res.data.code === 0 && res.data.data) {
|
|
return res.data.data;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 添加客户
|
|
*/
|
|
export async function addCreditCustomer(data: CreditCustomer) {
|
|
const res = await request.post<ApiResult<unknown>>(
|
|
'/credit/credit-customer',
|
|
data
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.message;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 修改客户
|
|
*/
|
|
export async function updateCreditCustomer(data: CreditCustomer) {
|
|
const res = await request.put<ApiResult<unknown>>(
|
|
'/credit/credit-customer',
|
|
data
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.message;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 删除客户
|
|
*/
|
|
export async function removeCreditCustomer(id?: number) {
|
|
const res = await request.delete<ApiResult<unknown>>(
|
|
'/credit/credit-customer/' + id
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.message;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 批量删除客户
|
|
*/
|
|
export async function removeBatchCreditCustomer(data: (number | undefined)[]) {
|
|
const res = await request.delete<ApiResult<unknown>>(
|
|
'/credit/credit-customer/batch',
|
|
{
|
|
data
|
|
}
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.message;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 根据id查询客户
|
|
*/
|
|
export async function getCreditCustomer(id: number) {
|
|
const res = await request.get<ApiResult<CreditCustomer>>(
|
|
'/credit/credit-customer/' + id
|
|
);
|
|
if (res.data.code === 0 && res.data.data) {
|
|
return res.data.data;
|
|
}
|
|
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));
|
|
}
|