|
@@ -0,0 +1,70 @@
|
|
|
+<script setup lang="ts">
|
|
|
+import { useTemplateRef } from 'vue';
|
|
|
+import { message } from 'ant-design-vue';
|
|
|
+
|
|
|
+import { useRequest } from '@/hooks/request';
|
|
|
+import { t } from '@/i18n';
|
|
|
+import { addProtocolBaseInfo, completeProtocolConfig, downloadUserProtocol, updateProtocolBaseInfo } from '@/api';
|
|
|
+import { downloadBlob } from '@/utils';
|
|
|
+
|
|
|
+import ProtocolContent from './ProtocolContent.vue';
|
|
|
+
|
|
|
+import type { SetupProtocolForm, UseGuideStepItemExpose, UseGuideStepItemProps } from '@/types';
|
|
|
+
|
|
|
+const props = defineProps<UseGuideStepItemProps<SetupProtocolForm>>();
|
|
|
+
|
|
|
+const { handleRequest } = useRequest();
|
|
|
+const fileName = '';
|
|
|
+
|
|
|
+const exportData = () => {
|
|
|
+ handleRequest(async () => {
|
|
|
+ const { id } = props.form.protocolInfo;
|
|
|
+ if (id) {
|
|
|
+ const file = await downloadUserProtocol(id);
|
|
|
+ downloadBlob(file, fileName);
|
|
|
+ message.success(t('setupProtocol.downloadProtocolSuccessful', { name: fileName }));
|
|
|
+ }
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
+const protocolContentRef = useTemplateRef('protocolContent');
|
|
|
+
|
|
|
+const finish = async () => {
|
|
|
+ await protocolContentRef.value?.validateProtocolInfo();
|
|
|
+
|
|
|
+ if (props.form.protocolInfo.id) {
|
|
|
+ await updateProtocolBaseInfo(props.form.protocolInfo);
|
|
|
+ } else {
|
|
|
+ await addProtocolBaseInfo(props.form.protocolInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ await completeProtocolConfig(props.form.protocolInfo.id as number);
|
|
|
+};
|
|
|
+
|
|
|
+defineExpose<UseGuideStepItemExpose>({
|
|
|
+ exportData,
|
|
|
+ finish,
|
|
|
+});
|
|
|
+</script>
|
|
|
+
|
|
|
+<template>
|
|
|
+ <div>
|
|
|
+ <div class="result-header">
|
|
|
+ <div class="use-guide-title">{{ $t('setupProtocol.createProtocol') }}</div>
|
|
|
+ </div>
|
|
|
+ <ProtocolContent class="result-protocol" ref="protocolContent" :info="form.protocolInfo" />
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+.result-header {
|
|
|
+ display: flex;
|
|
|
+ justify-content: space-between;
|
|
|
+ width: calc(62% + 17px);
|
|
|
+ margin-bottom: 36px;
|
|
|
+}
|
|
|
+
|
|
|
+.result-protocol {
|
|
|
+ margin: 0 17px;
|
|
|
+}
|
|
|
+</style>
|