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

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 -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