Browse Source

时间周期

liushengqiang 2 years ago
parent
commit
b3919b4bdf

+ 3 - 3
src/views/home/component/Attendance.tsx

@@ -157,9 +157,9 @@ export default defineComponent({
               console.log(value, 123);
               emit('change', value);
             }}>
-            <Tab name="本周" title="本周"></Tab>
-            <Tab name="本月" title="本月"></Tab>
-            <Tab name="本学期" title="本学期"></Tab>
+            <Tab name="week" title="本周"></Tab>
+            <Tab name="month" title="本月"></Tab>
+            <Tab name="term" title="本学期"></Tab>
           </Tabs>
           <div
             class={styles.tagRight}

+ 3 - 3
src/views/home/component/Practice.tsx

@@ -51,9 +51,9 @@ export default defineComponent({
               console.log(value);
               emit('change', value);
             }}>
-            <Tab name="本周" title="本周"></Tab>
-            <Tab name="本月" title="本月"></Tab>
-            <Tab name="本学期" title="本学期"></Tab>
+            <Tab name="week" title="本周"></Tab>
+            <Tab name="month" title="本月"></Tab>
+            <Tab name="term" title="本学期"></Tab>
           </Tabs>
         </div>
         <div class={styles.practiceContainer}>

+ 17 - 11
src/views/home/contentItem.tsx

@@ -43,7 +43,9 @@ export default defineComponent({
     const { musicGroupId } = toRefs(props);
     /** 统计 */
     const getSchool = async () => {
-      const res = await api_schoolIndexStat({musicGroupId: musicGroupId.value});
+      const res = await api_schoolIndexStat({
+        musicGroupId: musicGroupId.value
+      });
       if (res.data) {
         const {
           gradeDistributions,
@@ -67,16 +69,20 @@ export default defineComponent({
     };
 
     /** 出勤统计 */
-    const getAttendanceStat = async () => {
-      const res = await api_schoolIndexAttendanceStat({});
+    const getAttendanceStat = async (period: string) => {
+      const res = await api_schoolIndexAttendanceStat({
+        period
+      });
       if (res.data) {
         data.studentAttendance = res.data;
       }
     };
 
     /** 练习统计 */
-    const getLessonStat = async () => {
-      const res = await api_schoolIndexLessonStat({});
+    const getLessonStat = async (period: string) => {
+      const res = await api_schoolIndexLessonStat({
+        period
+      });
       if (res.data) {
         data.studentLessons = res.data;
       }
@@ -84,8 +90,8 @@ export default defineComponent({
 
     const init = () => {
       getSchool();
-      getAttendanceStat();
-      getLessonStat();
+      getAttendanceStat('week');
+      getLessonStat('week');
     };
     onMounted(() => {
       init();
@@ -98,14 +104,14 @@ export default defineComponent({
         <DetailData data={data.subjectGradeDistributions} />
         <Attendance
           data={data.studentAttendance}
-          onChange={() => {
-            getAttendanceStat();
+          onChange={(value) => {
+            getAttendanceStat(value);
           }}
         />
         <Practice
           data={data.studentLessons}
-          onChange={() => {
-            getLessonStat();
+          onChange={(value) => {
+            getLessonStat(value);
           }}
         />
       </div>