|
|
@@ -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) {
|