刘洋 преди 1 година
родител
ревизия
dcdebe1a7a
променени са 2 файла, в които са добавени 15 реда и са изтрити 7 реда
  1. 10 4
      src/components/global/custom-date-picker/index.vue
  2. 5 3
      src/views/report/sop-analysis/index.vue

+ 10 - 4
src/components/global/custom-date-picker/index.vue

@@ -11,6 +11,7 @@
 import { ref, onMounted } from 'vue';
 import dayjs from 'dayjs';
 import { useVModel } from '@vueuse/core';
+import { dateFormat } from '@/utils/tool';
 const props = defineProps({
   modelValue: Array,
 });
@@ -27,13 +28,18 @@ const range = useVModel(props, 'modelValue', emit);
 
 onMounted(() => {
   if (!props.modelValue?.length) {
+    const now = Date.now();
     range.value = [
-      dayjs().startOf('year').format('YYYY-MM-DD'),
-      dayjs().endOf('year').format('YYYY-MM-DD'),
+      // dayjs().startOf('year').format('YYYY-MM-DD'),
+      // dayjs().endOf('year').format('YYYY-MM-DD'),
+      dateFormat(now - 31536000000, 'yyyy-MM-dd'),
+      dateFormat(now, 'yyyy-MM-dd'),
     ];
     emit('timeChange', [
-      dayjs().startOf('year').format('YYYY-MM-DD'),
-      dayjs().endOf('year').format('YYYY-MM-DD'),
+      // dayjs().startOf('year').format('YYYY-MM-DD'),
+      // dayjs().endOf('year').format('YYYY-MM-DD'),
+      dateFormat(now - 31536000000, 'yyyy-MM-dd'),
+      dateFormat(now, 'yyyy-MM-dd'),
     ]);
   }
 });

+ 5 - 3
src/views/report/sop-analysis/index.vue

@@ -366,6 +366,7 @@ const options8 = computed(() => {
   }
   if (res.length && res[0].sopSupplierAvgViewInfo?.length) {
     res = res.map((item) => {
+      item.sopSupplierAvgViewInfo = item.sopSupplierAvgViewInfo || [];
       item.sopSupplierAvgViewInfo.sort((a, b) => a.supplierId - b.supplierId);
       return item;
     });
@@ -373,9 +374,10 @@ const options8 = computed(() => {
     sData = res[0].sopSupplierAvgViewInfo.map((item) => ({
       name: item.supplierName,
       data: res.map((v) => {
-        return v.sopSupplierAvgViewInfo.find(
-          (x) => x.supplierId == item.supplierId
-        ).rate;
+        return (
+          v.sopSupplierAvgViewInfo.find((x) => x.supplierId == item.supplierId)
+            ?.rate || []
+        );
       }),
     }));
   }