发起变更保存接口统一修改

This commit is contained in:
2026-09-04 14:20:59 +08:00
parent 7d05236399
commit 8706ec4b92
6 changed files with 221 additions and 195 deletions
@@ -12,8 +12,8 @@ import { AiError, aiTypeJudge, aiLevelScore } from "@/service/api/ai";
const themeStore = useThemeStore();
const changeStore = useChangeStore();
const props = defineProps(['orgTree','templateList','typeList','levelList','isAiOpen','title','currentId','formInfo'])
const emit = defineEmits(['confirmTab']);
const props = defineProps(['type','orgTree','templateList','typeList','levelList','isAiOpen','title','currentId','formInfo'])
const emit = defineEmits(['save','submit','confirmTab']);
const aiFail = (e: any) => {
if (e instanceof AiError) window.$message?.warning(`AI 分析失败:${e.message},可手动填写`);
@@ -158,6 +158,7 @@ const filterMembersBySpecialties = (data: any, specialties: string[]) => {
});
return result;
}
// 当前模板
const currentTemplate = computed(() => {
let template = props.templateList.find((item: any) =>
@@ -278,6 +279,19 @@ const renderSwitcherIcon = (node:any) => {
});
}
// 保存草稿
const saveDraft = () => {
emit('save');
}
// 提交
const submitConfirm = () => {
emit('submit', props.type);
}
// // 确认标签内容
const confirmTab = (tab:string, val:boolean) => {
emit('confirmTab', tab, val);
}
defineExpose({form})
</script>
@@ -522,11 +536,14 @@ defineExpose({form})
</div>
<Footer
ref="footerRef"
type="form"
:type="props.type"
:currentId="props.currentId"
:title="props.title"
:isAiOpen="props.isAiOpen"
:currentForm="form"
@save="saveDraft"
@submit="submitConfirm"
@confirmTab="confirmTab"
/>
<!-- 侧边抽屉AI 类型判定 / 等级判定表 -->
<NDrawer :show="sheet !== ''" @update:show="(v) => !v && (sheet = '')" placement="right" :width="sheet === 'level' ? '45rem' : '28rem'">
@@ -1,16 +1,16 @@
<!-- 变更预识别 -->
<script setup lang="ts">
import { ref } from 'vue';
import { inject, ref } from 'vue';
import { Icon } from '@iconify/vue'
import { useThemeStore } from '@/store/modules/theme';
import { AiError, aiRecognize, aiRiskPreAnalysis } from "@/service/api/ai";
import { precheckSaveApi } from "@/service/api/change";
import ChangeCompareTable from "./ChangeCompareTable.vue";
const themeStore = useThemeStore();
const props = defineProps(['title','currentId'])
const emit = defineEmits(['save'])
const generalLoading = inject('generalLoading', {saveLoading: ref<boolean>(false),btnDisabled: ref<boolean>(false)})
const {saveLoading,btnDisabled} = generalLoading
const aiFail = (e: any) => {
if (e instanceof AiError) window.$message?.warning(`AI 分析失败:${e.message},可手动填写`);
@@ -22,16 +22,12 @@ const isAiGenerated = ref<boolean>(false);
const preLoading = ref<boolean>(false);
// 生成变更申请单loading
const generateLoading = ref<boolean>(false);
// 保存loading
const saveLoading = ref<boolean>(false);
// 风险预分析loading
const analyzing = ref<boolean>(false);
// 编辑风险预分析
const preRiskEdit = ref<string>('');
// 是否显示险预分析
const preRiskShow = ref<boolean>(false);
// 按钮禁用
const btnDisabled = ref<boolean>(false);
// 表单
const form = ref<{
description: string,
@@ -134,30 +130,8 @@ const genForm = async () => {
};
// 保存草稿
const saveDraft = async () => {
// 变更预识别
if(props.title?.trim()===''){
return window.$message?.warning('请填写变更名称');
}
if(form.value.description?.trim() === ''){
return window.$message?.warning('请填写变更内容描述');
}
saveLoading.value = true;
btnDisabled.value = true;
const {error} = await precheckSaveApi({
change_id: props.currentId,
title: props.title,
description: form.value.description,
severity: form.value.severity,
probability: form.value.probability,
protection: form.value.protection,
compare_rows: form.value.compare_rows,
})
if(!error){
window.$message?.success("已保存为草稿,可在左侧「我的草稿」中继续编辑");
}
saveLoading.value = false;
btnDisabled.value = false;
const saveDraft = () => {
emit('save');
}
defineExpose({form})
@@ -7,13 +7,28 @@ import Footer from './footer.vue';
const themeStore = useThemeStore();
const props = defineProps(['isAiOpen','title','currentId'])
const emit = defineEmits(['confirmTab']);
const props = defineProps(['type','isAiOpen','title','currentId'])
const emit = defineEmits(['save','submit','confirmTab']);
// 是否是ai生成
const isAiGenerated = ref<boolean>(false);
const form = ref<{ content: string }>({
content: ''
});
// 保存草稿
const saveDraft = () => {
emit('save');
}
// 提交
const submitConfirm = () => {
emit('submit', props.type);
}
// // 确认标签内容
const confirmTab = (tab:string, val:boolean) => {
emit('confirmTab', tab, val);
}
defineExpose({form})
</script>
<template>
@@ -41,11 +56,14 @@ const form = ref<{ content: string }>({
</div>
</div>
<Footer
type="train"
ref="footerRef"
:type="props.type"
:currentId="props.currentId"
:title="props.title"
:isAiOpen="props.isAiOpen"
:currentForm="form"
@save="saveDraft"
@submit="submitConfirm"
@confirmTab="confirmTab"
/>
</template>
<style scoped lang="scss">
+12 -71
View File
@@ -1,10 +1,9 @@
<!-- 通用底部操作 -->
<script setup lang="ts">
import { computed, reactive, ref } from 'vue';
import { computed, inject, ref } from 'vue';
import { storeToRefs } from 'pinia';
import { Icon } from '@iconify/vue'
import { useChangeStore } from '@/store/modules/change';
import { applicationSaveApi, trainingSaveApi } from '@/service/api/change';
const changeStore = useChangeStore();
const { getStepsInfo, getFlowInfo } = storeToRefs(changeStore);
@@ -16,13 +15,14 @@ const props = defineProps([
'isAiOpen',
'currentForm'
])
const emit = defineEmits(['confirmTab']);
const emit = defineEmits(['save','submit','confirmTab']);
const generalLoading = inject('generalLoading', {saveLoading: ref<boolean>(false),btnDisabled: ref<boolean>(false)})
const {saveLoading,btnDisabled} = generalLoading
const approvalDrawerShow = ref<boolean>(false);
const btnDisabled = ref<boolean>(false);
const downloadLoading = ref<boolean>(false);
const regenerateLoading = ref<boolean>(false);
const saveLoading = ref<boolean>(false);
const submitLoading = ref<boolean>(false);
const confirmed = ref<boolean>(false);
@@ -91,78 +91,19 @@ const download = async () => {
const regenerate = async () => {
}
// 确认标签内容完毕
// 确认标签内容
const confirmTab = async () => {
}
// 变更申请表表单必填判断
const changeApplyRules = () => {
let form = props.currentForm;
if(form.org_id === null){
window.$message?.warning('请选择申请部门');
return true
}
if(form.main_changes?.length===0){
window.$message?.warning('请添加主要变更内容');
return true
}
if(form.main_changes.some((str:string)=>str.trim()==='')){
window.$message?.warning('请填写主要变更内容');
return true
}
if(form.change_type===null){
window.$message?.warning('请选择变更类型');
return true
}
if(form.change_level===null){
window.$message?.warning('请选择变更等级');
return true
}
if(form.duration_type===null){
window.$message?.warning('请选择变更时限');
return true
}
if(form.duration_type === 1 && form.restore_deadline===null){
window.$message?.warning('请选择计划恢复时间');
return true
}
return false
confirmed.value = !confirmed.value;
emit('confirmTab', props.type, confirmed.value);
}
// 保存
const saveDraft = async () => {
if(props.type==='form'){
if(changeApplyRules()){
return
}
}
if(props.type==='train'){
if(props.currentForm.content.trim() === ''){
return window.$message?.warning(`请输入变更培训内容`);
}
}
saveLoading.value = true;
btnDisabled.value = true;
// 保存变更申请表
if(props.type==='form'){
const {error} = await applicationSaveApi(props.currentId, props.currentForm);
if(!error){
window.$message?.success("已保存为草稿,可在左侧「我的草稿」中继续编辑");
}
}
// 保存变更培训内容
if(props.type==='train'){
const {error} = await trainingSaveApi(props.currentId, {content: props.currentForm.content});
if(!error){
window.$message?.success(`变更培训内容已保存`);
}
}
saveLoading.value = false;
btnDisabled.value = false;
emit('save');
}
// 提交
const submitApply = async () => {
const submitApply = () => {
emit('submit');
}
// 更新选中审批人 user_id