发起变更保存和提交完成
This commit is contained in:
@@ -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
|
||||
});
|
||||
}
|
||||
|
||||
+1
-1
@@ -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 '';
|
||||
}
|
||||
|
||||
@@ -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("提交成功");
|
||||
|
||||
@@ -164,6 +164,7 @@ const questions = ref<any>([
|
||||
],
|
||||
},
|
||||
]);
|
||||
|
||||
// 筛选涉及专业的人员和部门
|
||||
const filterMembersBySpecialties = (data: any, specialties: string[]) => {
|
||||
const result: any[] = [];
|
||||
|
||||
@@ -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 () => {
|
||||
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 () => {
|
||||
|
||||
Reference in New Issue
Block a user