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 = '预投工时分配'; };