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 = []; selectedItems.value = [];
}); });
const handleCreate = withInfo(() => { const handleCreate = withInfo(async () => {
if (checkBatchMode()) return; 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) // - 认证中按未认证控制(上限10,且直接toast阻止)
if (hasMaxField && Number.isFinite(maxCustomerArchive)) { // - 未认证:达到10提示去认证
if (maxCustomerArchive !== -1 && managedArchiveCountAllTeams.value >= maxCustomerArchive) { // - 已认证:达到100提示联系客服
uni.showModal({ // 只是把“在管档案数”来源改为新接口(医生创建的所有团队汇总)。
title: '提示', let total = null;
content: `当前管理档案数已达上限 ${maxCustomerArchive} 个,无法继续新增。如需提升档案管理数,请联系客服处理。`, let limit = null;
cancelText: '知道了', let unlimited = false;
confirmText: '添加客服', try {
success: (res) => { const corpId = getCorpId();
if (res.confirm) { const userId = getUserId();
openAddCustomerServiceEntry(); if (corpId && userId) {
} const res = await api('doctorCreatedTeamsCustomerLimitation', { corpId, userId }, false);
} if (res?.success) {
}); const count = Number(res?.count ?? res?.data?.count);
return; if (Number.isFinite(count)) total = count;
}
} else {
// 100上限:无法继续新增 -> 引导联系客服(预留入口)
if (managedArchiveCountAllTeams.value >= 100) {
uni.showModal({
title: '提示',
content: '当前管理档案数已达 100 个,无法继续新增。如需提升档案管理数,请联系客服处理。',
cancelText: '知道了',
confirmText: '添加客服',
success: (res) => {
if (res.confirm) {
openAddCustomerServiceEntry();
}
}
});
return;
}
// 未认证 + 达到10上限:提示去认证 const rawLimit = Number(res?.limit ?? res?.data?.limit);
if (!isVerified.value && managedArchiveCountAllTeams.value >= 10) { if (Number.isFinite(rawLimit)) {
if (verifyStatus.value === 'verifying') { limit = rawLimit;
toast('信息认证中,请耐心等待!'); unlimited = rawLimit === -1;
return; }
} }
uni.showModal({ }
title: '提示', } catch {
content: '当前管理档案数已达上限 10 个,完成认证即可升级至 100 个。', // ignore
cancelText: '暂不认证', }
confirmText: '去认证', if (!Number.isFinite(total)) {
success: (res) => { total = Number(managedArchiveCountAllTeams.value || 0) || 0;
if (res.confirm) { }
startVerifyFlow();
} // 接口异常兜底:仍按旧前端默认规则(未认证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; 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', addCustomer: 'add',
updateCustomer: 'update', updateCustomer: 'update',
transferCustomers: 'transferCustomers', transferCustomers: 'transferCustomers',
doctorCreatedTeamsCustomerLimitation: 'doctorCreatedTeamsCustomerLimitation',
getGroups: 'getGroups', getGroups: 'getGroups',
createGroup: 'createGroup', createGroup: 'createGroup',
updateGroup: 'updateGroup', updateGroup: 'updateGroup',