ext-webflow-template.vue 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <template>
  2. <!--
  3. v-bind、v-on 部分是把不需要处理的 prop、事件 直接原封不动的转发给 sd-webflow,供业务单使用
  4. @actionBtnClick 表示这个事件需要处理一下,不能原样转发。详情见下方代码
  5. :header-buttons 部分的效果是:在业务单顶部按钮的基础上,统一增加 save 和 close 两个按钮
  6. -->
  7. <sd-webflow-delegate
  8. ref="webflow"
  9. v-bind="restAttrs"
  10. v-on="restListeners"
  11. @firstMeaningfulPaint="firstMeaningfulPaint"
  12. >
  13. <!--
  14. 这一段表示不需要特殊处理的 slot,直接转发
  15. -->
  16. <template v-for="(_, slot) of restSlots" v-slot:[slot]="scope">
  17. <slot :name="slot" v-bind="scope" />
  18. </template>
  19. </sd-webflow-delegate>
  20. </template>
  21. <script>
  22. import webflowTemplateMixin from '@/_extension-points/webflow/webflow-template-mixin'
  23. import loginService from '@/login/login-service'
  24. import components from './_import-components/ext-webflow-template-import'
  25. export default {
  26. name: 'ExtWebflowTemplate',
  27. components,
  28. mixins: [webflowTemplateMixin],
  29. computed: {
  30. restSlots() {
  31. // 把需要特殊处理的 slot 排除在外
  32. const { ...rest } = this.$scopedSlots
  33. return rest
  34. },
  35. restListeners() {
  36. // 把需要特殊处理的事件排除在外
  37. const { firstMeaningfulPaint, ...rest } = this.$listeners
  38. return rest
  39. },
  40. restAttrs() {
  41. // 把需要特殊处理的 prop 排除在外
  42. const { actionBtnClick, ...rest } = this.$attrs
  43. return rest
  44. },
  45. },
  46. mounted() {},
  47. methods: {
  48. firstMeaningfulPaint(evt, { FlowData }) {
  49. if (navigator.sendBeacon) {
  50. navigator.sendBeacon(
  51. 'api/framework/v1/operate-monitor/open-task-log?access_token=' +
  52. loginService.getTokens().access_token,
  53. new Blob(
  54. [
  55. JSON.stringify({
  56. instId: FlowData.instId,
  57. title: FlowData.processFormData.processFormPropertyValues.find(
  58. (field) => field.dataType === 'title'
  59. ).value,
  60. totalCostTime: new Date().valueOf() - parseInt(window.performance.timeOrigin),
  61. timeOrigin: parseInt(window.performance.timeOrigin),
  62. url: window.location.href,
  63. }),
  64. ],
  65. {
  66. type: 'application/json',
  67. }
  68. )
  69. )
  70. }
  71. },
  72. },
  73. }
  74. </script>
  75. <style module lang="scss">
  76. @use '@/common/design' as *;
  77. </style>