From 9b09d13712c0c005891450a3bf4b6d848ec0ff37 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期三, 29 十一月 2023 10:28:24 +0800
Subject: [PATCH] 2023.11.29

---
 pages/mAssessment/gradereport/gradereport.js |  405 +++++++++++++++++++++++++++++++--------------------------
 1 files changed, 223 insertions(+), 182 deletions(-)

diff --git a/pages/mAssessment/gradereport/gradereport.js b/pages/mAssessment/gradereport/gradereport.js
index b076adb..bbfe53a 100644
--- a/pages/mAssessment/gradereport/gradereport.js
+++ b/pages/mAssessment/gradereport/gradereport.js
@@ -1,11 +1,11 @@
 // pages/gradereport/gradereport.js
-import bLoadingStatus from '../../../base/behaviors/bLoadingStatus'
-import bLoadingToast from '../../../base/behaviors/bLoadingToast'
+import bLoadingStatus from '../../../base/behaviors/bLoadingStatus';
+import bLoadingToast from '../../../base/behaviors/bLoadingToast';
 
-const echarts = require("../../../component/ec-canvas/echarts")
-const assessmentService = require("../../../service/assessmentservice")
-const moment = require('../../../utils/moment.min')
-const app = getApp()
+const echarts = require('../../../component/ec-canvas/echarts');
+const assessmentService = require('../../../service/assessmentservice');
+const moment = require('../../../utils/moment.min');
+const app = getApp();
 
 function setOption(chart, data) {
   var option = {
@@ -23,7 +23,7 @@
         // textBorderWidth: 1
       },
       subtextStyle: {
-        fontFamily: "寰蒋闆呴粦",
+        fontFamily: '寰蒋闆呴粦',
         fontSize: 10,
         color: 'black',
         textBorderColor: 'black',
@@ -34,12 +34,12 @@
     color: ['white'],
     tooltip: {},
     legend: {
-      show: false
+      show: false,
     },
     radar: {
       radius: '60%',
       axisName: {
-        color: 'white'
+        color: 'white',
       },
       shape: 'polygon',
       axisLine: {
@@ -47,40 +47,44 @@
         lineStyle: {
           color: 'white',
           type: 'dashed',
-          join: 'round'
-        }
+          join: 'round',
+        },
       },
       axisLabel: {
-        show: false
+        show: false,
       },
       splitLine: {
         show: true,
-        color: 'white'
+        color: 'white',
       },
       splitArea: {
         show: true,
         areaStyle: {
           color: ['#4ca796', '#63c5b3', '#74DFCB', '#76E6D2', '#75ECD7'],
-        }
+        },
       },
-      indicator: data.indicator
+      indicator: data.indicator,
     },
-    series: [{
-      name: "寰楀垎",
-      type: "radar",
-      areaStyle: {
-        color: 'white',
-        opacity: 0.9
+    series: [
+      {
+        name: '寰楀垎',
+        type: 'radar',
+        areaStyle: {
+          color: 'white',
+          opacity: 0.9,
+        },
+        label: {
+          show: false,
+          position: 'inside',
+        },
+        data: [
+          {
+            value: data.value,
+            name: '寰楀垎',
+          },
+        ],
       },
-      label: {
-        show: false,
-        position: 'inside'
-      },
-      data: [{
-        value: data.value,
-        name: "寰楀垎"
-      }]
-    }],
+    ],
     // grid: {
     //   x: 30,
     //   y: 30,
@@ -98,41 +102,52 @@
    */
   data: {
     ec: {
-      lazyLoad: true
+      lazyLoad: true,
     },
     creditText: '----------------------',
-    gradeDetails: [{
-      name: '鑷瘎寰楀垎',
-      detail: '--'
-    }, {
-      name: '椋庨櫓鎺掑悕',
-      detail: '--'
-    }, {
-      name: '椋庨櫓绛夌骇',
-      detail: '--'
-    }, {
-      name: '鑷瘎鍛ㄦ湡',
-      detail: '--'
-    }, {
-      name: '鑷瘎鏃堕棿',
-      detail: '--'
-    }],
+    gradeDetails: [
+      {
+        name: '鑷瘎寰楀垎',
+        detail: '--',
+      },
+      {
+        name: '椋庨櫓鎺掑悕',
+        detail: '--',
+      },
+      {
+        name: '椋庨櫓绛夌骇',
+        detail: '--',
+      },
+      {
+        name: '鑷瘎鍛ㄦ湡',
+        detail: '--',
+      },
+      {
+        name: '鑷瘎鏃堕棿',
+        detail: '--',
+      },
+    ],
 
     //澶卞垎鐨勭被鍨�
     losePointsItem: [],
-    losePoints: [{
-      baseRule: '',
-      name: '',
-      itemlist: [{
-        ruleName: '----',
-        score: '--',
-        remark: '------------'
-      },{
-        ruleName: '----',
-        score: '--',
-        remark: '------------'
-      }]
-    }]
+    losePoints: [
+      {
+        baseRule: '',
+        name: '',
+        itemlist: [
+          {
+            ruleName: '----',
+            score: '--',
+            remark: '------------',
+          },
+          {
+            ruleName: '----',
+            score: '--',
+            remark: '------------',
+          },
+        ],
+      },
+    ],
   },
 
   /**
@@ -141,15 +156,15 @@
   onLoad: function (options) {
     if (options.period) {
       this.setData({
-        period: options.period
-      })
+        period: options.period,
+      });
     } else {
-      let now = moment()
+      let now = moment();
       //鏍规嵁褰撳墠鏃堕棿鑾峰彇璇勪及鍛ㄦ湡YYYY/M-M
-      let period = `${now.year()}/${now.month()+1}-${now.month()+1}`
+      let period = `${now.year()}/${now.month() + 1}-${now.month() + 1}`;
       this.setData({
-        period: period
-      })
+        period: period,
+      });
     }
   },
 
@@ -158,137 +173,163 @@
    */
   onReady: function () {
     this.ecComponent = this.selectComponent('#mychart-dom-radar');
-    this.initChart()
+    this.initChart();
   },
 
   /**
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず
    */
-  onShow: function () {
-
-  },
+  onShow: function () {},
 
   initChart: function () {
     var data = {
       score: '--',
       level: '涓�鑸�',
-      indicator: [{
-        name: "娉曡",
-        max: 100
-      }, {
-        name: "绠$悊",
-        max: 100
-      }, {
-        name: "鎵胯",
-        max: 100
-      }, {
-        name: "瀹堟硶",
-        max: 100
-      }, {
-        name: "璁惧",
-        max: 100
-      }],
-      value: [100, 100, 80, 5, 67, 82]
-    }
-      this.ecComponent.init((canvas, width, height, dpr) => {
-        // 鑾峰彇缁勪欢鐨� canvas銆亀idth銆乭eight 鍚庣殑鍥炶皟鍑芥暟
-        // 鍦ㄨ繖閲屽垵濮嬪寲鍥捐〃
-        const chart = echarts.init(canvas, null, {
-          width: width,
-          height: height,
-          devicePixelRatio: dpr // new
-        });
-        // setOption(chart, data);
-  
-        // 灏嗗浘琛ㄥ疄渚嬬粦瀹氬埌 this 涓婏紝鍙互鍦ㄥ叾浠栨垚鍛樺嚱鏁帮紙濡� dispose锛変腑璁块棶
-        this.chart = chart;
+      indicator: [
+        {
+          name: '娉曡',
+          max: 100,
+        },
+        {
+          name: '绠$悊',
+          max: 100,
+        },
+        {
+          name: '鎵胯',
+          max: 100,
+        },
+        {
+          name: '瀹堟硶',
+          max: 100,
+        },
+        {
+          name: '璁惧',
+          max: 100,
+        },
+      ],
+      value: [100, 100, 80, 5, 67, 82],
+    };
+    this.ecComponent.init((canvas, width, height, dpr) => {
+      // 鑾峰彇缁勪欢鐨� canvas銆亀idth銆乭eight 鍚庣殑鍥炶皟鍑芥暟
+      // 鍦ㄨ繖閲屽垵濮嬪寲鍥捐〃
+      const chart = echarts.init(canvas, null, {
+        width: width,
+        height: height,
+        devicePixelRatio: dpr, // new
+      });
+      // setOption(chart, data);
 
-        this.getDetail()
-  
-        // 娉ㄦ剰杩欓噷涓�瀹氳杩斿洖 chart 瀹炰緥锛屽惁鍒欎細褰卞搷浜嬩欢澶勭悊绛�
-        return chart;
+      // 灏嗗浘琛ㄥ疄渚嬬粦瀹氬埌 this 涓婏紝鍙互鍦ㄥ叾浠栨垚鍛樺嚱鏁帮紙濡� dispose锛変腑璁块棶
+      this.chart = chart;
+
+      this.getDetail();
+
+      // 娉ㄦ剰杩欓噷涓�瀹氳杩斿洖 chart 瀹炰緥锛屽惁鍒欎細褰卞搷浜嬩欢澶勭悊绛�
+      return chart;
     });
   },
 
   getDetail() {
-    var that = this
-    this.setData({loading: true})
-    assessmentService.getDetail(app.globalData.accessToken.userId, this.data.period, {
-      success(data) {
-        let creditText = data.creditText
-        let year = data.period.split('/')[0]
-        let month = data.period.split('/')[1].split('-')[0]
-        let gradeDetails = [{
-          name: '鑷瘎寰楀垎',
-          detail: data.score
-        }, {
-          name: '椋庨櫓鎺掑悕',
-          detail: data.rank
-        }, {
-          name: '椋庨櫓绛夌骇',
-          detail: data.level
-        }, {
-          name: '鑷瘎鍛ㄦ湡',
-          detail: `${year}骞�${month}鏈坄
-        }, {
-          name: '鑷瘎鏃堕棿',
-          detail: moment(data.time).format("YYYY-MM-DD HH:mm")
-        }]
-        let losePointsItem = []
-        let losePoints = []
-        for (const key in data.loseScore) {
-          const s = data.loseScore[key];
-          if (Object.keys(s).length > 0) {
-            losePointsItem.push(key)
-            for (const key1 in s) {
-              const rule = s[key1];
-              let p = {
-                baseRule: key,
-                name: key1,
-                itemlist: []
-              }
-              rule.forEach(r => {
-                // fixme :  姝ゅ鏆傛椂灏嗐�愰楗�戠被鍨嬬殑浼佷笟璇勪及寤鸿鐨勭涓�鍙ヨ瘽鍒犻櫎
-                if (app.globalData.userInfo.extension2  === '1') {
-                  const i = r.third.indexOf('锛�')
-                  r.third = r.third.slice(i+1)
-                  r.third = r.third.replaceAll('浣�', '鎮�')
-                }
-                p.itemlist.push({
-                  ruleName: r.first,
-                  score: r.second,
-                  remark: r.third
-                })
-              });
-              losePoints.push(p)
-            }
-          }
-        }
-        let classPoints = {
-          score: data.score,
-          level: data.level,
-          indicator: [],
-          value: []
-        }
-        data.classScore.forEach(c => {
-          classPoints.indicator.push({
-            name: c.first,
-            max: c.second
-          })
-          classPoints.value.push(c.third)
-        });
+    var that = this;
+    this.setData({ loading: true });
+    assessmentService.getDetail(
+      app.globalData.accessToken.userId,
+      this.data.period,
+      {
+        success(data) {
+          let creditText = data.creditText;
+          let year = data.period.split('/')[0];
+          let month = data.period.split('/')[1].split('-')[0];
+          let gradeDetails = [
+            {
+              name: '鑷瘎寰楀垎',
+              detail: data.score,
+            },
+            {
+              name: '椋庨櫓鎺掑悕',
+              detail: data.rank,
+            },
+            {
+              name: '椋庨櫓绛夌骇',
+              detail: data.level,
+            },
+            {
+              name: '鑷瘎鍛ㄦ湡',
+              detail: `${year}骞�${month}鏈坄,
+            },
+            {
+              name: '鑷瘎鏃堕棿',
+              detail: moment(data.time).format('YYYY-MM-DD HH:mm'),
+            },
+          ];
+          const {
+            pointsItem: losePointsItem,
+            points: losePoints,
+          } = that.parsePoint(data.loseScore);
+          const { pointsItem, points } = that.parsePoint(data.scoring);
+          let classPoints = {
+            score: data.score,
+            level: data.level,
+            indicator: [],
+            value: [],
+          };
+          data.classScore.forEach(c => {
+            classPoints.indicator.push({
+              name: c.first,
+              max: c.second,
+            });
+            classPoints.value.push(c.third);
+          });
 
-        that.setData({
-          creditText: creditText,
-          gradeDetails: gradeDetails,
-          losePoints: losePoints,
-          losePointsItem: losePointsItem
-        })
-        setOption(that.chart, classPoints)
+          that.setData({
+            creditText,
+            gradeDetails,
+            losePoints,
+            losePointsItem,
+            pointsItem,
+            points,
+          });
+          setOption(that.chart, classPoints);
+        },
+        complete() {
+          that.setData({ loading: false });
+        },
       },
-      complete() {
-        that.setData({loading: false})
+    );
+  },
+
+  parsePoint(itemList) {
+    const pointsItem = [];
+    const points = [];
+    for (const key in itemList) {
+      const s = itemList[key];
+      if (Object.keys(s).length > 0) {
+        pointsItem.push(key);
+        for (const key1 in s) {
+          const rule = s[key1];
+          let p = {
+            baseRule: key,
+            name: key1,
+            itemlist: [],
+          };
+          rule.forEach(r => {
+            // fixme :  姝ゅ鏆傛椂灏嗐�愰楗�戠被鍨嬬殑浼佷笟璇勪及寤鸿鐨勭涓�鍙ヨ瘽鍒犻櫎
+            if (app.globalData.userInfo.extension2 === '1') {
+              const i = r.third.indexOf('锛�');
+              r.third = r.third.slice(i + 1);
+              r.third = r.third.replaceAll('浣�', '鎮�');
+            }
+            p.itemlist.push({
+              ruleName: r.first,
+              score: r.second,
+              remark: r.third,
+            });
+          });
+          points.push(p);
+        }
       }
-    })
-  }
-})
\ No newline at end of file
+    }
+
+    return { pointsItem, points };
+  },
+});

--
Gitblit v1.9.3