diff --git a/components/form-template/form-cell/form-positive-find.vue b/components/form-template/form-cell/form-positive-find.vue index 31d3973..0be0a5c 100644 --- a/components/form-template/form-cell/form-positive-find.vue +++ b/components/form-template/form-cell/form-positive-find.vue @@ -9,20 +9,16 @@ - - - - {{ idx + 1 }}、{{ i.category || '' }} - {{ i.opinion || '' }} - - - - + + + {{ idx + 1 }}、{{ i.category || '' }} + {{ i.opinion || '' }} + + + 编辑 + 删除 + + 暂无内容,点击右侧 + 添加 @@ -90,12 +86,14 @@ function edit(item, idx) { function remove(idx) { if (props.disableChange) return; - confirm('确定删除吗?', () => { - const list = value.value.map((i) => ({ category: i.category, opinion: i.opinion })); - list.splice(idx, 1); - emitChange(list); - toast('已删除'); - }); + confirm('确定删除吗?') + .then(() => { + const list = value.value.map((i) => ({ category: i.category, opinion: i.opinion })); + list.splice(idx, 1); + emitChange(list); + toast('已删除'); + }) + .catch(() => {}); } @@ -127,37 +125,49 @@ function remove(idx) { margin-top: 20rpx; } .item { - padding: 20rpx 0; + display: flex; + align-items: flex-start; + justify-content: space-between; + gap: 24rpx; + padding: 24rpx 0; + border-bottom: 2rpx solid #f3f4f6; +} +.item:last-child { + border-bottom: none; +} +.item-main { + flex: 1; + min-width: 0; } .item-title { font-size: 28rpx; color: #111827; font-weight: 600; + word-break: break-all; } .item-sub { margin-top: 12rpx; font-size: 26rpx; color: #6b7280; white-space: pre-wrap; + word-break: break-all; } -.actions { - display: flex; - height: 100%; - align-items: stretch; -} -.action { - width: 140rpx; +.item-actions { display: flex; align-items: center; - justify-content: center; + gap: 20rpx; + flex-shrink: 0; + padding-top: 4rpx; +} +.text-action { font-size: 26rpx; - color: #fff; + line-height: 1; } -.action.edit { - background: #0877F1; +.text-action.edit { + color: #0877F1; } -.action.del { - background: #ff4d4f; +.text-action.del { + color: #ff4d4f; } .empty { margin-top: 20rpx; diff --git a/pages/case/group-manage.vue b/pages/case/group-manage.vue index 1fefe3d..ca029dd 100644 --- a/pages/case/group-manage.vue +++ b/pages/case/group-manage.vue @@ -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,32 +280,56 @@ 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; - const corpId = getCorpId(); - const teamId = getTeamId(); - if (!corpId || !teamId) { - toast('缺少团队信息'); - return; - } - loading(''); - try { - const delRes = await api('removeGroup', { corpId, id: item._id, teamId, groupType: 'team' }); - if (!delRes?.success) { - toast(delRes?.message || '删除失败'); - 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 { + 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; + } + toast('删除成功'); + uni.setStorageSync(GROUPS_RELOAD_KEY, 1); + await loadGroups(); + } finally { + hideLoading(); } - toast('删除成功'); - uni.setStorageSync(GROUPS_RELOAD_KEY, 1); - await loadGroups(); - } finally { - hideLoading(); - } - }, - }); + }, + }); + })(); }; const closeDialog = () => { diff --git a/pages/home/case-home.vue b/pages/home/case-home.vue index c1a637f..9717687 100644 --- a/pages/home/case-home.vue +++ b/pages/home/case-home.vue @@ -1434,9 +1434,7 @@ const handleCreate = withInfo(async () => { } uni.showModal({ title: '提示', - content: limitText - ? `当前管理档案数已达上限 ${limitText} 个,完成认证可提升档案管理上限。` - : '当前管理档案数已达上限,完成认证可提升档案管理上限。', + content: '当前管理档案数已达上限10个,完成认证后可提升档案管理数至100个。', cancelText: '暂不认证', confirmText: '去认证', success: (res) => { diff --git a/pages/others/edit-positive-find.vue b/pages/others/edit-positive-find.vue index c4233a2..ddf614d 100644 --- a/pages/others/edit-positive-find.vue +++ b/pages/others/edit-positive-find.vue @@ -44,7 +44,17 @@ const eventName = ref(''); onLoad((opt) => { eventName.value = String(opt?.eventName || ''); - if (opt?.title) uni.setNavigationBarTitle({ title: String(opt.title) }); + if (opt?.title) { + let title = String(opt.title); + try { + title = decodeURIComponent(title); + } catch { + title = String(opt.title); + } + uni.setNavigationBarTitle({ title: title || '阳性发现及处理意见' }); + } else { + uni.setNavigationBarTitle({ title: '阳性发现及处理意见' }); + } const data = uni.getStorageSync('current-positive-find') || {}; category.value = typeof data?.category === 'string' ? data.category : ''; opinion.value = typeof data?.opinion === 'string' ? data.opinion : '';