Эх сурвалжийг харах

报表接口字段结构修改

刘洋 1 жил өмнө
parent
commit
5c69e8135b

+ 19 - 12
src/views/report/sop-analysis/index.vue

@@ -291,7 +291,7 @@
 import { ref, computed, watch, onMounted } from 'vue';
 import TableLoop from '@/components/common/table-loop/index.vue';
 import { useRequest } from 'vue-request';
-import { division } from '@/utils/tool';
+import { division, dateFormat } from '@/utils/tool';
 import {
   sopServiceList,
   warningTop,
@@ -358,20 +358,27 @@ const {
 } = useRequest(supWarningTrend);
 
 const options8 = computed(() => {
-  let res = result8.value || {};
-  let keys = Object.keys(res);
+  let res = result8.value || [];
   let xData = [],
     sData = [];
-  let values = Object.values(res);
-  if (values.length) {
-    xData = values[0].map((item) => item.click_date);
+  if (res.length) {
+    xData = res.map((item) => item.timeStr);
+  }
+  if (res.length && res[0].sopSupplierAvgViewInfo?.length) {
+    res = res.map((item) => {
+      item.sopSupplierAvgViewInfo.sort((a, b) => a.supplierId - b.supplierId);
+      return item;
+    });
+
+    sData = res[0].sopSupplierAvgViewInfo.map((item) => ({
+      name: item.supplierName,
+      data: res.map((v) => {
+        return v.sopSupplierAvgViewInfo.find(
+          (x) => x.supplierId == item.supplierId
+        ).rate;
+      }),
+    }));
   }
-  sData = keys.map((key, index) => {
-    return {
-      name: key,
-      data: values[index].map((item) => item.count),
-    };
-  });
   return createLineOption({ xData, sData });
 });