diff --git a/src/api/oa/erp/projectReportDetail/types.ts b/src/api/oa/erp/projectReportDetail/types.ts index 6676748..5ae0a65 100644 --- a/src/api/oa/erp/projectReportDetail/types.ts +++ b/src/api/oa/erp/projectReportDetail/types.ts @@ -1,5 +1,5 @@ import { ProjectReportVO, ProjectReportForm, ProjectReportQuery } from '@/api/oa/erp/projectReport/types'; -export interface ProjectReportDetailVO extends extraInfo { +export interface ProjectReportDetailVO extends BaseEntity, extraInfo { /** * 项目周报明细ID */ diff --git a/src/views/oa/erp/projectReport/edit.vue b/src/views/oa/erp/projectReport/edit.vue index 854c7f2..4f068fc 100644 --- a/src/views/oa/erp/projectReport/edit.vue +++ b/src/views/oa/erp/projectReport/edit.vue @@ -135,144 +135,115 @@ - - - - + +
项目周报具体信息
+
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ + +
- + - + @@ -400,15 +371,18 @@ + @@ -458,9 +432,16 @@ - - - + @@ -738,12 +719,70 @@ const projectReportDetailData = reactive { + if (value === null || value === undefined || value === '') { + callback(); + return; + } + // 转换为数字 + const numValue = Number(value); + // 检查是否为数字 + if (isNaN(numValue)) { + callback(new Error('请输入有效的数字')); + return; + } + // 检查是否在0-1之间 + if (numValue < 0 || numValue > 1) { + callback(new Error('请输入0-1之间的数字')); + return; + } + // 检查小数位数(可选) + const decimalPlaces = value.toString().split('.')[1]; + if (decimalPlaces && decimalPlaces.length > 2) { + callback(new Error('最多支持两位小数')); + return; + } + callback(); + }, + trigger: 'blur' + } + ] + } }); // 解构明细数据 const { form: detailForm, queryParams: detailQueryParams, rules: detailRules } = toRefs(projectReportDetailData); - +// 验证修改对话框中的计划完成率输入 +const validateModifyPlannedCompletionRate = (value: string) => { + if (!value) return; + // 转换为数字 + const numValue = Number(value); + // 如果输入无效或超出范围,重置为有效值 + if (isNaN(numValue)) { + detailForm.value.plannedCompletionRate = 0; + return; + } + // 限制在0-1之间 + if (numValue < 0) { + detailForm.value.plannedCompletionRate = 0; + } else if (numValue > 1) { + detailForm.value.plannedCompletionRate = 1; + } else { + // 限制小数位数(可选) + const decimalPlaces = value.split('.')[1]; + if (decimalPlaces && decimalPlaces.length > 2) { + detailForm.value.plannedCompletionRate = parseFloat(numValue.toFixed(2)); + } + } +}; // OSS功能 const dialog = reactive({ visible: false, @@ -786,7 +825,17 @@ const submitOss = () => { dialog.visible = false; proxy?.$modal.msgSuccess('附件已更新'); }; - +// 监听上传组件返回的文件(ossId 串)并同步到表单字段 +// 同步表单初值到上传模型 +watch( + () => form.value.ossId, + (val) => { + if (!dialog.visible) { + ossFileModel.value = val as any; + projectReportForm.value.ossId = val as any; + } + } +); const ReportDialog = reactive({ visible: false, title: '' @@ -825,13 +874,13 @@ const columns = ref([ { key: 17, label: `合同ID(预留)`, visible: false }, { key: 18, label: `附件ID`, visible: true }, { key: 19, label: `备注`, visible: true }, - { key: 20, label: `激活标识`, visible: false }, - { key: 21, label: `删除标志`, visible: true }, - { key: 22, label: `创建部门`, visible: true }, - { key: 23, label: `创建时间`, visible: true }, - { key: 24, label: `创建人`, visible: true }, - { key: 25, label: `更新人`, visible: true }, - { key: 26, label: `更新时间`, visible: true } + { key: 20, label: `激活标识`, visible: false } + // { key: 21, label: `删除标志`, visible: true }, + // { key: 22, label: `创建部门`, visible: true }, + // { key: 23, label: `创建时间`, visible: true }, + // { key: 24, label: `创建人`, visible: true }, + // { key: 25, label: `更新人`, visible: true }, + // { key: 26, label: `更新时间`, visible: true } ]); // 项目周报明细表单引用 @@ -937,7 +986,7 @@ const validatePlannedCompletionRate = (value: string) => { const numValue = Number(value); // 如果输入无效或超出范围,重置为有效值 if (isNaN(numValue)) { - projectReportForm.value.plannedCompletionRate = ''; + projectReportForm.value.plannedCompletionRate = 0; return; } // 限制在0-1之间 @@ -968,6 +1017,7 @@ const formattedPlannedCompletionRate = computed(() => { /** 表单重置 */ const reset = () => { detailForm.value = { ...initProjectReportDetailFormData }; + modifyDatePart.value = ''; // 重置修改对话框的日期部分 projectReportDetailDialogFormRef.value?.resetFields(); }; /** 修改按钮操作 */ @@ -976,6 +1026,34 @@ const handleUpdate = async (row?: ProjectReportDetailVO) => { const _reportDetailId = row?.reportDetailId || ids.value[0]; const res = await getProjectReportDetail(_reportDetailId); Object.assign(detailForm.value, res.data); + + // 从 fillTime 中提取日期部分,用于日期选择器 + if (detailForm.value.fillTime) { + const [date] = detailForm.value.fillTime.split(' '); + if (date) { + modifyDatePart.value = date; + // 计算工作周 + detailForm.value.currentWorkWeek = getWorkWeek(date); + } + } else { + // 如果没有日期,设置当前日期 + const now = new Date(); + const year = now.getFullYear(); + const month = String(now.getMonth() + 1).padStart(2, '0'); + const day = String(now.getDate()).padStart(2, '0'); + const dateStr = `${year}-${month}-${day}`; + + // 设置当前时间 + const hours = String(now.getHours()).padStart(2, '0'); + const minutes = String(now.getMinutes()).padStart(2, '0'); + const seconds = String(now.getSeconds()).padStart(2, '0'); + const timeStr = `${hours}:${minutes}:${seconds}`; + + modifyDatePart.value = dateStr; + detailForm.value.fillTime = `${dateStr} ${timeStr}`; + detailForm.value.currentWorkWeek = getWorkWeek(dateStr); + } + ReportDialog.visible = true; ReportDialog.title = '修改项目周报明细'; }; @@ -1146,6 +1224,41 @@ watch( { immediate: true } ); +// 添加修改对话框的日期部分变量 +const modifyDatePart = ref(''); +// 处理修改对话框日期变化 +const handleModifyDateChange = (selectedDate) => { + if (selectedDate) { + // 获取当前时间(保持原有时间或使用当前时间) + let timeStr = ''; + if (detailForm.value.fillTime && detailForm.value.fillTime.includes(' ')) { + const [, time] = detailForm.value.fillTime.split(' '); + if (time) { + timeStr = time; + } else { + const now = new Date(); + const hours = String(now.getHours()).padStart(2, '0'); + const minutes = String(now.getMinutes()).padStart(2, '0'); + const seconds = String(now.getSeconds()).padStart(2, '0'); + timeStr = `${hours}:${minutes}:${seconds}`; + } + } else { + const now = new Date(); + const hours = String(now.getHours()).padStart(2, '0'); + const minutes = String(now.getMinutes()).padStart(2, '0'); + const seconds = String(now.getSeconds()).padStart(2, '0'); + timeStr = `${hours}:${minutes}:${seconds}`; + } + // 组合成完整的日期时间字符串 + detailForm.value.fillTime = `${selectedDate} ${timeStr}`; + // 计算工作周 + detailForm.value.currentWorkWeek = getWorkWeek(selectedDate); + } else { + // 如果清空了日期 + detailForm.value.fillTime = ''; + detailForm.value.currentWorkWeek = ''; + } +}; // 审批记录 const handleApprovalRecord = () => { approvalRecordRef.value.init(projectReportForm.value.reportDetailId); @@ -1162,17 +1275,6 @@ const approvalVerifyOpen = async () => { await submitVerifyRef.value.openDialog(routeParams.value.taskId); }; -// 监听上传组件返回的文件(ossId 串)并同步到表单字段 -// 同步表单初值到上传模型 -watch( - () => form.value.ossId, - (val) => { - if (!dialog.visible) { - ossFileModel.value = val as any; - projectReportForm.value.ossId = val as any; - } - } -); const isCodeGenerated = ref(false); // 生成项目周报编号 diff --git a/src/views/oa/erp/projectReport/index.vue b/src/views/oa/erp/projectReport/index.vue index 0a869ac..5688c26 100644 --- a/src/views/oa/erp/projectReport/index.vue +++ b/src/views/oa/erp/projectReport/index.vue @@ -5,13 +5,7 @@ - - - + @@ -107,13 +101,11 @@ - -