Browse Source

fix: change evaluate

DESKTOP-USV654P\pc 3 months ago
parent
commit
3533878953
1 changed files with 64 additions and 62 deletions
  1. 64 62
      src/views/course/statistics/components/detail.vue

+ 64 - 62
src/views/course/statistics/components/detail.vue

@@ -133,87 +133,89 @@
       },
     ];
     const dataList: Recordable[] = [];
-    if (resData) {
-      const { rowTitle, columnTitle, data, allClassTime } = JSON.parse(resData);
+    try {
+      if (resData) {
+        const { rowTitle, columnTitle, data, allClassTime } = JSON.parse(resData);
 
-      const totalRow: Recordable = { timeName: '合计课时' };
+        const totalRow: Recordable = { timeName: '合计课时' };
 
-      rowTitle.forEach((item, index) => {
-        columns.push({
-          title: item.scheduleDate,
-          dataIndex: `day${index}`,
-          width: 120,
-          customRender: formatDay,
+        rowTitle.forEach((item, index) => {
+          columns.push({
+            title: item.scheduleDate,
+            dataIndex: `day${index}`,
+            width: 120,
+            customRender: formatDay,
+          });
         });
-      });
 
-      columnTitle.forEach((col) => {
-        let row: Recordable = {
-          timeName: col.type,
-        };
+        columnTitle.forEach((col) => {
+          let row: Recordable = {
+            timeName: col.type,
+          };
 
-        rowTitle.forEach((item, index) => {
-          const filter = data.filter(
-            (f) =>
-              formatToDate(f.scheduleDate, 'MM.DD') === `${item.scheduleDate}` &&
-              f.type === col.type,
-          );
+          rowTitle.forEach((item, index) => {
+            const filter = data.filter(
+              (f) =>
+                formatToDate(f.scheduleDate, 'MM.DD') === `${item.scheduleDate}` &&
+                f.type === col.type,
+            );
 
-          const colName = `day${index}`;
+            const colName = `day${index}`;
 
-          totalRow[colName] = { courseName: item.content };
+            totalRow[colName] = { courseName: item.content };
 
-          row[colName] = {};
-          row['total'] = col.content === 0 ? '' : col.content;
+            row[colName] = {};
+            row['total'] = col.content === 0 ? '' : col.content;
 
-          if (filter.length > 0) {
-            // console.log('filter', filter);
-            const filterItem = filter[0];
-            if (filterItem.content) {
-              const contents = filterItem.content.split(',');
-              const courseName = contents[0];
-              let className = '';
-              if (contents.length > 1) {
-                className = contents[1];
-              }
+            if (filter.length > 0) {
+              // console.log('filter', filter);
+              const filterItem = filter[0];
+              if (filterItem.content) {
+                const contents = filterItem.content.split(',');
+                const courseName = contents[0];
+                let className = '';
+                if (contents.length > 1) {
+                  className = contents[1];
+                }
 
-              row[colName]['courseName'] = courseName;
-              row[colName]['className'] = className;
+                row[colName]['courseName'] = courseName;
+                row[colName]['className'] = className;
 
-              if (filterItem.adjustType === 'course_exchange') {
-                row[colName]['color'] = '#facd91';
-              }
-              if (filterItem.adjustType === 'course_substitute') {
-                row[colName]['color'] = '#ec808d';
+                if (filterItem.adjustType === 'course_exchange') {
+                  row[colName]['color'] = '#facd91';
+                }
+                if (filterItem.adjustType === 'course_substitute') {
+                  row[colName]['color'] = '#ec808d';
+                }
               }
             }
-          }
-        });
-
-        dataList.push(row);
-      });
+          });
 
-      totalRow['total'] = allClassTime;
-      dataList.push(totalRow);
+          dataList.push(row);
+        });
 
-      // console.log('dataList', dataList);
-    }
+        totalRow['total'] = allClassTime;
+        dataList.push(totalRow);
 
-    columns.push({
-      title: '合计(课时)',
-      dataIndex: 'total',
-      width: 90,
-    });
+        // console.log('dataList', dataList);
+      }
 
-    setColumns(columns);
-    setTableData(dataList);
+      columns.push({
+        title: '合计(课时)',
+        dataIndex: 'total',
+        width: 90,
+      });
 
-    setTimeout(() => {
-      redoHeight();
-    }, 500);
+      setColumns(columns);
+      setTableData(dataList);
 
-    setModalProps({ confirmLoading: false });
-    closeFullLoading();
+      setTimeout(() => {
+        redoHeight();
+      }, 500);
+    } finally {
+      setModalProps({ confirmLoading: false });
+      closeFullLoading();
+    }
   };
 
   const formatDay = ({ text }) => {