diff --git a/hx-ai-intelligent/src/api/carbonEmissionFactorLibrary.ts b/hx-ai-intelligent/src/api/carbonEmissionFactorLibrary.ts index 708c970..edae9fa 100644 --- a/hx-ai-intelligent/src/api/carbonEmissionFactorLibrary.ts +++ b/hx-ai-intelligent/src/api/carbonEmissionFactorLibrary.ts @@ -35,4 +35,11 @@ export enum quickCalculation { // 碳排管理-碳排统计接口 export enum carbonEmission { carbonEmissionStatistics = '/carbon-smart/api/carbon/energy/correlation/carbonEmissionStatistics', +} +// 碳盘查接口 +export enum carbonInventoryCheck { + carbonInventoryList = '/carbon-smart/api/carbon/report/carbonInventoryList', + createOrUpdate = '/carbon-smart/api/carbon/report/createOrUpdate', + findById = '/carbon-smart/api/carbon/report/findById', + delete = '/carbon-smart/api/carbon/report/delete', } \ No newline at end of file diff --git a/hx-ai-intelligent/src/config/app.config.ts b/hx-ai-intelligent/src/config/app.config.ts index 9d09f0b..22f2982 100644 --- a/hx-ai-intelligent/src/config/app.config.ts +++ b/hx-ai-intelligent/src/config/app.config.ts @@ -6,8 +6,11 @@ import { get } from 'lodash-es'; import { computed, ref, toRef } from 'vue'; const ORGID = sessionStorage.getItem('ORGID') ? Number(sessionStorage.getItem('ORGID')) : ''; - +const isAdmin = sessionStorage.getItem('ISADMIN') + ? Boolean(sessionStorage.getItem('ISADMIN')) + : false; const selectDefaultValue = ref(ORGID); +const selectDefaultDisabled = ref(isAdmin); const transform = (data, map) => { return Object.keys(map).reduce((pre, cur) => { pre[cur] = data[map[cur]]; @@ -43,6 +46,7 @@ export const appConfig = { api: '/carbon-smart/user/login/logInInfo', size: 'large', defaultValue: selectDefaultValue, + disabled: selectDefaultDisabled, // autoSelectFirst: true, placeholder: '请选择', onSelect: async (cur, record) => { @@ -91,8 +95,11 @@ export const appConfig = { projectId: 'projectId', linkList: 'linkList', permissionVos: 'permissionVos', + adminFlag: 'adminFlag', }); sessionStorage.setItem('ORGID', info.orgId); + sessionStorage.setItem('ISADMIN', trD?.adminFlag === '1'); + selectDefaultDisabled.value = info?.adminFlag === '1'; selectDefaultValue.value = info.orgId; return { data: { ...trD } }; }); diff --git a/hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionFactorLibrary/index.vue b/hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionFactorLibrary/index.vue index 3bb69b9..8925bca 100644 --- a/hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionFactorLibrary/index.vue +++ b/hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionFactorLibrary/index.vue @@ -5,7 +5,7 @@
-
排放分类
+
排放分类
@@ -562,6 +562,7 @@ }); opMap.value.fuc = (formData: any) => { formData.emissionType = formData.emissionType[formData.emissionType.length - 1] + debugger return http.post(carbonEmissionFactorLibrary.creatOrUpdate, formData).then(() => { mainRef.value?.nsTableRef.reload(); visible.value = false; @@ -665,14 +666,22 @@ handle: (record: any) => { userAuthList.value.splice(0); setTimeout(() => { - console.log(record.id); - - http.post(carbonEmissionFactorLibrary.findById,{ id: record.id } ).then((res) => { - formData.value = res.data; + const measurementUnit = ref([]) + http.post(carbonEmissionFactorLibrary.getCarbonFactorTree,{}).then((res) => { + measurementUnit.value = res.data + http.post(carbonEmissionFactorLibrary.findById,{ id: record.id } ).then((res) => { + if (res.data.emissionType) { + let selectDevice = ref([Number(res.data.emissionType)]); + findParentIds(measurementUnit.value, res.data.emissionType, selectDevice.value); + res.data.emissionType = selectDevice + } + formData.value = res.data; + }); }); }, 10); opMap.value.type = 'edit'; opMap.value.fuc = (formData: any) => { + formData.emissionType = formData.emissionType[formData.emissionType.length - 1] return http.post(carbonEmissionFactorLibrary.creatOrUpdate, formData).then(() => { mainRef.value?.nsTableRef.reload(); visible.value = false; @@ -790,6 +799,27 @@ // pagination: { defaultPageSize: 10 }, rowKey: 'id', }); + function findParentIds(tree: any, targetId: number, result: any) { + for (let item of tree) { + if (item.children && item.children.length > 0) { + if (item.children.some((child: any) => child.id === Number(targetId))) { + result.unshift(item.id); // 将当前节点的id添加到结果数组的最前面 + findParentIds(tree, item.id, result); // 递归查找父级节点的id + break; // 找到后可以退出循环 + }else{ + for(let childsItem of item.children){ + if(childsItem.children && childsItem.children.length > 0){ + if (childsItem.children.some((child: any) => child.id === Number(targetId))) { + result.unshift(childsItem.id); // 将当前节点的id添加到结果数组的最前面 + findParentIds(tree, childsItem.id, result); // 递归查找父级节点的id + break; // 找到后可以退出循环 + } + } + } + } + } + } + } // 单位管理 const unitExpandedKeys = ref(); @@ -977,6 +1007,26 @@ padding-bottom: 10px; border-bottom: 1px solid #e9e9e9; } + .title{ + text-align: left; + height: 32px; + line-height: 32px; + font-weight: bold; + user-select: text; + position: relative; + padding-left: 9px; + } + .title::before { + content: ''; + position: absolute; + left: 0; + top: 50%; + transform: translateY(-50%); + height: 13px; + width: 3px; + border-radius: 1px; + background-color: #2778FF; + } .treeRow { display: flex; justify-content: space-between; diff --git a/hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/energyConsumption/index.vue b/hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/energyConsumption/index.vue index c4a1582..4978f78 100644 --- a/hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/energyConsumption/index.vue +++ b/hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/energyConsumption/index.vue @@ -363,9 +363,11 @@ getDictList() visible.value = true fetch(energyConsumption.findById , {id : record.id }).then((res) => { - // if(res.data.unit){ - // res.data.unit = res.data.unit.split(',') - // } + if (res.data.unit) { + let selectDevice = ref([Number(res.data.unit)]); + findParentIds(measurementUnit.value, res.data.unit, selectDevice.value); + res.data.unit = selectDevice + } formState.value = res.data }); }, @@ -398,6 +400,18 @@ }, rowKey: 'id', }); + // 定义一个递归函数来查找每一级的id 设备类型回显 层级方法 + function findParentIds(tree: any, targetId: number, result: any) { + for (let item of tree) { + if (item.children && item.children.length > 0) { + if (item.children.some((child: any) => child.value === targetId)) { + result.unshift(item.value); // 将当前节点的id添加到结果数组的最前面 + findParentIds(tree, item.value, result); // 递归查找父级节点的id + break; // 找到后可以退出循环 + } + } + } + } // 获取表格数据 const getTableList = () => { fetch(energyConsumption.pageList , queryParams.value).then((res) => { @@ -473,6 +487,7 @@ label: child.cnValue })) : [] })); + debugger }); // 获取自动采集节点的数据 fetch(group.queryDeviceGroupTree, { energyType: 'ELECTRICITY_USAGE',orgId: orgId.value }).then((res) => { diff --git a/hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/quickCalculation/index.vue b/hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/quickCalculation/index.vue index 602471f..a43aa27 100644 --- a/hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/quickCalculation/index.vue +++ b/hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/quickCalculation/index.vue @@ -3,7 +3,7 @@
-
因子分类
+
因子分类
@@ -507,6 +507,26 @@ padding-bottom: 10px; border-bottom: 1px solid #e9e9e9; } + .title{ + text-align: left; + height: 32px; + line-height: 32px; + font-weight: bold; + user-select: text; + position: relative; + padding-left: 9px; + } + .title::before { + content: ''; + position: absolute; + left: 0; + top: 50%; + transform: translateY(-50%); + height: 13px; + width: 3px; + border-radius: 1px; + background-color: #2778FF; + } ::v-deep .ant-table-title{ display: flex; height: 100%; diff --git a/hx-ai-intelligent/src/view/carbonEmissionManage/carbonInventoryCheck/fillInPage/index.vue b/hx-ai-intelligent/src/view/carbonEmissionManage/carbonInventoryCheck/fillInPage/index.vue index eb62cd7..33f731f 100644 --- a/hx-ai-intelligent/src/view/carbonEmissionManage/carbonInventoryCheck/fillInPage/index.vue +++ b/hx-ai-intelligent/src/view/carbonEmissionManage/carbonInventoryCheck/fillInPage/index.vue @@ -1,10 +1,406 @@ \ No newline at end of file diff --git a/hx-ai-intelligent/src/view/carbonEmissionManage/carbonInventoryCheck/index.vue b/hx-ai-intelligent/src/view/carbonEmissionManage/carbonInventoryCheck/index.vue index 89ff479..807cb39 100644 --- a/hx-ai-intelligent/src/view/carbonEmissionManage/carbonInventoryCheck/index.vue +++ b/hx-ai-intelligent/src/view/carbonEmissionManage/carbonInventoryCheck/index.vue @@ -5,7 +5,7 @@
- +
- - + + - - + + - - + + - - - - {{ item.cnValue }} - + + + 年度 + 月度 - - + +