CADModal.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <template>
  2. <BasicModal
  3. v-bind="$attrs"
  4. @register="registerModal"
  5. title="文档管理"
  6. width="900px"
  7. :defaultFullscreen="true"
  8. :showCancelBtn="false"
  9. :showOkBtn="false"
  10. :footer="null"
  11. destroyOnClose
  12. >
  13. <!-- <button @click="mxcadmode = !mxcadmode">Switch Previewer</button> -->
  14. <CADViewer v-if="mxcadmode" :id="fileid" :filename="filename" class="w-100%" :height="800" />
  15. <iframe v-else :src="iframesrc" class="w-100%" :height="800" ref="frameRef"></iframe>
  16. </BasicModal>
  17. </template>
  18. <script lang="ts" setup>
  19. import { ref } from 'vue';
  20. import { BasicModal, useModalInner } from '/@/components/Modal';
  21. import { onMounted } from 'vue';
  22. import CADViewer from '/@/views/vent/performance/fileDetail/commen/CADViewer.vue';
  23. import { useGlobSetting } from '/@/hooks/setting';
  24. import { AUTO_LOGIN_URL_QUERY } from '/@/router/constant';
  25. const { sysOrgCode } = useGlobSetting();
  26. // 不是布尔台的使用 mxcad 模式,是布尔台的使用 iframe 模式以避免“法律风险”
  27. const mxcadmode = ref(sysOrgCode !== 'sdmtjtbetmk');
  28. // CAD预览器的 DEMO 01 相关代码
  29. const iframesrc = ref('');
  30. // CAD预览器 DEMO 02
  31. const fileid = ref('');
  32. const filename = ref('');
  33. //表单赋值
  34. const [registerModal, { setModalProps }] = useModalInner(async ({ record }) => {
  35. //重置表单
  36. setModalProps({ confirmLoading: false });
  37. if (mxcadmode.value) {
  38. fileid.value = record.id;
  39. filename.value = record.fileName;
  40. } else {
  41. const origin = import.meta.env.PROD ? 'http://182.92.126.35:8092' : window.location.origin;
  42. iframesrc.value = `${origin}/fileManager/cad-viewer?${AUTO_LOGIN_URL_QUERY.key}=${AUTO_LOGIN_URL_QUERY.val}&id=${record.id}&filename=${record.fileName}`;
  43. }
  44. });
  45. onMounted(() => {});
  46. </script>
  47. <style scoped lang="less">
  48. ::v-deep .suffix {
  49. height: 32px;
  50. line-height: 32px;
  51. margin-left: 5px;
  52. color: #fff;
  53. }
  54. </style>