Compare commits

...

2 Commits

4 changed files with 170 additions and 63 deletions

View File

@ -9,20 +9,16 @@
</view> </view>
<view v-if="value.length" class="list"> <view v-if="value.length" class="list">
<uni-swipe-action> <view v-for="(i, idx) in value" :key="idx" class="item">
<uni-swipe-action-item v-for="(i, idx) in value" :key="idx"> <view class="item-main">
<view class="item"> <view class="item-title">{{ idx + 1 }}{{ i.category || '' }}</view>
<view class="item-title">{{ idx + 1 }}{{ i.category || '' }}</view> <view class="item-sub">{{ i.opinion || '' }}</view>
<view class="item-sub">{{ i.opinion || '' }}</view> </view>
</view> <view class="item-actions">
<template #right> <view class="text-action edit" @click.stop="edit(i, idx)">编辑</view>
<view class="actions"> <view class="text-action del" @click.stop="remove(idx)">删除</view>
<view class="action edit" @click.stop="edit(i, idx)">编辑</view> </view>
<view class="action del" @click.stop="remove(idx)">删除</view> </view>
</view>
</template>
</uni-swipe-action-item>
</uni-swipe-action>
</view> </view>
<view v-else class="empty">暂无内容点击右侧 + 添加</view> <view v-else class="empty">暂无内容点击右侧 + 添加</view>
@ -90,12 +86,14 @@ function edit(item, idx) {
function remove(idx) { function remove(idx) {
if (props.disableChange) return; if (props.disableChange) return;
confirm('确定删除吗?', () => { confirm('确定删除吗?')
const list = value.value.map((i) => ({ category: i.category, opinion: i.opinion })); .then(() => {
list.splice(idx, 1); const list = value.value.map((i) => ({ category: i.category, opinion: i.opinion }));
emitChange(list); list.splice(idx, 1);
toast('已删除'); emitChange(list);
}); toast('已删除');
})
.catch(() => {});
} }
</script> </script>
@ -127,37 +125,49 @@ function remove(idx) {
margin-top: 20rpx; margin-top: 20rpx;
} }
.item { .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 { .item-title {
font-size: 28rpx; font-size: 28rpx;
color: #111827; color: #111827;
font-weight: 600; font-weight: 600;
word-break: break-all;
} }
.item-sub { .item-sub {
margin-top: 12rpx; margin-top: 12rpx;
font-size: 26rpx; font-size: 26rpx;
color: #6b7280; color: #6b7280;
white-space: pre-wrap; white-space: pre-wrap;
word-break: break-all;
} }
.actions { .item-actions {
display: flex;
height: 100%;
align-items: stretch;
}
.action {
width: 140rpx;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; gap: 20rpx;
flex-shrink: 0;
padding-top: 4rpx;
}
.text-action {
font-size: 26rpx; font-size: 26rpx;
color: #fff; line-height: 1;
} }
.action.edit { .text-action.edit {
background: #0877F1; color: #0877F1;
} }
.action.del { .text-action.del {
background: #ff4d4f; color: #ff4d4f;
} }
.empty { .empty {
margin-top: 20rpx; margin-top: 20rpx;

View File

@ -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 showDialog = ref(false);
const dialogMode = ref('add'); // 'add' or 'edit' const dialogMode = ref('add'); // 'add' or 'edit'
const inputValue = ref(''); const inputValue = ref('');
@ -215,32 +280,56 @@ const handleEdit = (item, index) => {
const handleDelete = (item, index) => { const handleDelete = (item, index) => {
if (dragEnabledId.value) return; if (dragEnabledId.value) return;
if (item?.parentGroupId) return; if (item?.parentGroupId) return;
uni.showModal({ (async () => {
title: '提示', await ensureDoctor();
content: '确定要删除该分组吗?', const corpId = getCorpId();
success: async (res) => { const teamId = getTeamId();
if (!res.confirm) return; if (!corpId || !teamId) {
const corpId = getCorpId(); toast('缺少团队信息');
const teamId = getTeamId(); return;
if (!corpId || !teamId) { }
toast('缺少团队信息');
return; const groupId = String(item?._id || '');
} const memberRes = await fetchGroupMemberIds(groupId);
loading(''); if (!memberRes.success) {
try { toast(memberRes.message || '获取分组成员失败');
const delRes = await api('removeGroup', { corpId, id: item._id, teamId, groupType: 'team' }); return;
if (!delRes?.success) { }
toast(delRes?.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 = () => { const closeDialog = () => {

View File

@ -1434,9 +1434,7 @@ const handleCreate = withInfo(async () => {
} }
uni.showModal({ uni.showModal({
title: '提示', title: '提示',
content: limitText content: '当前管理档案数已达上限10个完成认证后可提升档案管理数至100个。',
? `当前管理档案数已达上限 ${limitText} 个,完成认证可提升档案管理上限。`
: '当前管理档案数已达上限,完成认证可提升档案管理上限。',
cancelText: '暂不认证', cancelText: '暂不认证',
confirmText: '去认证', confirmText: '去认证',
success: (res) => { success: (res) => {

View File

@ -44,7 +44,17 @@ const eventName = ref('');
onLoad((opt) => { onLoad((opt) => {
eventName.value = String(opt?.eventName || ''); 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') || {}; const data = uni.getStorageSync('current-positive-find') || {};
category.value = typeof data?.category === 'string' ? data.category : ''; category.value = typeof data?.category === 'string' ? data.category : '';
opinion.value = typeof data?.opinion === 'string' ? data.opinion : ''; opinion.value = typeof data?.opinion === 'string' ? data.opinion : '';