清除“Task”模块
This commit is contained in:
@@ -11,10 +11,12 @@
|
||||
|
||||
<el-row :gutter="16" class="kpi-row">
|
||||
<el-col :span="6">
|
||||
<KpiCard title="任务完成率" :value="formatPercent(progress?.completion_rate)" :loading="loading.progress" />
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<KpiCard title="逾期任务" :value="progress?.tasks_overdue ?? 0" :loading="loading.progress" />
|
||||
<KpiCard
|
||||
title="节点完成率"
|
||||
:value="milestoneCompletionRate"
|
||||
:subtext="milestoneCompletionText"
|
||||
:loading="loading.progress"
|
||||
/>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<KpiCard title="逾期 AE" :value="overdueAes" :loading="loading.overdueAes" />
|
||||
@@ -32,15 +34,12 @@
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-card class="section-card" header="我的待办任务">
|
||||
<el-alert v-if="errors.tasks" type="warning" :title="errors.tasks" show-icon class="mb-8" />
|
||||
<el-table v-else :data="todoTasks" style="width: 100%" v-loading="loading.tasks" @row-click="goTasks">
|
||||
<el-table-column prop="title" label="标题" />
|
||||
<el-table-column prop="priority" label="优先级" width="100" />
|
||||
<el-table-column prop="status" label="状态" width="120" />
|
||||
<el-table-column prop="due_date" label="截止日期" width="140" />
|
||||
</el-table>
|
||||
</el-card>
|
||||
<el-alert
|
||||
type="info"
|
||||
title="任务模块已并入伦理与启动管理,请在节点下处理相关事项"
|
||||
show-icon
|
||||
class="section-card"
|
||||
/>
|
||||
|
||||
<QuickActions class="mt-16" />
|
||||
</div>
|
||||
@@ -50,39 +49,38 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from "vue";
|
||||
import { ElAlert } from "element-plus";
|
||||
import { useRouter } from "vue-router";
|
||||
import { computed, onMounted, ref } from "vue";
|
||||
import { useAuthStore } from "../store/auth";
|
||||
import { useStudyStore } from "../store/study";
|
||||
import { fetchFinanceSummary, fetchMyTodoTasks, fetchOverdueAesCount, fetchOverdueQueriesCount, fetchProgress } from "../api/dashboard";
|
||||
import { fetchFinanceSummary, fetchOverdueAesCount, fetchOverdueQueriesCount, fetchProgress } from "../api/dashboard";
|
||||
import KpiCard from "../components/KpiCard.vue";
|
||||
import QuickActions from "../components/QuickActions.vue";
|
||||
|
||||
const auth = useAuthStore();
|
||||
const study = useStudyStore();
|
||||
const router = useRouter();
|
||||
|
||||
const progress = ref<any>(null);
|
||||
const financeSummary = ref<any>(null);
|
||||
const todoTasks = ref<any[]>([]);
|
||||
const overdueAes = ref<number>(0);
|
||||
const overdueQueries = ref<number>(0);
|
||||
|
||||
const loading = ref({
|
||||
progress: false,
|
||||
finance: false,
|
||||
tasks: false,
|
||||
overdueAes: false,
|
||||
overdueQueries: false,
|
||||
});
|
||||
|
||||
const errors = ref({
|
||||
progress: "",
|
||||
finance: "",
|
||||
tasks: "",
|
||||
overdueAes: "",
|
||||
overdueQueries: "",
|
||||
const milestoneCompletionRate = computed(() => {
|
||||
const total = progress.value?.milestones_total ?? 0;
|
||||
if (!total) return "-";
|
||||
return formatPercent((progress.value?.milestones_done ?? 0) / total);
|
||||
});
|
||||
|
||||
const milestoneCompletionText = computed(() => {
|
||||
const total = progress.value?.milestones_total ?? 0;
|
||||
const done = progress.value?.milestones_done ?? 0;
|
||||
return total ? `已完成 ${done}/${total}` : "暂无节点数据";
|
||||
});
|
||||
|
||||
const formatPercent = (v?: number | null) => {
|
||||
@@ -90,61 +88,38 @@ const formatPercent = (v?: number | null) => {
|
||||
return `${(v * 100).toFixed(0)}%`;
|
||||
};
|
||||
|
||||
const goTasks = () => {
|
||||
if (study.currentStudy) {
|
||||
router.push("/study/tasks");
|
||||
}
|
||||
};
|
||||
|
||||
const loadData = async () => {
|
||||
const studyId = study.currentStudy?.id;
|
||||
const userId = auth.user?.id;
|
||||
if (!studyId || !userId) return;
|
||||
if (!studyId) return;
|
||||
|
||||
loading.value.progress = true;
|
||||
loading.value.finance = true;
|
||||
loading.value.tasks = true;
|
||||
loading.value.overdueAes = true;
|
||||
loading.value.overdueQueries = true;
|
||||
|
||||
try {
|
||||
const [pRes, fRes, aesRes, dqRes, tasksRes] = await Promise.allSettled([
|
||||
const [pRes, fRes, aesRes, dqRes] = await Promise.allSettled([
|
||||
fetchProgress(studyId),
|
||||
fetchFinanceSummary(studyId),
|
||||
fetchOverdueAesCount(studyId),
|
||||
fetchOverdueQueriesCount(studyId),
|
||||
fetchMyTodoTasks(studyId, userId),
|
||||
]);
|
||||
|
||||
if (pRes.status === "fulfilled") {
|
||||
progress.value = pRes.value.data;
|
||||
} else {
|
||||
errors.value.progress = "进度数据加载失败";
|
||||
}
|
||||
if (fRes.status === "fulfilled") {
|
||||
financeSummary.value = fRes.value.data;
|
||||
} else {
|
||||
errors.value.finance = "费用汇总加载失败";
|
||||
}
|
||||
if (aesRes.status === "fulfilled") {
|
||||
overdueAes.value = aesRes.value.data?.total ?? 0;
|
||||
} else {
|
||||
errors.value.overdueAes = "逾期 AE 加载失败";
|
||||
}
|
||||
if (dqRes.status === "fulfilled") {
|
||||
overdueQueries.value = dqRes.value.data?.total ?? 0;
|
||||
} else {
|
||||
errors.value.overdueQueries = "逾期数据问题加载失败";
|
||||
}
|
||||
if (tasksRes.status === "fulfilled") {
|
||||
todoTasks.value = tasksRes.value.data?.items ?? [];
|
||||
} else {
|
||||
errors.value.tasks = "待办任务加载失败";
|
||||
}
|
||||
} finally {
|
||||
loading.value.progress = false;
|
||||
loading.value.finance = false;
|
||||
loading.value.tasks = false;
|
||||
loading.value.overdueAes = false;
|
||||
loading.value.overdueQueries = false;
|
||||
}
|
||||
|
||||
@@ -1,351 +0,0 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<el-card class="mb-12">
|
||||
<div class="filters">
|
||||
<el-select v-model="filters.status" placeholder="状态" clearable @change="loadTasks">
|
||||
<el-option v-for="opt in statusOptions" :key="opt.value" :label="opt.label" :value="opt.value" />
|
||||
</el-select>
|
||||
<el-select v-model="filters.milestone_id" placeholder="里程碑" clearable @change="loadTasks">
|
||||
<el-option v-for="m in milestones" :key="m.id" :label="m.name" :value="m.id" />
|
||||
</el-select>
|
||||
<el-select
|
||||
v-model="filters.assignee_id"
|
||||
placeholder="负责人"
|
||||
clearable
|
||||
filterable
|
||||
style="width: 200px"
|
||||
@change="loadTasks"
|
||||
>
|
||||
<el-option v-for="opt in assigneeOptions" :key="opt.value" :label="opt.label" :value="opt.value" />
|
||||
</el-select>
|
||||
<div class="spacer" />
|
||||
<PermissionAction action="task.create">
|
||||
<el-button type="primary" @click="openCreate">新建任务</el-button>
|
||||
</PermissionAction>
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
<el-card>
|
||||
<el-table :data="tasks" v-loading="loading" style="width: 100%">
|
||||
<el-table-column prop="title" label="标题" />
|
||||
<el-table-column prop="milestone_id" label="节点/里程碑">
|
||||
<template #default="scope">
|
||||
{{ milestoneName(scope.row.milestone_id) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="assignee_id" label="负责人" width="160">
|
||||
<template #default="scope">
|
||||
{{ assigneeName(scope.row.assignee_id) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="priority" label="优先级" width="100">
|
||||
<template #default="scope">
|
||||
<el-tag :type="priorityColor(scope.row.priority)">{{ priorityLabel(scope.row.priority) }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="status" label="状态" width="120">
|
||||
<template #default="scope">
|
||||
<el-tag :type="statusColor(scope.row.status)">{{ statusLabel(scope.row.status) }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="due_date" label="截止日期" width="140" />
|
||||
<el-table-column label="操作" width="200">
|
||||
<template #default="scope">
|
||||
<PermissionAction action="task.edit">
|
||||
<el-button type="primary" link size="small" @click="openEdit(scope.row)">编辑</el-button>
|
||||
</PermissionAction>
|
||||
<el-button
|
||||
v-if="showComplete(scope.row)"
|
||||
type="success"
|
||||
size="small"
|
||||
@click.stop="onComplete(scope.row)"
|
||||
>
|
||||
完成
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-pagination
|
||||
class="pagination"
|
||||
layout="prev, pager, next"
|
||||
:page-size="pageSize"
|
||||
:current-page="page"
|
||||
:total="total"
|
||||
@current-change="onPageChange"
|
||||
/>
|
||||
</el-card>
|
||||
|
||||
<TaskForm
|
||||
v-model="showForm"
|
||||
:task="editingTask"
|
||||
:milestones="milestones"
|
||||
:members="members"
|
||||
@success="loadTasks"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref, computed } from "vue";
|
||||
import { ElMessage } from "element-plus";
|
||||
import { fetchTasks, updateTask } from "../api/tasks";
|
||||
import { fetchMilestones } from "../api/milestones";
|
||||
import { listMembers } from "../api/members";
|
||||
import { useStudyStore } from "../store/study";
|
||||
import { useAuthStore } from "../store/auth";
|
||||
import PermissionAction from "../components/PermissionAction.vue";
|
||||
import { usePermission } from "../utils/permission";
|
||||
import TaskForm from "../components/TaskForm.vue";
|
||||
import { getDictColor, getDictLabel, getDictOptions, statusDict, priorityDict } from "../dictionaries";
|
||||
import { getAvailableActions, taskMachine } from "../state-machine";
|
||||
import { evaluateAction } from "../guards/actionGuard";
|
||||
import { logAudit } from "../audit";
|
||||
|
||||
const study = useStudyStore();
|
||||
const auth = useAuthStore();
|
||||
|
||||
const tasks = ref<any[]>([]);
|
||||
const milestones = ref<any[]>([]);
|
||||
const members = ref<any[]>([]);
|
||||
const loading = ref(false);
|
||||
const total = ref(0);
|
||||
const page = ref(1);
|
||||
const pageSize = 10;
|
||||
|
||||
const statusOptions = getDictOptions(statusDict).filter((opt) => ["TODO", "DOING", "DONE", "BLOCKED"].includes(opt.value));
|
||||
|
||||
const filters = ref({
|
||||
status: "",
|
||||
milestone_id: "",
|
||||
assignee_id: "",
|
||||
});
|
||||
|
||||
const showForm = ref(false);
|
||||
const editingTask = ref<any | null>(null);
|
||||
|
||||
const { can } = usePermission();
|
||||
const milestoneMap = computed(() =>
|
||||
milestones.value.reduce<Record<string, string>>((acc, cur) => {
|
||||
acc[cur.id] = cur.name || cur.id;
|
||||
return acc;
|
||||
}, {})
|
||||
);
|
||||
const memberMap = computed(() =>
|
||||
members.value.reduce<Record<string, string>>((acc, cur) => {
|
||||
const username = cur?.user?.display_name || cur?.user?.username || cur?.username;
|
||||
if (cur?.user_id) acc[cur.user_id] = username || cur.user_id;
|
||||
return acc;
|
||||
}, {})
|
||||
);
|
||||
const assigneeOptions = computed(() => {
|
||||
const seen = new Set<string>();
|
||||
return members.value
|
||||
.filter((m) => m.is_active !== false)
|
||||
.map((m) => {
|
||||
const user = m.user || {};
|
||||
return { value: m.user_id, label: user.display_name || user.username || m.username || "—" };
|
||||
})
|
||||
.filter((opt) => {
|
||||
if (seen.has(opt.value)) return false;
|
||||
seen.add(opt.value);
|
||||
return true;
|
||||
});
|
||||
});
|
||||
|
||||
const loadMilestones = async () => {
|
||||
if (!study.currentStudy) return;
|
||||
try {
|
||||
const { data } = await fetchMilestones(study.currentStudy.id);
|
||||
milestones.value = data.items || data; // 兼容
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.response?.data?.message || "里程碑加载失败");
|
||||
}
|
||||
};
|
||||
|
||||
const loadMembers = async () => {
|
||||
if (!study.currentStudy) return;
|
||||
try {
|
||||
const { data } = await listMembers(study.currentStudy.id, { limit: 500 });
|
||||
members.value = Array.isArray(data) ? data : data.items || [];
|
||||
} catch {
|
||||
members.value = [];
|
||||
}
|
||||
};
|
||||
|
||||
const loadTasks = async () => {
|
||||
if (!study.currentStudy) return;
|
||||
loading.value = true;
|
||||
try {
|
||||
const params: Record<string, any> = {
|
||||
skip: (page.value - 1) * pageSize,
|
||||
limit: pageSize,
|
||||
};
|
||||
if (filters.value.status) params.status = filters.value.status;
|
||||
if (filters.value.milestone_id) params.milestone_id = filters.value.milestone_id;
|
||||
if (filters.value.assignee_id) params.assignee_id = filters.value.assignee_id;
|
||||
|
||||
const { data } = await fetchTasks(study.currentStudy.id, params);
|
||||
if (Array.isArray(data)) {
|
||||
tasks.value = data;
|
||||
total.value = data.length;
|
||||
} else {
|
||||
tasks.value = data.items || [];
|
||||
total.value = data.total || tasks.value.length;
|
||||
}
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.response?.data?.message || "任务加载失败");
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const onPageChange = (p: number) => {
|
||||
page.value = p;
|
||||
loadTasks();
|
||||
};
|
||||
|
||||
const openCreate = () => {
|
||||
editingTask.value = null;
|
||||
showForm.value = true;
|
||||
};
|
||||
|
||||
const openEdit = (row: any) => {
|
||||
editingTask.value = row;
|
||||
showForm.value = true;
|
||||
};
|
||||
|
||||
const ensureUser = async () => {
|
||||
if (!auth.user && auth.token) {
|
||||
try {
|
||||
await auth.fetchMe();
|
||||
} catch {
|
||||
// ignore, canEdit 将保持 false
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const filterKey = computed(() => (study.currentStudy ? `tasks_filter_${study.currentStudy.id}` : null));
|
||||
const saveFilters = () => {
|
||||
if (!filterKey.value) return;
|
||||
localStorage.setItem(filterKey.value, JSON.stringify({ ...filters.value, page: page.value }));
|
||||
};
|
||||
const loadSavedFilters = () => {
|
||||
if (!filterKey.value) return;
|
||||
const raw = localStorage.getItem(filterKey.value);
|
||||
if (raw) {
|
||||
try {
|
||||
const parsed = JSON.parse(raw);
|
||||
filters.value.status = parsed.status || "";
|
||||
filters.value.milestone_id = parsed.milestone_id || "";
|
||||
filters.value.assignee_id = parsed.assignee_id || "";
|
||||
page.value = parsed.page || 1;
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const statusLabel = (v: string) => getDictLabel(statusDict, v);
|
||||
const statusColor = (v: string) => getDictColor(statusDict, v) || "info";
|
||||
const priorityLabel = (v: string) => getDictLabel(priorityDict, v);
|
||||
const priorityColor = (v: string) => getDictColor(priorityDict, v) || "info";
|
||||
|
||||
const milestoneName = (id: string) => milestoneMap.value[id] || id || "-";
|
||||
const assigneeName = (id: string) => {
|
||||
const fromPayload = tasks.value.find((t) => t.assignee_id === id)?.assignee;
|
||||
return (
|
||||
fromPayload?.display_name ||
|
||||
fromPayload?.username ||
|
||||
memberMap.value[id] ||
|
||||
id ||
|
||||
"-"
|
||||
);
|
||||
};
|
||||
|
||||
const showComplete = (row: any) => {
|
||||
const actions = getAvailableActions(taskMachine, row.status);
|
||||
const hasComplete = actions.some((a) => a.key === "complete");
|
||||
if (!hasComplete) return false;
|
||||
const decision = evaluateAction({
|
||||
actorRole: auth.user?.role || null,
|
||||
requiredPermission: "task.edit",
|
||||
stateMachine: taskMachine,
|
||||
currentState: row.status,
|
||||
actionKey: "complete",
|
||||
});
|
||||
return decision.allowed;
|
||||
};
|
||||
|
||||
const onComplete = async (row: any) => {
|
||||
if (!study.currentStudy) return;
|
||||
const action = getAvailableActions(taskMachine, row.status).find((a) => a.key === "complete");
|
||||
const decision = evaluateAction({
|
||||
actorRole: auth.user?.role || null,
|
||||
requiredPermission: "task.edit",
|
||||
stateMachine: taskMachine,
|
||||
currentState: row.status,
|
||||
actionKey: "complete",
|
||||
});
|
||||
if (!decision.allowed) {
|
||||
ElMessage.warning(decision.reason || "当前不可执行该操作");
|
||||
logAudit(decision.auditType, {
|
||||
targetId: row.id,
|
||||
targetName: row.title,
|
||||
reason: decision.reason,
|
||||
severity: decision.severity,
|
||||
});
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await updateTask(study.currentStudy.id, row.id, { status: action?.to || "DONE" });
|
||||
ElMessage.success("已完成");
|
||||
logAudit("TASK_COMPLETE", {
|
||||
targetId: row.id,
|
||||
targetName: row.title,
|
||||
before: { status: row.status },
|
||||
after: { status: action?.to || "DONE" },
|
||||
severity: "normal",
|
||||
});
|
||||
loadTasks();
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.response?.data?.message || "操作失败");
|
||||
logAudit("TASK_COMPLETE", {
|
||||
targetId: row.id,
|
||||
targetName: row.title,
|
||||
before: { status: row.status },
|
||||
after: { status: action?.to || "DONE" },
|
||||
severity: "warning",
|
||||
reason: e?.response?.data?.message,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
await ensureUser();
|
||||
loadSavedFilters();
|
||||
loadMilestones();
|
||||
loadMembers();
|
||||
loadTasks();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.page {
|
||||
padding: 16px;
|
||||
}
|
||||
.filters {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
}
|
||||
.spacer {
|
||||
flex: 1;
|
||||
}
|
||||
.pagination {
|
||||
margin-top: 12px;
|
||||
text-align: right;
|
||||
}
|
||||
.mb-12 {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
</style>
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user