RecognitionResult.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <script setup lang="ts">
  2. import { onMounted } from 'vue';
  3. import { message } from 'ant-design-vue';
  4. import { useRequest } from '@/hooks/request';
  5. import { t } from '@/i18n';
  6. import { downloadUserProtocol, getProtocolBaseInfo, updateProtocolBaseInfo } from '@/api';
  7. import { downloadBlob } from '@/utils';
  8. import ProtocolContent from './ProtocolContent.vue';
  9. import type { SetupProtocolForm, UseGuideStepItemExpose, UseGuideStepItemProps } from '@/types';
  10. const props = defineProps<UseGuideStepItemProps<SetupProtocolForm>>();
  11. const { handleRequest } = useRequest();
  12. let protocolName = '';
  13. let protocolType = '';
  14. let fileName = '';
  15. onMounted(() => {
  16. handleRequest(async () => {
  17. const data = await getProtocolBaseInfo(37);
  18. Object.assign(props.form.protocolInfo, data);
  19. protocolName = data.protocolName;
  20. protocolType = data.protocolType;
  21. fileName = `${protocolType} - ${protocolName}.xlsx`;
  22. });
  23. });
  24. const exportData = () => {
  25. handleRequest(async () => {
  26. const file = await downloadUserProtocol(protocolType, protocolName);
  27. downloadBlob(file, fileName);
  28. message.success(t('setupProtocol.downloadProtocolSuccessful', { name: fileName }));
  29. });
  30. };
  31. const finish = async () => {
  32. await updateProtocolBaseInfo(props.form.protocolInfo);
  33. };
  34. defineExpose<UseGuideStepItemExpose>({
  35. exportData,
  36. finish,
  37. });
  38. </script>
  39. <template>
  40. <div>
  41. <div class="result-header">
  42. <div class="use-guide-title">{{ $t('setupProtocol.recognitionResult') }}</div>
  43. <AButton>{{ $t('setupProtocol.reRecognize') }}</AButton>
  44. </div>
  45. <ProtocolContent class="result-protocol" :info="form.protocolInfo" />
  46. </div>
  47. </template>
  48. <style lang="scss" scoped>
  49. .result-header {
  50. display: flex;
  51. justify-content: space-between;
  52. width: calc(62% + 17px);
  53. margin-bottom: 36px;
  54. }
  55. .result-protocol {
  56. margin: 0 17px;
  57. }
  58. </style>