- 在所有信用模块的搜索参数接口中添加 userId 字段 - 集成 withCreditUserScope 数据范围工具函数到各个 API 请求 - 实现对行政许可、破产重整、分支机构、失信被执行人等所有信用数据的用户范围过滤 - 统一处理分页和列表查询的数据范围限制 - 确保所有信用相关 API 都支持基于用户的权限控制
128 lines
3.1 KiB
TypeScript
128 lines
3.1 KiB
TypeScript
import request from '@/utils/request';
|
|
import { withCreditUserScope } from '@/api/credit/utils/data-scope';
|
|
|
|
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: withCreditUserScope(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: withCreditUserScope(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, companyId?: number) {
|
|
const formData = new FormData();
|
|
formData.append('file', file);
|
|
if (companyId != null) {
|
|
formData.append('companyId', String(companyId));
|
|
}
|
|
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));
|
|
}
|