清除“Task”模块

This commit is contained in:
Cheng Zhou
2025-12-19 11:02:21 +08:00
parent 81412fe906
commit b475d4f763
30 changed files with 58 additions and 1090 deletions
+25 -33
View File
@@ -76,7 +76,6 @@ import { useRouter } from "vue-router";
import { ElMessage } from "element-plus";
import { useAuthStore } from "../../store/auth";
import { useStudyStore } from "../../store/study";
import { fetchTasks } from "../../api/tasks";
import { fetchAes } from "../../api/aes";
import { fetchFinanceItems } from "../../api/finance";
import { fetchImpTransactions } from "../../api/impTransactions";
@@ -113,25 +112,24 @@ const quickActions = computed(() => {
if (!currentStudyId.value) return [];
if (role.value === "CRA")
return [
{ label: "新建 AE", path: "/study/aes" },
{ label: "我的任务", path: "/study/tasks" },
{ label: "伦理与启动", path: "/study/milestones" },
{ label: "AE 列表", path: "/study/aes" },
];
if (role.value === "PM")
return [
{ label: "派发任务", path: "/study/tasks" },
{ label: "发公告", path: "/study/faq" },
{ label: "查看 CRA 列表", path: "/study/tasks" },
{ label: "伦理与启动", path: "/study/milestones" },
{ label: "费用审核", path: "/study/finance" },
{ label: "公告维护", path: "/study/faq" },
];
if (role.value === "PV") return [{ label: "AE 列表", path: "/study/aes" }];
if (role.value === "IMP") return [{ label: "药品台账", path: "/study/imp/transactions" }];
return [];
return [{ label: "伦理与启动", path: "/study/milestones" }];
});
const todayMorePath = computed(() => (role.value === "CRA" ? "/study/tasks" : "/study/tasks"));
const overdueMorePath = computed(() => (role.value === "CRA" ? "/study/tasks" : "/study/tasks"));
const todayMorePath = computed(() => (role.value === "IMP" ? "/study/imp/transactions" : "/study/aes"));
const overdueMorePath = computed(() => (role.value === "IMP" ? "/study/imp/transactions" : "/study/aes"));
const actionMorePath = computed(() => {
if (role.value === "IMP") return "/study/imp/transactions";
if (role.value === "PV") return "/study/aes";
if (role.value === "PM" || role.value === "ADMIN") return "/study/finance";
return "/study/aes";
});
@@ -141,19 +139,11 @@ const isOverdue = (d?: string | null) => {
return new Date(d) < new Date(todayStr.value);
};
const toTaskItem = (task: any): WorkItem => ({
title: task.title || "任务",
subtitle: study.currentStudy?.name || "",
status: task.due_date || task.status,
overdue: isOverdue(task.due_date),
path: "/study/tasks",
});
const toAeItem = (ae: any): WorkItem => ({
title: ae.term || "不良事件",
subtitle: study.currentStudy?.name || "",
status: ae.status,
overdue: false,
overdue: isOverdue(ae.expected_resolution_date || ae.updated_at),
path: `/study/aes/${ae.id}`,
});
@@ -178,19 +168,17 @@ const loadData = async () => {
loading.value = true;
try {
const studyId = currentStudyId.value;
const tasksReq = fetchTasks(studyId, { limit: 200, assignee_id: auth.user?.id });
const aesReq = fetchAes(studyId, { status: "NEW", limit: 50 });
const financeReq = fetchFinanceItems(studyId, { status: "SUBMITTED", limit: 50 });
const impReq = fetchImpTransactions ? fetchImpTransactions(studyId, { limit: 50 }) : Promise.resolve({ data: [] });
const [tasksRes, aesRes, financeRes, impRes] = await Promise.allSettled([tasksReq, aesReq, financeReq, impReq]);
const tasks = tasksRes.status === "fulfilled" ? (tasksRes.value.data.items || tasksRes.value.data || []) : [];
const [aesRes, financeRes, impRes] = await Promise.allSettled([aesReq, financeReq, impReq]);
const aes = aesRes.status === "fulfilled" ? (aesRes.value.data.items || aesRes.value.data || []) : [];
const finances =
financeRes.status === "fulfilled" ? (financeRes.value.data.items || financeRes.value.data || []) : [];
const impTx = impRes.status === "fulfilled" ? (impRes.value.data.items || impRes.value.data || []) : [];
buildSections(tasks, aes, finances, impTx);
buildSections(aes, finances, impTx);
} catch (e: any) {
ElMessage.error(e?.response?.data?.message || "工作台数据加载失败");
} finally {
@@ -198,21 +186,25 @@ const loadData = async () => {
}
};
const buildSections = (tasks: any[], aes: any[], finances: any[], impTx: any[]) => {
const buildSections = (aes: any[], finances: any[], impTx: any[]) => {
todayList.value = [];
overdueList.value = [];
actionList.value = [];
const openAes = aes.filter((a) => a.status !== "CLOSED");
const financePending = finances.filter((f) => f.status !== "PAID");
const overdueAes = openAes.filter((a) => isOverdue(a.expected_resolution_date || a.updated_at));
if (role.value === "CRA") {
todayList.value = tasks.filter((t) => t.due_date === todayStr.value).slice(0, 5).map(toTaskItem);
overdueList.value = tasks.filter((t) => isOverdue(t.due_date)).slice(0, 5).map(toTaskItem);
actionList.value = aes.slice(0, 5).map(toAeItem);
} else if (role.value === "PM") {
todayList.value = tasks.filter((t) => t.due_date === todayStr.value).slice(0, 5).map(toTaskItem);
overdueList.value = tasks.filter((t) => isOverdue(t.due_date)).slice(0, 5).map(toTaskItem);
const financePending = finances.slice(0, 3).map(toFinanceItem);
const aePending = aes.slice(0, 2).map(toAeItem);
actionList.value = [...financePending, ...aePending].slice(0, 5);
todayList.value = openAes.slice(0, 5).map(toAeItem);
overdueList.value = overdueAes.slice(0, 5).map(toAeItem);
actionList.value = openAes.slice(0, 5).map(toAeItem);
} else if (role.value === "PM" || role.value === "ADMIN") {
todayList.value = openAes.slice(0, 5).map(toAeItem);
overdueList.value = overdueAes.slice(0, 5).map(toAeItem);
const financeTodo = financePending.slice(0, 3).map(toFinanceItem);
actionList.value = [...financeTodo, ...openAes.slice(0, 2).map(toAeItem)].slice(0, 5);
} else if (role.value === "PV") {
const aeOpen = aes.filter((a) => a.status !== "CLOSED");
todayList.value = aeOpen.slice(0, 5).map(toAeItem);