## 主要修改 ### 1. 登录租户选择修复 - 新增全局租户状态管理(useLoginTenantId hook) - 使用 @vueuse/core 的 createGlobalState 持久化租户选择 - 确保组件重新挂载时租户ID不丢失 - 修复登录时租户自动跳回第一个的问题 - 删除登录时强制覆盖租户ID的代码 - 用户选择的租户现在会被正确使用 - 恢复"记住登录"功能 - 自动恢复上次登录的租户、用户名、密码 ### 2. ERP 动态API迁移 - 员工门户和经销商门户的ERP API从硬编码迁移到动态API系统 - /erp/customer/* → /erp/dynamic/v1/customer/* - 新增 customer/list, customer/detail, sales-areas, brands API - 修复API响应嵌套结构问题 - 动态API返回数据嵌套在 data 字段中 - 调整响应类型定义和数据处理逻辑 ### 3. 经销商管理数据显示修复 - 处理动态API响应的嵌套数据结构 - 兼容 res.rows 和 res.data.rows 两种格式 - 添加详细调试日志便于排查问题 ## 文件清单 - 新增文件: - hzhub-portal-employee/src/hooks/useLoginTenantId.ts - hzhub-portal-dealer/src/hooks/useLoginTenantId.ts - hzhub-portal-employee/src/api/erp/index.ts - hzhub-portal-dealer/src/api/erp/index.ts - 修改文件: - 登录组件:TenantAccountPassword.vue, AccountPassword.vue - API文件:auth/index.ts, auth/types.ts - 经销商页面:dealer/index.vue ## 测试验证 - ✅ 租户下拉列表正常显示 - ✅ 选择租户后不会跳回第一个 - ✅ 记住登录功能可用 - ✅ 经销商管理页面数据正常显示 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
92 lines
2.1 KiB
TypeScript
92 lines
2.1 KiB
TypeScript
import request from '@/utils/request';
|
|
|
|
/**
|
|
* 测试 ERP 数据库连接
|
|
*/
|
|
export function testErpConnection() {
|
|
return request.get<{
|
|
status: string;
|
|
database: string;
|
|
version: string;
|
|
error?: string;
|
|
}>('/erp/test/connection').json();
|
|
}
|
|
|
|
/**
|
|
* ERP 健康检查
|
|
*/
|
|
export function erpHealth() {
|
|
return request.get<string>('/erp/test/health').json();
|
|
}
|
|
|
|
/**
|
|
* 客户档案接口类型
|
|
*/
|
|
export interface CustomerVO {
|
|
customerCode: string;
|
|
customerName: string;
|
|
companyCode: string;
|
|
companyName: string;
|
|
brand: string;
|
|
brandName: string;
|
|
contactName: string;
|
|
salesAreaCode: string;
|
|
salesAreaName: string;
|
|
salesPersonCode: string;
|
|
salesPersonName: string;
|
|
saleDocCode: string;
|
|
saleDocName: string;
|
|
pricePlanCode: string;
|
|
pricePlanName: string;
|
|
customerType: string;
|
|
address: string;
|
|
phone: string;
|
|
email: string;
|
|
sdOrgCode: string;
|
|
sdOrgName: string;
|
|
province: string;
|
|
city: string;
|
|
isStop: number;
|
|
}
|
|
|
|
/**
|
|
* 分页查询客户列表
|
|
* 使用动态API: /erp/dynamic/v1/customer/list
|
|
*/
|
|
export function getCustomerList(params: {
|
|
pageNum: number;
|
|
pageSize: number;
|
|
keyword?: string;
|
|
companyCode?: string;
|
|
salesAreaCode?: string;
|
|
brand?: string;
|
|
}) {
|
|
return request.get<{ rows: CustomerVO[]; total: number; code: number; msg: string }>(
|
|
'/erp/dynamic/v1/customer/list',
|
|
params
|
|
).json();
|
|
}
|
|
|
|
/**
|
|
* 获取客户详情
|
|
* 使用动态API: /erp/dynamic/v1/customer/detail
|
|
*/
|
|
export function getCustomerDetail(customerCode: string) {
|
|
return request.get<{ code: number; msg: string; data: CustomerVO }>(`/erp/dynamic/v1/customer/detail?customerCode=${customerCode}`).json();
|
|
}
|
|
|
|
/**
|
|
* 获取销区列表
|
|
* 使用动态API: /erp/dynamic/v1/customer/sales-areas
|
|
*/
|
|
export function getSalesAreas() {
|
|
return request.get<{ code: number; msg: string; data: CustomerVO[] }>('/erp/dynamic/v1/customer/sales-areas').json();
|
|
}
|
|
|
|
/**
|
|
* 获取品牌列表
|
|
* 使用动态API: /erp/dynamic/v1/customer/brands
|
|
*/
|
|
export function getBrands() {
|
|
return request.get<{ code: number; msg: string; data: CustomerVO[] }>('/erp/dynamic/v1/customer/brands').json();
|
|
} |