|
@@ -2,7 +2,7 @@
|
|
import { onMounted, ref } from 'vue';
|
|
import { onMounted, ref } from 'vue';
|
|
import { message } from 'ant-design-vue';
|
|
import { message } from 'ant-design-vue';
|
|
|
|
|
|
-import { uploadUserProtocol } from '@/api';
|
|
|
|
|
|
+import { reUploadUserProtocol, uploadUserProtocol } from '@/api';
|
|
import { waitTime } from '@/utils';
|
|
import { waitTime } from '@/utils';
|
|
|
|
|
|
import type { SetupProtocolForm, UseGuideStepItemProps } from '@/types';
|
|
import type { SetupProtocolForm, UseGuideStepItemProps } from '@/types';
|
|
@@ -18,10 +18,18 @@ onMounted(async () => {
|
|
currentPercent.value = 100;
|
|
currentPercent.value = 100;
|
|
|
|
|
|
try {
|
|
try {
|
|
- const { protocolType, protocolFile } = props.form;
|
|
|
|
|
|
+ const { protocolType, protocolFile, protocolInfo } = props.form;
|
|
const file = protocolFile?.[0].originFileObj;
|
|
const file = protocolFile?.[0].originFileObj;
|
|
- const data = await uploadUserProtocol(protocolType as string, file as File);
|
|
|
|
- Object.assign(props.form.protocolInfo, data);
|
|
|
|
|
|
+ let data;
|
|
|
|
+
|
|
|
|
+ if (protocolInfo.id) {
|
|
|
|
+ // 若协议 id 存在,则此前已经上传过该协议,故调用重新配置的接口以删除旧协议,并上传新协议
|
|
|
|
+ data = await reUploadUserProtocol(protocolType as string, protocolInfo.id, file as File);
|
|
|
|
+ } else {
|
|
|
|
+ data = await uploadUserProtocol(protocolType as string, file as File);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Object.assign(protocolInfo, data);
|
|
props.goToStep(props.stepIndex + 1);
|
|
props.goToStep(props.stepIndex + 1);
|
|
} catch (err) {
|
|
} catch (err) {
|
|
props.goToStep(props.stepIndex - 1);
|
|
props.goToStep(props.stepIndex - 1);
|