feat: 更新管理档案数上限提示信息
This commit is contained in:
parent
9fbee9caf4
commit
aed96bceb2
@ -187,6 +187,71 @@ async function loadGroups() {
|
||||
}
|
||||
}
|
||||
|
||||
function normalizeListPayload(res) {
|
||||
const payload =
|
||||
res && typeof res === 'object'
|
||||
? res.data && typeof res.data === 'object' && !Array.isArray(res.data)
|
||||
? res.data
|
||||
: res
|
||||
: {};
|
||||
const list = Array.isArray(payload.list) ? payload.list : Array.isArray(payload.data) ? payload.data : [];
|
||||
const total = Number(payload.total ?? res?.total ?? list.length) || 0;
|
||||
return { list, total };
|
||||
}
|
||||
|
||||
async function fetchGroupMemberIds(groupId) {
|
||||
const corpId = getCorpId();
|
||||
const teamId = getTeamId();
|
||||
const userId = getUserId();
|
||||
if (!corpId || !teamId || !userId || !groupId) {
|
||||
return { success: false, message: '缺少用户/团队信息', ids: [] };
|
||||
}
|
||||
|
||||
const ids = [];
|
||||
const seen = new Set();
|
||||
const pageSize = 200;
|
||||
let page = 1;
|
||||
let total = 0;
|
||||
|
||||
while (true) {
|
||||
const res = await api('searchCorpCustomerForCaseList', {
|
||||
corpId,
|
||||
userId,
|
||||
teamId,
|
||||
page,
|
||||
pageSize,
|
||||
groupIds: [String(groupId)],
|
||||
});
|
||||
if (!res?.success) {
|
||||
return { success: false, message: res?.message || '获取分组成员失败', ids: [] };
|
||||
}
|
||||
|
||||
const { list, total: nextTotal } = normalizeListPayload(res);
|
||||
total = nextTotal;
|
||||
list.forEach((member) => {
|
||||
const memberId = String(member?._id || member?.id || '');
|
||||
if (!memberId || seen.has(memberId)) return;
|
||||
seen.add(memberId);
|
||||
ids.push(memberId);
|
||||
});
|
||||
|
||||
if (list.length < pageSize || (total > 0 && ids.length >= total)) break;
|
||||
page += 1;
|
||||
}
|
||||
|
||||
return { success: true, ids };
|
||||
}
|
||||
|
||||
async function removeMembersFromGroup(memberIds, groupId) {
|
||||
for (const memberId of memberIds) {
|
||||
const res = await api('addGroupIdForMember', { memberId, fromGroupId: String(groupId) });
|
||||
if (!res?.success) {
|
||||
return { success: false, message: res?.message || '分组成员移出失败' };
|
||||
}
|
||||
}
|
||||
return { success: true };
|
||||
}
|
||||
|
||||
const showDialog = ref(false);
|
||||
const dialogMode = ref('add'); // 'add' or 'edit'
|
||||
const inputValue = ref('');
|
||||
@ -215,20 +280,43 @@ const handleEdit = (item, index) => {
|
||||
const handleDelete = (item, index) => {
|
||||
if (dragEnabledId.value) return;
|
||||
if (item?.parentGroupId) return;
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该分组吗?',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return;
|
||||
(async () => {
|
||||
await ensureDoctor();
|
||||
const corpId = getCorpId();
|
||||
const teamId = getTeamId();
|
||||
if (!corpId || !teamId) {
|
||||
toast('缺少团队信息');
|
||||
return;
|
||||
}
|
||||
|
||||
const groupId = String(item?._id || '');
|
||||
const memberRes = await fetchGroupMemberIds(groupId);
|
||||
if (!memberRes.success) {
|
||||
toast(memberRes.message || '获取分组成员失败');
|
||||
return;
|
||||
}
|
||||
|
||||
const memberIds = memberRes.ids;
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: memberIds.length
|
||||
? '分组删除后,所有分组内成员自动出组。确定要删除该分组吗?'
|
||||
: '确定要删除该分组吗?',
|
||||
cancelText: '取消',
|
||||
confirmText: '确定删除',
|
||||
success: async (res) => {
|
||||
if (!res.confirm) return;
|
||||
loading('');
|
||||
try {
|
||||
const delRes = await api('removeGroup', { corpId, id: item._id, teamId, groupType: 'team' });
|
||||
if (memberIds.length) {
|
||||
const removeRes = await removeMembersFromGroup(memberIds, groupId);
|
||||
if (!removeRes.success) {
|
||||
toast(removeRes.message || '删除失败');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const delRes = await api('removeGroup', { corpId, id: groupId, teamId, groupType: 'team' });
|
||||
if (!delRes?.success) {
|
||||
toast(delRes?.message || '删除失败');
|
||||
return;
|
||||
@ -241,6 +329,7 @@ const handleDelete = (item, index) => {
|
||||
}
|
||||
},
|
||||
});
|
||||
})();
|
||||
};
|
||||
|
||||
const closeDialog = () => {
|
||||
|
||||
@ -1434,9 +1434,7 @@ const handleCreate = withInfo(async () => {
|
||||
}
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: limitText
|
||||
? `当前管理档案数已达上限 ${limitText} 个,完成认证可提升档案管理上限。`
|
||||
: '当前管理档案数已达上限,完成认证可提升档案管理上限。',
|
||||
content: '当前管理档案数已达上限10个,完成认证后可提升档案管理数至100个。',
|
||||
cancelText: '暂不认证',
|
||||
confirmText: '去认证',
|
||||
success: (res) => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user