发起变更保存接口统一修改
This commit is contained in:
@@ -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})
|
||||
|
||||
Reference in New Issue
Block a user