design.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <template>
  2. <div ref="container" class="w-full h-[calc(100vh-88px)]">
  3. <iframe ref="iframe" :src="iframeUrl" frameborder="0" height="100%" style="height: 100%; width: inherit"></iframe>
  4. </div>
  5. </template>
  6. <script setup name="WarmFlow" lang="ts">
  7. const { proxy } = getCurrentInstance();
  8. import { onMounted } from 'vue';
  9. import { getToken } from '@/utils/auth';
  10. // definitionId为需要查询的流程定义id,
  11. // disabled为是否可编辑, 例如:查看的时候不可编辑,不可保存
  12. const iframeUrl = ref('');
  13. const baseUrl = import.meta.env.VITE_APP_BASE_API;
  14. const iframeLoaded = () => {
  15. // iframe监听组件内设计器保存事件
  16. window.onmessage = (event) => {
  17. switch (event.data.method) {
  18. case 'close':
  19. close();
  20. break;
  21. }
  22. };
  23. };
  24. const open = async (definitionId, disabled) => {
  25. const url = baseUrl + `/warm-flow-ui/index.html?id=${definitionId}&disabled=${disabled}`;
  26. iframeUrl.value = url + '&Authorization=Bearer ' + getToken() + '&clientid=' + import.meta.env.VITE_APP_CLIENT_ID;
  27. };
  28. /** 关闭按钮 */
  29. function close() {
  30. const obj = { path: '/workflow/processDefinition', query: { activeName: proxy.$route.query.activeName } };
  31. proxy.$tab.closeOpenPage(obj);
  32. }
  33. onMounted(() => {
  34. iframeLoaded();
  35. open(proxy.$route.query.definitionId, proxy.$route.query.disabled);
  36. });
  37. /**
  38. * 对外暴露子组件方法
  39. */
  40. defineExpose({
  41. open
  42. });
  43. </script>