发起变更保存和提交完成

This commit is contained in:
2026-09-10 16:10:06 +08:00
parent db8100130a
commit 8e2bc84b02
5 changed files with 76 additions and 34 deletions
+9
View File
@@ -35,3 +35,12 @@ export function getChangeDetailApi(id: number) {
method: 'get', 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
});
}
+1 -1
View File
@@ -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) { if(!timestamp) {
return ''; return '';
} }
+43 -31
View File
@@ -10,6 +10,7 @@ import { useChangeStore } from '@/store/modules/change';
import { queryUnsavedApi, saveChangeApi, submitChangeApi, getChangeDetailApi } from '@/service/api/change'; import { queryUnsavedApi, saveChangeApi, submitChangeApi, getChangeDetailApi } from '@/service/api/change';
import { systemConfigApi, templateListApi, } from '@/service/api/system'; import { systemConfigApi, templateListApi, } from '@/service/api/system';
import { orgListApi } from '@/service/api/user'; import { orgListApi } from '@/service/api/user';
import { formatTimestamp } from "@/utils/common";
import ChangePre from "./modules/changePre.vue"; import ChangePre from "./modules/changePre.vue";
import ChangeApply from "./modules/changeApply.vue"; import ChangeApply from "./modules/changeApply.vue";
import ChangeTraining from "./modules/changeTraining.vue"; import ChangeTraining from "./modules/changeTraining.vue";
@@ -112,9 +113,6 @@ const tabList = computed(() => {
const tabChange = (id: string) => { const tabChange = (id: string) => {
if(tab.value==='pre'){ if(tab.value==='pre'){
changePreForm.value = changePreRef.value?.form; changePreForm.value = changePreRef.value?.form;
// if(!changePreForm.value?.description){
// return window.$message?.warning('请先填写变更内容描述');
// }
} }
if(tab.value==='form'){ if(tab.value==='form'){
changeApplyForm.value = changeApplyRef.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; confirmed.value[tab] = val;
} }
@@ -134,6 +132,12 @@ const confirmTab = (tab: string, val: boolean) => {
const getAllFormData = () => { const getAllFormData = () => {
let changePreForm = changePreRef.value?.form; let changePreForm = changePreRef.value?.form;
let changeApplyForm = changeApplyRef.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 questions = changeApplyRef.value?.questions;
let newQuestions = questions.map(({ question_id, score }:any) => ({ question_id, score })); let newQuestions = questions.map(({ question_id, score }:any) => ({ question_id, score }));
let changeRiskForm = riskAnalysisRef.value?.riskRecords; let changeRiskForm = riskAnalysisRef.value?.riskRecords;
@@ -154,7 +158,7 @@ const getAllFormData = () => {
return { return {
title: title.value, title: title.value,
precheck:{...changePreForm}, precheck:{...changePreForm},
apply_form:{...changeApplyForm,level_score:newQuestions}, apply_form:{...changeApplyData,level_score:newQuestions},
approval_flow: {steps:flowList}, approval_flow: {steps:flowList},
risk_records:changeRiskForm, risk_records:changeRiskForm,
train:{...changeTrainingForm}, train:{...changeTrainingForm},
@@ -179,31 +183,31 @@ const saveDraft = async () => {
// 变更申请表表单必填判断 // 变更申请表表单必填判断
const changeApplyRules = (form:any) => { const changeApplyRules = (form:any) => {
if(form.org_id === null){ if(form.org_id === null){
window.$message?.warning('请选择申请部门'); window.$message?.warning('请选择申请部门,在「变更申请表」标签页选择');
return true return true
} }
if(form.main_changes?.length===0){ if(form.main_changes?.length===0){
window.$message?.warning('请添加主要变更内容'); window.$message?.warning('请添加主要变更内容,在「变更申请表」标签页添加');
return true return true
} }
if(form.main_changes.some((str:string)=>str.trim()==='')){ if(form.main_changes.some((str:string)=>str.trim()==='')){
window.$message?.warning('请填写主要变更内容'); window.$message?.warning('请填写主要变更内容,在「变更申请表」标签页填写');
return true return true
} }
if(form.change_type===null){ if(form.change_type===null){
window.$message?.warning('请选择变更类型'); window.$message?.warning('请选择变更类型,在「变更申请表」标签页选择');
return true return true
} }
if(form.change_level===null){ if(form.change_level===null){
window.$message?.warning('请选择变更等级'); window.$message?.warning('请选择变更等级,在「变更申请表」标签页选择');
return true return true
} }
if(form.duration_type===null){ if(form.duration_type===null){
window.$message?.warning('请选择变更时限'); window.$message?.warning('请选择变更时限,在「变更申请表」标签页选择');
return true return true
} }
if(form.duration_type === 1 && form.restore_deadline===null){ if(form.duration_type === 1 && form.restore_deadline===null){
window.$message?.warning('请选择计划恢复时间'); window.$message?.warning('请选择计划恢复时间,在「变更申请表」标签页选择');
return true return true
} }
return false return false
@@ -211,28 +215,36 @@ const changeApplyRules = (form:any) => {
// 提交 // 提交
const submitConfirm = async (type: string) => { const submitConfirm = async (type: string) => {
if(aiEnabled.value){ // if(aiEnabled.value){
const allTrue = Object.values(confirmed.value).every(value => value === true); // const allTrue = Object.values(confirmed.value).every(value => value === true);
if(!allTrue){ // if(!allTrue){
return window.$message?.warning('全部标签页确认后方可提交(标签栏已用红点标出)'); // return window.$message?.warning('全部标签页确认后方可提交(标签栏已用红点标出)');
} // }
} // }
let form = getAllFormData(); let form = getAllFormData();
if(form.title.trim() === ''){ // if(form.title.trim() === ''){
return window.$message?.warning('请填写变更名称'); // return window.$message?.warning('请填写变更名称');
} // }
// if(aiEnabled.value){
// if(!changePreForm.value?.description){
// return window.$message?.warning('请填写变更内容描述,在「变更预识别」标签页填写');
// }
// }
// 变更申请表 // 变更申请表
if(type==='form'){ // if(type==='form'){
if(changeApplyRules(form)){ // if(changeApplyRules(form)){
return; // return;
} // }
} // }
// 变更培训内容 // 变更培训内容
if(type==='train'){ // if(type==='train'){
if(form.train.content.trim() === ''){ // if(form.train.content.trim() === ''){
return window.$message?.warning('请填写培训内容'); // return window.$message?.warning('请填写培训内容,在「变更培训内容」标签页填写');
} // }
} // }
const {error} = await submitChangeApi(currentId.value, form); const {error} = await submitChangeApi(currentId.value, form);
if(!error){ if(!error){
window.$message?.success("提交成功"); window.$message?.success("提交成功");
@@ -164,6 +164,7 @@ const questions = ref<any>([
], ],
}, },
]); ]);
// 筛选涉及专业的人员和部门 // 筛选涉及专业的人员和部门
const filterMembersBySpecialties = (data: any, specialties: string[]) => { const filterMembersBySpecialties = (data: any, specialties: string[]) => {
const result: any[] = []; const result: any[] = [];
+22 -2
View File
@@ -4,6 +4,7 @@ import { computed, inject, ref } from 'vue';
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
import { Icon } from '@iconify/vue' import { Icon } from '@iconify/vue'
import { useChangeStore } from '@/store/modules/change'; import { useChangeStore } from '@/store/modules/change';
import { useAiAnalysisApi } from '@/service/api/change';
const changeStore = useChangeStore(); const changeStore = useChangeStore();
const { getStepsInfo, getFlowInfo } = storeToRefs(changeStore); const { getStepsInfo, getFlowInfo } = storeToRefs(changeStore);
@@ -98,8 +99,27 @@ const setRegenerateLoading = (v: boolean) => {
// 确认标签内容 // 确认标签内容
const confirmTab = async () => { const confirmTab = async () => {
confirmed.value = !confirmed.value; let stepId = 0;
emit('confirmTab', props.type, confirmed.value); 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 () => { const saveDraft = async () => {