Browse Source

taskid:099 remark:'commit'

temp
fks-xuxinyue 4 months ago
parent
commit
ee99ba7340
  1. 9
      hx-ai-intelligent/src/api/carbonEmissionFactorLibrary.ts
  2. 3
      hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionFactorLibrary/index.vue
  3. 1
      hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/energyConsumption/index.vue
  4. 333
      hx-ai-intelligent/src/view/carbonEmissionManage/carbonInventoryCheck/fillInPage/index.vue

9
hx-ai-intelligent/src/api/carbonEmissionFactorLibrary.ts

@ -42,4 +42,13 @@ export enum carbonInventoryCheck {
createOrUpdate = '/carbon-smart/api/carbon/report/createOrUpdate',
findById = '/carbon-smart/api/carbon/report/findById',
delete = '/carbon-smart/api/carbon/report/delete',
// 填报页面接口
// 最左侧碳盘查报告树
getCategoryTree = '/carbon-smart/api/carbon/inventory/contact/getCategoryTree',
updateCategoryTree = '/carbon-smart/api/carbon/inventory/contact/update',
// 排放源中左侧树
getInventoryTree = '/carbon-smart/api/carbon/inventory/getInventoryTree',
create = '/carbon-smart/api/carbon/inventory/create',
update = '/carbon-smart/api/carbon/inventory/update',
del = '/carbon-smart/api/carbon/inventory/del',
}

3
hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionFactorLibrary/index.vue

@ -562,7 +562,6 @@
});
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;
@ -602,7 +601,7 @@
name: 'userAdd',
handle: () => {
unitManagement.value = true,
fetch(carbonEmissionFactorLibrary.findOutermost).then((res) => {
fetch(carbonEmissionFactorLibrary.findOutermost,{grp:'MEASUREMENT_UNIT'}).then((res) => {
groupData.value = res.data
});
getUnitTree()

1
hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/energyConsumption/index.vue

@ -487,7 +487,6 @@
label: child.cnValue
})) : []
}));
debugger
});
//
fetch(group.queryDeviceGroupTree, { energyType: 'ELECTRICITY_USAGE',orgId: orgId.value }).then((res) => {

333
hx-ai-intelligent/src/view/carbonEmissionManage/carbonInventoryCheck/fillInPage/index.vue

@ -19,21 +19,25 @@
</div>
</a-form>
<a-tree
:expanded-keys="expandedKeys"
:expanded-keys="expandedKeysL"
:selectedKeys="selectedKeysL"
:auto-expand-parent="autoExpandParent"
:tree-data="gData"
v-if="gData && gData.length > 0"
:height="233"
show-line
style="padding: 0 16px !important;"
@expand="onExpand"
@expand="onExpandL"
@select="onSelectL"
block-node
>
<template #title="{ title }">
<span v-if="title.indexOf(searchValue) > -1">
{{ title.substring(0, title.indexOf(searchValue)) }}
<template #title="{ cnValue }">
<span v-if="cnValue && searchValue && cnValue.indexOf(searchValue) > -1">
{{ cnValue.substring(0, cnValue.indexOf(searchValue)) }}
<span style="color: #f50">{{ searchValue }}</span>
{{ title.substring(title.indexOf(searchValue) + searchValue.length) }}
{{ cnValue.substring(cnValue.indexOf(searchValue) + searchValue.length) }}
</span>
<span v-else>{{ title }}</span>
<span v-else>{{ cnValue }}</span>
</template>
</a-tree>
</div>
@ -55,22 +59,21 @@
<div style="display: flex;" v-if="fillInPage">
<div class="mainLeft">
<a-tree
v-model:expandedKeys="expandedKeysR"
v-model:selectedKeys="selectedKeys"
v-model:checkedKeys="checkedKeys"
:expandedKeys="expandedKeysR"
:selectedKeys="selectedKeysR"
:checkedKeys="checkedKeys"
:tree-data="treeData"
@select="onSelectR"
block-node
>
<template #title="data">
<div class="treeRow">
<div>
<span>{{ data.title }}</span>
<span>{{ data.emissionSource }}</span>
</div>
<div class="actionMore">
<EditOutlined v-if="!data.parentId" @click="editGroup(data)" />
<EditOutlined v-else @click="editUnit(data)" />
<EditOutlined @click="editUnit(data)" />
<MinusCircleOutlined style="margin-left: 6px;" @click="delUnit(data)" />
<PlusCircleOutlined v-if="!data.parentId" style="margin-left: 6px;" @click="addUnit(data)" />
</div>
</div>
</template>
@ -110,7 +113,7 @@
:scroll="{ x: 2000 }">
</a-table>
</div>
<div v-if="isClickedTplx">
<div v-if="isClickedTplx" style="width: 100%; height: 100%">
<div ref="tplxChart" style="width: 100%; height: 68vh"></div>
</div>
</div>
@ -136,9 +139,11 @@
<a-tree
:expanded-keys="categoryExpandedKeys"
:selectedKeys="categorySelectedKeys"
:checkedKeys="categoryCheckedKeys"
:tree-data="categoryTreeData"
v-if="categoryTreeData && categoryTreeData.length > 0"
class="draggable-tree"
@check="checkTreeNode"
checkable
block-node>
<template #title="data">
@ -152,7 +157,7 @@
</div>
<template #footer>
<a-button style="margin-right: 8px" @click="closeCategoryConfig">取消</a-button>
<a-button type="primary" @click="closeUnitManag">确定</a-button>
<a-button type="primary" @click="submitCategory">确定</a-button>
</template>
</a-drawer>
<!-- 新增/编辑排放源树节点 -->
@ -170,41 +175,24 @@
:label-col="labelCol"
:wrapper-col="wrapperCol"
>
<a-form-item ref="name" label="排放源" name="energyType">
<a-select
ref="select"
v-model:value="formState.unit"
>
<a-select-option value="jack">Jack</a-select-option>
<a-select-option value="lucy">Lucy</a-select-option>
</a-select>
<a-form-item ref="name" label="排放源" name="emissionSource">
<a-input v-model:value="formState.emissionSource" placeholder="请输入排放源" />
</a-form-item>
<a-form-item ref="name" label="计量单位" name="energyType">
<a-select
ref="select"
v-model:value="formState.unit"
>
<a-select-option value="jack">Jack</a-select-option>
<a-select-option value="lucy">Lucy</a-select-option>
</a-select>
<a-form-item ref="name" label="计量单位" name="unitId">
<a-cascader v-model:value="formState.unitId" :options="measurementUnit" />
</a-form-item>
<a-form-item ref="name" label="温室气体" name="energyType">
<a-form-item ref="name" label="温室气体" name="greenhouseGases">
<a-select
ref="select"
v-model:value="formState.unit"
v-model:value="formState.greenhouseGases"
>
<a-select-option value="jack">Jack</a-select-option>
<a-select-option value="lucy">Lucy</a-select-option>
<a-select-option v-for="(item, index) in groupData" :key="index" :value="item.id">
{{ item.cnValue }}
</a-select-option>
</a-select>
</a-form-item>
<a-form-item ref="name" label="碳排单位" name="energyType">
<a-select
ref="select"
v-model:value="formState.unit"
>
<a-select-option value="jack">Jack</a-select-option>
<a-select-option value="lucy">Lucy</a-select-option>
</a-select>
<a-form-item ref="name" label="碳排单位" name="carbonEmissionUnits">
<a-cascader v-model:value="formState.carbonEmissionUnits" :options="CarbonUnit" />
</a-form-item>
<!-- <a-form-item label="排放类型" name="emissionType" :required="isRequired">
<a-select v-model:value="formState.emissionType" placeholder="请选择排放类型">
@ -345,14 +333,14 @@
</template>
<script lang="ts" setup>
import { ref, watch } from 'vue';
import { ref, watch, toRaw } from 'vue';
import { http } from '/nerv-lib/util/http';
import { Pagination } from 'ant-design-vue';
import { Pagination, Modal, message } from 'ant-design-vue';
import type { TreeProps,TableColumnsType,UploadChangeParam } from 'ant-design-vue';
import { EditOutlined,PlusCircleOutlined,MinusCircleOutlined,UploadOutlined } from '@ant-design/icons-vue';
import * as echarts from 'echarts';
import { columns,voucherColumns,drawerColumns } from '../config';
import { energyConsumption,carbonEmissionFactorLibrary } from '/@/api/carbonEmissionFactorLibrary';
import { energyConsumption,carbonEmissionFactorLibrary,carbonInventoryCheck } from '/@/api/carbonEmissionFactorLibrary';
defineOptions({
energyType: 'fillInPage', // name
components: {
@ -362,7 +350,7 @@
const orgId = ref('');
const result = JSON.parse(sessionStorage.getItem('ORGID')!);
orgId.value = result;
const fetch = (api, params = { orgId } ) => {
const fetch = (api, params = { orgId:orgId.value } ) => {
return http.post(api, params);
};
//
@ -424,13 +412,14 @@
}
return parentKey;
};
const expandedKeys = ref<(string | number)[]>([]);
const expandedKeysL = ref<(string | number)[]>([]);
const selectedKeysL = ref<string[]>(['0-0']);
const searchValue = ref<string>('');
const autoExpandParent = ref<boolean>(true);
const gData = ref<TreeProps['treeData']>(genData);
const onExpand = (keys: string[]) => {
expandedKeys.value = keys;
const onExpandL = (keys: string[]) => {
expandedKeysL.value = keys;
autoExpandParent.value = false;
};
@ -443,10 +432,34 @@
return null;
})
.filter((item, i, self) => item && self.indexOf(item) === i);
expandedKeys.value = expanded;
expandedKeysL.value = expanded;
searchValue.value = value;
autoExpandParent.value = true;
});
//
const categoryId = ref()
const onSelectL = (selectedKey: string[], info: any) => {
selectedKeysL.value = selectedKey;
categoryId.value = info.node.id
formState.value.categoryId = categoryId.value
};
//
const selectedIds = ref([]);
const getReportTree = () => {
fetch(carbonInventoryCheck.getCategoryTree).then((res) => {
gData.value = res.data
if(res.data.length > 0){
categoryId.value = res.data[0].id
formState.value.categoryId = categoryId.value
selectedIds.value = getAllIds(gData.value);
}
getEmissionSourceTree();
});
};
getReportTree();
const getAllIds = (nodes: TreeNode[]): number[] => {
return nodes.flatMap(node => [node.id, ...(node.children ? getAllIds(node.children) : [])]);
};
//
const data = [...Array(12)].map((_, i) => ({
key: i,
@ -460,36 +473,25 @@
gender: 'M',
}));
//
const treeData: TreeProps['treeData'] = [
{
title: 'parent 1',
key: '0-0',
children: [
{
title: 'parent 1-0',
key: '0-0-0',
children: [
{ title: 'leaf', key: '0-0-0-0'},
{ title: 'leaf', key: '0-0-0-1' },
],
},
{
title: 'parent 1-1',
key: '0-0-1',
children: [{ key: '0-0-1-0', title: 'sss' }],
},
],
},
];
const expandedKeysR = ref<string[]>(['0-0-0', '0-0-1']);
const selectedKeys = ref<string[]>(['0-0-0', '0-0-1']);
const checkedKeys = ref<string[]>(['0-0-0', '0-0-1']);
const treeData = ref<TreeProps['treeData']>(genData);
//
const getEmissionSourceTree = () => {
fetch(carbonInventoryCheck.getInventoryTree, { categoryId: categoryId.value }).then((res) => {
treeData.value = res.data
});
};
//
const onSelectR = (selectedKey: string[], info: any) => {
selectedKeysR.value = selectedKey;
};
const expandedKeysR = ref<string[]>([]);
const selectedKeysR = ref<string[]>(['0-0']);
const checkedKeys = ref<string[]>([]);
watch(expandedKeysR, () => {
console.log('expandedKeysR', expandedKeysR);
});
watch(selectedKeys, () => {
console.log('selectedKeys', selectedKeys);
watch(selectedKeysR, () => {
console.log('selectedKeys', selectedKeysR);
});
watch(checkedKeys, () => {
console.log('checkedKeys', checkedKeys);
@ -500,14 +502,44 @@
const categoryTreeData = ref<TreeProps['treeData']>(genData);
const categoryExpandedKeys = ref<string[]>();
const categorySelectedKeys = ref<string[]>([]);
const categoryCheckedKeys = ref<string[]>([]);
const checkTreeNode = (checkedKeys, info) => {
categoryCheckedKeys.value = checkedKeys
queryConfigure.value.dictionaryIdList = categoryCheckedKeys.value
}
const getUnitTree = () => {
fetch(carbonEmissionFactorLibrary.dictionaryUnitManagement).then((res) => {
fetch(carbonEmissionFactorLibrary.dictionaryUnitManagement,{grp:'CATEGORY_CONFIGURATION'}).then((res) => {
categoryTreeData.value = res.data
categoryCheckedKeys.value = selectedIds.value.map(id => String(id));
// key
categoryTreeData.value = formatTreeData(categoryTreeData.value);
});
}
getUnitTree()
const formatTreeData = (treeData) => {
return treeData.map(node => {
const newNode = { ...node };
newNode.key = String(node.id); // id key
if (node.children) {
newNode.children = formatTreeData(node.children);
}
return newNode;
});
};
const openCategoryConfig = () => {
categoryConfig.value = true;
getUnitTree()
};
//
const queryConfigure = ref({
orgId:orgId.value
})
const submitCategory = () => {
fetch(carbonInventoryCheck.updateCategoryTree,queryConfigure.value).then((res) => {
categoryConfig.value = false;
getReportTree();
});
};
const closeCategoryConfig = () => {
categoryConfig.value = false;
@ -518,15 +550,138 @@
const labelCol = { span: 5 };
const wrapperCol = { span: 19 };
const formState = ref({
orgId: orgId.value,
orgId: orgId.value
})
//
const measurementUnit = ref([])
//
const CarbonUnit = ref([])
//
const groupData = ref([])
// form
const rules: Record<string, Rule[]> = {
energyType: [{ required: true, message: '请输入能源种类', trigger: 'change' }],
isComputeCarbon: [{ required: true, message: '请选择是否计算碳排', trigger: 'change' }]
emissionSource: [{ required: true, message: '请输入排放源', trigger: 'change' }],
unitId: [{ required: true, message: '请选择计量单位', trigger: 'change' }],
greenhouseGases: [{ required: true, message: '请选择温室气体', trigger: 'change' }],
carbonEmissionUnits: [{ required: true, message: '请选择碳排单位', trigger: 'change' }],
};
const addTreeNodeData = () => {
addTreeNodeVisible.value = true;
getDictData()
};
//
const getDictData = () => {
//
fetch(carbonEmissionFactorLibrary.dictionaryUnitManagement, { grp: 'MEASUREMENT_UNIT'}).then((res) => {
measurementUnit.value = res.data
measurementUnit.value = measurementUnit.value.map(item => ({
value: item.id,
label: item.cnValue,
children: item.children ? item.children.map(child => ({
value: child.id,
label: child.cnValue
})) : []
}));
});
//
fetch(carbonEmissionFactorLibrary.dictionaryUnitManagement, { grp: 'GREENHOUSE_GASES'}).then((res) => {
CarbonUnit.value = res.data
CarbonUnit.value = CarbonUnit.value.map(item => ({
value: item.id,
label: item.cnValue,
children: item.children ? item.children.map(child => ({
value: child.id,
label: child.cnValue
})) : []
}));
});
//
fetch(carbonEmissionFactorLibrary.findOutermost,{grp:'GREENHOUSE_GASES'}).then((res) => {
groupData.value = res.data
});
};
const onSubmit = () => {
formRef.value
.validate()
.then(() => {
console.log('values', formState, toRaw(formState));
if(formState.value.unitId){
formState.value.unitId = formState.value.unitId.join(',').split(',')[1]
}
if(formState.value.carbonEmissionUnits){
formState.value.carbonEmissionUnits = formState.value.carbonEmissionUnits.join(',').split(',')[1]
}
if(formState.value.id){
fetch(carbonInventoryCheck.update , formState.value).then((res) => {
addTreeNodeVisible.value = false
formState.value = {
orgId: orgId.value,
}
message.success('操作成功!');
getEmissionSourceTree();
});
}else{
fetch(carbonInventoryCheck.create , formState.value).then((res) => {
addTreeNodeVisible.value = false
formState.value = {
orgId: orgId.value,
}
message.success('操作成功!');
getEmissionSourceTree();
});
}
})
.catch(error => {
console.log('error', error);
});
};
const editUnit = (data) => {
getDictData()
addTreeNodeVisible.value = true;
setTimeout(() => {
let selectDevice = ref([Number(data.unitId)]);
findParentIds(measurementUnit.value, data.unitId, selectDevice.value);
data.unitId = selectDevice
let selectDeviceC = ref([Number(data.carbonEmissionUnits)]);
findParentIds(CarbonUnit.value, data.carbonEmissionUnits, selectDeviceC.value);
data.carbonEmissionUnits = selectDeviceC
formState.value.id = data.id
formState.value = data
}, 500);
};
// 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 delUnit = (data) => {
Modal.confirm({
title: '警告',
content: '确定要删除吗?',
okText: '确定',
okType: 'primary',
cancelText: '取消',
onOk() {
fetch(carbonInventoryCheck.del , {id:data.id}).then((res) => {
message.success('操作成功!');
getEmissionSourceTree();
});
},
onCancel() {
console.log('Cancel');
},
});
};
const onClose = () => {
addTreeNodeVisible.value = false;
@ -637,7 +792,9 @@
fillInPage.value = false
isClickedPftj.value = false
isClickedTplx.value = true
drawEcharts();
setTimeout(() => {
drawEcharts();
}, 500);
};
//
const pftjColumn = [
@ -939,8 +1096,8 @@
};
itemStyleColor.push(datalist[d]);
}
option = {
backgroundColor: "#031d7a",
const option = {
backgroundColor: "transparent",
tooltip: {
trigger: "item",
triggerOn: "mousemove",
@ -1171,7 +1328,7 @@
height: 5vh;
display: flex;
align-items: center;
justify-content: space-evenly;
margin-left: 10%;
}
.treePart{
width: 70%;

Loading…
Cancel
Save