lex hace 2 años
padre
commit
07375a969a

+ 23 - 3
src/school/train-report/month-report.tsx

@@ -1,5 +1,5 @@
 import OHeader from '@/components/o-header'
-import { defineComponent, onMounted, reactive } from 'vue'
+import { defineComponent, nextTick, onMounted, reactive } from 'vue'
 import styles from './report.module.less'
 import iconOrchestra from '@/views/mine-orchestra/images/icon-or.png'
 import {
@@ -33,6 +33,7 @@ import { useRoute, useRouter } from 'vue-router'
 import { postMessage, promisefiyPostMessage } from '@/helpers/native-message'
 import html2canvas from 'html2canvas'
 import iconArrow from './images/icon-arrow.png'
+import { useRect } from '@vant/use'
 
 export const reportCourseType = {
   PERCUSSION: '打击乐',
@@ -58,7 +59,9 @@ export default defineComponent({
       id: route.query.id,
       share: route.query.share as any,
       showQrcode: false,
-      url: window.location.href + '&share=1'
+      url: window.location.href + '&share=1',
+      width: 0,
+      height: 0
     })
     const reportData = reactive({
       orchestraName: null,
@@ -223,7 +226,24 @@ export default defineComponent({
           {{
             right: () =>
               forms.share != 1 && (
-                <i class={styles.iconShare} onClick={() => (forms.showQrcode = true)}></i>
+                <i
+                  class={styles.iconShare}
+                  onClick={() => {
+                    forms.showQrcode = true
+                    nextTick(() => {
+                      const previewContainer = document.querySelector(
+                        '#preview-container'
+                      ) as HTMLElement
+                      const share = useRect(previewContainer)
+                      forms.width = share.width
+                      forms.height = share.height
+                      if (share.width > 0 && share.height > 0) {
+                        previewContainer.style.width = Math.round(share.width) + 'px'
+                        previewContainer.style.height = Math.round(share.height) + 'px'
+                      }
+                    })
+                  }}
+                ></i>
               )
           }}
         </OHeader>

+ 23 - 3
src/school/train-report/week-report.tsx

@@ -1,5 +1,5 @@
 import OHeader from '@/components/o-header'
-import { defineComponent, onMounted, reactive } from 'vue'
+import { defineComponent, onMounted, reactive, nextTick } from 'vue'
 import styles from './report.module.less'
 import iconOrchestra from '@/views/mine-orchestra/images/icon-or.png'
 import {
@@ -34,6 +34,7 @@ import { postMessage, promisefiyPostMessage } from '@/helpers/native-message'
 import html2canvas from 'html2canvas'
 import dayjs from 'dayjs'
 import iconArrow from './images/icon-arrow.png'
+import { useRect } from '@vant/use'
 
 export const reportCourseType = {
   PERCUSSION: '打击乐',
@@ -59,7 +60,9 @@ export default defineComponent({
       id: route.query.id,
       showQrcode: false,
       share: route.query.share as any,
-      url: window.location.href + '&share=1'
+      url: window.location.href + '&share=1',
+      width: 0,
+      height: 0
     })
     const reportData = reactive({
       orchestraName: null,
@@ -217,7 +220,24 @@ export default defineComponent({
           {{
             right: () =>
               forms.share != 1 && (
-                <i class={styles.iconShare} onClick={() => (forms.showQrcode = true)}></i>
+                <i
+                  class={styles.iconShare}
+                  onClick={() => {
+                    forms.showQrcode = true
+                    nextTick(() => {
+                      const previewContainer = document.querySelector(
+                        '#preview-container'
+                      ) as HTMLElement
+                      const share = useRect(previewContainer)
+                      forms.width = share.width
+                      forms.height = share.height
+                      if (share.width > 0 && share.height > 0) {
+                        previewContainer.style.width = Math.round(share.width) + 'px'
+                        previewContainer.style.height = Math.round(share.height) + 'px'
+                      }
+                    })
+                  }}
+                ></i>
               )
           }}
         </OHeader>