diff --git a/src/views/my/initiateChange/index.vue b/src/views/my/initiateChange/index.vue index d95a8ec..0a98135 100644 --- a/src/views/my/initiateChange/index.vue +++ b/src/views/my/initiateChange/index.vue @@ -35,6 +35,13 @@ const changeTrainingRef = ref(null); const pssrRef = ref(null); const evaluationRef = ref(null); const closeConfirmRef = ref(null); +// 表单数据 +const changePreForm = ref(null) +const changeApplyForm = ref(null) +const riskAnalysisForm = ref(null) +const changeTrainingForm = ref(null) +const pssrForm = ref(null) +const evaluationForm = ref(null) // 组织树 const orgTree = ref([]); // 变更类型选项 @@ -54,7 +61,6 @@ const changeNo = ref(''); const currentId = ref(0); // 是否确认 const confirmed = ref<{[key: string]: boolean}>({ - 'pre': false, 'form': false, 'risk': false, 'train': false, @@ -63,9 +69,6 @@ const confirmed = ref<{[key: string]: boolean}>({ // 'close': false, }); -// 变更预分析表单数据 -const changePreForm = ref(null) -const changeApplyForm = ref(null) // 当前申请表所选变更类型的文本编码(供 PSSR 等 AI 接口使用) const applyTypeLabel = computed(() => typeList.value.find((t) => t.value === changeApplyForm.value?.change_type)?.label ?? ''); @@ -95,12 +98,12 @@ const onApplyGenerated = async (res: any) => { // **********************tab切换*********************** const TABS = [ - { id: "pre", name: "变更预识别", icon: 'lucide:sparkles' }, - { id: "form", name: "变更申请表", icon: 'akar-icons:file' }, - { id: "risk", name: "风险分析记录表", icon: 'proicons:alert-triangle' }, - { id: "train", name: "变更培训内容", icon: 'lucide:graduation-cap' }, - { id: "pssr", name: "PSSR 检查内容", icon: 'tabler:clipboard-check' }, - { id: "evaluation", name: "验收评价", icon: 'material-symbols:check-circle-outline' }, + { step: 0, id: "pre", name: "变更预识别", icon: 'lucide:sparkles' }, + { step: 1, id: "form", name: "变更申请表", icon: 'akar-icons:file' }, + { step: 2, id: "risk", name: "风险分析记录表", icon: 'proicons:alert-triangle' }, + { step: 3, id: "train", name: "变更培训内容", icon: 'lucide:graduation-cap' }, + { step: 4, id: "pssr", name: "PSSR 检查内容", icon: 'tabler:clipboard-check' }, + { step: 5,id: "evaluation", name: "验收评价", icon: 'material-symbols:check-circle-outline' }, // { id: "close", name: "变更关闭确认表", icon: 'quill:folder-open' }, ]; // 当前标签 @@ -215,36 +218,28 @@ const changeApplyRules = (form:any) => { // 提交 const submitConfirm = async (type: string) => { - // if(aiEnabled.value){ - // const allTrue = Object.values(confirmed.value).every(value => value === true); - // if(!allTrue){ - // return window.$message?.warning('全部标签页确认后方可提交(标签栏已用红点标出)'); - // } - // } let form = getAllFormData(); - // if(form.title.trim() === ''){ - // return window.$message?.warning('请填写变更名称'); - // } - - // if(aiEnabled.value){ - // if(!changePreForm.value?.description){ - // return window.$message?.warning('请填写变更内容描述,在「变更预识别」标签页填写'); - // } - // } + if(form.title.trim() === ''){ + return window.$message?.warning('请填写变更名称'); + } + if(aiEnabled.value){ + if(!changePreForm.value?.description){ + return window.$message?.warning('请填写变更内容描述,在「变更预识别」标签页填写'); + } + } // 变更申请表 - // if(type==='form'){ - // if(changeApplyRules(form)){ - // return; - // } - // } - - // 变更培训内容 - // if(type==='train'){ - // if(form.train.content.trim() === ''){ - // return window.$message?.warning('请填写培训内容,在「变更培训内容」标签页填写'); - // } - // } + if(type==='form'){ + if(changeApplyRules(form)){ + return; + } + } + if(aiEnabled.value){ + const allTrue = Object.values(confirmed.value).every(value => value === true); + if(!allTrue){ + return window.$message?.warning('全部标签页确认后方可提交(标签栏已用红点标出)'); + } + } const {error} = await submitChangeApi(currentId.value, form); if(!error){ window.$message?.success("提交成功"); @@ -255,7 +250,25 @@ const submitConfirm = async (type: string) => { const getChangeDetail = async () => { const {data,error} = await getChangeDetailApi(currentId.value); if(!error){ - + title.value = data.title; + changeNo.value = data.change_no; + changePreForm.value = data.precheck; + changeApplyForm.value = data.apply_form; + riskAnalysisForm.value = data.risk_records; + changeTrainingForm.value = data.train; + pssrForm.value = data.pssr; + evaluationForm.value = data.accept_form; + + // 解析每个步骤是否完成 + // 构建 step_no -> status 的映射 + const statusMap = new Map(data?.steps?.map((step:any) => [step.step_no, step.status])); + // 生成结果 + const result:any = {}; + TABS.filter(({ id }) => id !== 'pre').forEach(({ step, id }) => { + const status = statusMap.get(step); + result[id] = status === 1; // status 为 1 时 true,其它(含无匹配)为 false + }); + confirmed.value = result; } } // 查询变更未保存数据 @@ -357,7 +370,8 @@ onMounted(() => { @@ -375,6 +389,8 @@ onMounted(() => { :title="title" :currentId="currentId" :formInfo="changePreForm" + :currentForm="changeApplyForm" + :confirmed="confirmed[tab]" @save="saveDraft" @submit="submitConfirm" @confirmTab="confirmTab" @@ -391,6 +407,8 @@ onMounted(() => { :currentId="currentId" :formInfo="changeApplyForm" :preInfo="changePreForm" + :currentForm="riskAnalysisForm" + :confirmed="confirmed[tab]" @save="saveDraft" @submit="submitConfirm" @confirmTab="confirmTab" @@ -405,6 +423,8 @@ onMounted(() => { :title="title" :currentId="currentId" :formInfo="changePreForm" + :currentForm="changeTrainingForm" + :confirmed="confirmed[tab]" @save="saveDraft" @submit="submitConfirm" @confirmTab="confirmTab" @@ -420,6 +440,8 @@ onMounted(() => { :currentId="currentId" :formInfo="changePreForm" :changeType="applyTypeLabel" + :currentForm="pssrForm" + :confirmed="confirmed[tab]" @save="saveDraft" @submit="submitConfirm" @confirmTab="confirmTab" @@ -435,6 +457,8 @@ onMounted(() => { :title="title" :currentId="currentId" :formInfo="changeApplyForm" + :currentForm="evaluationForm" + :confirmed="confirmed[tab]" @save="saveDraft" @submit="submitConfirm" @confirmTab="confirmTab" diff --git a/src/views/my/initiateChange/modules/changeApply.vue b/src/views/my/initiateChange/modules/changeApply.vue index e7c11c8..59ea8cc 100644 --- a/src/views/my/initiateChange/modules/changeApply.vue +++ b/src/views/my/initiateChange/modules/changeApply.vue @@ -1,6 +1,6 @@