Forráskód Böngészése

fix: 修复能耗统计与价格配置相关问题

yusheng 6 hónapja
szülő
commit
21fb37ded7

+ 12 - 6
src/views/energyConsumptionStatistics/index.vue

@@ -85,7 +85,6 @@
                 </template>
               </ele-pro-table>
             </div>
-
           </div>
         </template>
       </ele-split-layout>
@@ -243,6 +242,11 @@
             label: '价格单位',
             align: 'center',
             minWidth: 120,
+            formatter: (row) => {
+              return energyConsumingUnitList
+                .find((item) => item.value == row.energyClassificationCode)
+                ?.unit.find((item) => item.value == row.priceUnit)?.label;
+            },
             showOverflowTooltip: true
           },
           {
@@ -253,8 +257,7 @@
             showOverflowTooltip: true
           }
         ],
-        cacheKeyUrl: 'ems-energy-statistics-list',
-
+        cacheKeyUrl: 'ems-energy-statistics-list'
       };
     },
     computed: {
@@ -287,8 +290,11 @@
             label: '抄表时间',
             value: 'createTime',
             type: 'date',
-            width:300,
-            valueAr: ['currentMeterReadingTimeStart', 'currentMeterReadingTimeEnd']
+            width: 300,
+            valueAr: [
+              'currentMeterReadingTimeStart',
+              'currentMeterReadingTimeEnd'
+            ]
           }
         ];
       }
@@ -369,6 +375,7 @@
           page,
           limit,
           ...where,
+          ...this.searchForm,
           areaId: this.areaId,
           categoryLevelId: this.categoryLevelId
         });
@@ -482,7 +489,6 @@
           }
         }
       }
-
     }
   }
 </style>

+ 28 - 31
src/views/useEnergyZoning/components/energyPriceConfig.vue

@@ -108,10 +108,9 @@
 <script>
   import { getPage } from '@/api/EnergyPricingScheme/index.js';
   import { energyConsumingUnitList, priceTypeList } from '@/enum/dict.js';
-  import {
-    checkEnergyPricingConfiguration,
-    getById
-  } from '@/api/regionalManage';
+  import { checkEnergyPricingConfiguration } from '@/api/regionalManage';
+  import { getById } from '@/api/EnergyPricingScheme/index.js';
+
   export default {
     name: 'EnergyPriceConfig',
     data() {
@@ -120,15 +119,19 @@
         tableData: [],
         energyConsumingUnitList,
         priceTypeList,
-        areaRow: null
+        areaId: null
       };
     },
     methods: {
       // 打开弹窗
       async open(row) {
-        this.areaRow = await getById(row.id);
+        // this.areaRow = await getById(row.id);
+        this.areaId = row.id;
         this.visible = true;
         this.tableData = [];
+        if (row.priceSchemeId.length) {
+          this.loadExistData(row.priceSchemeId);
+        }
         // // 如果有已配置的价格方案数据,需要回显
         // if (row.energyConsumingUnitList && row.energyConsumingUnitList.length) {
         //   this.loadExistData(row.energyConsumingUnitList);
@@ -136,31 +139,25 @@
       },
       // 加载已存在的数据
       async loadExistData(list) {
-        for (const item of list) {
-          const row = {
-            energyClassificationCode: item.energyClassificationCode,
-            priceSchemeId: item.priceSchemeId,
-            schemeType: item.schemeType,
-            effectiveDate: item.effectiveDate,
-            priceSchemeList: []
+        let tableData = await list.map(async (id) => {
+          const data = await getById(id);
+          const res = await getPage({
+            energyClassificationCode: data.energyClassificationCode,
+            status: 1,
+            approvalStatus: 2,
+            page: 1,
+            limit: 9999
+          });
+          return {
+            energyClassificationCode: data.energyClassificationCode,
+            priceSchemeId: data.id,
+            schemeType: data.schemeType,
+            effectiveDate: data.effectiveDate,
+            priceSchemeList: res.list
           };
-          // 加载对应的价格方案列表
-          if (item.energyClassificationCode) {
-            try {
-              const res = await getPage({
-                energyClassificationCode: item.energyClassificationCode,
-                status: 1,
-                approvalStatus: 2,
-                page: 1,
-                limit: 9999
-              });
-              row.priceSchemeList = res || [];
-            } catch (e) {
-              console.error('加载价格方案失败', e);
-            }
-          }
-          this.tableData.push(row);
-        }
+        });
+        this.tableData = await Promise.all(tableData);
+        console.log(this.tableData, 'this.tableData');
       },
       // 关闭弹窗
       updateVisible(val) {
@@ -221,7 +218,7 @@
         }
       },
       checkPriceSchemeBind() {
-        checkEnergyPricingConfiguration(this.areaRow.id)
+        checkEnergyPricingConfiguration(this.areaId)
           .then((result) => {
             // result 是关联的区域名称
             if (result) {