From 8e2bc84b027ffa705a0fcf28f99125ef8be112fc Mon Sep 17 00:00:00 2001 From: bestlee Date: Thu, 10 Sep 2026 16:10:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E8=B5=B7=E5=8F=98=E6=9B=B4=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E5=92=8C=E6=8F=90=E4=BA=A4=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/service/api/change.ts | 9 +++ src/utils/common.ts | 2 +- src/views/my/initiateChange/index.vue | 74 +++++++++++-------- .../my/initiateChange/modules/changeApply.vue | 1 + .../my/initiateChange/modules/footer.vue | 24 +++++- 5 files changed, 76 insertions(+), 34 deletions(-) diff --git a/src/service/api/change.ts b/src/service/api/change.ts index bc9dcf0..34321a4 100644 --- a/src/service/api/change.ts +++ b/src/service/api/change.ts @@ -35,3 +35,12 @@ export function getChangeDetailApi(id: number) { method: 'get', }); } + +// 使用ai分析-步骤确认/取消 +export function useAiAnalysisApi(id: number, stepId: number, params: {action: string}) { + return request({ + url: `/api/changes/${id}/steps/${stepId}/confirm`, + method: 'post', + data: params + }); +} diff --git a/src/utils/common.ts b/src/utils/common.ts index 1aba4a5..1c0d05b 100644 --- a/src/utils/common.ts +++ b/src/utils/common.ts @@ -77,7 +77,7 @@ export const getColorWithOpacity = (color: string, opacity: number) => { }; // 时间戳转换成年月日时分秒 -export function formatTimestamp(timestamp: number | string,format: string = 'yyyy-MM-dd HH:mm:ss') { +export function formatTimestamp(timestamp: number | string | Date | null,format: string = 'yyyy-MM-dd HH:mm:ss') { if(!timestamp) { return ''; } diff --git a/src/views/my/initiateChange/index.vue b/src/views/my/initiateChange/index.vue index 6d99f35..d95a8ec 100644 --- a/src/views/my/initiateChange/index.vue +++ b/src/views/my/initiateChange/index.vue @@ -10,6 +10,7 @@ import { useChangeStore } from '@/store/modules/change'; import { queryUnsavedApi, saveChangeApi, submitChangeApi, getChangeDetailApi } from '@/service/api/change'; import { systemConfigApi, templateListApi, } from '@/service/api/system'; import { orgListApi } from '@/service/api/user'; +import { formatTimestamp } from "@/utils/common"; import ChangePre from "./modules/changePre.vue"; import ChangeApply from "./modules/changeApply.vue"; import ChangeTraining from "./modules/changeTraining.vue"; @@ -112,9 +113,6 @@ const tabList = computed(() => { const tabChange = (id: string) => { if(tab.value==='pre'){ changePreForm.value = changePreRef.value?.form; - // if(!changePreForm.value?.description){ - // return window.$message?.warning('请先填写变更内容描述'); - // } } if(tab.value==='form'){ changeApplyForm.value = changeApplyRef.value?.form; @@ -126,7 +124,7 @@ const tabChange = (id: string) => { } // 标签内容确认 -const confirmTab = (tab: string, val: boolean) => { +const confirmTab = async (tab: string, val: boolean) => { confirmed.value[tab] = val; } @@ -134,6 +132,12 @@ const confirmTab = (tab: string, val: boolean) => { const getAllFormData = () => { let changePreForm = changePreRef.value?.form; let changeApplyForm = changeApplyRef.value?.form; + let changeApplyData = { + ...changeApplyForm, + plan_use_date:formatTimestamp(changeApplyForm.plan_use_date,'yyyy-MM-dd'), + restore_deadline:formatTimestamp(changeApplyForm.restore_deadline,'yyyy-MM-dd'), + }; + let questions = changeApplyRef.value?.questions; let newQuestions = questions.map(({ question_id, score }:any) => ({ question_id, score })); let changeRiskForm = riskAnalysisRef.value?.riskRecords; @@ -154,7 +158,7 @@ const getAllFormData = () => { return { title: title.value, precheck:{...changePreForm}, - apply_form:{...changeApplyForm,level_score:newQuestions}, + apply_form:{...changeApplyData,level_score:newQuestions}, approval_flow: {steps:flowList}, risk_records:changeRiskForm, train:{...changeTrainingForm}, @@ -179,31 +183,31 @@ const saveDraft = async () => { // 变更申请表表单必填判断 const changeApplyRules = (form:any) => { if(form.org_id === null){ - window.$message?.warning('请选择申请部门'); + window.$message?.warning('请选择申请部门,在「变更申请表」标签页选择'); return true } if(form.main_changes?.length===0){ - window.$message?.warning('请添加主要变更内容'); + window.$message?.warning('请添加主要变更内容,在「变更申请表」标签页添加'); return true } if(form.main_changes.some((str:string)=>str.trim()==='')){ - window.$message?.warning('请填写主要变更内容'); + window.$message?.warning('请填写主要变更内容,在「变更申请表」标签页填写'); return true } if(form.change_type===null){ - window.$message?.warning('请选择变更类型'); + window.$message?.warning('请选择变更类型,在「变更申请表」标签页选择'); return true } if(form.change_level===null){ - window.$message?.warning('请选择变更等级'); + window.$message?.warning('请选择变更等级,在「变更申请表」标签页选择'); return true } if(form.duration_type===null){ - window.$message?.warning('请选择变更时限'); + window.$message?.warning('请选择变更时限,在「变更申请表」标签页选择'); return true } if(form.duration_type === 1 && form.restore_deadline===null){ - window.$message?.warning('请选择计划恢复时间'); + window.$message?.warning('请选择计划恢复时间,在「变更申请表」标签页选择'); return true } return false @@ -211,28 +215,36 @@ 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('全部标签页确认后方可提交(标签栏已用红点标出)'); - } - } + // 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(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==='form'){ + // if(changeApplyRules(form)){ + // return; + // } + // } + // 变更培训内容 - if(type==='train'){ - if(form.train.content.trim() === ''){ - return window.$message?.warning('请填写培训内容'); - } - } + // if(type==='train'){ + // if(form.train.content.trim() === ''){ + // return window.$message?.warning('请填写培训内容,在「变更培训内容」标签页填写'); + // } + // } const {error} = await submitChangeApi(currentId.value, form); if(!error){ window.$message?.success("提交成功"); diff --git a/src/views/my/initiateChange/modules/changeApply.vue b/src/views/my/initiateChange/modules/changeApply.vue index b1d2018..e7c11c8 100644 --- a/src/views/my/initiateChange/modules/changeApply.vue +++ b/src/views/my/initiateChange/modules/changeApply.vue @@ -164,6 +164,7 @@ const questions = ref([ ], }, ]); + // 筛选涉及专业的人员和部门 const filterMembersBySpecialties = (data: any, specialties: string[]) => { const result: any[] = []; diff --git a/src/views/my/initiateChange/modules/footer.vue b/src/views/my/initiateChange/modules/footer.vue index 8f15742..ecc7163 100644 --- a/src/views/my/initiateChange/modules/footer.vue +++ b/src/views/my/initiateChange/modules/footer.vue @@ -4,6 +4,7 @@ import { computed, inject, ref } from 'vue'; import { storeToRefs } from 'pinia'; import { Icon } from '@iconify/vue' import { useChangeStore } from '@/store/modules/change'; +import { useAiAnalysisApi } from '@/service/api/change'; const changeStore = useChangeStore(); const { getStepsInfo, getFlowInfo } = storeToRefs(changeStore); @@ -98,8 +99,27 @@ const setRegenerateLoading = (v: boolean) => { // 确认标签内容 const confirmTab = async () => { - confirmed.value = !confirmed.value; - emit('confirmTab', props.type, confirmed.value); + let stepId = 0; + if(props.type==='form'){ + stepId = 1; + } + if(props.type==='risk'){ + stepId = 2; + } + if(props.type==='train'){ + stepId = 3; + } + if(props.type==='pssr'){ + stepId = 4; + } + if(props.type==='evaluation'){ + stepId = 5; + } + const {error} = await useAiAnalysisApi(props.currentId, stepId, {action: !confirmed.value ? 'CONFIRM' : 'CANCEL'}); + if(!error){ + confirmed.value = !confirmed.value; + emit('confirmTab', props.type, confirmed.value); + } } // 保存 const saveDraft = async () => {