123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334 |
- import OSticky from '@/components/o-sticky'
- import { Button, DatePicker, Grid, GridItem, Icon, Image, List, Picker, Popover, Popup } from 'vant'
- import { defineComponent, nextTick, onMounted, reactive } from 'vue'
- import styles from './information.module.less'
- import iconSaveImage from '../images/icon-save-image.png'
- import iconWechat from '../images/icon-wechat.png'
- import OQrcode from '@/components/o-qrcode'
- import request from '@/helpers/request'
- import { useRoute } from 'vue-router'
- import { CountUp } from 'countup.js'
- import OEmpty from '@/components/o-empty'
- import dayjs from 'dayjs'
- export default defineComponent({
- name: 'detail-information',
- setup() {
- const route = useRoute()
- const state = reactive({
- timeShow: false,
- currentData: [dayjs().year() + ''],
- actionText: '上学期',
- actionType: 'up',
- actionTerm: [
- { text: '上学期', color: 'var(--van-primary-color)', value: 'up' },
- { text: '下学期', value: 'down' }
- ],
- oPopover: false,
- check: [],
- checkboxRefs: [] as any,
- showQrcode: false,
- qrcodeUrl: '',
- isLoading: false,
- list: [] as any,
- listState: {
- dataShow: true, // 判断是否有数据
- loading: false,
- finished: false
- },
- params: {
- startTime: dayjs().year() - 1 + '-09-01 00:00:00',
- endTime: dayjs(dayjs().year() + '-03-01 00:00:00')
- .subtract(1, 'day')
- .format('YYYY-MM-DD HH:mm:ss'),
- page: 1,
- rows: 20
- },
- orchestraInfo: {} as any // 乐团详情
- })
- // 选择学期
- const onSelect = (val: any) => {
- console.log(val)
- state.actionTerm.forEach((item: any) => {
- item.color = null
- })
- val.color = 'var(--van-primary-color)'
- state.actionText = val.text
- state.actionType = val.value
- if (val.value === 'up') {
- state.params.startTime = Number(state.currentData[0]) - 1 + '-09-01 00:00:00'
- state.params.endTime = dayjs(state.currentData[0] + '-03-01 00:00:00')
- .subtract(1, 'day')
- .format('YYYY-MM-DD HH:mm:ss')
- } else if (val.value === 'down') {
- console.log(dayjs().add(1, 'year'), 'dayjs().add(1, ')
- state.params.startTime = dayjs(state.currentData[0] + '-03-01 00:00:00')
- .subtract(1, 'day')
- .format('YYYY-MM-DD HH:mm:ss')
- state.params.endTime = Number(state.currentData[0]) + '-09-01 00:00:00'
- }
- onSearch()
- }
- const onConfirmDate = (date: any) => {
- state.currentData = date.selectedValues
- if (state.actionType == 'up') {
- state.params.startTime = Number(date.selectedValues[0]) - 1 + '-09-01 00:00:00'
- state.params.endTime = dayjs(date.selectedValues[0] + '-03-01 00:00:00')
- .subtract(1, 'day')
- .format('YYYY-MM-DD HH:mm:ss')
- } else if (state.actionType == 'down') {
- state.params.startTime = dayjs(date.selectedValues[0] + '-03-01 00:00:00')
- .subtract(1, 'day')
- .format('YYYY-MM-DD HH:mm:ss')
- state.params.endTime = Number(date.selectedValues[0]) + '-09-01 00:00:00'
- }
- state.timeShow = false
- onSearch()
- }
- const getDetails = async () => {
- try {
- const { data } = await request.get('/api-school/orchestra/detail/' + route.query.id)
- state.orchestraInfo = data || {}
- } catch {
- //
- }
- }
- // 班级列表
- const getList = async () => {
- try {
- if (state.isLoading) return
- state.isLoading = true
- const res = await request.post('/api-school/classGroup/page', {
- data: {
- ...state.params,
- orchestraId: route.query.id
- }
- })
- state.listState.loading = false
- const result = res.data || {}
- // 处理重复请求数据
- if (state.list.length > 0 && result.current === 1) {
- return
- }
- const rows = result.rows || []
- state.list = state.list.concat(rows)
- state.listState.finished = result.current >= result.pages
- state.params.page = result.current + 1
- state.listState.dataShow = state.list.length > 0
- state.isLoading = false
- } catch {
- state.listState.dataShow = false
- state.listState.finished = true
- state.isLoading = false
- }
- }
- const onSearch = () => {
- state.params.page = 1
- state.list = []
- state.listState.dataShow = true // 判断是否有数据
- state.listState.loading = false
- state.listState.finished = false
- getList()
- }
- const initNumCountUp = () => {
- nextTick(() => {
- // 在读学生
- new CountUp('currentStudentNum', Math.random() * 1000).start()
- new CountUp('time1', Math.random() * 100).start()
- new CountUp('time2', Math.random() * 100).start()
- new CountUp('time3', Math.random() * 100).start()
- })
- }
- onMounted(() => {
- getDetails()
- getList()
- initNumCountUp()
- })
- return () => (
- <>
- <div style={{ padding: '12px 13px 16px', background: '#F8F8F8' }}>
- <div class={styles.searchBand} onClick={() => (state.timeShow = true)}>
- {state.currentData[0]}年 <Icon name={state.timeShow ? 'arrow-up' : 'arrow-down'} />
- </div>
- <Popover
- v-model:show={state.oPopover}
- actions={state.actionTerm}
- showArrow={false}
- placement="bottom"
- offset={[0, 12]}
- style={{ zIndex: '9999' }}
- onSelect={onSelect}
- >
- {{
- reference: () => (
- <div class={styles.searchBand} style="margin-left: 16px">
- {state.actionText} <Icon name={state.oPopover ? 'arrow-up' : 'arrow-down'} />
- </div>
- )
- }}
- </Popover>
- </div>
- <Grid border={false} class={styles.gridContainer}>
- <GridItem>
- <p class={[styles.title, styles.red]}>
- <span id="currentStudentNum">0</span>
- <i>名</i>
- </p>
- <p class={styles.name}>在读学生</p>
- </GridItem>
- <GridItem>
- <p class={[styles.title, styles.red]}>
- <span id="time1">0</span>%
- </p>
- <p class={styles.name}>到课率</p>
- </GridItem>
- <GridItem>
- <p class={[styles.title, styles.red]}>
- <span id="time2">0</span>%
- </p>
- <p class={styles.name}>作业提交率</p>
- </GridItem>
- <GridItem>
- <p class={[styles.title, styles.red]}>
- <span id="time3">0</span>%
- </p>
- <p class={styles.name}>练习合格率</p>
- </GridItem>
- </Grid>
- {state.listState.dataShow ? (
- <List
- v-model:loading={state.listState.loading}
- finished={state.listState.finished}
- finishedText=" "
- class={[styles.liveList]}
- onLoad={getList}
- immediateCheck={false}
- >
- {state.list.map((item: any) => (
- <div class={[styles.gridContainer, styles.gridClass]}>
- <div class={styles.className}>
- <i class={styles.line}></i>
- {item.name}
- </div>
- <Grid border={false} columnNum={3}>
- <GridItem>
- <p class={styles.title}>{item.preStudentNum || 0}</p>
- <p class={styles.name}>在读学生</p>
- </GridItem>
- <GridItem>
- <p class={[styles.title, styles.teacher, 'van-ellipsis']}>
- {item.teacherName || '-'}
- </p>
- <p class={styles.name}>伴学指导</p>
- </GridItem>
- <GridItem>
- <p class={styles.title}>
- {item.completeCourseScheduleNum || 0}/{item.courseScheduleNum || 0}
- </p>
- <p class={styles.name}>课时</p>
- </GridItem>
- </Grid>
- </div>
- ))}
- </List>
- ) : (
- <OEmpty btnStatus={false} classImgSize="SMALL" tips="暂无班级" />
- )}
- {/* */}
- {state.orchestraInfo.type === 'DELIVERY' &&
- ['REGISTER', 'DOING', 'DONE'].includes(state.orchestraInfo.status) && (
- <OSticky position="bottom">
- <div class={'btnGroup'}>
- <Button
- round
- block
- type="primary"
- onClick={() => {
- state.showQrcode = true
- state.qrcodeUrl =
- window.location.origin + '/orchestra-student/#/preApply?id=' + route.query.id
- }}
- >
- 报名二维码
- </Button>
- </div>
- </OSticky>
- )}
- <Popup
- v-model:show={state.showQrcode}
- position="bottom"
- style={{ background: 'transparent' }}
- safeAreaInsetBottom={true}
- >
- <div class={styles.codeContainer}>
- <div class={styles.codeImg}>
- <div class={styles.codeContent}>
- <h2 class={styles.codeTitle}>乐团报名</h2>
- <div class={[styles.codeName, 'van-ellipsis']}>{state.orchestraInfo.name}</div>
- <div class={styles.codeQr}>
- <OQrcode text={state.qrcodeUrl} size={'400'} />
- </div>
- <div style={{ textAlign: 'center' }}>
- <span class={styles.codeBtnText}>扫描上方二维码完成资料填写</span>
- </div>
- <div class={styles.codeTips}>二维码将在两小时后失效,请及时登记</div>
- </div>
- </div>
- <div class={styles.codeBottom}>
- <Icon
- name="cross"
- size={22}
- class={styles.close}
- color="#666"
- onClick={() => (state.showQrcode = false)}
- />
- <h3 class={styles.title}>
- <i></i>分享方式
- </h3>
- <Grid columnNum={2} border={false}>
- <GridItem>
- {{
- icon: () => <Image class={styles.shareImg} src={iconSaveImage} />,
- text: () => <div class={styles.shareText}>保存图片</div>
- }}
- </GridItem>
- <GridItem>
- {{
- icon: () => <Image class={styles.shareImg} src={iconWechat} />,
- text: () => <div class={styles.shareText}>微信</div>
- }}
- </GridItem>
- </Grid>
- </div>
- </div>
- </Popup>
- <Popup v-model:show={state.timeShow} position="bottom" round>
- <DatePicker
- v-model={state.currentData}
- columnsType={['year']}
- onConfirm={onConfirmDate}
- onCancel={() => (state.timeShow = false)}
- />
- </Popup>
- </>
- )
- }
- })
|