czh-20260501-增加密级相关功能

This commit is contained in:
zhihao
2026-05-01 03:10:47 +08:00
parent d9d5ab70cc
commit c15be6a79b
14 changed files with 1197 additions and 162 deletions
+67 -25
View File
@@ -9,7 +9,7 @@
:permission-map="permissionMap"
@view-select="onViewSelect"
@list-select="onListSelect"
@create-list="onCreateList"
@create-list-modal="onCreateListModal"
@create-group="onCreateGroup"
@rename-list="onRenameList"
@delete-list="onDeleteList"
@@ -90,12 +90,13 @@
@unfollow-task="onUnfollowTask"
@move-task="onMoveTask"
/>
<CollaboratorModal ref="collaboratorModalRef" :task-list-id="currentListId" :is-owner="isCurrentOwner" @changed="onCollaboratorsChanged" />
<CollaboratorModal ref="collaboratorModalRef" :task-list-id="currentListId" :is-owner="isCurrentOwner" :secret-level="currentList?.secretLevel || 1" :secret-text="currentList?.secretText || '非密'" @changed="onCollaboratorsChanged" />
</div>
</template>
<script lang="ts" name="tasklist-index-page" setup>
import { ref, computed, onMounted } from 'vue';
import { message } from 'ant-design-vue';
import { useModal } from '/@/components/Modal';
import { useDrawer } from '/@/components/Drawer';
import { useUserStore } from '/@/store/modules/user';
@@ -134,8 +135,10 @@
myFollowedTasks,
moveTask,
moveTaskGroup,
getCurrentUserSecurityLevel,
} from './TaskList.api';
import { DEFAULT_VISIBLE_FIELDS } from './types';
import { isOverdue, checkUserSecLevel } from './utils/taskUtils';
import type {
TaskListGroup,
StatusFilter,
@@ -162,7 +165,7 @@
const currentDrawerTaskId = ref<string>('');
const [registerTaskModal, { openModal: openTaskModal }] = useModal();
const [registerListModal, { openModal: _openListModal }] = useModal();
const [registerListModal, { openModal: openListModal }] = useModal();
const [registerDetailDrawer, { openDrawer: openDetailDrawer }] = useDrawer();
const collaboratorModalRef = ref<InstanceType<typeof CollaboratorModal> | null>(null);
@@ -170,6 +173,8 @@
const userStore = useUserStore();
const currentUserSecurityLevel = ref<number>(3);
const flatTasks = ref<TaskItem[]>([]);
const flatViewTitle = ref('');
const flatViewEditable = ref(false);
@@ -227,6 +232,8 @@
sortOrder: fav.sortOrder || 0,
delFlag: 0,
groups: [],
secretLevel: fav.secretLevel,
secretText: fav.secretText,
};
if (fav.pid) {
@@ -261,7 +268,14 @@
return groups;
}
onMounted(() => {
onMounted(async () => {
try {
const level = await getCurrentUserSecurityLevel();
currentUserSecurityLevel.value = level || 3;
console.log('[TaskList] 当前用户密级:', currentUserSecurityLevel.value);
} catch (e) {
console.error('[TaskList] 获取用户密级失败', e);
}
loadFavorites();
onViewSelect('my-tasks');
});
@@ -565,6 +579,8 @@
ownerName: item.ownerName || '',
collaboratorNames: item.collaboratorNames || '',
createTimeStr: item.createTimeStr || '',
secretLevel: (item as any).secretLevel,
secretText: (item as any).secretText,
},
],
}));
@@ -587,32 +603,22 @@
console.error('[TaskList] 创建任务失败', e);
}
} else {
openTaskModal(true, { groupId, mainId: currentListId.value });
openTaskModal(true, { groupId, mainId: currentListId.value, secretLevel: currentList.value?.secretLevel || 1, secretText: currentList.value?.secretText || '非密' });
}
}
async function onCreateList(name: string, groupId: string) {
if (!name || !name.trim()) return;
try {
const listId = await addTaskList({
tasklistName: name.trim(),
pid: groupId || undefined,
sortOrder: 1,
});
if (listId) {
await addToFavorites({ taskListId: listId, pid: groupId || undefined });
}
await loadFavorites();
} catch (e) {
console.error('[TaskList] 创建清单失败', e);
}
function onCreateListModal(groupId: string) {
openListModal(true, {
groupId,
userSecurityLevel: currentUserSecurityLevel.value,
});
}
function onListCreated(listId?: string) {
async function onListCreated(listId?: string) {
if (listId) {
addToFavorites({ taskListId: listId });
await addToFavorites({ taskListId: listId });
}
loadFavorites();
await loadFavorites();
}
async function onTaskCreated() {
@@ -775,7 +781,7 @@
const task = allTasks.find((t) => t.id === taskId);
if (task) {
const readOnly = isFlatView.value ? !canEditFlatTask(task) : currentList.value?.myPermission === '3';
openDetailDrawer(true, { task, allTasks, readOnly });
openDetailDrawer(true, { task, allTasks, readOnly, secretLevel: currentList.value?.secretLevel || 1 });
}
}
@@ -834,11 +840,20 @@
const task = allTasks.find((t) => t.id === currentDrawerTaskId.value);
if (task) {
const readOnly = isFlatView.value ? !canEditFlatTask(task) : currentList.value?.myPermission === '3';
openDetailDrawer(true, { task, allTasks, readOnly });
openDetailDrawer(true, { task, allTasks, readOnly, secretLevel: currentList.value?.secretLevel || 1 });
}
}
async function onUpdateTaskField(taskId: string, field: string, value: any) {
const userFields = ['assigneeId', 'participantId', 'followersId'];
if (userFields.includes(field) && value) {
const secretLevel = currentList.value?.secretLevel || 1;
const { ok, invalidNames } = await checkUserSecLevel(value, secretLevel);
if (!ok) {
message.warning(`以下人员的密级不满足当前清单(${currentList.value?.secretText || '非密'})要求:${invalidNames.join('、')}`);
return;
}
}
try {
await editTask({ id: taskId, [field]: value });
if (isFlatView.value) {
@@ -855,6 +870,17 @@
}
async function onUpdateTaskFields(taskId: string, fields: Record<string, any>) {
const userFields = ['assigneeId', 'participantId', 'followersId'];
for (const f of userFields) {
if (fields[f]) {
const secretLevel = currentList.value?.secretLevel || 1;
const { ok, invalidNames } = await checkUserSecLevel(fields[f], secretLevel);
if (!ok) {
message.warning(`以下人员的密级不满足当前清单(${currentList.value?.secretText || '非密'})要求:${invalidNames.join('、')}`);
return;
}
}
}
try {
await editTask({ id: taskId, ...fields });
if (isFlatView.value) {
@@ -871,6 +897,22 @@
}
async function onSaveTask(updatedTask: TaskItem) {
const secretLevel = currentList.value?.secretLevel || 1;
const secretText = currentList.value?.secretText || '非密';
const userIdFields = [
{ value: updatedTask.assigneeId, label: '负责人' },
{ value: updatedTask.participantId, label: '参与人' },
{ value: updatedTask.followersId, label: '关注人' },
];
for (const { value } of userIdFields) {
if (value) {
const { ok, invalidNames } = await checkUserSecLevel(value, secretLevel);
if (!ok) {
message.warning(`以下人员的密级不满足当前清单(${secretText})要求:${invalidNames.join('、')}`);
return;
}
}
}
try {
await editTask({
id: updatedTask.id,