feat: 更新医生创建团队的客户限制接口逻辑
This commit is contained in:
parent
a6179e0624
commit
17fc85b5fb
@ -1355,35 +1355,70 @@ 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 {
|
||||||
|
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;
|
||||||
|
|
||||||
|
const rawLimit = Number(res?.limit ?? res?.data?.limit);
|
||||||
|
if (Number.isFinite(rawLimit)) {
|
||||||
|
limit = rawLimit;
|
||||||
|
unlimited = rawLimit === -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} 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) => {
|
success: (res) => {
|
||||||
if (res.confirm) {
|
if (res.tapIndex === 0) {
|
||||||
openAddCustomerServiceEntry();
|
openInvitePatientEntry();
|
||||||
|
} else if (res.tapIndex === 1) {
|
||||||
|
openCreatePatientEntry();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// 100上限:无法继续新增 -> 引导联系客服(预留入口)
|
const limitText = Number.isFinite(limit) ? String(limit) : '';
|
||||||
if (managedArchiveCountAllTeams.value >= 100) {
|
|
||||||
|
// 已认证:达到上限 -> 引导联系客服(预留入口)
|
||||||
|
if (isVerified.value && total >= limit) {
|
||||||
uni.showModal({
|
uni.showModal({
|
||||||
title: '提示',
|
title: '提示',
|
||||||
content: '当前管理档案数已达 100 个,无法继续新增。如需提升档案管理数,请联系客服处理。',
|
content: limitText
|
||||||
|
? `当前管理档案数已达上限 ${limitText} 个,无法继续新增。如需提升档案管理数,请联系客服处理。`
|
||||||
|
: '当前管理档案数已达上限,无法继续新增。如需提升档案管理数,请联系客服处理。',
|
||||||
cancelText: '知道了',
|
cancelText: '知道了',
|
||||||
confirmText: '添加客服',
|
confirmText: '添加客服',
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
@ -1395,15 +1430,17 @@ const handleCreate = withInfo(() => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 未认证 + 达到10上限:提示去认证
|
// 未认证/认证中:达到上限 -> 提示去认证(认证中直接toast阻止)
|
||||||
if (!isVerified.value && managedArchiveCountAllTeams.value >= 10) {
|
if (!isVerified.value && total >= limit) {
|
||||||
if (verifyStatus.value === 'verifying') {
|
if (verifyStatus.value === 'verifying') {
|
||||||
toast('信息认证中,请耐心等待!');
|
toast('信息认证中,请耐心等待!');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uni.showModal({
|
uni.showModal({
|
||||||
title: '提示',
|
title: '提示',
|
||||||
content: '当前管理档案数已达上限 10 个,完成认证即可升级至 100 个。',
|
content: limitText
|
||||||
|
? `当前管理档案数已达上限 ${limitText} 个,完成认证可提升档案管理上限。`
|
||||||
|
: '当前管理档案数已达上限,完成认证可提升档案管理上限。',
|
||||||
cancelText: '暂不认证',
|
cancelText: '暂不认证',
|
||||||
confirmText: '去认证',
|
confirmText: '去认证',
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
@ -1414,7 +1451,6 @@ const handleCreate = withInfo(() => {
|
|||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// 未达上限:显示新增入口
|
// 未达上限:显示新增入口
|
||||||
uni.showActionSheet({
|
uni.showActionSheet({
|
||||||
|
|||||||
@ -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',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user