Procházet zdrojové kódy

日常迭代

master
dong před 6 měsíci
rodič
revize
4093f66679

+ 48
- 0
src/api/home/Multisite.ts Zobrazit soubor

@@ -690,3 +690,51 @@ export const priceanalysisURL = (params: {}, body: FormData) => {
690 690
     }
691 691
   });
692 692
 };
693
+// 国网报表按日
694
+export const stategriddayURL = (params: {}, id: any) => {
695
+  return http.post<Station.summary>(`/stategrid/singlebetween/${id}/day`, qs.stringify(params));
696
+};
697
+// 国网报表按月份
698
+export const stategridmonthURL = (params: {}, id: any) => {
699
+  return http.post<Station.summary>(`/stategrid/singlebetween/${id}/month`, qs.stringify(params));
700
+};
701
+// 国网报表按年
702
+export const stategridyearURL = (params: {}, id: any) => {
703
+  return http.post<Station.summary>(`/stategrid/singlebetween/${id}/year`, qs.stringify(params));
704
+};
705
+// 导出电量报表汇总-按日
706
+export const selectstartegridbetweenexcelday = (params: {}, id: any) => {
707
+  return http.post<other.Data>(`/stategrid/${id}/selectstategridexcelsinglebetweenday`, qs.stringify(params));
708
+};
709
+// 导出电量报表报表汇总-按月
710
+export const summaryearmonthEXcelURL = (params: {}, id: any) => {
711
+  return http.post<other.Data>(`/stategrid/${id}/selectstategridexcelsinglebetweenmonth`, qs.stringify(params));
712
+};
713
+// 导出电量报表报表汇总-按年
714
+export const summaryearEXcel = (params: {}, id: any) => {
715
+  return http.post<other.Data>(`/stategrid/${id}/selectstategridexcelsinglebetweenyear`, qs.stringify(params));
716
+};
717
+// 国网收益报表-汇总_日表
718
+export const getstategriddayURL = (params: {}, id: any) => {
719
+  return http.post<Station.summary>(`/stategrid/profit/${id}/day`, qs.stringify(params));
720
+};
721
+// 国网收益报表-汇总_月表
722
+export const getstategridmonthURL = (params: {}, id: any) => {
723
+  return http.post<Station.summary>(`/stategrid/profit/${id}/month`, qs.stringify(params));
724
+};
725
+// 国网收益报表-汇总_年表
726
+export const getstategridyearURL = (params: {}, id: any) => {
727
+  return http.post<Station.summary>(`/stategrid/profit/${id}/year`, qs.stringify(params));
728
+};
729
+// 国网导出收益报表汇总-按日
730
+export const stategridEXcelday = (params: {}, id: any) => {
731
+  return http.post<other.Data>(`/stategrid/${id}/selectstartegridprofitexceldaysingle`, qs.stringify(params));
732
+};
733
+// 国网导出收益报表报表汇总-按月
734
+export const stategridEXcelmonth = (params: {}, id: any) => {
735
+  return http.post<other.Data>(`/stategrid/${id}/selectstartegridprofitexcelmonthsingle`, qs.stringify(params));
736
+};
737
+// 国网导出收益报表报表汇总-按年
738
+export const stategridEXcelyear = (params: {}, id: any) => {
739
+  return http.post<other.Data>(`/stategrid/${id}/selectstartegridprofitexcelyearsingle`, qs.stringify(params));
740
+};

+ 2
- 0
src/languages/modules/en.ts Zobrazit soubor

@@ -323,6 +323,7 @@ export default {
323 323
       "The site summary displays all site report data, supporting daily display for 31 days and monthly display of data within one year.",
324 324
     SiteSummary: "Site Summary",
325 325
     Singlereport: "Single site report",
326
+    GridReport: "State Grid Report",
326 327
     timeframe: "time frame",
327 328
     reporttype: "report type",
328 329
     selectsite: "select site",
@@ -352,6 +353,7 @@ export default {
352 353
       "The site summary displays all site report data, supporting daily display for 31 days and monthly display of data within one year.",
353 354
     SiteSummary: "Summary",
354 355
     Singlereport: "Single site report",
356
+    StateGrid: "state grid",
355 357
     StartTime: "Start Time",
356 358
     EndTime: "End Time",
357 359
     Query: "Query",

+ 2
- 0
src/languages/modules/zh.ts Zobrazit soubor

@@ -320,6 +320,7 @@ export default {
320 320
     summary: "站点汇总展示所有站点报表数据,支持按日展示31天,按月展示一年内数据。",
321 321
     SiteSummary: "站点汇总",
322 322
     Singlereport: "单站报表",
323
+    GridReport: "国网报表",
323 324
     timeframe: "时间范围",
324 325
     reporttype: "报表类型",
325 326
     selectsite: "选择站点",
@@ -348,6 +349,7 @@ export default {
348 349
     summary: " 站点汇总展示所有站点报表数据,支持按日展示31天,按月展示一年内数据。",
349 350
     SiteSummary: "站点汇总",
350 351
     Singlereport: "单站报表",
352
+    StateGrid: "国网报表",
351 353
     StartTime: "开始时间",
352 354
     EndTime: "结束时间",
353 355
     Query: "查询",

+ 1
- 1
src/views/Administration/addition.vue Zobrazit soubor

@@ -75,7 +75,7 @@
75 75
                     </el-select>
76 76
                   </template>
77 77
                 </el-table-column>
78
-                <el-table-column prop="buyPrice" :label="$t('Administration.Endperiod')">
78
+                <el-table-column prop="buyPrice" :label="$t('Administration.Purchase')">
79 79
                   <template #default="scope">
80 80
                     <el-input v-model="scope.row.buyPrice" type="number"></el-input>
81 81
                   </template>

+ 2
- 2
src/views/Administration/index.vue Zobrazit soubor

@@ -851,6 +851,6 @@ onMounted(() => {
851 851
 <style scoped lang="scss">
852 852
 @import "./index.scss";
853 853
 </style>
854
-<!--
855
-  script
854
+<!-- 
855
+  
856 856
  -->

+ 339
- 3
src/views/incomeforms/index.vue Zobrazit soubor

@@ -264,11 +264,120 @@
264 264
             </div>
265 265
           </div>
266 266
         </el-tab-pane>
267
+        <el-tab-pane :label="$t('incomeforms.StateGrid')" name="国网报表" v-if="BUTTONS.stategrid">
268
+          <div class="tabdiv">
269
+            <div class="tabpanesite">
270
+              <div class="tabpane">
271
+                <div class="tabpane_1">{{ $t("incomeforms.selectsite") }}:</div>
272
+                <el-select
273
+                  v-model="stategridSite"
274
+                  :placeholder="$t('incomeforms.selectsite')"
275
+                  size="large"
276
+                  style="width: 240px"
277
+                  @change="postemsDevice"
278
+                >
279
+                  <el-option v-for="item in cities" :key="item.id" :label="item.stationName" :value="item.id" />
280
+                </el-select>
281
+                &ensp;&ensp;&ensp;&ensp; &ensp;&ensp;
282
+                <div>时间范围:</div>
283
+                <div class="tabpane1">
284
+                  <el-date-picker
285
+                    v-if="timetype != 'year'"
286
+                    v-model="StateGridtime"
287
+                    :type="timetype"
288
+                    :shortcuts="shortcuts"
289
+                    :format="format"
290
+                    :value-format="format"
291
+                    :start-placeholder="$t('incomeforms.StartTime')"
292
+                    :end-placeholder="$t('incomeforms.EndTime')"
293
+                    size="large"
294
+                    :disabled-date="pickerOptions"
295
+                  />
296
+                  <el-date-picker
297
+                    v-if="timetype == 'year'"
298
+                    v-model="StateGridtime"
299
+                    type="yearrange"
300
+                    :format="format"
301
+                    :value-format="format"
302
+                    :shortcuts="shortcuts"
303
+                    :start-placeholder="$t('incomeforms.StartTime')"
304
+                    :end-placeholder="$t('incomeforms.EndTime')"
305
+                    size="large"
306
+                    :disabled-date="pickerOptions"
307
+                  />
308
+                  <!-- <YearPicker
309
+                    v-if="timetype == 'year'"
310
+                    style="width: 300px"
311
+                    ref="statisticPicker"
312
+                    :label-width="50"
313
+                    :init-year="dateValue"
314
+                    :start-year1="timepicker[0]"
315
+                    :end-year2="timepicker[1]"
316
+                    @update-time-range="updateStatisticYear"
317
+                  /> -->
318
+                  <el-select
319
+                    v-model="stategridvalue"
320
+                    placeholder="选择日期"
321
+                    size="large"
322
+                    style="width: 80px"
323
+                    @change="getSummarygrid"
324
+                  >
325
+                    <el-option v-for="item in daymonthyear" :key="item.value" :label="item.label" :value="item.value" />
326
+                  </el-select>
327
+                </div>
328
+                &ensp;&ensp;
329
+                <el-button type="primary" size="large" color="#0052d9" @click="gatSummarygrid">
330
+                  {{ $t("incomeforms.Query") }}
331
+                </el-button>
332
+                <el-button size="large" @click="onstategridreset">{{ $t("incomeforms.Reset") }} </el-button>
333
+                <!-- <el-button v-if="BUTTONS.export" size="large" @click="onexport" type="primary" plain>导出</el-button> -->
334
+              </div>
335
+
336
+              <div v-if="BUTTONS.export" class="exportright">
337
+                <el-dropdown trigger="click" :hide-on-click="false" @visible-change="onclose">
338
+                  <el-button size="large" type="primary" plain>{{ $t("incomeforms.export") }}</el-button>
339
+                  <template #dropdown>
340
+                    <el-dropdown-menu v-for="(item, index) in columnList" :key="index">
341
+                      <el-dropdown-item>
342
+                        <el-checkbox @change="oncheck" v-model="item.ifcolumn" :label="item.label" size="large" />
343
+                        <template v-if="item.children">
344
+                          <template v-for="(items, i) in item.children" :key="i">
345
+                            <el-checkbox @change="onchildren" v-model="items.ifcolumn" :label="items.label" size="large" />
346
+                          </template>
347
+                        </template>
348
+                      </el-dropdown-item>
349
+                    </el-dropdown-menu>
350
+                    <div class="dropdown">
351
+                      <el-button @click="stategridexport" type="primary" plain>{{ $t("incomeforms.export") }}</el-button>
352
+                    </div>
353
+                  </template>
354
+                </el-dropdown>
355
+              </div>
356
+            </div>
357
+            &ensp;&ensp;
358
+
359
+            <el-table :data="tableData.list" style="width: 100%" align="center" :show-overflow-tooltip="true">
360
+              <!-- <el-table-column type="selection" width="55" /> -->
361
+              <template v-for="(item, index) in columnList" :key="index">
362
+                <el-table-column v-if="item.ifcolumn" :label="item.label" :prop="item.prop" align="center">
363
+                  <template v-if="item.children">
364
+                    <template v-for="(items, i) in item.children" :key="i">
365
+                      <el-table-column v-if="items.ifcolumn" :label="items.label" :prop="items.prop" align="center">
366
+                      </el-table-column>
367
+                    </template>
368
+                  </template>
369
+                </el-table-column>
370
+              </template>
371
+            </el-table>
372
+          </div>
373
+        </el-tab-pane>
267 374
       </el-tabs>
268 375
     </el-card>
269 376
   </div>
270 377
 </template>
271
-<!--    -->
378
+<!-- 
379
+     
380
+  -->
272 381
 <script setup lang="ts">
273 382
 import { onMounted, Ref, ref } from "vue";
274 383
 import {
@@ -284,7 +393,13 @@ import {
284 393
   reportsummaryyearEXcel,
285 394
   reportsingleExcel,
286 395
   singlemonthExcel,
287
-  singleyeaeExcel
396
+  singleyeaeExcel,
397
+  getstategriddayURL,
398
+  getstategridmonthURL,
399
+  getstategridyearURL,
400
+  stategridEXcelday,
401
+  stategridEXcelmonth,
402
+  stategridEXcelyear
288 403
 } from "@/api/home/Multisite";
289 404
 import { other, Station } from "@/api/interface";
290 405
 import { useAuthButtons } from "@/hooks/useAuthButtons";
@@ -461,15 +576,23 @@ const activeName = ref("站点汇总");
461 576
 
462 577
 const handleClick = async (val: any) => {
463 578
   activeName.value = val.props.name;
579
+  console.log(val.props.name);
580
+
464 581
   if (val.props.name == "站点汇总") {
465 582
     getdaymonthyear(1);
466 583
     gatSummary();
584
+  } else if (val.props.name == "国网报表") {
585
+    await poststationstationName();
586
+
587
+    await getSummarygrid(1);
588
+    await gatSummarygrid();
467 589
   } else {
468 590
     await poststationstationName();
469 591
     await onreportforms(2);
470 592
   }
471 593
 };
472 594
 const timepicker: Ref<any> = ref([]);
595
+const StateGridtime: Ref<any> = ref([]);
473 596
 
474 597
 // 禁用日期
475 598
 const pickerOptions = (time: { getTime: (arg0: Date) => number }) => {
@@ -481,6 +604,7 @@ const pickerOptions = (time: { getTime: (arg0: Date) => number }) => {
481 604
 // };
482 605
 // 选择日期
483 606
 const daymonthyearvalue = ref(1);
607
+const stategridvalue = ref(1); //国网报表
484 608
 
485 609
 const shortcuts = ref([
486 610
   {
@@ -637,6 +761,116 @@ const getdaymonthyear = async (value: any) => {
637 761
     // getreportpoweryear();
638 762
   }
639 763
 };
764
+// 国网报表
765
+const getSummarygrid = async (value: any) => {
766
+  stategridvalue.value = value;
767
+  if (value == 1) {
768
+    timetype.value = "daterange";
769
+    format.value = "YYYY-MM-DD";
770
+    shortcuts.value = [
771
+      {
772
+        text: "过去7天",
773
+        value: () => {
774
+          const end = new Date();
775
+          const start = new Date();
776
+          start.setDate(start.getDate() - 7);
777
+          return [start, end];
778
+        }
779
+      },
780
+      {
781
+        text: "过去1个月",
782
+        value: () => {
783
+          const end = new Date();
784
+          const start = new Date();
785
+          start.setMonth(start.getMonth() - 1);
786
+          return [start, end];
787
+        }
788
+      },
789
+      {
790
+        text: "过去3个月",
791
+        value: () => {
792
+          const end = new Date();
793
+          const start = new Date();
794
+          start.setMonth(start.getMonth() - 3);
795
+          return [start, end];
796
+        }
797
+      }
798
+    ];
799
+    const today = new Date();
800
+    const currentDate = today.toISOString().split("T")[0];
801
+    StateGridtime.value = [currentDate, currentDate];
802
+    // getreportpowerday();
803
+  } else if (value == 2) {
804
+    const today = new Date();
805
+    const currentDate = today.toISOString().split("T")[0];
806
+    const currentYearMonth = currentDate.slice(0, 7);
807
+
808
+    StateGridtime.value = [currentYearMonth, currentYearMonth];
809
+    // getreportpoweryearMonth();
810
+    timetype.value = "monthrange";
811
+    format.value = "YYYY-MM";
812
+
813
+    shortcuts.value = [
814
+      {
815
+        text: "本月",
816
+        value: () => {
817
+          return [new Date(), new Date()];
818
+        }
819
+      },
820
+      {
821
+        text: "过去6个月",
822
+        value: () => {
823
+          const end = new Date();
824
+          const start = new Date();
825
+          start.setMonth(start.getMonth() - 6);
826
+          return [start, end];
827
+        }
828
+      },
829
+      {
830
+        text: "今年",
831
+        value: () => {
832
+          const end = new Date();
833
+          const start = new Date(new Date().getFullYear(), 0);
834
+          return [start, end];
835
+        }
836
+      }
837
+    ];
838
+  } else {
839
+    const today = new Date();
840
+    const currentDate = today.toISOString().split("T")[0];
841
+    // 获取去年同月的日期
842
+    StateGridtime.value = [currentDate.substring(0, 4), currentDate.substring(0, 4)];
843
+    console.log(StateGridtime.value);
844
+    timetype.value = "yearrange";
845
+    format.value = "YYYY";
846
+
847
+    shortcuts.value = [
848
+      {
849
+        text: "今年",
850
+        value: () => {
851
+          return [new Date(), new Date()];
852
+        }
853
+      },
854
+      {
855
+        text: "过去1年",
856
+        value: () => {
857
+          const end = new Date();
858
+          const start = new Date(new Date().setFullYear(new Date().getFullYear() - 1));
859
+          return [start, end];
860
+        }
861
+      },
862
+      {
863
+        text: "过去2年",
864
+        value: () => {
865
+          const start = new Date();
866
+          const end = new Date(new Date().setFullYear(new Date().getFullYear() - 2));
867
+          return [start, end];
868
+        }
869
+      }
870
+    ];
871
+    // getreportpoweryear();
872
+  }
873
+};
640 874
 
641 875
 // 查询
642 876
 const gatSummary = () => {
@@ -648,10 +882,24 @@ const gatSummary = () => {
648 882
     getreportpoweryear();
649 883
   }
650 884
 };
885
+// 国网报表查询
886
+const gatSummarygrid = () => {
887
+  if (stategridvalue.value == 1) {
888
+    getstategridday();
889
+  } else if (stategridvalue.value == 2) {
890
+    getstategridmonth();
891
+  } else if (stategridvalue.value == 3) {
892
+    getstategridyear();
893
+  }
894
+};
651 895
 // 重置
652 896
 const onreset = () => {
653 897
   getdaymonthyear(1);
654 898
 };
899
+// 重置
900
+const onstategridreset = () => {
901
+  getSummarygrid(1);
902
+};
655 903
 const onclose = (val: boolean) => {
656 904
   console.log(val);
657 905
   setTimeout(() => {
@@ -822,6 +1070,54 @@ const onexport = async () => {
822 1070
     downloadxlsx(timepicker.value[0] + "-" + timepicker.value[1], data);
823 1071
   }
824 1072
 };
1073
+// 国网导出
1074
+const stategridexport = async () => {
1075
+  let obj: string[] = []; // 假设 prop 是 string 类型,如果不是,请根据实际类型修改
1076
+
1077
+  if (columnList.value) {
1078
+    for (const column of columnList.value) {
1079
+      if (column?.ifcolumn) {
1080
+        if (column.prop) {
1081
+          obj.push(column.prop);
1082
+        }
1083
+        if (column.children) {
1084
+          for (const child of column.children) {
1085
+            if (child?.ifcolumn && child.prop) {
1086
+              obj.push(child.prop);
1087
+            }
1088
+          }
1089
+        }
1090
+      }
1091
+    }
1092
+  }
1093
+
1094
+  const jsonString = obj.join(",");
1095
+  if (stategridvalue.value == 1) {
1096
+    let obj = {
1097
+      excel: jsonString,
1098
+      startDate: timepicker.value[0],
1099
+      endDate: timepicker.value[1]
1100
+    };
1101
+    const { data } = await stategridEXcelday(obj, stategridSite.value);
1102
+    downloadxlsx(timepicker.value[0], data);
1103
+  } else if (stategridvalue.value == 2) {
1104
+    let obj = {
1105
+      excel: jsonString,
1106
+      startYearMonth: timepicker.value[0],
1107
+      endYearMonth: timepicker.value[1]
1108
+    };
1109
+    const { data } = await stategridEXcelmonth(obj, stategridSite.value);
1110
+    downloadxlsx(timepicker.value[0], data);
1111
+  } else if (stategridvalue.value == 3) {
1112
+    let obj = {
1113
+      excel: jsonString,
1114
+      startYear: timepicker.value[0],
1115
+      endYear: timepicker.value[1]
1116
+    };
1117
+    const { data } = await stategridEXcelyear(obj, stategridSite.value);
1118
+    downloadxlsx(timepicker.value[0] + "-" + timepicker.value[1], data);
1119
+  }
1120
+};
825 1121
 const downloadxlsx = (item: string, data: other.Data) => {
826 1122
   console.log(item, data);
827 1123
 
@@ -830,7 +1126,7 @@ const downloadxlsx = (item: string, data: other.Data) => {
830 1126
   const hours = formatTime(date.getHours());
831 1127
   const minutes = formatTime(date.getMinutes());
832 1128
   const seconds = formatTime(date.getSeconds());
833
-  let fileName = `${item} ${hours}:${minutes}:${seconds}电量报表.xlsx`;
1129
+  let fileName = `${item} ${hours}:${minutes}:${seconds}${activeName.value == "站点汇总" ? "收益报表" : "国网收益报表"}.xlsx`;
834 1130
   fetch(fileUrl)
835 1131
     .then(response => response.blob())
836 1132
     .then(blob => {
@@ -906,6 +1202,42 @@ const getreportpoweryear = async () => {
906 1202
   data.list.push(data.total);
907 1203
   tableData.value = data;
908 1204
 };
1205
+const gridtableData = ref(); // 国网
1206
+
1207
+// 国网日
1208
+const getstategridday = async () => {
1209
+  let obj = {
1210
+    startDate: timepicker.value[0],
1211
+    endDate: timepicker.value[1]
1212
+  };
1213
+  const { data } = await getstategriddayURL(obj, Singlevalue.value);
1214
+  data.total.ymdHour = "总计";
1215
+  data.list.push(data.total);
1216
+  gridtableData.value = data;
1217
+};
1218
+// 国网月份
1219
+const getstategridmonth = async () => {
1220
+  let obj = {
1221
+    startYearMonth: timepicker.value[0],
1222
+    endYearMonth: timepicker.value[1]
1223
+  };
1224
+  const { data } = await getstategridmonthURL(obj, Singlevalue.value);
1225
+  data.total.ymdHour = "总计";
1226
+  data.list.push(data.total);
1227
+  gridtableData.value = data;
1228
+};
1229
+// 国网年份
1230
+
1231
+const getstategridyear = async () => {
1232
+  let obj = {
1233
+    startYear: timepicker.value[0],
1234
+    endYear: timepicker.value[1]
1235
+  };
1236
+  const { data } = await getstategridyearURL(obj, Singlevalue.value);
1237
+  data.total.ymdHour = "总计";
1238
+  data.list.push(data.total);
1239
+  gridtableData.value = data;
1240
+};
909 1241
 
910 1242
 const reportformsindex = ref(2);
911 1243
 const pickertype: Ref<any> = ref("daterange");
@@ -1021,10 +1353,14 @@ const onreportforms = (val: any) => {
1021 1353
 
1022 1354
 // 选择站点
1023 1355
 const Singlevalue = ref("");
1356
+const stategridSite = ref(""); // 国网
1357
+
1024 1358
 const cities: Ref<Station.todo[]> = ref([]);
1025 1359
 const poststationstationName = async () => {
1026 1360
   const { data } = await stationstationName({});
1027 1361
   Singlevalue.value = data[0].id;
1362
+  stategridSite.value = data[0].id;
1363
+
1028 1364
   cities.value = data;
1029 1365
   // getsingleincomeday();
1030 1366
 };

+ 380
- 3
src/views/reportforms/index.vue Zobrazit soubor

@@ -369,13 +369,136 @@
369 369
             </el-table>
370 370
           </div>
371 371
         </el-tab-pane>
372
+        <el-tab-pane :label="$t('reportforms.GridReport')" name="国网报表" v-if="BUTTONS.stategrid">
373
+          <div class="tabdiv">
374
+            <div class="tabpanesite">
375
+              <div class="tabpane">
376
+                <div class="tabpane_1">{{ $t("reportforms.selectsite") }}:</div>
377
+                <el-select
378
+                  v-model="stategridSite"
379
+                  :placeholder="$t('reportforms.selectsite')"
380
+                  size="large"
381
+                  style="width: 240px"
382
+                  @change="postemsDevice"
383
+                >
384
+                  <el-option v-for="item in cities" :key="item.id" :label="item.stationName" :value="item.id" />
385
+                </el-select>
386
+                &ensp;&ensp;&ensp;&ensp; &ensp;&ensp;
387
+                <div>{{ $t("reportforms.timeframe") }}:</div>
388
+                <div class="tabpane1">
389
+                  <!-- year -->
390
+                  <el-date-picker
391
+                    v-if="timetype != 'year'"
392
+                    v-model="StateGrid"
393
+                    :type="timetype"
394
+                    :shortcuts="shortcuts"
395
+                    :format="format"
396
+                    :value-format="format"
397
+                    start-placeholder="开始时间"
398
+                    end-placeholder="结束时间"
399
+                    size="large"
400
+                    :disabled-date="pickerOptions"
401
+                  />
402
+                  <el-date-picker
403
+                    v-if="timetype == 'year'"
404
+                    v-model="StateGrid"
405
+                    type="yearrange"
406
+                    :format="format"
407
+                    :value-format="format"
408
+                    :shortcuts="shortcuts"
409
+                    start-placeholder="开始时间"
410
+                    end-placeholder="结束时间"
411
+                    size="large"
412
+                    :disabled-date="pickerOptions"
413
+                  />
414
+                  <!-- <YearPicker
415
+                    v-if="timetype == 'year'"
416
+                    style="width: 300px"
417
+                    ref="statisticPicker"
418
+                    :label-width="50"
419
+                    :shortcuts="shortcuts"
420
+                    :init-year="dateValue"
421
+                    :start-year1="timepicker[0]"
422
+                    :end-year2="timepicker[1]"
423
+                    @update-time-range="updateStatisticYear"
424
+                  /> -->
425
+                  <el-select
426
+                    v-model="StateGriddate"
427
+                    placeholder="选择日期"
428
+                    size="large"
429
+                    style="width: 80px"
430
+                    @change="StateGridchange"
431
+                  >
432
+                    <el-option v-for="item in daymonthyear" :key="item.value" :label="item.label" :value="item.value" />
433
+                  </el-select>
434
+                </div>
435
+                &ensp;&ensp;
436
+                <el-button type="primary" size="large" color="#0052d9" @click="gatstategridSummary">{{
437
+                  $t("reportforms.Query")
438
+                }}</el-button>
439
+                <el-button size="large" @click="onstategridreset">{{ $t("reportforms.Reset") }}</el-button>
440
+              </div>
441
+
442
+              <div class="exportright" v-if="BUTTONS.export">
443
+                <el-dropdown trigger="click" :hide-on-click="false" @visible-change="onclose">
444
+                  <el-button size="large" type="primary" plain>{{ $t("reportforms.export") }}</el-button>
445
+                  <template #dropdown>
446
+                    <el-dropdown-menu v-for="(item, index) in columnList" :key="index">
447
+                      <el-dropdown-item>
448
+                        <el-checkbox @change="oncheck" v-model="item.ifcolumn" :label="item.label" size="large" />
449
+                        <template v-if="item.children">
450
+                          <template v-for="(items, i) in item.children" :key="i">
451
+                            <el-checkbox @change="onchildren" v-model="items.ifcolumn" :label="items.label" size="large" />
452
+                          </template>
453
+                        </template>
454
+                      </el-dropdown-item>
455
+                    </el-dropdown-menu>
456
+                    <div class="dropdown">
457
+                      <el-button @click="onexportstategrid" type="primary" plain>{{ $t("reportforms.export") }}</el-button>
458
+                    </div>
459
+                  </template>
460
+                </el-dropdown>
461
+              </div>
462
+            </div>
463
+            &ensp;&ensp;
464
+            <el-table :data="GridReportdata.list" style="width: 100%" align="center" :show-overflow-tooltip="true">
465
+              <!-- <el-table-column type="selection" width="55" /> -->
466
+              <template v-for="(item, index) in columnList" :key="index">
467
+                <el-table-column v-if="item.ifcolumn" :label="item.label" :prop="item.prop" align="center">
468
+                  <template v-if="item.children">
469
+                    <template v-for="(items, i) in item.children" :key="i">
470
+                      <el-table-column v-if="items.ifcolumn" :label="items.label" :prop="items.prop" align="center">
471
+                      </el-table-column>
472
+                    </template>
473
+                  </template>
474
+                </el-table-column>
475
+              </template>
476
+              <!-- <el-table-column prop="stationName" label="站点名称" width="150" align="center" />
477
+              <el-table-column label="充电量(kWh)" align="center">
478
+                <el-table-column prop="chargeSharp" label="尖" align="center" />
479
+                <el-table-column prop="chargePeak" label="峰" align="center" />
480
+                <el-table-column prop="chargeShoulder" label="平" align="center" />
481
+                <el-table-column prop="chargeValley" label="谷" align="center" />
482
+                <el-table-column prop="chargeTotal" label="总" align="center" />
483
+              </el-table-column>
484
+              <el-table-column label="放电量(kWh)" align="center">
485
+                <el-table-column prop="dischargeSharp" label="尖" align="center" />
486
+                <el-table-column prop="dischargePeak" label="峰" align="center" />
487
+                <el-table-column prop="dischargeShoulder" label="平" align="center" />
488
+                <el-table-column prop="dischargeValley" label="谷" align="center" />
489
+                <el-table-column prop="dischargeTotal" label="总" align="center" />
490
+              </el-table-column>
491
+              <el-table-column prop="overallEfficiency" label="综合效率(%)" width="150" align="center" /> -->
492
+            </el-table>
493
+          </div>
494
+        </el-tab-pane>
372 495
       </el-tabs>
373 496
     </el-card>
374 497
   </div>
375 498
 </template>
376 499
 <!--   
377
-
378
- -->
500
+     
501
+-->
379 502
 <script setup lang="ts">
380 503
 import { onMounted, Ref, ref } from "vue";
381 504
 import {
@@ -396,7 +519,13 @@ import {
396 519
   betweenbiaoExcel,
397 520
   betweenyearMonthExcel,
398 521
   betweenyearExcel,
399
-  selectemssytemNameURL
522
+  selectemssytemNameURL,
523
+  stategriddayURL,
524
+  stategridmonthURL,
525
+  stategridyearURL,
526
+  selectstartegridbetweenexcelday,
527
+  summaryearmonthEXcelURL,
528
+  summaryearEXcel
400 529
 } from "@/api/home/Multisite";
401 530
 import { useAuthButtons } from "@/hooks/useAuthButtons";
402 531
 const { BUTTONS } = useAuthButtons();
@@ -559,12 +688,17 @@ const singlecolumnList = ref([
559 688
 const currentDate = ref();
560 689
 const activeName = ref("站点汇总");
561 690
 const timepicker: Ref<any> = ref([]);
691
+const StateGrid: Ref<any> = ref([]); // 国网报表
562 692
 //year daterange
563 693
 const timetype: Ref<any> = ref("daterange");
564 694
 const handleClick = async (val: any) => {
565 695
   if (val.props.name == "站点汇总") {
566 696
     getdaymonthyear(1);
567 697
     gatSummary();
698
+  } else if (val.props.name == "国网报表") {
699
+    await poststationstationName();
700
+    await StateGridchange(1);
701
+    await gatstategridSummary();
568 702
   } else {
569 703
     await poststationstationName();
570 704
     await onreportforms(2);
@@ -584,6 +718,7 @@ const pickerOptions = (time: { getTime: (arg0: Date) => number }) => {
584 718
 // 选择日期
585 719
 
586 720
 const daymonthyearvalue = ref(1);
721
+const StateGriddate = ref(1); // 国网报表
587 722
 const daymonthyear = ref([
588 723
   {
589 724
     value: 1,
@@ -737,6 +872,115 @@ const getdaymonthyear = async (value: any) => {
737 872
     // getreportpoweryear();
738 873
   }
739 874
 };
875
+const StateGridchange = async (value: any) => {
876
+  StateGriddate.value = value;
877
+  if (value == 1) {
878
+    timetype.value = "daterange";
879
+    format.value = "YYYY-MM-DD";
880
+    shortcuts.value = [
881
+      {
882
+        text: "过去7天",
883
+        value: () => {
884
+          const end = new Date();
885
+          const start = new Date();
886
+          start.setDate(start.getDate() - 7);
887
+          return [start, end];
888
+        }
889
+      },
890
+      {
891
+        text: "过去1个月",
892
+        value: () => {
893
+          const end = new Date();
894
+          const start = new Date();
895
+          start.setMonth(start.getMonth() - 1);
896
+          return [start, end];
897
+        }
898
+      },
899
+      {
900
+        text: "过去3个月",
901
+        value: () => {
902
+          const end = new Date();
903
+          const start = new Date();
904
+          start.setMonth(start.getMonth() - 3);
905
+          return [start, end];
906
+        }
907
+      }
908
+    ];
909
+    const today = new Date();
910
+    const currentDate = today.toISOString().split("T")[0];
911
+    StateGrid.value = [currentDate, currentDate];
912
+    // getreportpowerday();
913
+  } else if (value == 2) {
914
+    const today = new Date();
915
+    const currentDate = today.toISOString().split("T")[0];
916
+    const currentYearMonth = currentDate.slice(0, 7);
917
+
918
+    StateGrid.value = [currentYearMonth, currentYearMonth];
919
+    // getreportpoweryearMonth();
920
+    timetype.value = "monthrange";
921
+    format.value = "YYYY-MM";
922
+
923
+    shortcuts.value = [
924
+      {
925
+        text: "本月",
926
+        value: () => {
927
+          return [new Date(), new Date()];
928
+        }
929
+      },
930
+      {
931
+        text: "过去6个月",
932
+        value: () => {
933
+          const end = new Date();
934
+          const start = new Date();
935
+          start.setMonth(start.getMonth() - 6);
936
+          return [start, end];
937
+        }
938
+      },
939
+      {
940
+        text: "今年",
941
+        value: () => {
942
+          const end = new Date();
943
+          const start = new Date(new Date().getFullYear(), 0);
944
+          return [start, end];
945
+        }
946
+      }
947
+    ];
948
+  } else {
949
+    const today = new Date();
950
+    const currentDate = today.toISOString().split("T")[0];
951
+    // 获取去年同月的日期
952
+    StateGrid.value = [currentDate.substring(0, 4), currentDate.substring(0, 4)];
953
+    console.log(StateGrid.value);
954
+    timetype.value = "yearrange";
955
+    format.value = "YYYY";
956
+
957
+    shortcuts.value = [
958
+      {
959
+        text: "今年",
960
+        value: () => {
961
+          return [new Date(), new Date()];
962
+        }
963
+      },
964
+      {
965
+        text: "过去1年",
966
+        value: () => {
967
+          const end = new Date();
968
+          const start = new Date(new Date().setFullYear(new Date().getFullYear() - 1));
969
+          return [start, end];
970
+        }
971
+      },
972
+      {
973
+        text: "过去2年",
974
+        value: () => {
975
+          const start = new Date();
976
+          const end = new Date(new Date().setFullYear(new Date().getFullYear() - 2));
977
+          return [start, end];
978
+        }
979
+      }
980
+    ];
981
+    // getreportpoweryear();
982
+  }
983
+};
740 984
 // 查询
741 985
 const gatSummary = () => {
742 986
   // getdaymonthyear(daymonthyearvalue.value);
@@ -748,10 +992,24 @@ const gatSummary = () => {
748 992
     getreportpoweryear();
749 993
   }
750 994
 };
995
+// 国网查询
996
+const gatstategridSummary = () => {
997
+  if (StateGriddate.value == 1) {
998
+    getstategriddayURL();
999
+  } else if (StateGriddate.value == 2) {
1000
+    getstategridmonthURL();
1001
+  } else if (StateGriddate.value == 3) {
1002
+    getstategridyearURL();
1003
+  }
1004
+};
751 1005
 // 重置
752 1006
 const onreset = () => {
753 1007
   getdaymonthyear(1);
754 1008
 };
1009
+// 重置
1010
+const onstategridreset = () => {
1011
+  StateGridchange(1);
1012
+};
755 1013
 const onclose = (val: boolean) => {
756 1014
   console.log(val);
757 1015
   setTimeout(() => {
@@ -949,6 +1207,83 @@ const downloadxlsx = (item: string, data: other.Data) => {
949 1207
       console.error("下载文件时出错:", error);
950 1208
     });
951 1209
 };
1210
+// 国网导出
1211
+const onexportstategrid = async () => {
1212
+  let obj: string[] = []; // 假设 prop 是 string 类型,如果不是,请根据实际类型修改
1213
+
1214
+  if (columnList.value) {
1215
+    for (const column of columnList.value) {
1216
+      if (column?.ifcolumn) {
1217
+        if (column.prop) {
1218
+          obj.push(column.prop);
1219
+        }
1220
+        if (column.children) {
1221
+          for (const child of column.children) {
1222
+            if (child?.ifcolumn && child.prop) {
1223
+              obj.push(child.prop);
1224
+            }
1225
+          }
1226
+        }
1227
+      }
1228
+    }
1229
+  }
1230
+  const jsonString = obj.join(",");
1231
+
1232
+  if (StateGriddate.value == 1) {
1233
+    let obj = {
1234
+      excel: jsonString,
1235
+      startDate: StateGrid.value[0],
1236
+      endDate: StateGrid.value[1]
1237
+    };
1238
+    const { data } = await selectstartegridbetweenexcelday(obj, stategridSite.value);
1239
+    getdownloadxlsx(StateGrid.value[0], data);
1240
+  } else if (StateGriddate.value == 2) {
1241
+    let obj = {
1242
+      excel: jsonString,
1243
+
1244
+      startYearMonth: StateGrid.value[0],
1245
+      endYearMonth: StateGrid.value[1]
1246
+    };
1247
+    const { data } = await summaryearmonthEXcelURL(obj, stategridSite.value);
1248
+    getdownloadxlsx(StateGrid.value[0], data);
1249
+  } else if (StateGriddate.value == 3) {
1250
+    let obj = {
1251
+      excel: jsonString,
1252
+      startYear: StateGrid.value[0],
1253
+      endYear: StateGrid.value[1]
1254
+    };
1255
+    const { data } = await summaryearEXcel(obj, stategridSite.value);
1256
+    getdownloadxlsx(StateGrid.value[0] + "-" + StateGrid.value[1], data);
1257
+  }
1258
+};
1259
+const getdownloadxlsx = (item: string, data: other.Data) => {
1260
+  let fileUrl = `download/${data.msg}`;
1261
+  const date = new Date();
1262
+  const hours = formatTime(date.getHours());
1263
+  const minutes = formatTime(date.getMinutes());
1264
+  const seconds = formatTime(date.getSeconds());
1265
+  let fileName = `${item} ${hours}:${minutes}:${seconds}国网电量报表.xlsx`;
1266
+  fetch(fileUrl)
1267
+    .then(response => response.blob())
1268
+    .then(blob => {
1269
+      // 创建一个临时的URL对象
1270
+      const url = URL.createObjectURL(blob);
1271
+      // 创建一个隐藏的<a>标签,并设置其href属性为临时URL
1272
+      const a = document.createElement("a");
1273
+      a.href = url;
1274
+      a.download = fileName; // 设置下载的文件名
1275
+      a.style.display = "none";
1276
+      // 将<a>标签添加到文档中,并模拟点击下载
1277
+      document.body.appendChild(a);
1278
+      a.click();
1279
+      // 下载完成后,移除<a>标签和临时URL对象
1280
+      document.body.removeChild(a);
1281
+      URL.revokeObjectURL(url);
1282
+    })
1283
+    .catch(error => {
1284
+      console.error("下载文件时出错:", error);
1285
+    });
1286
+};
952 1287
 const formatTime = (time: number) => {
953 1288
   return time < 10 ? `0${time}` : time; // 如果时间小于 10,在前面加上 0
954 1289
 };
@@ -1002,6 +1337,45 @@ const getreportpoweryear = async () => {
1002 1337
   data.list.push(data.total);
1003 1338
   tableData.value = data;
1004 1339
 };
1340
+// 国网表格
1341
+const GridReportdata = ref();
1342
+// 日
1343
+const getstategriddayURL = async () => {
1344
+  let obj = {
1345
+    startDate: StateGrid.value[0],
1346
+    endDate: StateGrid.value[1]
1347
+  };
1348
+  const { data } = await stategriddayURL(obj, stategridSite.value);
1349
+  data.total.stationName = "总计";
1350
+
1351
+  data.list.push(data.total);
1352
+  GridReportdata.value = data;
1353
+};
1354
+// 月份
1355
+const getstategridmonthURL = async () => {
1356
+  let obj = {
1357
+    startYearMonth: StateGrid.value[0],
1358
+    endYearMonth: StateGrid.value[1]
1359
+  };
1360
+  const { data } = await stategridmonthURL(obj, stategridSite.value);
1361
+  data.total.stationName = "总计";
1362
+
1363
+  data.list.push(data.total);
1364
+  GridReportdata.value = data;
1365
+};
1366
+// 年份
1367
+const getstategridyearURL = async () => {
1368
+  let obj = {
1369
+    startYear: StateGrid.value[0],
1370
+    endYear: StateGrid.value[1]
1371
+  };
1372
+  const { data } = await stategridyearURL(obj, stategridSite.value);
1373
+  data.total.stationName = "总计";
1374
+
1375
+  data.list.push(data.total);
1376
+  GridReportdata.value = data;
1377
+};
1378
+
1005 1379
 const reportformsindex = ref(2);
1006 1380
 const pickertype: Ref<any> = ref("date");
1007 1381
 
@@ -1147,11 +1521,14 @@ const onchart = (val: any) => {
1147 1521
 };
1148 1522
 // 选择站点
1149 1523
 const Singlevalue = ref("");
1524
+const stategridSite = ref("");
1525
+
1150 1526
 const cities: Ref<Station.todo[]> = ref([]);
1151 1527
 
1152 1528
 const poststationstationName = async () => {
1153 1529
   const { data } = await stationstationName({});
1154 1530
   Singlevalue.value = data[0].id;
1531
+  stategridSite.value = data[0].id;
1155 1532
   cities.value = data;
1156 1533
   return;
1157 1534
   getemsSystemsingleStation();

Načítá se…
Zrušit
Uložit