CADModal.vue 2.1 KB

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