|
|
|
|
@ -12,6 +12,8 @@
|
|
|
|
|
:pageType="routeParams.type"
|
|
|
|
|
:mode="false"
|
|
|
|
|
/>
|
|
|
|
|
</el-card>
|
|
|
|
|
<el-card shadow="never">
|
|
|
|
|
<el-form
|
|
|
|
|
ref="projectFormRef"
|
|
|
|
|
:model="form"
|
|
|
|
|
@ -23,7 +25,17 @@
|
|
|
|
|
<el-row :gutter="20">
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item label="项目名称" prop="projectName">
|
|
|
|
|
<el-input v-model="form.projectName" placeholder="请输入项目名称" />
|
|
|
|
|
<el-input v-model="form.projectName" placeholder="请输入项目名称" :disabled="routeParams.reportData && routeParams.type === 'add'">
|
|
|
|
|
<template #suffix>
|
|
|
|
|
<el-icon
|
|
|
|
|
style="cursor: pointer; margin-right: 4px; font-size: 14px"
|
|
|
|
|
@click="openProjectSelect"
|
|
|
|
|
v-show="!routeParams.reportData && routeParams.type === 'add'"
|
|
|
|
|
>
|
|
|
|
|
<Search />
|
|
|
|
|
</el-icon>
|
|
|
|
|
</template>
|
|
|
|
|
</el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
@ -38,22 +50,22 @@
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item label="项目经理" prop="managerName">
|
|
|
|
|
<el-input v-model="form.managerName" placeholder="请输入项目经理" />
|
|
|
|
|
<el-input v-model="form.managerName" placeholder="请输入项目经理" :disabled="routeParams.type === 'add'" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item label="部门" prop="deptName">
|
|
|
|
|
<el-input v-model="form.deptName" placeholder="请输入部门" />
|
|
|
|
|
<el-input v-model="form.deptName" placeholder="请输入部门" :disabled="routeParams.type === 'add'" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item label="部门负责人" prop="chargeName">
|
|
|
|
|
<el-input v-model="form.chargeName" placeholder="请输入部门负责人" />
|
|
|
|
|
<el-input v-model="form.chargeName" placeholder="请输入部门负责人" :disabled="routeParams.type === 'add'" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item label="分管副总" prop="deputyName">
|
|
|
|
|
<el-input v-model="form.deputyName" placeholder="请输入分管副总" />
|
|
|
|
|
<el-input v-model="form.deputyName" placeholder="请输入分管副总" :disabled="routeParams.type === 'add'" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
@ -115,6 +127,8 @@
|
|
|
|
|
</el-form>
|
|
|
|
|
</el-card>
|
|
|
|
|
|
|
|
|
|
<ProjectSelect ref="projectSelectRef" :multiple="false" @confirm-call-back="projectInfoSelectCallBack"></ProjectSelect>
|
|
|
|
|
|
|
|
|
|
<!-- 项目周报具体信息管理区域 -->
|
|
|
|
|
<el-card shadow="never" style="margin-top: 20px">
|
|
|
|
|
<template #header>
|
|
|
|
|
@ -124,12 +138,14 @@
|
|
|
|
|
<!-- 项目周报具体信息表格 -->
|
|
|
|
|
<div style="margin-bottom: 16px">
|
|
|
|
|
<el-button
|
|
|
|
|
type="primary"
|
|
|
|
|
icon="Plus"
|
|
|
|
|
v-if="!hasReportDetails && routeParams.type !== 'view' && routeParams.type !== 'approval' && routeParams.type !== 'add'"
|
|
|
|
|
@click="handleAddReport"
|
|
|
|
|
>新增周报
|
|
|
|
|
</el-button>
|
|
|
|
|
type="warning"
|
|
|
|
|
plain
|
|
|
|
|
icon="Download"
|
|
|
|
|
@click="handleExport"
|
|
|
|
|
v-hasPermi="['oa/erp:projectReportDetail:export']"
|
|
|
|
|
v-if="routeParams.type === 'view'"
|
|
|
|
|
>导出</el-button
|
|
|
|
|
>
|
|
|
|
|
</div>
|
|
|
|
|
<el-table v-loading="buttonLoading" border :data="projectReportDetailList" v-if="routeParams.type !== 'add' && routeParams.type !== 'approval'">
|
|
|
|
|
<el-table-column label="项目周报明细ID" align="center" prop="reportDetailId" v-if="columns[0].visible" />
|
|
|
|
|
@ -146,10 +162,18 @@
|
|
|
|
|
<el-table-column label="本周完成工作" align="center" prop="tasksCompleted" v-if="columns[7].visible" />
|
|
|
|
|
<el-table-column label="下周计划" align="center" prop="nextPlan" v-if="columns[8].visible" />
|
|
|
|
|
<el-table-column label="风险及解决措施" align="center" prop="riskResolution" v-if="columns[9].visible" />
|
|
|
|
|
<el-table-column label="项目状态" align="center" prop="scheduleStatus" v-if="columns[12].visible">
|
|
|
|
|
<template #default="scope">
|
|
|
|
|
<dict-tag :options="project_risk_status" :value="scope.row.scheduleStatus" />
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column label="计划完成率" align="center" prop="plannedCompletionRate" v-if="columns[10].visible" />
|
|
|
|
|
<el-table-column label="周报情况说明" align="center" prop="informationNote" v-if="columns[11].visible" />
|
|
|
|
|
<el-table-column label="项目状态" align="center" prop="scheduleStatus" v-if="columns[12].visible" />
|
|
|
|
|
<el-table-column label="周报状态(1暂存 2审批中 3可用)" align="center" prop="projectReportStatus" v-if="columns[13].visible" />
|
|
|
|
|
<el-table-column label="周报状态(1暂存 2审批中 3可用)" align="center" prop="projectReportStatus" v-if="columns[13].visible">
|
|
|
|
|
<template #default="scope">
|
|
|
|
|
<dict-tag :options="project_report_status" :value="scope.row.projectReportStatus" />
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column label="流程状态" align="center" prop="flowStatus" v-if="columns[14].visible" />
|
|
|
|
|
<el-table-column label="排序号" align="center" prop="sortOrder" v-if="columns[15].visible" />
|
|
|
|
|
<el-table-column label="项目阶段(预留)" align="center" prop="projectPhases" v-if="columns[16].visible" />
|
|
|
|
|
@ -186,12 +210,20 @@
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item label="填写日期" prop="fillTime">
|
|
|
|
|
<el-date-picker clearable v-model="projectReportForm.fillTime" type="date" value-format="YYYY-MM-DD" placeholder="请选择填写日期" />
|
|
|
|
|
<el-date-picker
|
|
|
|
|
clearable
|
|
|
|
|
v-model="datePart"
|
|
|
|
|
type="date"
|
|
|
|
|
format="YYYY-MM-DD"
|
|
|
|
|
value-format="YYYY-MM-DD"
|
|
|
|
|
placeholder="请选择填写日期"
|
|
|
|
|
@change="handleDateChange"
|
|
|
|
|
/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item label="所在的工作周" prop="currentWorkWeek">
|
|
|
|
|
<el-input v-model="projectReportForm.currentWorkWeek" placeholder="请输入所在的工作周" clearable @keyup.enter="console.log(1)" />
|
|
|
|
|
<el-input v-model="projectReportForm.currentWorkWeek" placeholder="请输入所在的工作周" clearable />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
@ -235,8 +267,10 @@
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item label="项目阶段" prop="projectPhases">
|
|
|
|
|
<el-input v-model="projectReportForm.projectPhases" placeholder="请输入项目阶段" clearable />
|
|
|
|
|
<el-form-item label="项目状态" prop="scheduleStatus">
|
|
|
|
|
<el-select v-model="projectReportForm.scheduleStatus" placeholder="请选择项目状态" clearable>
|
|
|
|
|
<el-option v-for="dict in project_risk_status" :key="dict.value" :label="dict.label" :value="dict.value" />
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
@ -249,7 +283,7 @@
|
|
|
|
|
<el-input v-model="projectReportForm.ossId" placeholder="请输入附件ID" clearable />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-col :span="12" v-show="false">
|
|
|
|
|
<el-form-item label="激活标识" prop="activeFlag">
|
|
|
|
|
<el-input v-model="projectReportForm.activeFlag" placeholder="请输入激活标识" clearable />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
@ -352,8 +386,6 @@
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup name="ContractInfoEdit" lang="ts">
|
|
|
|
|
import { addContractInfo, contractSubmitAndFlowStart, getContractInfo, updateContractInfo } from '@/api/oa/erp/contractInfo';
|
|
|
|
|
import { ContractInfoForm } from '@/api/oa/erp/contractInfo/types';
|
|
|
|
|
import { ContractMaterialVO, ContractprojectReportForm } from '@/api/oa/erp/contractMaterial/types';
|
|
|
|
|
import { getBaseUnitInfoList } from '@/api/oa/base/unitInfo';
|
|
|
|
|
import { getRuleGenerateCode } from '@/api/system/codeRule';
|
|
|
|
|
@ -385,6 +417,7 @@ import {
|
|
|
|
|
ProjectReportDetailFormEx
|
|
|
|
|
} from '@/api/oa/erp/projectReportDetail/types';
|
|
|
|
|
import { fa } from 'element-plus/es/locale/index.mjs';
|
|
|
|
|
import ProjectSelect from '@/components/ProjectSelect/index.vue';
|
|
|
|
|
|
|
|
|
|
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
|
|
|
|
const route = useRoute();
|
|
|
|
|
@ -392,12 +425,12 @@ const router = useRouter();
|
|
|
|
|
|
|
|
|
|
// 路由参数
|
|
|
|
|
const routeParams = ref<Record<string, any>>({});
|
|
|
|
|
const { contract_category, business_direction, contract_flag, contract_type, contract_status, plan_flag } = toRefs<any>(
|
|
|
|
|
proxy?.useDict('contract_category', 'business_direction', 'contract_flag', 'contract_type', 'contract_status', 'plan_flag')
|
|
|
|
|
);
|
|
|
|
|
const { project_report_status, project_risk_status } = toRefs<any>(proxy?.useDict('project_report_status', 'project_risk_status'));
|
|
|
|
|
|
|
|
|
|
const buttonLoading = ref(false);
|
|
|
|
|
const projectFormRef = ref<ElFormInstance>();
|
|
|
|
|
// 根据项目名称选择项目组件引用
|
|
|
|
|
const projectSelectRef = ref<InstanceType<typeof ProjectSelect>>();
|
|
|
|
|
|
|
|
|
|
// 审批相关组件引用
|
|
|
|
|
const submitVerifyRef = ref<InstanceType<typeof SubmitVerify>>();
|
|
|
|
|
@ -418,6 +451,12 @@ const flowInstanceBizExtBo = ref<Record<string, any>>({});
|
|
|
|
|
const type = ref(0);
|
|
|
|
|
const total = ref(0);
|
|
|
|
|
|
|
|
|
|
// 定义缓存键
|
|
|
|
|
const CACHE_KEYS = {
|
|
|
|
|
PROJECT_REPORT_DRAFT: 'project_report_draft_data',
|
|
|
|
|
PROJECT_REPORT_DETAIL_DRAFT: 'project_report_detail_draft_data'
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 项目周报上半部分
|
|
|
|
|
const initFormData: ProjectReportForm = {
|
|
|
|
|
reportId: undefined,
|
|
|
|
|
@ -482,6 +521,47 @@ const dialog = reactive<DialogOption>({
|
|
|
|
|
title: ''
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const projectReportList = ref<ProjectReportVO[]>([]);
|
|
|
|
|
|
|
|
|
|
// 打开项目选择框
|
|
|
|
|
const openProjectSelect = () => {
|
|
|
|
|
projectSelectRef.value.open();
|
|
|
|
|
};
|
|
|
|
|
/** 查询项目周报信息列表 */
|
|
|
|
|
const getList = async () => {
|
|
|
|
|
// loading.value = true;
|
|
|
|
|
const res = await listProjectReport(queryParams.value);
|
|
|
|
|
projectReportList.value = res.rows;
|
|
|
|
|
total.value = res.total;
|
|
|
|
|
// loading.value = false;
|
|
|
|
|
};
|
|
|
|
|
//根据项目名称回调项目信息
|
|
|
|
|
const projectInfoSelectCallBack = (data: any) => {
|
|
|
|
|
if (data.length > 0) {
|
|
|
|
|
setFromProjectInfo(data);
|
|
|
|
|
getList();
|
|
|
|
|
} else {
|
|
|
|
|
projectFormRef.value?.resetFields();
|
|
|
|
|
proxy?.$modal.msgWarning('请选择项目信息');
|
|
|
|
|
getList();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
// 根据项目信息设置表格内容
|
|
|
|
|
const setFromProjectInfo = (data: any) => {
|
|
|
|
|
const projectInfoList = data;
|
|
|
|
|
form.value.projectId = projectInfoList[0].projectId;
|
|
|
|
|
form.value.projectName = projectInfoList[0].projectName;
|
|
|
|
|
form.value.projectCode = projectInfoList[0].projectCode;
|
|
|
|
|
form.value.managerId = projectInfoList[0].managerId;
|
|
|
|
|
form.value.milestonePlan = projectInfoList[0].milestonePlan;
|
|
|
|
|
form.value.deptId = projectInfoList[0].deptId;
|
|
|
|
|
form.value.chargeId = projectInfoList[0].chargeId;
|
|
|
|
|
form.value.deputyId = projectInfoList[0].deputyId;
|
|
|
|
|
form.value.managerName = projectInfoList[0].managerName;
|
|
|
|
|
form.value.deptName = projectInfoList[0].deptName;
|
|
|
|
|
form.value.chargeName = projectInfoList[0].chargeName;
|
|
|
|
|
form.value.deputyName = projectInfoList[0].deputyName;
|
|
|
|
|
};
|
|
|
|
|
/** 文件按钮操作 */
|
|
|
|
|
const handleFile = () => {
|
|
|
|
|
type.value = 0;
|
|
|
|
|
@ -529,9 +609,9 @@ const hasReportDetails = computed(() => {
|
|
|
|
|
|
|
|
|
|
// 列显隐信息
|
|
|
|
|
const columns = ref<FieldOption[]>([
|
|
|
|
|
{ key: 0, label: `项目周报明细ID`, visible: true },
|
|
|
|
|
{ key: 1, label: `项目周报ID`, visible: true },
|
|
|
|
|
{ key: 2, label: `项目ID`, visible: true },
|
|
|
|
|
{ key: 0, label: `项目周报明细ID`, visible: false },
|
|
|
|
|
{ key: 1, label: `项目周报ID`, visible: false },
|
|
|
|
|
{ key: 2, label: `项目ID`, visible: false },
|
|
|
|
|
{ key: 3, label: `填写日期`, visible: true },
|
|
|
|
|
{ key: 4, label: `所在的工作周`, visible: true },
|
|
|
|
|
{ key: 5, label: `所属里程碑`, visible: true },
|
|
|
|
|
@ -544,12 +624,12 @@ const columns = ref<FieldOption[]>([
|
|
|
|
|
{ key: 12, label: `项目状态`, visible: true },
|
|
|
|
|
{ key: 13, label: `周报状态(1暂存 2审批中 3可用)`, visible: true },
|
|
|
|
|
{ key: 14, label: `流程状态`, visible: true },
|
|
|
|
|
{ key: 15, label: `排序号`, visible: true },
|
|
|
|
|
{ key: 16, label: `项目阶段(预留)`, visible: true },
|
|
|
|
|
{ key: 17, label: `合同ID(预留)`, visible: true },
|
|
|
|
|
{ key: 15, label: `排序号`, visible: false },
|
|
|
|
|
{ key: 16, label: `项目阶段(预留)`, visible: false },
|
|
|
|
|
{ key: 17, label: `合同ID(预留)`, visible: false },
|
|
|
|
|
{ key: 18, label: `附件ID`, visible: true },
|
|
|
|
|
{ key: 19, label: `备注`, visible: true },
|
|
|
|
|
{ key: 20, label: `激活标识`, visible: true },
|
|
|
|
|
{ key: 20, label: `激活标识`, visible: false },
|
|
|
|
|
{ key: 21, label: `删除标志`, visible: true },
|
|
|
|
|
{ key: 22, label: `创建部门`, visible: true },
|
|
|
|
|
{ key: 23, label: `创建时间`, visible: true },
|
|
|
|
|
@ -590,12 +670,36 @@ const initprojectReportFormData: ProjectReportDetailFormEx = {
|
|
|
|
|
} as any;
|
|
|
|
|
|
|
|
|
|
const projectReportForm = ref<ProjectReportDetailFormEx>({ ...initprojectReportFormData });
|
|
|
|
|
const projectReportFormQuery = ref<ProjectReportDetailQuery>({
|
|
|
|
|
pageNum: 1,
|
|
|
|
|
pageSize: 10,
|
|
|
|
|
reportId: undefined,
|
|
|
|
|
projectId: undefined,
|
|
|
|
|
fillTime: undefined,
|
|
|
|
|
currentWorkWeek: undefined,
|
|
|
|
|
milestonePlan: undefined,
|
|
|
|
|
secondaryPhase: undefined,
|
|
|
|
|
tasksCompleted: undefined,
|
|
|
|
|
nextPlan: undefined,
|
|
|
|
|
riskResolution: undefined,
|
|
|
|
|
plannedCompletionRate: undefined,
|
|
|
|
|
informationNote: undefined,
|
|
|
|
|
scheduleStatus: undefined,
|
|
|
|
|
projectReportStatus: undefined,
|
|
|
|
|
flowStatus: undefined,
|
|
|
|
|
sortOrder: undefined,
|
|
|
|
|
projectPhases: undefined,
|
|
|
|
|
contractId: undefined,
|
|
|
|
|
ossId: undefined,
|
|
|
|
|
activeFlag: undefined,
|
|
|
|
|
params: {}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 项目周报明细表单规则验证
|
|
|
|
|
const reportRules = {
|
|
|
|
|
tasksCompleted: [{ required: true, message: '本周完成工作不能为空', trigger: 'blur' }],
|
|
|
|
|
nextPlan: [{ required: true, message: '下周计划不能为空', trigger: 'blur' }],
|
|
|
|
|
riskResolution: [{ required: true, message: '风险及解决措施不能为空', trigger: 'blur' }]
|
|
|
|
|
secondaryPhase: [{ required: true, message: '二级进度阶段不能为空', trigger: 'blur' }]
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 新增周报明细
|
|
|
|
|
@ -634,7 +738,16 @@ const handleDeleteMaterial = async (row: ContractMaterialVO) => {
|
|
|
|
|
console.error('删除合同物料失败:', error);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** 导出按钮操作 */
|
|
|
|
|
const handleExport = () => {
|
|
|
|
|
proxy?.download(
|
|
|
|
|
'oa/erp/projectReportDetail/export',
|
|
|
|
|
{
|
|
|
|
|
...queryParams.value
|
|
|
|
|
},
|
|
|
|
|
`projectReportDetail_${new Date().getTime()}.xlsx`
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
// 重置项目周报添加对话框
|
|
|
|
|
const resetProjectReportForm = () => {
|
|
|
|
|
projectReportForm.value = { ...initprojectReportFormData };
|
|
|
|
|
@ -678,45 +791,125 @@ const submitProjectReportForm = () => {
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
// 添加响应式变量来存储日期部分
|
|
|
|
|
const datePart = ref(''); // 日期部分(YYYY-MM-DD)
|
|
|
|
|
|
|
|
|
|
onMounted(async () => {
|
|
|
|
|
nextTick(async () => {
|
|
|
|
|
// 获取路由参数
|
|
|
|
|
routeParams.value = route.query;
|
|
|
|
|
// 是否为查看或更新
|
|
|
|
|
const reportDataStr = routeParams.value.reportData as string;
|
|
|
|
|
if (reportDataStr && (routeParams.value.type === 'update' || routeParams.value.type === 'view' || routeParams.value.type === 'add')) {
|
|
|
|
|
proxy?.$modal.loading('正在加载数据,请稍后...');
|
|
|
|
|
const reportData = JSON.parse(decodeURIComponent(reportDataStr));
|
|
|
|
|
Object.assign(form.value, reportData);
|
|
|
|
|
Object.assign(projectReportForm.value, reportData);
|
|
|
|
|
// console.log(form.value);
|
|
|
|
|
// console.log(projectReportForm.value);
|
|
|
|
|
proxy?.$modal.closeLoading();
|
|
|
|
|
} else if (routeParams.value.type === 'add') {
|
|
|
|
|
} else if (routeParams.value.type === 'approval' || routeParams.value.type === 'view') {
|
|
|
|
|
// 编辑或审批模式:从接口获取数据
|
|
|
|
|
const projectDetailReportId = routeParams.value.id;
|
|
|
|
|
if (projectDetailReportId) {
|
|
|
|
|
proxy?.$modal.loading('正在加载数据,请稍后...');
|
|
|
|
|
const reportDetailRes = await getProjectReportDetail(projectDetailReportId);
|
|
|
|
|
const reportId = reportDetailRes.data.reportId;
|
|
|
|
|
if (reportId && routeParams.value.type === 'view') {
|
|
|
|
|
const reportRes = await getProjectReport(reportId);
|
|
|
|
|
Object.assign(form.value, reportRes.data);
|
|
|
|
|
Object.assign(projectReportForm.value, reportDetailRes.data);
|
|
|
|
|
projectReportDetailList.value = [reportDetailRes.data];
|
|
|
|
|
// 工作周计算函数 - 包含星期几
|
|
|
|
|
const getWorkWeek = (dateString) => {
|
|
|
|
|
if (!dateString) return '';
|
|
|
|
|
|
|
|
|
|
const date = new Date(dateString);
|
|
|
|
|
if (isNaN(date.getTime())) {
|
|
|
|
|
return '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const year = date.getFullYear();
|
|
|
|
|
const firstDayOfYear = new Date(year, 0, 1);
|
|
|
|
|
|
|
|
|
|
// 使用时间戳计算天数差
|
|
|
|
|
const timeDiff = date.getTime() - firstDayOfYear.getTime();
|
|
|
|
|
const days = Math.floor(timeDiff / (24 * 60 * 60 * 1000)) + 1;
|
|
|
|
|
|
|
|
|
|
// 计算周数
|
|
|
|
|
const firstDayWeek = firstDayOfYear.getDay();
|
|
|
|
|
const isoFirstDayWeek = firstDayWeek === 0 ? 7 : firstDayWeek;
|
|
|
|
|
const weekNumber = Math.ceil((days + isoFirstDayWeek - 1) / 7);
|
|
|
|
|
|
|
|
|
|
// 获取星期几(0-周日,1-周一,...,6-周六)
|
|
|
|
|
const weekday = date.getDay();
|
|
|
|
|
const weekdays = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'];
|
|
|
|
|
|
|
|
|
|
return `${weekdays[weekday]}`;
|
|
|
|
|
};
|
|
|
|
|
// 初始化默认日期
|
|
|
|
|
const initDefaultDate = () => {
|
|
|
|
|
if (routeParams.value.type === 'add') {
|
|
|
|
|
// 尝试从缓存读取数据
|
|
|
|
|
const cachedFormData = proxy?.$cache.local.getJSON(CACHE_KEYS.PROJECT_REPORT_DRAFT);
|
|
|
|
|
const cachedDetailData = proxy?.$cache.local.getJSON(CACHE_KEYS.PROJECT_REPORT_DETAIL_DRAFT);
|
|
|
|
|
|
|
|
|
|
if (cachedFormData) {
|
|
|
|
|
// 恢复表单数据
|
|
|
|
|
Object.assign(form.value, cachedFormData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (cachedDetailData) {
|
|
|
|
|
// 恢复明细数据
|
|
|
|
|
Object.assign(projectReportForm.value, cachedDetailData);
|
|
|
|
|
|
|
|
|
|
// 如果缓存中有fillTime,设置日期部分
|
|
|
|
|
if (projectReportForm.value.fillTime) {
|
|
|
|
|
const [date] = projectReportForm.value.fillTime.split(' ');
|
|
|
|
|
if (date) {
|
|
|
|
|
datePart.value = date;
|
|
|
|
|
// 重新计算工作周
|
|
|
|
|
projectReportForm.value.currentWorkWeek = getWorkWeek(date);
|
|
|
|
|
}
|
|
|
|
|
if (reportId && routeParams.value.type === 'approval') {
|
|
|
|
|
const reportRes = await getProjectReport(reportId);
|
|
|
|
|
Object.assign(form.value, reportRes.data);
|
|
|
|
|
Object.assign(projectReportForm.value, reportDetailRes.data);
|
|
|
|
|
}
|
|
|
|
|
proxy?.$modal.closeLoading();
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// 如果没有缓存数据,设置默认值
|
|
|
|
|
const now = new Date();
|
|
|
|
|
|
|
|
|
|
// 格式化日期为 YYYY-MM-DD
|
|
|
|
|
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}`;
|
|
|
|
|
|
|
|
|
|
// 格式化时间为 HH:mm:ss(用于保存)
|
|
|
|
|
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}`;
|
|
|
|
|
|
|
|
|
|
// 设置日期部分
|
|
|
|
|
datePart.value = dateStr;
|
|
|
|
|
|
|
|
|
|
// 组合成完整的日期时间字符串(带当前时间)
|
|
|
|
|
projectReportForm.value.fillTime = `${dateStr} ${timeStr}`;
|
|
|
|
|
|
|
|
|
|
// 计算工作周
|
|
|
|
|
projectReportForm.value.currentWorkWeek = getWorkWeek(dateStr);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 处理日期变化
|
|
|
|
|
const handleDateChange = (selectedDate) => {
|
|
|
|
|
if (selectedDate) {
|
|
|
|
|
// 获取当前时间(用户提交流程的时间)
|
|
|
|
|
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');
|
|
|
|
|
const timeStr = `${hours}:${minutes}:${seconds}`;
|
|
|
|
|
|
|
|
|
|
// 组合成完整的日期时间字符串(日期为用户选择的,时间为当前时间)
|
|
|
|
|
projectReportForm.value.fillTime = `${selectedDate} ${timeStr}`;
|
|
|
|
|
|
|
|
|
|
// 计算工作周
|
|
|
|
|
projectReportForm.value.currentWorkWeek = getWorkWeek(selectedDate);
|
|
|
|
|
} else {
|
|
|
|
|
// 如果清空了日期
|
|
|
|
|
projectReportForm.value.fillTime = '';
|
|
|
|
|
projectReportForm.value.currentWorkWeek = '';
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 监听 fillTime 变化,当从后端获取数据时设置日期部分
|
|
|
|
|
watch(
|
|
|
|
|
() => projectReportForm.value.fillTime,
|
|
|
|
|
(newValue) => {
|
|
|
|
|
if (newValue && (routeParams.value.type === 'update' || routeParams.value.type === 'view' || routeParams.value.type === 'approval')) {
|
|
|
|
|
// 解析日期时间字符串,只取日期部分
|
|
|
|
|
const [date] = newValue.split(' ');
|
|
|
|
|
if (date) {
|
|
|
|
|
datePart.value = date;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
{ immediate: true }
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// 审批记录
|
|
|
|
|
const handleApprovalRecord = () => {
|
|
|
|
|
@ -746,12 +939,7 @@ watch(
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
const isCodeGenerated = ref(false);
|
|
|
|
|
// 生成更规范的唯一标识
|
|
|
|
|
const generateUniqueId = () => {
|
|
|
|
|
const timestamp = Date.now().toString(36);
|
|
|
|
|
const randomStr = Math.random().toString(36).substr(2, 9);
|
|
|
|
|
return `XMZB-${timestamp}-${randomStr}`;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 生成项目周报编号
|
|
|
|
|
const generateCode = async () => {
|
|
|
|
|
if (isCodeGenerated.value) return; // 如果已经生成过,直接返回
|
|
|
|
|
@ -765,14 +953,122 @@ const generateCode = async () => {
|
|
|
|
|
proxy?.$modal.msgError('生成业务编号失败');
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
// 保存草稿到缓存
|
|
|
|
|
const saveToDraftCache = () => {
|
|
|
|
|
try {
|
|
|
|
|
// 保存主表单数据
|
|
|
|
|
proxy?.$cache.local.setJSON(CACHE_KEYS.PROJECT_REPORT_DRAFT, form.value);
|
|
|
|
|
|
|
|
|
|
// 保存明细表单数据
|
|
|
|
|
proxy?.$cache.local.setJSON(CACHE_KEYS.PROJECT_REPORT_DETAIL_DRAFT, projectReportForm.value);
|
|
|
|
|
|
|
|
|
|
console.log('草稿数据已保存到缓存');
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('保存草稿到缓存失败:', error);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 从缓存加载草稿
|
|
|
|
|
const loadFromDraftCache = () => {
|
|
|
|
|
try {
|
|
|
|
|
const cachedFormData = proxy?.$cache.local.getJSON(CACHE_KEYS.PROJECT_REPORT_DRAFT);
|
|
|
|
|
const cachedDetailData = proxy?.$cache.local.getJSON(CACHE_KEYS.PROJECT_REPORT_DETAIL_DRAFT);
|
|
|
|
|
|
|
|
|
|
if (cachedFormData) {
|
|
|
|
|
Object.assign(form.value, cachedFormData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (cachedDetailData) {
|
|
|
|
|
Object.assign(projectReportForm.value, cachedDetailData);
|
|
|
|
|
|
|
|
|
|
// 恢复日期显示
|
|
|
|
|
if (projectReportForm.value.fillTime) {
|
|
|
|
|
const [date] = projectReportForm.value.fillTime.split(' ');
|
|
|
|
|
if (date) {
|
|
|
|
|
datePart.value = date;
|
|
|
|
|
projectReportForm.value.currentWorkWeek = getWorkWeek(date);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return !!cachedFormData || !!cachedDetailData;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('从缓存加载草稿失败:', error);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 清除草稿缓存
|
|
|
|
|
const clearDraftCache = () => {
|
|
|
|
|
try {
|
|
|
|
|
proxy?.$cache.local.remove(CACHE_KEYS.PROJECT_REPORT_DRAFT);
|
|
|
|
|
proxy?.$cache.local.remove(CACHE_KEYS.PROJECT_REPORT_DETAIL_DRAFT);
|
|
|
|
|
console.log('草稿缓存已清除');
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('清除草稿缓存失败:', error);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 添加缓存操作按钮(可选,用于手动清除缓存)
|
|
|
|
|
const handleClearDraft = () => {
|
|
|
|
|
clearDraftCache();
|
|
|
|
|
proxy?.$modal.msgSuccess('草稿缓存已清除');
|
|
|
|
|
// 重置表单
|
|
|
|
|
projectFormRef.value?.resetFields();
|
|
|
|
|
projectReportDetailFormRef.value?.resetFields();
|
|
|
|
|
datePart.value = '';
|
|
|
|
|
initDefaultDate();
|
|
|
|
|
};
|
|
|
|
|
/** 提交按钮 */
|
|
|
|
|
const submitForm = async (status: string, mode: boolean) => {
|
|
|
|
|
try {
|
|
|
|
|
buttonLoading.value = true;
|
|
|
|
|
|
|
|
|
|
// 验证两个表单
|
|
|
|
|
let formValid = false;
|
|
|
|
|
let detailFormValid = false;
|
|
|
|
|
|
|
|
|
|
// 验证第一个表单
|
|
|
|
|
await new Promise((resolve) => {
|
|
|
|
|
projectFormRef.value?.validate((valid: boolean) => {
|
|
|
|
|
formValid = valid;
|
|
|
|
|
resolve(null);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (!formValid) {
|
|
|
|
|
proxy?.$modal.msgError('请完善项目周报信息');
|
|
|
|
|
// 滚动到第一个错误字段
|
|
|
|
|
const errorFields = document.querySelector('.el-form-item__error');
|
|
|
|
|
if (errorFields) {
|
|
|
|
|
errorFields.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 验证第二个表单
|
|
|
|
|
await new Promise((resolve) => {
|
|
|
|
|
projectReportDetailFormRef.value?.validate((valid: boolean) => {
|
|
|
|
|
detailFormValid = valid;
|
|
|
|
|
resolve(null);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (!detailFormValid) {
|
|
|
|
|
proxy?.$modal.msgError('请完善项目周报明细信息');
|
|
|
|
|
// 滚动到第一个错误字段
|
|
|
|
|
const errorFields = document.querySelector('.el-form-item__error');
|
|
|
|
|
if (errorFields) {
|
|
|
|
|
errorFields.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 设置后端发起和不等于草稿状态 直接走流程发起
|
|
|
|
|
if (status != 'draft') {
|
|
|
|
|
// 后端发起流程模式
|
|
|
|
|
projectReportForm.value.flowCode = FlowCodeEnum.PROJECT_REPRORT_CODE;
|
|
|
|
|
const msg = await generateCode();
|
|
|
|
|
// 流程变量
|
|
|
|
|
projectReportForm.value.variables = {
|
|
|
|
|
projectId: projectReportForm.value.projectId,
|
|
|
|
|
@ -781,7 +1077,7 @@ const submitForm = async (status: string, mode: boolean) => {
|
|
|
|
|
// 流程实例业务扩展字段
|
|
|
|
|
projectReportForm.value.bizExt = {
|
|
|
|
|
businessTitle: '项目周报明细',
|
|
|
|
|
businessCode: generateUniqueId()
|
|
|
|
|
businessCode: msg
|
|
|
|
|
};
|
|
|
|
|
// 直接使用现有的两个表单数据
|
|
|
|
|
const requestData = {
|
|
|
|
|
@ -791,25 +1087,78 @@ const submitForm = async (status: string, mode: boolean) => {
|
|
|
|
|
projectReportForm.value.flowStatus = 'waiting';
|
|
|
|
|
const res = await projectReportSubmitAndFlowStart(requestData);
|
|
|
|
|
projectReportForm.value = { ...projectReportForm.value, ...res.data };
|
|
|
|
|
|
|
|
|
|
// 提交成功后清除缓存
|
|
|
|
|
clearDraftCache();
|
|
|
|
|
|
|
|
|
|
proxy?.$modal.msgSuccess('操作成功');
|
|
|
|
|
proxy?.$tab.closePage();
|
|
|
|
|
router.go(-1);
|
|
|
|
|
} else {
|
|
|
|
|
// 暂存逻辑
|
|
|
|
|
if (status === 'draft') {
|
|
|
|
|
projectReportForm.value.flowStatus = 'draft';
|
|
|
|
|
// 暂存时保存到缓存
|
|
|
|
|
saveToDraftCache();
|
|
|
|
|
}
|
|
|
|
|
// if (form.value.contractId) {
|
|
|
|
|
// await updateContractInfo(form.value).finally(() => (buttonLoading.value = false));
|
|
|
|
|
// } else {
|
|
|
|
|
// await addContractInfo(form.value).finally(() => (buttonLoading.value = false));
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
buttonLoading.value = false;
|
|
|
|
|
proxy?.$modal.msgSuccess('暂存成功');
|
|
|
|
|
proxy?.$tab.closePage();
|
|
|
|
|
router.go(-1);
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('提交失败:', error);
|
|
|
|
|
proxy?.$modal.msgError('提交失败');
|
|
|
|
|
} finally {
|
|
|
|
|
buttonLoading.value = false;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
onMounted(async () => {
|
|
|
|
|
nextTick(async () => {
|
|
|
|
|
// 获取路由参数
|
|
|
|
|
routeParams.value = route.query;
|
|
|
|
|
// 是否为查看或更新
|
|
|
|
|
const reportDataStr = routeParams.value.reportData as string;
|
|
|
|
|
if (reportDataStr && (routeParams.value.type === 'update' || routeParams.value.type === 'view' || routeParams.value.type === 'add')) {
|
|
|
|
|
proxy?.$modal.loading('正在加载数据,请稍后...');
|
|
|
|
|
const reportData = JSON.parse(decodeURIComponent(reportDataStr));
|
|
|
|
|
Object.assign(form.value, reportData);
|
|
|
|
|
if (routeParams.value.type === 'add') {
|
|
|
|
|
Object.assign(projectReportForm.value, reportData);
|
|
|
|
|
projectReportForm.value.informationNote = '';
|
|
|
|
|
} else if (routeParams.value.type === 'view') {
|
|
|
|
|
Object.assign(projectReportFormQuery.value, reportData);
|
|
|
|
|
const res = await listProjectReportDetail(projectReportFormQuery.value);
|
|
|
|
|
console.log()
|
|
|
|
|
projectReportDetailList.value = res.rows;
|
|
|
|
|
console.log(projectReportDetailList.value);
|
|
|
|
|
}
|
|
|
|
|
proxy?.$modal.closeLoading();
|
|
|
|
|
} else if (routeParams.value.type === 'add') {
|
|
|
|
|
// 纯新增模式,初始化默认日期和时间,会检查缓存
|
|
|
|
|
initDefaultDate();
|
|
|
|
|
} else if (routeParams.value.type === 'approval' || routeParams.value.type === 'view') {
|
|
|
|
|
// 编辑或审批模式:从接口获取数据
|
|
|
|
|
const projectDetailReportId = routeParams.value.id;
|
|
|
|
|
if (projectDetailReportId) {
|
|
|
|
|
proxy?.$modal.loading('正在加载数据,请稍后...');
|
|
|
|
|
const reportDetailRes = await getProjectReportDetail(projectDetailReportId);
|
|
|
|
|
const reportId = reportDetailRes.data.reportId;
|
|
|
|
|
if (reportId && routeParams.value.type === 'view') {
|
|
|
|
|
const reportRes = await getProjectReport(reportId);
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
proxy?.$modal.closeLoading();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
</script>
|
|
|
|
|
|