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;
}
// 沿
// - 10toast
// - 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',