|
@@ -1,8 +1,19 @@
|
|
|
import OHeader from '@/components/o-header'
|
|
|
-import { defineComponent, reactive } from 'vue'
|
|
|
+import { defineComponent, onMounted, reactive } from 'vue'
|
|
|
import styles from './report.module.less'
|
|
|
import iconOrchestra from '@/views/mine-orchestra/images/icon-or.png'
|
|
|
-import { Grid, GridItem, Icon, Image, Popup } from 'vant'
|
|
|
+import {
|
|
|
+ closeToast,
|
|
|
+ Grid,
|
|
|
+ GridItem,
|
|
|
+ Icon,
|
|
|
+ Image,
|
|
|
+ Popup,
|
|
|
+ showFailToast,
|
|
|
+ showLoadingToast,
|
|
|
+ showSuccessToast,
|
|
|
+ showToast
|
|
|
+} from 'vant'
|
|
|
import trainWeek from './images/month/icon-train-month.png'
|
|
|
import OrchestraNum from './modal/orchestra-num'
|
|
|
import TrainClass from './modal/train-class'
|
|
@@ -14,52 +25,243 @@ import iconClass from './images/icon-class.png'
|
|
|
import iconSaveImage from '@/school/orchestra/images/icon-save-image.png'
|
|
|
import iconWechat from '@/school/orchestra/images/icon-wechat.png'
|
|
|
import OQrcode from '@/components/o-qrcode'
|
|
|
+import request from '@/helpers/request'
|
|
|
+import { useRoute, useRouter } from 'vue-router'
|
|
|
+import { postMessage, promisefiyPostMessage } from '@/helpers/native-message'
|
|
|
+import html2canvas from 'html2canvas'
|
|
|
+
|
|
|
+export const reportCourseType = {
|
|
|
+ PERCUSSION: '打击乐',
|
|
|
+ FLUTE: '长笛',
|
|
|
+ SAX: '萨克斯',
|
|
|
+ CLARINET: '单簧管',
|
|
|
+ TRUMPET: '小号',
|
|
|
+ TROMBONE: '长号',
|
|
|
+ HORN: '圆号',
|
|
|
+ BARITONE_TUBA: '上低音号-大号',
|
|
|
+ EUPHONIUM: '上低音号',
|
|
|
+ TUBA: '大号',
|
|
|
+ MUSIC_THEORY: '乐理',
|
|
|
+ INSTRUMENTAL_ENSEMBLE: '合奏'
|
|
|
+}
|
|
|
|
|
|
export default defineComponent({
|
|
|
name: 'train-report',
|
|
|
setup() {
|
|
|
+ const router = useRouter()
|
|
|
+ const route = useRoute()
|
|
|
const forms = reactive({
|
|
|
+ id: route.query.id,
|
|
|
+ share: route.query.share as any,
|
|
|
showQrcode: false,
|
|
|
- url: 'http://'
|
|
|
+ url: window.location.href + '&share=1'
|
|
|
+ })
|
|
|
+ const reportData = reactive({
|
|
|
+ orchestraName: null,
|
|
|
+ monthlyTime: null,
|
|
|
+ startTime: null,
|
|
|
+ endTime: null,
|
|
|
+ COURSEWARE: {},
|
|
|
+ coursewareList: [] as any,
|
|
|
+ COURSE_SCHEDULE: {},
|
|
|
+ KNOWLEDGE: {},
|
|
|
+ ORCHESTRA: {},
|
|
|
+ PHOTO: {} as any,
|
|
|
+ STUDENT_ATTENDANCE: {},
|
|
|
+ TEACHER_ATTENDANCE: {}
|
|
|
+ })
|
|
|
+
|
|
|
+ const getDetail = async () => {
|
|
|
+ try {
|
|
|
+ const { data } = await request.get('/api-school/open/orchestraReport/detail/' + forms.id)
|
|
|
+ reportData.COURSEWARE = data.reportItem.COURSEWARE || {}
|
|
|
+ reportData.COURSE_SCHEDULE = data.reportItem.COURSE_SCHEDULE || {}
|
|
|
+ reportData.KNOWLEDGE = data.reportItem.KNOWLEDGE || {}
|
|
|
+ reportData.ORCHESTRA = data.reportItem.ORCHESTRA || {}
|
|
|
+ reportData.PHOTO = data.reportItem.PHOTO || {}
|
|
|
+ reportData.STUDENT_ATTENDANCE = data.reportItem.STUDENT_ATTENDANCE || {}
|
|
|
+ reportData.TEACHER_ATTENDANCE = data.reportItem.TEACHER_ATTENDANCE || {}
|
|
|
+ reportData.orchestraName = data.orchestraName || ''
|
|
|
+ reportData.monthlyTime = data.monthlyTime || ''
|
|
|
+ reportData.startTime = data.startTime || ''
|
|
|
+ reportData.endTime = data.endTime || ''
|
|
|
+
|
|
|
+ const courseware = reportData.COURSEWARE
|
|
|
+ for (const i in courseware) {
|
|
|
+ i != 'TOTAL' && reportData.coursewareList.push(reportCourseType[i])
|
|
|
+ }
|
|
|
+ } catch {
|
|
|
+ //
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ const imgs = reactive({
|
|
|
+ saveLoading: false,
|
|
|
+ image: null as any,
|
|
|
+ shareLoading: false
|
|
|
+ })
|
|
|
+ const onSaveImg = async () => {
|
|
|
+ // 判断是否在保存中...
|
|
|
+ if (imgs.saveLoading) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ imgs.saveLoading = true
|
|
|
+ // 判断是否已经生成图片
|
|
|
+ if (imgs.image) {
|
|
|
+ saveImg()
|
|
|
+ } else {
|
|
|
+ const container: any = document.getElementById(`preview-container`)
|
|
|
+ html2canvas(container, {
|
|
|
+ allowTaint: true,
|
|
|
+ useCORS: true,
|
|
|
+ backgroundColor: null
|
|
|
+ })
|
|
|
+ .then(async (canvas) => {
|
|
|
+ const url = canvas.toDataURL('image/png')
|
|
|
+ imgs.image = url
|
|
|
+ saveImg()
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ closeToast()
|
|
|
+ imgs.saveLoading = false
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const onShare = () => {
|
|
|
+ if (imgs.shareLoading) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ imgs.shareLoading = true
|
|
|
+ if (imgs.image) {
|
|
|
+ openShare()
|
|
|
+ } else {
|
|
|
+ const container: any = document.getElementById(`preview-container`)
|
|
|
+ html2canvas(container, {
|
|
|
+ allowTaint: true,
|
|
|
+ useCORS: true,
|
|
|
+ backgroundColor: null
|
|
|
+ })
|
|
|
+ .then(async (canvas) => {
|
|
|
+ const url = canvas.toDataURL('image/png')
|
|
|
+ imgs.image = url
|
|
|
+ openShare()
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ closeToast()
|
|
|
+ imgs.shareLoading = false
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const openShare = () => {
|
|
|
+ const image = imgs.image
|
|
|
+ setTimeout(() => {
|
|
|
+ imgs.shareLoading = false
|
|
|
+ }, 100)
|
|
|
+ if (image) {
|
|
|
+ postMessage(
|
|
|
+ {
|
|
|
+ api: 'shareTripartite',
|
|
|
+ content: {
|
|
|
+ title: '',
|
|
|
+ desc: '',
|
|
|
+ image,
|
|
|
+ video: '',
|
|
|
+ type: 'image',
|
|
|
+ // button: ['copy']
|
|
|
+ shareType: 'wechat'
|
|
|
+ }
|
|
|
+ },
|
|
|
+ (res: any) => {
|
|
|
+ if (res && res.content) {
|
|
|
+ showToast(res.content.message || (res.content.status ? '分享成功' : '分享失败'))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const saveImg = async () => {
|
|
|
+ showLoadingToast({ message: '图片生成中...', forbidClick: true })
|
|
|
+ setTimeout(() => {
|
|
|
+ imgs.saveLoading = false
|
|
|
+ }, 100)
|
|
|
+ const res = await promisefiyPostMessage({
|
|
|
+ api: 'savePicture',
|
|
|
+ content: {
|
|
|
+ base64: imgs.image
|
|
|
+ }
|
|
|
+ })
|
|
|
+ if (res?.content?.status === 'success') {
|
|
|
+ showSuccessToast('保存成功')
|
|
|
+ } else {
|
|
|
+ showFailToast('保存失败')
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ onMounted(() => {
|
|
|
+ getDetail()
|
|
|
})
|
|
|
return () => (
|
|
|
- <div class={[styles.trainWeek, styles.trainMonth]}>
|
|
|
+ <div
|
|
|
+ class={[
|
|
|
+ styles.trainWeek,
|
|
|
+ styles.trainMonth,
|
|
|
+ forms.share == 1 ? styles.trasinMonthShare : ''
|
|
|
+ ]}
|
|
|
+ >
|
|
|
<div class={styles.trainContainer}></div>
|
|
|
- <OHeader background="transparent" border={false} title=" ">
|
|
|
+ <OHeader background="transparent" border={false} title=" " backIconColor="white">
|
|
|
{{
|
|
|
- right: () => <i class={styles.iconShare} onClick={() => (forms.showQrcode = true)}></i>
|
|
|
+ right: () =>
|
|
|
+ forms.share != 1 && (
|
|
|
+ <i class={styles.iconShare} onClick={() => (forms.showQrcode = true)}></i>
|
|
|
+ )
|
|
|
}}
|
|
|
</OHeader>
|
|
|
<div class={[styles.headerContant, styles.teacherHeaderContant]}>
|
|
|
<div class={styles.orchestra}>
|
|
|
<Image src={iconOrchestra} class={styles.iconOrchestra} />
|
|
|
- <span>武汉市洪山区实验小学第一届乐团</span>
|
|
|
+ <span>{reportData.orchestraName}</span>
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <Image src={trainWeek} class={styles.iconTrainWeek} />
|
|
|
</div>
|
|
|
- <Image src={trainWeek} class={styles.iconTrainWeek} />
|
|
|
- <div class={styles.trainTimer}>2023/1/16-2023/1/22</div>
|
|
|
+ <div class={styles.trainTimer}>{reportData.monthlyTime}</div>
|
|
|
</div>
|
|
|
|
|
|
- <OrchestraNum type="month" />
|
|
|
- <TrainClass type="month" />
|
|
|
+ <OrchestraNum type="month" reportData={reportData.ORCHESTRA} />
|
|
|
+ <TrainClass type="month" reportData={reportData.COURSE_SCHEDULE} />
|
|
|
|
|
|
<div class={[styles.trainPhoto, styles.teacherTrainPhoto]}>
|
|
|
<Image src={iconPhoto} class={styles.iconPhoto} />
|
|
|
<p>
|
|
|
- 本月上传<span>17</span>张训练照片
|
|
|
+ 本月上传<span>{reportData.PHOTO.TOTAL || 0}</span>张训练照片
|
|
|
+ </p>
|
|
|
+ <p
|
|
|
+ onClick={() => {
|
|
|
+ if (forms.share == 1) return
|
|
|
+ router.push({
|
|
|
+ path: '/school-photo'
|
|
|
+ })
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ 本月上传<span>{reportData.PHOTO.TOTAL || 0}</span>张训练照片
|
|
|
+ {forms.share != 1 && <Icon name="arrow" />}
|
|
|
</p>
|
|
|
</div>
|
|
|
|
|
|
- <StudentAttendance type="month" />
|
|
|
- <TeacherAttendance type="month" />
|
|
|
+ <StudentAttendance type="month" reportData={reportData.STUDENT_ATTENDANCE} />
|
|
|
+ <TeacherAttendance type="month" reportData={reportData.TEACHER_ATTENDANCE} />
|
|
|
|
|
|
- <div class={[styles.trainPhoto, styles.teacherTrainClass, styles.trainClass]}>
|
|
|
+ <div class={[styles.trainClass, styles.teacherTrainClass]}>
|
|
|
<Image src={iconClass} class={styles.iconPhoto} />
|
|
|
<div>
|
|
|
- <p>课件使用未达标班级</p>
|
|
|
- <p class={styles.subjectNames}>长笛班 单簧管班 萨克斯班 小号班 大号</p>
|
|
|
+ <p class={styles.subjectTips}>课件使用未达标班级</p>
|
|
|
+ <p class={styles.subjectNames}>
|
|
|
+ {reportData.coursewareList.map((item: string) => item + ' ')}
|
|
|
+ </p>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <TrainProgress type="month" />
|
|
|
+ <TrainProgress type="month" reportData={reportData.KNOWLEDGE} />
|
|
|
|
|
|
<Popup
|
|
|
v-model:show={forms.showQrcode}
|
|
@@ -78,10 +280,12 @@ export default defineComponent({
|
|
|
>
|
|
|
<div class={styles.orchestra}>
|
|
|
<Image src={iconOrchestra} class={styles.iconOrchestra} />
|
|
|
- <span>武汉市洪山区实验小学第一届乐团</span>
|
|
|
+ <span>{reportData.orchestraName}</span>
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <Image src={trainWeek} class={styles.iconTrainWeek} />
|
|
|
</div>
|
|
|
- <Image src={trainWeek} class={styles.iconTrainWeek} />
|
|
|
- <div class={styles.trainTimer}>2023/1/16-2023/1/22</div>
|
|
|
+ <div class={styles.trainTimer}>{reportData.monthlyTime}</div>
|
|
|
</div>
|
|
|
|
|
|
<div class={styles.codeQr}>
|
|
@@ -107,13 +311,13 @@ export default defineComponent({
|
|
|
<i></i>分享方式
|
|
|
</h3>
|
|
|
<Grid columnNum={2} border={false}>
|
|
|
- <GridItem>
|
|
|
+ <GridItem onClick={onSaveImg}>
|
|
|
{{
|
|
|
icon: () => <Image class={styles.shareImg} src={iconSaveImage} />,
|
|
|
text: () => <div class={styles.shareText}>保存图片</div>
|
|
|
}}
|
|
|
</GridItem>
|
|
|
- <GridItem>
|
|
|
+ <GridItem onClick={onShare}>
|
|
|
{{
|
|
|
icon: () => <Image class={styles.shareImg} src={iconWechat} />,
|
|
|
text: () => <div class={styles.shareText}>微信</div>
|