czh-20260521-更改计划名称以及优化新增分组流程
This commit is contained in:
@@ -44,6 +44,7 @@
|
||||
@update:visible-fields="(v) => (visibleFields = v)"
|
||||
@list-select="onListSelect"
|
||||
@open-collaborator="onOpenCollaborator"
|
||||
@open-collaborator-for-list="onOpenCollaboratorForList"
|
||||
@add-to-favorites="onAddToFavorites"
|
||||
@remove-from-favorites="onRemoveFromFavorites"
|
||||
@move-task="onMoveTask"
|
||||
@@ -90,7 +91,7 @@
|
||||
@unfollow-task="onUnfollowTask"
|
||||
@move-task="onMoveTask"
|
||||
/>
|
||||
<CollaboratorModal ref="collaboratorModalRef" :task-list-id="currentListId" :is-owner="isCurrentOwner" :secret-level="currentList?.secretLevel || 1" :secret-text="currentList?.secretText || '非密'" @changed="onCollaboratorsChanged" />
|
||||
<CollaboratorModal ref="collaboratorModalRef" :task-list-id="collaboratorTargetListId || currentListId" :is-owner="collaboratorTargetListId ? isOwnerOfTargetList : isCurrentOwner" :secret-level="collaboratorTargetList ? collaboratorTargetList.secretLevel || 1 : currentList?.secretLevel || 1" :secret-text="collaboratorTargetList ? collaboratorTargetList.secretText || '非密' : currentList?.secretText || '非密'" @changed="onCollaboratorsChanged" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -169,6 +170,7 @@
|
||||
const [registerDetailDrawer, { openDrawer: openDetailDrawer }] = useDrawer();
|
||||
|
||||
const collaboratorModalRef = ref<InstanceType<typeof CollaboratorModal> | null>(null);
|
||||
const collaboratorTargetListId = ref('');
|
||||
const defaultGroupRealIdMap = ref<Record<string, string>>({});
|
||||
|
||||
const userStore = useUserStore();
|
||||
@@ -277,7 +279,7 @@
|
||||
console.error('[TaskList] 获取用户密级失败', e);
|
||||
}
|
||||
loadFavorites();
|
||||
onViewSelect('my-tasks');
|
||||
onQuickAccessTabClick('all');
|
||||
});
|
||||
|
||||
function findListInGroups(groups: TaskListGroup[], listId: string): TaskList | null {
|
||||
@@ -297,13 +299,14 @@
|
||||
const isCurrentOwner = computed(() => currentList.value?.myPermission === '1');
|
||||
|
||||
async function loadPermissionForList(listId: string) {
|
||||
const silentOpts = { successMessageMode: 'none' as const };
|
||||
try {
|
||||
const perm = await getMyPermission({ taskListId: listId });
|
||||
const perm = await getMyPermission({ taskListId: listId }, silentOpts);
|
||||
const list = findListById(listId);
|
||||
if (list) {
|
||||
list.myPermission = perm || '';
|
||||
}
|
||||
const collabs: any[] = await getCollaborators({ taskListId: listId });
|
||||
const collabs: any[] = await getCollaborators({ taskListId: listId }, silentOpts);
|
||||
const names = collabs.map((c: any) => c.username).filter(Boolean);
|
||||
if (list) {
|
||||
list.collaboratorNames = names.join(',');
|
||||
@@ -446,7 +449,7 @@
|
||||
|
||||
if (view === 'my-tasks') {
|
||||
try {
|
||||
flatViewTitle.value = '我负责的任务';
|
||||
flatViewTitle.value = '我的事项';
|
||||
flatViewEditable.value = true;
|
||||
flatTaskEditMap.value = new Map();
|
||||
const data: any[] = await myResponsibleTasks();
|
||||
@@ -456,7 +459,7 @@
|
||||
}
|
||||
} else if (view === 'followed') {
|
||||
try {
|
||||
flatViewTitle.value = '我关注的任务';
|
||||
flatViewTitle.value = '关注事项';
|
||||
flatViewEditable.value = false;
|
||||
const data: any[] = await myFollowedTasks();
|
||||
const items = (data || []).map(buildFlatTaskItem);
|
||||
@@ -485,12 +488,71 @@
|
||||
}
|
||||
|
||||
function onOpenCollaborator() {
|
||||
collaboratorTargetListId.value = '';
|
||||
collaboratorModalRef.value?.open();
|
||||
}
|
||||
|
||||
async function onCollaboratorsChanged() {
|
||||
if (currentListId.value) {
|
||||
await loadPermissionForList(currentListId.value);
|
||||
const collaboratorTargetList = computed(() => {
|
||||
if (!collaboratorTargetListId.value) return null;
|
||||
for (const group of quickAccessGroups.value) {
|
||||
for (const list of group.taskLists) {
|
||||
if (list.id === collaboratorTargetListId.value) return list;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
||||
const isOwnerOfTargetList = computed(() => {
|
||||
return collaboratorTargetList.value?.myPermission === '1';
|
||||
});
|
||||
|
||||
function onOpenCollaboratorForList(listId: string) {
|
||||
const list = findListInQuickAccess(listId);
|
||||
if (list && list.myPermission !== '1') {
|
||||
message.warning('仅所有者可管理协作者');
|
||||
return;
|
||||
}
|
||||
collaboratorTargetListId.value = listId;
|
||||
collaboratorModalRef.value?.open();
|
||||
}
|
||||
|
||||
function findListInQuickAccess(listId: string): TaskList | null {
|
||||
for (const group of quickAccessGroups.value) {
|
||||
for (const list of group.taskLists) {
|
||||
if (list.id === listId) return list;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
async function onCollaboratorsChanged(collaboratorNames?: string) {
|
||||
const targetId = collaboratorTargetListId.value || currentListId.value;
|
||||
if (targetId && collaboratorNames !== undefined) {
|
||||
updateListCollaboratorNames(targetId, collaboratorNames);
|
||||
}
|
||||
if (targetId) {
|
||||
await loadPermissionForList(targetId);
|
||||
}
|
||||
collaboratorTargetListId.value = '';
|
||||
}
|
||||
|
||||
function updateListCollaboratorNames(listId: string, names: string) {
|
||||
for (const group of quickAccessGroups.value) {
|
||||
const idx = group.taskLists.findIndex((l) => l.id === listId);
|
||||
if (idx >= 0) {
|
||||
group.taskLists[idx] = { ...group.taskLists[idx], collaboratorNames: names };
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (currentList.value && currentList.value.id === listId) {
|
||||
currentList.value = { ...currentList.value, collaboratorNames: names };
|
||||
}
|
||||
for (const group of taskListGroups.value) {
|
||||
const idx = group.taskLists.findIndex((l) => l.id === listId);
|
||||
if (idx >= 0) {
|
||||
group.taskLists[idx] = { ...group.taskLists[idx], collaboratorNames: names };
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -581,6 +643,7 @@
|
||||
createTimeStr: item.createTimeStr || '',
|
||||
secretLevel: (item as any).secretLevel,
|
||||
secretText: (item as any).secretText,
|
||||
myPermission: item.myPermission,
|
||||
},
|
||||
],
|
||||
}));
|
||||
@@ -630,8 +693,19 @@
|
||||
async function onCreateGroup(name: string) {
|
||||
const groupName = name?.trim() || '新建分组';
|
||||
try {
|
||||
await addTaskListGroup({ tasklistName: groupName });
|
||||
await loadFavorites();
|
||||
const newId = await addTaskListGroup({ tasklistName: groupName });
|
||||
const maxSort = taskListGroups.value.reduce((max, g) => Math.max(max, g.sortOrder ?? 0), 0);
|
||||
const newGroup: TaskListGroup = {
|
||||
id: newId,
|
||||
name: groupName,
|
||||
pid: '0',
|
||||
hasChild: '0',
|
||||
type: 0,
|
||||
sortOrder: maxSort + 1,
|
||||
delFlag: 0,
|
||||
taskLists: [],
|
||||
};
|
||||
taskListGroups.value.push(newGroup);
|
||||
} catch (e) {
|
||||
console.error('[TaskList] 创建分组失败', e);
|
||||
}
|
||||
@@ -681,8 +755,6 @@
|
||||
await moveTaskList({ favoriteId, targetGroupId: targetGroupId || '', sortOrder });
|
||||
} catch (e) {
|
||||
console.error('[TaskList] 移动清单失败', e);
|
||||
} finally {
|
||||
await loadFavorites();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -691,8 +763,6 @@
|
||||
await moveGroup({ groupId, sortOrder });
|
||||
} catch (e) {
|
||||
console.error('[TaskList] 移动分组失败', e);
|
||||
} finally {
|
||||
await loadFavorites();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -850,7 +920,7 @@
|
||||
const secretLevel = currentList.value?.secretLevel || 1;
|
||||
const { ok, invalidNames } = await checkUserSecLevel(value, secretLevel);
|
||||
if (!ok) {
|
||||
message.warning(`以下人员的密级不满足当前清单(${currentList.value?.secretText || '非密'})要求:${invalidNames.join('、')}`);
|
||||
message.warning(`以下人员的密级不满足当前计划(${currentList.value?.secretText || '非密'})要求:${invalidNames.join('、')}`);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -876,7 +946,7 @@
|
||||
const secretLevel = currentList.value?.secretLevel || 1;
|
||||
const { ok, invalidNames } = await checkUserSecLevel(fields[f], secretLevel);
|
||||
if (!ok) {
|
||||
message.warning(`以下人员的密级不满足当前清单(${currentList.value?.secretText || '非密'})要求:${invalidNames.join('、')}`);
|
||||
message.warning(`以下人员的密级不满足当前计划(${currentList.value?.secretText || '非密'})要求:${invalidNames.join('、')}`);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -908,7 +978,7 @@
|
||||
if (value) {
|
||||
const { ok, invalidNames } = await checkUserSecLevel(value, secretLevel);
|
||||
if (!ok) {
|
||||
message.warning(`以下人员的密级不满足当前清单(${secretText})要求:${invalidNames.join('、')}`);
|
||||
message.warning(`以下人员的密级不满足当前计划(${secretText})要求:${invalidNames.join('、')}`);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user