CADModal.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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" 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. // 使用须知:
  22. // 本组件是内含CADViewer的模态框组件,CADViewer提供两种实现方式分别是 内置 及 外链。
  23. // 需要特别说明的是外链方式,该方式的出现源于对版权纠纷的忌惮。
  24. // 实现原理是通过 iframe 嵌入一个支持内置实现方式的项目并传递数据然后使用。
  25. // 1、新建菜单
  26. // 路径要求为`/fileManager/cad-viewer`,组件要求为`vent/performance/fileDetail/commen/CADViewer`。
  27. // 上面用到的组件包含了内置方式的具体实现
  28. // 2、新建角色及用户
  29. // 该方式需要一个自动登录角色及用户,该用户的账号密码可在 /store/modules/user 查阅。
  30. // 同时,自动登录角色需要对上述菜单授权,同时,若该菜单存在父级,请同时授权其直系父级菜单
  31. import { ref } from 'vue';
  32. import { BasicModal, useModalInner } from '/@/components/Modal';
  33. import { onMounted } from 'vue';
  34. import CADViewer from './CADViewer.vue';
  35. // import { useGlobSetting } from '/@/hooks/setting';
  36. // import { useAutoLogin } from '/@/hooks/vent/useAutoLogin';
  37. // import { MOCK_LOGIN_UESRNAME } from '/@/store/constant';
  38. defineProps({
  39. fileid: {
  40. type: String,
  41. default: '',
  42. },
  43. });
  44. // const { sysOrgCode } = useGlobSetting();
  45. // const { getUrl } = useAutoLogin();
  46. // 不是布尔台的使用 mxcad 模式,是布尔台的使用 iframe 模式以避免“法律风险”
  47. // 暂时只允许本地预览模式,是因为认证需要机器码,目前仅在神东公司端有这个认证服务,前端也只有这一个码存好了
  48. const mxcadmode = ref(true);
  49. // const mxcadmode = ref(sysOrgCode !== 'sdmtjtbetmk');
  50. // CAD预览器的 DEMO 01 相关代码
  51. const iframesrc = ref('');
  52. // CAD预览器 DEMO 02
  53. // const fileid = ref('');
  54. // const filename = ref('');
  55. //表单赋值
  56. const [registerModal, { setModalProps }] = useModalInner(async ({ record }) => {
  57. //重置表单
  58. setModalProps({ confirmLoading: false });
  59. // if (mxcadmode.value) {
  60. // fileid.value = record.id;
  61. // filename.value = record.fileName;
  62. // } else {
  63. // // 当以 iframe 模式运行时,origin 在生产模式下需要指向本项目公司端所部署的地址
  64. // const origin = import.meta.env.PROD ? 'http://10.248.235.101:8092' : window.location.origin;
  65. // // const origin = import.meta.env.DEV ? 'http://182.92.126.35:8092' : window.location.origin;
  66. // iframesrc.value = getUrl(`${origin}/fileManager/cad-viewer`, {
  67. // // [SKIP_SSO_URL_QUERY.key]: SKIP_SSO_URL_QUERY.val,
  68. // id: record.id,
  69. // filename: record.fileName,
  70. // workNo: MOCK_LOGIN_UESRNAME,
  71. // });
  72. // // iframesrc.value = `${origin}/fileManager/cad-viewer?${SKIP_SSO_URL_QUERY.key}=${SKIP_SSO_URL_QUERY.val}&${MOCK_LOGIN_URL_QUERY.key}=${MOCK_LOGIN_URL_QUERY.val}&id=${record.id}&filename=${record.fileName}`;
  73. // }
  74. });
  75. onMounted(() => {});
  76. </script>
  77. <style scoped lang="less">
  78. ::v-deep .suffix {
  79. height: 32px;
  80. line-height: 32px;
  81. margin-left: 5px;
  82. color: #fff;
  83. }
  84. </style>