feat: 更新医生创建团队的客户限制接口逻辑

This commit is contained in:
Jafeng 2026-02-11 16:48:26 +08:00
parent a6179e0624
commit 17fc85b5fb
2 changed files with 89 additions and 52 deletions

View File

@ -1355,65 +1355,101 @@ const toggleBatchMode = withInfo(() => {
selectedItems.value = [];
});
const handleCreate = withInfo(() => {
const handleCreate = withInfo(async () => {
if (checkBatchMode()) return;
const rawMax = doctorInfo.value?.maxCustomerArchive;
const hasMaxField = rawMax !== undefined && rawMax !== null && String(rawMax).trim() !== '';
const maxCustomerArchive = hasMaxField ? Number(rawMax) : NaN;
// maxCustomerArchive:
// -1 = 无限;存在该字段则优先按该字段限制;不存在则沿用原有规则(未认证10/已认证100)
if (hasMaxField && Number.isFinite(maxCustomerArchive)) {
if (maxCustomerArchive !== -1 && managedArchiveCountAllTeams.value >= maxCustomerArchive) {
uni.showModal({
title: '提示',
content: `当前管理档案数已达上限 ${maxCustomerArchive} 个,无法继续新增。如需提升档案管理数,请联系客服处理。`,
cancelText: '知道了',
confirmText: '添加客服',
success: (res) => {
if (res.confirm) {
openAddCustomerServiceEntry();
}
}
});
return;
}
} else {
// 100上限:无法继续新增 -> 引导联系客服(预留入口)
if (managedArchiveCountAllTeams.value >= 100) {
uni.showModal({
title: '提示',
content: '当前管理档案数已达 100 个,无法继续新增。如需提升档案管理数,请联系客服处理。',
cancelText: '知道了',
confirmText: '添加客服',
success: (res) => {
if (res.confirm) {
openAddCustomerServiceEntry();
}
}
});
return;
}
// 规则沿用原前端逻辑:
// - 认证中按未认证控制(上限10,且直接toast阻止)
// - 未认证:达到10提示去认证
// - 已认证:达到100提示联系客服
// 只是把“在管档案数”来源改为新接口(医生创建的所有团队汇总)。
let total = null;
let limit = null;
let unlimited = false;
try {
const corpId = getCorpId();
const userId = getUserId();
if (corpId && userId) {
const res = await api('doctorCreatedTeamsCustomerLimitation', { corpId, userId }, false);
if (res?.success) {
const count = Number(res?.count ?? res?.data?.count);
if (Number.isFinite(count)) total = count;
// 未认证 + 达到10上限:提示去认证
if (!isVerified.value && managedArchiveCountAllTeams.value >= 10) {
if (verifyStatus.value === 'verifying') {
toast('信息认证中,请耐心等待!');
return;
const rawLimit = Number(res?.limit ?? res?.data?.limit);
if (Number.isFinite(rawLimit)) {
limit = rawLimit;
unlimited = rawLimit === -1;
}
}
uni.showModal({
title: '提示',
content: '当前管理档案数已达上限 10 个,完成认证即可升级至 100 个。',
cancelText: '暂不认证',
confirmText: '去认证',
success: (res) => {
if (res.confirm) {
startVerifyFlow();
}
}
} catch {
// ignore
}
if (!Number.isFinite(total)) {
total = Number(managedArchiveCountAllTeams.value || 0) || 0;
}
// 接口异常兜底:仍按旧前端默认规则(未认证10/已认证100)
if (!Number.isFinite(limit)) {
limit = isVerified.value ? 100 : 10;
unlimited = false;
}
// 无限:直接放行
if (unlimited) {
uni.showActionSheet({
itemList: ['邀请患者建档', '我帮患者建档'],
success: (res) => {
if (res.tapIndex === 0) {
openInvitePatientEntry();
} else if (res.tapIndex === 1) {
openCreatePatientEntry();
}
});
}
});
return;
}
const limitText = Number.isFinite(limit) ? String(limit) : '';
// 已认证:达到上限 -> 引导联系客服(预留入口)
if (isVerified.value && total >= limit) {
uni.showModal({
title: '提示',
content: limitText
? `当前管理档案数已达上限 ${limitText} 个,无法继续新增。如需提升档案管理数,请联系客服处理。`
: '当前管理档案数已达上限,无法继续新增。如需提升档案管理数,请联系客服处理。',
cancelText: '知道了',
confirmText: '添加客服',
success: (res) => {
if (res.confirm) {
openAddCustomerServiceEntry();
}
}
});
return;
}
// 未认证/认证中:达到上限 -> 提示去认证(认证中直接toast阻止)
if (!isVerified.value && total >= limit) {
if (verifyStatus.value === 'verifying') {
toast('信息认证中,请耐心等待!');
return;
}
uni.showModal({
title: '提示',
content: limitText
? `当前管理档案数已达上限 ${limitText} 个,完成认证可提升档案管理上限。`
: '当前管理档案数已达上限,完成认证可提升档案管理上限。',
cancelText: '暂不认证',
confirmText: '去认证',
success: (res) => {
if (res.confirm) {
startVerifyFlow();
}
}
});
return;
}
// 未达上限:显示新增入口

View File

@ -69,6 +69,7 @@ const urlsConfig = {
addCustomer: 'add',
updateCustomer: 'update',
transferCustomers: 'transferCustomers',
doctorCreatedTeamsCustomerLimitation: 'doctorCreatedTeamsCustomerLimitation',
getGroups: 'getGroups',
createGroup: 'createGroup',
updateGroup: 'updateGroup',