From 43b37e303b49c3f5a0243527a5e7442c1bf315ff Mon Sep 17 00:00:00 2001 From: yangk Date: Fri, 22 May 2026 09:48:44 +0800 Subject: [PATCH] =?UTF-8?q?feat(timesheetPreAlloc):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=BD=93=E6=9C=88=E5=8F=AF=E7=94=A8=E9=A2=84=E6=8A=95=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E6=9F=A5=E8=AF=A2=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 listAvailableSourceProjects API 接口用于查询指定月份已填报工时的来源预投项目 - 修改月份选择时清空项目选择并重新加载对应的预投项目选项 - 添加 loadSourceProjectOptions 方法用于根据月份代码加载可用的源项目选项 - 更新新增表单时同步加载当前月份的预投项目选项 - 优化项目选项加载逻辑以支持按月份过滤的预投项目显示 --- src/api/oa/erp/timesheetPreAlloc/index.ts | 11 +++++++ src/views/oa/erp/timesheetPreAlloc/index.vue | 30 ++++++++++++++++---- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/src/api/oa/erp/timesheetPreAlloc/index.ts b/src/api/oa/erp/timesheetPreAlloc/index.ts index a6b6fd5..d3a5ac5 100644 --- a/src/api/oa/erp/timesheetPreAlloc/index.ts +++ b/src/api/oa/erp/timesheetPreAlloc/index.ts @@ -38,6 +38,17 @@ export const getStaffAllocDetails = (query: { monthCode: string; projectId: stri }); }; +/** + * 查询当前部门指定月份已填报工时的来源预投项目 + */ +export const listAvailableSourceProjects = (query: { monthCode: string }): AxiosPromise => { + return request({ + url: '/oa/erp/timesheetPreAlloc/listAvailableSourceProjects', + method: 'get', + params: query + }); +}; + /** * 新增预投工时分配 * @param data diff --git a/src/views/oa/erp/timesheetPreAlloc/index.vue b/src/views/oa/erp/timesheetPreAlloc/index.vue index f9e639a..44eb761 100644 --- a/src/views/oa/erp/timesheetPreAlloc/index.vue +++ b/src/views/oa/erp/timesheetPreAlloc/index.vue @@ -25,7 +25,7 @@ @@ -248,7 +248,8 @@ import { delTimesheetPreAlloc, addTimesheetPreAlloc, updateTimesheetPreAlloc, - getStaffAllocDetails + getStaffAllocDetails, + listAvailableSourceProjects } from '@/api/oa/erp/timesheetPreAlloc'; import { TimesheetPreAllocVO, @@ -272,6 +273,7 @@ const { alloc_status } = toRefs(proxy?.useDict('alloc_status')); const timesheetPreAllocList = ref([]); const selectedRows = ref([]); +const querySourceProjectOptions = ref([]); const sourceProjectOptions = ref([]); const targetProjectOptions = ref([]); const buttonLoading = ref(false); @@ -377,9 +379,9 @@ const currentAllocStatus = computed(() => { const hasAppliedSelected = computed(() => selectedRows.value.some((row) => row.appliedFlag === '1')); const loadProjectOptions = async () => { - if (sourceProjectOptions.value.length === 0) { + if (querySourceProjectOptions.value.length === 0) { const sourceRes: any = await getErpProjectInfoList({ projectCategory: '4' }); - sourceProjectOptions.value = (sourceRes.data || []).map(normalizeProject); + querySourceProjectOptions.value = (sourceRes.data || []).map(normalizeProject); } if (targetProjectOptions.value.length === 0) { const [logisticsRes, spareRes]: any[] = await Promise.all([ @@ -393,6 +395,15 @@ const loadProjectOptions = async () => { } }; +const loadSourceProjectOptions = async (monthCode?: string) => { + if (!monthCode) { + sourceProjectOptions.value = []; + return; + } + const res: any = await listAvailableSourceProjects({ monthCode }); + sourceProjectOptions.value = (res.data || []).map(normalizeProject); +}; + const normalizeStaffAlloc = (staff: PreAllocStaffAlloc): PreAllocStaffAlloc => ({ staffUserId: staff.staffUserId, staffName: staff.staffName, @@ -464,6 +475,14 @@ const loadStaffAllocDetails = async () => { } }; +const handleMonthChange = async () => { + form.value.projectId = undefined; + form.value.projectCode = undefined; + form.value.projectName = undefined; + form.value.staffAllocList = []; + await loadSourceProjectOptions(form.value.monthCode); +}; + const getList = async () => { loading.value = true; const params = { @@ -506,6 +525,7 @@ const handleSelectionChange = (selection: TimesheetPreAllocVO[]) => { const handleAdd = async () => { reset(); await loadProjectOptions(); + await loadSourceProjectOptions(form.value.monthCode); dialog.visible = true; dialog.title = '预投工时分配'; };