|  | @@ -1,39 +1,35 @@
 | 
	
		
			
				|  |  | -import { Ref, defineComponent, onMounted, reactive, ref } from 'vue';
 | 
	
		
			
				|  |  | +import { Ref, computed, defineComponent, onMounted, reactive, ref } from 'vue';
 | 
	
		
			
				|  |  |  import styles from '../index.module.less';
 | 
	
		
			
				|  |  |  import { NButton, NDataTable, NNumberAnimation } from 'naive-ui';
 | 
	
		
			
				|  |  |  import numeral from 'numeral';
 | 
	
		
			
				|  |  |  import { useECharts } from '@/hooks/web/useECharts';
 | 
	
		
			
				|  |  |  import Pagination from '/src/components/pagination';
 | 
	
		
			
				|  |  | -import { getTrainingStat } from '@/views/data-module/api'
 | 
	
		
			
				|  |  | -import { getTimes } from '/src/utils/dateFormat';
 | 
	
		
			
				|  |  | +import { getTestStat } from '@/views/data-module/api';
 | 
	
		
			
				|  |  | +import { getMinutes, getSecend, getTimes } from '/src/utils/dateFormat';
 | 
	
		
			
				|  |  |  import { useRoute, useRouter } from 'vue-router';
 | 
	
		
			
				|  |  | +import { getTrainingStatList } from '../../classList/api';
 | 
	
		
			
				|  |  |  export default defineComponent({
 | 
	
		
			
				|  |  |    name: 'home-practiceData',
 | 
	
		
			
				|  |  | -  props:{
 | 
	
		
			
				|  |  | -    timer:{
 | 
	
		
			
				|  |  | -      type:Array,
 | 
	
		
			
				|  |  | -      defaut:()=>[]
 | 
	
		
			
				|  |  | +  props: {
 | 
	
		
			
				|  |  | +    timer: {
 | 
	
		
			
				|  |  | +      type: Array,
 | 
	
		
			
				|  |  | +      defaut: () => []
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |    },
 | 
	
		
			
				|  |  | -  setup(props,{expose}) {
 | 
	
		
			
				|  |  | +  setup(props, { expose }) {
 | 
	
		
			
				|  |  |      const chartRef = ref<HTMLDivElement | null>(null);
 | 
	
		
			
				|  |  |      const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>);
 | 
	
		
			
				|  |  |      const practiceFlag = ref(true);
 | 
	
		
			
				|  |  |      const payForm = reactive({
 | 
	
		
			
				|  |  |        height: '360px',
 | 
	
		
			
				|  |  |        width: '100%',
 | 
	
		
			
				|  |  | -      studentNum: 0,
 | 
	
		
			
				|  |  | +      practiceUserCount: 0,
 | 
	
		
			
				|  |  |        paymentAmount: 0,
 | 
	
		
			
				|  |  | -      dateList: [
 | 
	
		
			
				|  |  | -        '2022-10-10',
 | 
	
		
			
				|  |  | -        '2022-10-11',
 | 
	
		
			
				|  |  | -        '2022-10-12',
 | 
	
		
			
				|  |  | -        '2022-10-13',
 | 
	
		
			
				|  |  | -        '2022-10-14',
 | 
	
		
			
				|  |  | -        '2022-10-15',
 | 
	
		
			
				|  |  | -        '2022-10-16'
 | 
	
		
			
				|  |  | -      ],
 | 
	
		
			
				|  |  | -      timeList: [90, 128, 242, 120, 186, 77, 148]
 | 
	
		
			
				|  |  | +      practiceDurationAvg: 0,
 | 
	
		
			
				|  |  | +      practiceDays: 0,
 | 
	
		
			
				|  |  | +      practiceDurationTotal: 0,
 | 
	
		
			
				|  |  | +      dateList: [],
 | 
	
		
			
				|  |  | +      timeList: []
 | 
	
		
			
				|  |  |      });
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      const state = reactive({
 | 
	
	
		
			
				|  | @@ -91,51 +87,92 @@ export default defineComponent({
 | 
	
		
			
				|  |  |        ] as any,
 | 
	
		
			
				|  |  |        goCourseVisiable: false
 | 
	
		
			
				|  |  |      });
 | 
	
		
			
				|  |  | +    const currentTimer = computed(() => {
 | 
	
		
			
				|  |  | +      return props.timer;
 | 
	
		
			
				|  |  | +    });
 | 
	
		
			
				|  |  |      const columns = () => {
 | 
	
		
			
				|  |  |        return [
 | 
	
		
			
				|  |  |          {
 | 
	
		
			
				|  |  |            title: '日期',
 | 
	
		
			
				|  |  | -          key: 'createTime'
 | 
	
		
			
				|  |  | +          key: 'date'
 | 
	
		
			
				|  |  |          },
 | 
	
		
			
				|  |  |          {
 | 
	
		
			
				|  |  | -          title: '练习人数',
 | 
	
		
			
				|  |  | -          key: 'quantityNum',
 | 
	
		
			
				|  |  | -          render(row: any) {
 | 
	
		
			
				|  |  | -            return <span>{row.quantityNum}人</span>;
 | 
	
		
			
				|  |  | -          }
 | 
	
		
			
				|  |  | -        },
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  |            title: '平均练习时长(分钟)',
 | 
	
		
			
				|  |  | -          key: 'submitNum',
 | 
	
		
			
				|  |  | +          key: 'practiceDuration',
 | 
	
		
			
				|  |  |            render(row: any) {
 | 
	
		
			
				|  |  | -            return <span>{row.submitNum}分钟</span>;
 | 
	
		
			
				|  |  | +            return (
 | 
	
		
			
				|  |  | +              <>
 | 
	
		
			
				|  |  | +                {' '}
 | 
	
		
			
				|  |  | +                <>
 | 
	
		
			
				|  |  | +                  {row.practiceDuration
 | 
	
		
			
				|  |  | +                    ? getMinutes(row.practiceDuration) > 0
 | 
	
		
			
				|  |  | +                      ? getMinutes(row.practiceDuration) +
 | 
	
		
			
				|  |  | +                      '分' +
 | 
	
		
			
				|  |  | +                      getSecend(row.practiceDuration) +
 | 
	
		
			
				|  |  | +                      '秒'
 | 
	
		
			
				|  |  | +                      : getSecend(row.practiceDuration) + '秒'
 | 
	
		
			
				|  |  | +                    : 0 + '分钟'}
 | 
	
		
			
				|  |  | +                </>
 | 
	
		
			
				|  |  | +              </>
 | 
	
		
			
				|  |  | +            );
 | 
	
		
			
				|  |  |            }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |        ];
 | 
	
		
			
				|  |  |      };
 | 
	
		
			
				|  |  |      const getList = async () => {
 | 
	
		
			
				|  |  | -      try{
 | 
	
		
			
				|  |  | -        const res = await getTrainingStat({  ...getTimes(props.timer, ['startTime', 'endTime'], 'YYYY-MM-DD')})
 | 
	
		
			
				|  |  | +      try {
 | 
	
		
			
				|  |  | +        const res = await getTrainingStatList({
 | 
	
		
			
				|  |  | +          page: 1,
 | 
	
		
			
				|  |  | +          rows: 999,
 | 
	
		
			
				|  |  | +          ...getTimes(
 | 
	
		
			
				|  |  | +            currentTimer.value,
 | 
	
		
			
				|  |  | +            ['startTime', 'endTime'],
 | 
	
		
			
				|  |  | +            'YYYY-MM-DD'
 | 
	
		
			
				|  |  | +          )
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        const res2 = await getTestStat({
 | 
	
		
			
				|  |  | +          page: 1,
 | 
	
		
			
				|  |  | +          rows: 999,
 | 
	
		
			
				|  |  | +          ...getTimes(
 | 
	
		
			
				|  |  | +            currentTimer.value,
 | 
	
		
			
				|  |  | +            ['startTime', 'endTime'],
 | 
	
		
			
				|  |  | +            'YYYY-MM-DD'
 | 
	
		
			
				|  |  | +          )
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  | +        state.tableList = res.data.rows;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -      }catch(e){
 | 
	
		
			
				|  |  | -        console.log(e)
 | 
	
		
			
				|  |  | +        payForm.practiceDurationAvg = res2.data.practiceDurationAvg;
 | 
	
		
			
				|  |  | +        payForm.practiceUserCount = res2.data.practiceUserCount;
 | 
	
		
			
				|  |  | +        payForm.dateList = res2.data.trainingStatDetailList.map((item: any) => {
 | 
	
		
			
				|  |  | +          return item.date;
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        payForm.timeList = res2.data.trainingStatDetailList.map((item: any) => {
 | 
	
		
			
				|  |  | +          return item.practiceDuration;
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        console.log('trainingStatDetailList', payForm.timeList);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        setChart();
 | 
	
		
			
				|  |  | +      } catch (e) {
 | 
	
		
			
				|  |  | +        console.log(e);
 | 
	
		
			
				|  |  |        }
 | 
	
		
			
				|  |  |      };
 | 
	
		
			
				|  |  | -    expose({getList})
 | 
	
		
			
				|  |  | +    expose({ getList });
 | 
	
		
			
				|  |  |      const setChart = () => {
 | 
	
		
			
				|  |  |        setOptions({
 | 
	
		
			
				|  |  |          tooltip: {
 | 
	
		
			
				|  |  |            trigger: 'axis',
 | 
	
		
			
				|  |  |            axisPointer: {
 | 
	
		
			
				|  |  | -            type: 'none'
 | 
	
		
			
				|  |  | +            type: 'shadow'
 | 
	
		
			
				|  |  |            }
 | 
	
		
			
				|  |  |          },
 | 
	
		
			
				|  |  |          legend: {
 | 
	
		
			
				|  |  |            show: false,
 | 
	
		
			
				|  |  |            selected: {
 | 
	
		
			
				|  |  |              //在这里设置默认展示就ok了
 | 
	
		
			
				|  |  | -            '练习时长(分钟)': practiceFlag.value
 | 
	
		
			
				|  |  | +            '平均练习时长(分钟)': practiceFlag.value
 | 
	
		
			
				|  |  |            }
 | 
	
		
			
				|  |  |          },
 | 
	
		
			
				|  |  |          xAxis: {
 | 
	
	
		
			
				|  | @@ -177,14 +214,14 @@ export default defineComponent({
 | 
	
		
			
				|  |  |              data: payForm.timeList,
 | 
	
		
			
				|  |  |              type: 'bar',
 | 
	
		
			
				|  |  |              barWidth: '48px',
 | 
	
		
			
				|  |  | -            label: {
 | 
	
		
			
				|  |  | -              // 柱图头部显示值
 | 
	
		
			
				|  |  | -              show: true,
 | 
	
		
			
				|  |  | -              position: 'top',
 | 
	
		
			
				|  |  | -              color: '#333',
 | 
	
		
			
				|  |  | -              fontSize: '12px',
 | 
	
		
			
				|  |  | -              fontWeight: 600
 | 
	
		
			
				|  |  | -            },
 | 
	
		
			
				|  |  | +            // label: {
 | 
	
		
			
				|  |  | +            //   // 柱图头部显示值
 | 
	
		
			
				|  |  | +            //   show: true,
 | 
	
		
			
				|  |  | +            //   position: 'top',
 | 
	
		
			
				|  |  | +            //   color: '#333',
 | 
	
		
			
				|  |  | +            //   fontSize: '12px',
 | 
	
		
			
				|  |  | +            //   fontWeight: 600
 | 
	
		
			
				|  |  | +            // },
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              itemStyle: {
 | 
	
		
			
				|  |  |                normal: {
 | 
	
	
		
			
				|  | @@ -206,15 +243,17 @@ export default defineComponent({
 | 
	
		
			
				|  |  |            if (Array.isArray(item)) {
 | 
	
		
			
				|  |  |              return [
 | 
	
		
			
				|  |  |                item[0].axisValueLabel,
 | 
	
		
			
				|  |  | -              ...item.map(
 | 
	
		
			
				|  |  | -                (d: any) =>
 | 
	
		
			
				|  |  | -                  `<br/>${
 | 
	
		
			
				|  |  | -                    d.marker
 | 
	
		
			
				|  |  | -                  }<span style="margin-top:10px;margin-left:5px;font-size: 13px;font-weight: 500;
 | 
	
		
			
				|  |  | +              ...item.map((d: any) => {
 | 
	
		
			
				|  |  | +                let str;
 | 
	
		
			
				|  |  | +                getMinutes(d.value) > 0
 | 
	
		
			
				|  |  | +                  ? (str =
 | 
	
		
			
				|  |  | +                    getMinutes(d.value) + '分' + getSecend(d.value) + '秒')
 | 
	
		
			
				|  |  | +                  : (str = getSecend(d.value) + '秒');
 | 
	
		
			
				|  |  | +                return `<br/>${d.marker}<span style="margin-top:10px;margin-left:5px;font-size: 13px;font-weight: 500;
 | 
	
		
			
				|  |  |                    color: #131415;font-weight: 600;
 | 
	
		
			
				|  |  |                    margin-top:12px
 | 
	
		
			
				|  |  | -                  line-height: 18px;">练习时长: ${d.value}${'分钟'} </span>`
 | 
	
		
			
				|  |  | -              )
 | 
	
		
			
				|  |  | +                  line-height: 18px;">平均练习时长: ${str} </span>`;
 | 
	
		
			
				|  |  | +              })
 | 
	
		
			
				|  |  |              ].join('');
 | 
	
		
			
				|  |  |            } else {
 | 
	
		
			
				|  |  |              return item;
 | 
	
	
		
			
				|  | @@ -231,10 +270,9 @@ export default defineComponent({
 | 
	
		
			
				|  |  |        });
 | 
	
		
			
				|  |  |      };
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    onMounted(()=>{
 | 
	
		
			
				|  |  | -      getList()
 | 
	
		
			
				|  |  | -      setChart();
 | 
	
		
			
				|  |  | -    })
 | 
	
		
			
				|  |  | +    onMounted(() => {
 | 
	
		
			
				|  |  | +      getList();
 | 
	
		
			
				|  |  | +    });
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      return () => (
 | 
	
		
			
				|  |  |        <>
 | 
	
	
		
			
				|  | @@ -244,7 +282,9 @@ export default defineComponent({
 | 
	
		
			
				|  |  |                <div class={styles.TrainDataItem}>
 | 
	
		
			
				|  |  |                  <p class={styles.TrainDataItemTitle}>
 | 
	
		
			
				|  |  |                    <span>
 | 
	
		
			
				|  |  | -                    <NNumberAnimation from={0} to={32}></NNumberAnimation>
 | 
	
		
			
				|  |  | +                    <NNumberAnimation
 | 
	
		
			
				|  |  | +                      from={0}
 | 
	
		
			
				|  |  | +                      to={payForm.practiceUserCount}></NNumberAnimation>
 | 
	
		
			
				|  |  |                    </span>
 | 
	
		
			
				|  |  |                    人
 | 
	
		
			
				|  |  |                  </p>
 | 
	
	
		
			
				|  | @@ -252,10 +292,28 @@ export default defineComponent({
 | 
	
		
			
				|  |  |                </div>
 | 
	
		
			
				|  |  |                <div class={styles.TrainDataItem}>
 | 
	
		
			
				|  |  |                  <p class={styles.TrainDataItemTitle}>
 | 
	
		
			
				|  |  | -                  <span>
 | 
	
		
			
				|  |  | -                    <NNumberAnimation from={0} to={32}></NNumberAnimation>
 | 
	
		
			
				|  |  | -                  </span>
 | 
	
		
			
				|  |  | -                  分钟
 | 
	
		
			
				|  |  | +                  {getMinutes(payForm.practiceDurationAvg) > 0 ? (
 | 
	
		
			
				|  |  | +                    <div>
 | 
	
		
			
				|  |  | +                      <span>
 | 
	
		
			
				|  |  | +                        <NNumberAnimation
 | 
	
		
			
				|  |  | +                          from={0}
 | 
	
		
			
				|  |  | +                          to={getMinutes(
 | 
	
		
			
				|  |  | +                            payForm.practiceDurationAvg
 | 
	
		
			
				|  |  | +                          )}></NNumberAnimation>
 | 
	
		
			
				|  |  | +                      </span>{' '}
 | 
	
		
			
				|  |  | +                      分
 | 
	
		
			
				|  |  | +                    </div>
 | 
	
		
			
				|  |  | +                  ) : null}
 | 
	
		
			
				|  |  | +                  <div>
 | 
	
		
			
				|  |  | +                    <span>
 | 
	
		
			
				|  |  | +                      <NNumberAnimation
 | 
	
		
			
				|  |  | +                        from={0}
 | 
	
		
			
				|  |  | +                        to={getSecend(
 | 
	
		
			
				|  |  | +                          payForm.practiceDurationAvg
 | 
	
		
			
				|  |  | +                        )}></NNumberAnimation>
 | 
	
		
			
				|  |  | +                    </span>{' '}
 | 
	
		
			
				|  |  | +                    秒
 | 
	
		
			
				|  |  | +                  </div>
 | 
	
		
			
				|  |  |                  </p>
 | 
	
		
			
				|  |  |                  <p class={styles.TrainDataItemsubTitle}>平均练习时长</p>
 | 
	
		
			
				|  |  |                </div>
 | 
	
	
		
			
				|  | @@ -290,14 +348,14 @@ export default defineComponent({
 | 
	
		
			
				|  |  |                loading={state.loading}
 | 
	
		
			
				|  |  |                columns={columns()}
 | 
	
		
			
				|  |  |                data={state.tableList}></NDataTable>
 | 
	
		
			
				|  |  | -            <Pagination
 | 
	
		
			
				|  |  | +            {/* <Pagination
 | 
	
		
			
				|  |  |                v-model:page={state.pagination.page}
 | 
	
		
			
				|  |  |                v-model:pageSize={state.pagination.rows}
 | 
	
		
			
				|  |  |                v-model:pageTotal={state.pagination.pageTotal}
 | 
	
		
			
				|  |  |                onList={getList}
 | 
	
		
			
				|  |  |                sync
 | 
	
		
			
				|  |  |                saveKey="orchestraRegistration-key"
 | 
	
		
			
				|  |  | -            />
 | 
	
		
			
				|  |  | +            /> */}
 | 
	
		
			
				|  |  |            </div>
 | 
	
		
			
				|  |  |          </div>
 | 
	
		
			
				|  |  |        </>
 |