1.1.41 项目周报跳转逻辑流程优化

dev
yinq 4 weeks ago
parent 845bdec99d
commit 0416b2a7ee

@ -13,6 +13,14 @@
:mode="false"
/>
</el-card>
<el-alert
v-if="showAddDetailFromMasterBanner"
type="info"
:closable="false"
show-icon
class="mb-2"
title="正在为所选项目周报新增一条明细:上方为项目信息(只读),请在下方填写本周报明细。"
/>
<el-card shadow="never">
<el-form ref="projectFormRef" :model="form" :disabled="true" :rules="rules" label-width="120px">
<el-row :gutter="20">
@ -23,7 +31,7 @@
<el-icon
style="cursor: pointer; margin-right: 4px; font-size: 14px"
@click="openProjectSelect"
v-if="!routeParams.reportData && routeParams.type === 'add'"
v-if="showProjectSearchSuffix"
>
<Search />
</el-icon>
@ -33,7 +41,7 @@
</el-col>
<el-col :span="12">
<el-form-item label="项目编号" prop="projectCode">
<el-input v-model="form.projectCode" placeholder="请输入项目编号" :disabled="routeParams.reportData && routeParams.type === 'add'" />
<el-input v-model="form.projectCode" placeholder="请输入项目编号" :disabled="projectCodeLockedInAddFromList" />
</el-form-item>
</el-col>
<el-col :span="12">
@ -140,7 +148,7 @@
</el-card>
<el-card shadow="never">
<template #header v-if="routeParams.type === 'view' && routeParams.reportData">
<template #header v-if="isMasterWeeklyListView">
<el-row :gutter="10" class="mb8">
<!-- <el-col :span="1.5">
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['oa/erp:projectReportDetail:edit']"
@ -168,7 +176,7 @@
v-loading="loading"
border
:data="projectReportDetailList"
v-if="routeParams.type === 'view' && routeParams.reportData"
v-if="isMasterWeeklyListView"
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="55" align="center" />
@ -231,7 +239,7 @@
</el-table-column>
</el-table>
<pagination
v-show="total > 0 && routeParams.type === 'view' && routeParams.reportData"
v-show="total > 0 && isMasterWeeklyListView"
:total="total"
v-model:page="projectReportFormQuery.pageNum"
v-model:limit="projectReportFormQuery.pageSize"
@ -243,12 +251,7 @@
:disabled="isDetailFormDisabled"
:rules="reportRules"
label-width="120px"
v-if="
routeParams.type === 'add' ||
routeParams.type === 'approval' ||
routeParams.type === 'update' ||
(routeParams.type === 'view' && !routeParams.reportData)
"
v-if="showDetailEditorForm"
>
<el-row :gutter="20">
<el-col :span="12" v-show="false">
@ -607,6 +610,38 @@ const modifiedPageType = computed(() => {
//
const routeParams = ref<Record<string, any>>({});
/** 列表「查看」按周报主表查看多条明细reportId 或旧 reportData */
const isMasterWeeklyListView = computed(() => {
if (routeParams.value.type !== 'view') return false;
if (routeParams.value.reportId != null && String(routeParams.value.reportId) !== '') return true;
return !!routeParams.value.reportData;
});
/** 是否带有主表上下文(带 reportId / 旧 reportData纯新增无 */
const hasMasterReportContextQuery = computed(() => {
if (routeParams.value.reportId != null && String(routeParams.value.reportId) !== '') return true;
return !!routeParams.value.reportData;
});
/** 底部明细编辑表单(主表多行查看时不展示) */
const showDetailEditorForm = computed(() => {
const t = routeParams.value.type;
if (t === 'add' || t === 'approval' || t === 'update') return true;
if (t === 'view' && !isMasterWeeklyListView.value) return true;
return false;
});
const showProjectSearchSuffix = computed(() => routeParams.value.type === 'add' && !hasMasterReportContextQuery.value);
const projectCodeLockedInAddFromList = computed(
() => routeParams.value.type === 'add' && hasMasterReportContextQuery.value
);
/** 从列表「在已有周报下新增明细」进入(显式 addMode避免与纯新增混淆 */
const showAddDetailFromMasterBanner = computed(
() => routeParams.value.type === 'add' && routeParams.value.addMode === 'detail'
);
//
const { project_report_status, project_risk_status } = toRefs<any>(proxy?.useDict('project_report_status', 'project_risk_status'));
@ -1208,9 +1243,11 @@ const isDetailFormDisabled = computed(() => {
return isFormDisabled.value || hasApprovalData.value;
});
// routeParams.type reportData
// /
const shouldCheckApprovalData = computed(() => {
return (routeParams.value.type === 'add' || routeParams.value.type === 'update') && routeParams.value.reportData;
const t = routeParams.value.type;
if (!(t === 'add' || t === 'update')) return false;
return !!(routeParams.value.reportId || routeParams.value.reportData);
});
//
@ -1218,10 +1255,12 @@ const checkApprovalData = async () => {
try {
if (!shouldCheckApprovalData.value) return;
const reportDataStr = routeParams.value.reportData as string;
if (reportDataStr) {
let reportId: string | number | undefined = form.value.reportId ?? routeParams.value.reportId;
const reportDataStr = routeParams.value.reportData as string | undefined;
if (!reportId && reportDataStr) {
const reportData = JSON.parse(decodeURIComponent(reportDataStr));
const reportId = reportData.reportId;
reportId = reportData.reportId;
}
if (reportId) {
// projectReportStatus = '2'
@ -1248,7 +1287,6 @@ const checkApprovalData = async () => {
hasApprovalData.value = false;
}
}
}
} catch (error) {
console.error('检查审批数据失败:', error);
}
@ -1378,23 +1416,22 @@ const submitForm = async (status: string, mode: boolean) => {
}
};
onMounted(async () => {
nextTick(async () => {
//
routeParams.value = route.query;
const reportDataStr = routeParams.value.reportData as string;
await nextTick(async () => {
routeParams.value = { ...route.query };
const type = String(routeParams.value.type || '');
const reportDataStr = routeParams.value.reportData as string | undefined;
const masterReportIdRaw = routeParams.value.reportId;
const masterReportId =
masterReportIdRaw !== undefined && masterReportIdRaw !== null && String(masterReportIdRaw) !== ''
? String(masterReportIdRaw)
: undefined;
const detailBizIdRaw = routeParams.value.id;
const detailBizId =
detailBizIdRaw !== undefined && detailBizIdRaw !== null && String(detailBizIdRaw) !== ''
? String(detailBizIdRaw)
: undefined;
if (reportDataStr && (routeParams.value.type === 'view' || routeParams.value.type === 'add' || routeParams.value.type === 'update')) {
proxy?.$modal.loading('正在加载数据,请稍后...');
const reportData = JSON.parse(decodeURIComponent(reportDataStr));
Object.assign(form.value, reportData);
if (routeParams.value.type === 'add') {
// add
if (shouldCheckApprovalData.value) {
await checkApprovalData();
} else {
Object.assign(projectReportForm.value, reportData);
//
const setFillTimeNow = () => {
const now = new Date();
const year = now.getFullYear();
const month = String(now.getMonth() + 1).padStart(2, '0');
@ -1403,6 +1440,9 @@ onMounted(async () => {
const minutes = String(now.getMinutes()).padStart(2, '0');
const seconds = String(now.getSeconds()).padStart(2, '0');
projectReportForm.value.fillTime = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
};
const clearDraftDetailFields = () => {
projectReportForm.value.informationNote = undefined;
projectReportForm.value.remark = undefined;
projectReportForm.value.ossId = undefined;
@ -1412,62 +1452,147 @@ onMounted(async () => {
projectReportForm.value.createBy = undefined;
projectReportForm.value.updateBy = undefined;
projectReportForm.value.updateTime = undefined;
};
try {
// JSON reportData
if (reportDataStr && (type === 'view' || type === 'add' || type === 'update')) {
proxy?.$modal.loading('正在加载数据,请稍后...');
const reportData = JSON.parse(decodeURIComponent(reportDataStr));
Object.assign(form.value, reportData);
if (type === 'add') {
if (shouldCheckApprovalData.value) {
await checkApprovalData();
} else {
Object.assign(projectReportForm.value, reportData);
setFillTimeNow();
clearDraftDetailFields();
}
} else if (routeParams.value.type === 'view') {
} else if (type === 'view') {
await getProjectDetail();
} else {
const reportId = routeParams.value.id;
const res = await listProjectReportDetail({ pageNum: 1, pageSize: 10, reportId: reportId });
const rid = routeParams.value.id;
const res = await listProjectReportDetail({ pageNum: 1, pageSize: 10, reportId: rid });
if (res.rows && res.rows.length > 0) {
const detailData = res.rows[0];
Object.assign(projectReportForm.value, detailData);
Object.assign(projectReportForm.value, res.rows[0]);
}
// view
if (projectReportForm.value.beginDate && projectReportForm.value.endDate) {
dateRange.value = [projectReportForm.value.beginDate, projectReportForm.value.endDate];
}
}
proxy?.$modal.closeLoading();
} else if (routeParams.value.type === 'add') {
//
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 hours = String(now.getHours()).padStart(2, '0');
const minutes = String(now.getMinutes()).padStart(2, '0');
const seconds = String(now.getSeconds()).padStart(2, '0');
projectReportForm.value.fillTime = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
} else if (routeParams.value.type === 'approval' || routeParams.value.type === 'view' || routeParams.value.type === 'update') {
//
const projectDetailReportId = routeParams.value.id;
if (projectDetailReportId) {
return;
}
// id
if (type === 'approval' && detailBizId) {
proxy?.$modal.loading('正在加载数据,请稍后...');
const reportDetailRes = await getProjectReportDetail(projectDetailReportId);
const reportId = reportDetailRes.data.reportId;
if (reportId && routeParams.value.type === 'view') {
const reportRes = await getProjectReport(reportId);
const reportDetailRes = await getProjectReportDetail(detailBizId);
const rid = reportDetailRes.data.reportId;
if (rid) {
const reportRes = await getProjectReport(rid);
Object.assign(form.value, reportRes.data);
Object.assign(projectReportForm.value, reportDetailRes.data);
}
if (projectReportForm.value.beginDate && projectReportForm.value.endDate) {
dateRange.value = [projectReportForm.value.beginDate, projectReportForm.value.endDate];
}
proxy?.$modal.closeLoading();
return;
}
//
if (type === 'view' && masterReportId) {
proxy?.$modal.loading('正在加载数据,请稍后...');
const reportRes = await getProjectReport(masterReportId);
Object.assign(form.value, reportRes.data);
await getProjectDetail();
proxy?.$modal.closeLoading();
return;
}
// 稿
if (type === 'update' && masterReportId) {
proxy?.$modal.loading('正在加载数据,请稍后...');
const reportRes = await getProjectReport(masterReportId);
Object.assign(form.value, reportRes.data);
const res = await listProjectReportDetail({ pageNum: 1, pageSize: 10, reportId: masterReportId });
if (res.rows && res.rows.length > 0) {
Object.assign(projectReportForm.value, res.rows[0]);
}
if (projectReportForm.value.beginDate && projectReportForm.value.endDate) {
dateRange.value = [projectReportForm.value.beginDate, projectReportForm.value.endDate];
}
proxy?.$modal.closeLoading();
return;
}
//
if (type === 'add' && masterReportId) {
proxy?.$modal.loading('正在加载数据,请稍后...');
const reportRes = await getProjectReport(masterReportId);
Object.assign(form.value, reportRes.data);
if (shouldCheckApprovalData.value) {
await checkApprovalData();
}
if (!hasApprovalData.value) {
projectReportForm.value = { ...initProjectReportFormData };
projectReportForm.value.reportId = form.value.reportId;
projectReportForm.value.projectId = form.value.projectId;
projectReportForm.value.milestonePlan = form.value.milestonePlan;
setFillTimeNow();
clearDraftDetailFields();
dateRange.value = ['', ''] as [DateModelType, DateModelType];
}
proxy?.$modal.closeLoading();
return;
}
//
if (type === 'add') {
setFillTimeNow();
return;
}
// id/
if (type === 'view' && detailBizId && !masterReportId) {
proxy?.$modal.loading('正在加载数据,请稍后...');
const reportDetailRes = await getProjectReportDetail(detailBizId);
const rid = reportDetailRes.data.reportId;
if (rid) {
const reportRes = await getProjectReport(rid);
Object.assign(form.value, reportRes.data);
Object.assign(projectReportForm.value, reportDetailRes.data);
projectReportDetailList.value = [reportDetailRes.data];
}
if (reportId && routeParams.value.type === 'approval') {
const reportRes = await getProjectReport(reportId);
Object.assign(form.value, reportRes.data);
Object.assign(projectReportForm.value, reportDetailRes.data);
}
// view
if (projectReportForm.value.beginDate && projectReportForm.value.endDate) {
dateRange.value = [projectReportForm.value.beginDate, projectReportForm.value.endDate];
}
if (reportId && routeParams.value.type === 'update') {
const reportRes = await getProjectReport(reportId);
proxy?.$modal.closeLoading();
return;
}
// id
if (type === 'update' && detailBizId && !masterReportId) {
proxy?.$modal.loading('正在加载数据,请稍后...');
const reportDetailRes = await getProjectReportDetail(detailBizId);
const rid = reportDetailRes.data.reportId;
if (rid) {
const reportRes = await getProjectReport(rid);
Object.assign(form.value, reportRes.data);
Object.assign(projectReportForm.value, reportDetailRes.data);
}
if (projectReportForm.value.beginDate && projectReportForm.value.endDate) {
dateRange.value = [projectReportForm.value.beginDate, projectReportForm.value.endDate];
}
proxy?.$modal.closeLoading();
}
} catch (e) {
console.error('项目周报编辑页加载失败:', e);
proxy?.$modal.closeLoading();
}
});
});

@ -92,7 +92,7 @@
<template #header>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="Plus" @click="handleAdd(null)" v-hasPermi="['oa/erp:projectReport:add']"></el-button>
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['oa/erp:projectReport:add']"></el-button>
</el-col>
<!-- <el-col :span="1.5">
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['oa/erp:projectReport:edit']"
@ -129,10 +129,20 @@
<el-table-column label="激活标识" align="center" prop="activeFlag" width="100" v-if="columns[13].visible" />
<el-table-column label="创建时间" align="center" prop="createTime" width="100" v-if="columns[14].visible" />
<el-table-column label="更新时间" align="center" prop="updateTime" width="100" v-if="columns[15].visible" />
<el-table-column label="操作" align="center" width="150" fixed="right" class-name="small-padding fixed-width">
<el-table-column label="操作" align="center" width="200" fixed="right" class-name="small-padding fixed-width">
<template #default="scope">
<el-tooltip content="新增已有周报明细" placement="top" v-if="scope.row.status !== '1'">
<el-button link type="primary" icon="Plus" @click="handleAdd(scope.row)" v-hasPermi="['oa/erp:projectReport:add']"></el-button>
<el-tooltip
v-if="scope.row.status !== '1'"
:content="`为「${scope.row.projectName || '该项目'}」新增一条周报明细`"
placement="top"
>
<el-button
link
type="primary"
icon="DocumentAdd"
@click="handleAddWeeklyDetail(scope.row)"
v-hasPermi="['oa/erp:projectReport:add']"
></el-button>
</el-tooltip>
<el-tooltip content="修改" placement="top" v-if="scope.row.status === '1'">
<el-button
@ -548,48 +558,56 @@ const submitForm = () => {
}
});
};
/** 新增按钮操作 */
const handleAdd = (row?: ProjectReportVO) => {
reset();
/** 跳转编辑页(与工时填报一致:仅传必要 query */
function navigateToProjectReportEdit(query: Record<string, string | number | undefined>) {
proxy.$tab.closePage(route);
const routeParams = {
router.push({
path: '/project/projectReport/edit',
query: query as Record<string, any>
});
}
/** 顶部「新增」:空白主表 */
const handleAdd = () => {
reset();
navigateToProjectReportEdit({
type: 'add',
reportData: null
};
if (row && Object.keys(row).length > 0) {
routeParams.reportData = encodeURIComponent(JSON.stringify(row));
}
router.push({
path: '/project/projectReport/edit',
query: routeParams
pageNum: queryParams.value.pageNum
});
};
/** 查看按钮操作 */
/** 行内:在已有周报主表下新增一条明细 */
const handleAddWeeklyDetail = (row: ProjectReportVO) => {
if (row?.reportId == null || row.reportId === '') {
proxy?.$modal.msgWarning('当前行缺少周报主键,无法新增明细');
return;
}
reset();
navigateToProjectReportEdit({
type: 'add',
addMode: 'detail',
reportId: row.reportId,
pageNum: queryParams.value.pageNum
});
};
/** 查看:按周报主键加载 */
const handleView = (row?: ProjectReportVO) => {
if (!row?.reportId) return;
reset();
proxy.$tab.closePage(route);
router.push({
path: '/project/projectReport/edit',
query: {
navigateToProjectReportEdit({
type: 'view',
//
reportData: encodeURIComponent(JSON.stringify(row))
}
reportId: row.reportId,
pageNum: queryParams.value.pageNum
});
};
/** 修改按钮操作 */
/** 修改草稿:按周报主键加载 */
const handleUpdateReport = (row?: ProjectReportVO) => {
if (!row?.reportId) return;
reset();
const _reportId = row?.reportId;
proxy.$tab.closePage(route);
router.push({
path: '/project/projectReport/edit',
query: {
id: _reportId,
navigateToProjectReportEdit({
type: 'update',
// 便使
reportData: encodeURIComponent(JSON.stringify(row))
}
reportId: row.reportId,
pageNum: queryParams.value.pageNum
});
};
/** 修改按钮操作 */

Loading…
Cancel
Save