Browse Source

taskid:088 remark:"commit"

temp
fks-xuxinyue 4 months ago
parent
commit
85cd183493
  1. 4
      hx-ai-intelligent/src/api/carbonEmissionFactorLibrary.ts
  2. 179
      hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/carbonEmissions/index copy.vue
  3. 136
      hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/carbonEmissions/index.vue
  4. 3
      hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/config.ts
  5. 120
      hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/energyConsumption/index.vue
  6. 54
      hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/quickCalculation/index.vue

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

@ -32,3 +32,7 @@ export enum quickCalculation {
update = '/carbon-smart/api/carbon/energy/correlation/update',
del = '/carbon-smart/api/carbon/energy/correlation/del',
}
// 碳排管理-碳排统计接口
export enum carbonEmission {
carbonEmissionStatistics = '/carbon-smart/api/carbon/energy/correlation/carbonEmissionStatistics',
}

179
hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/carbonEmissions/index copy.vue

@ -1,179 +0,0 @@
<template>
<a-table :columns="columns" :data-source="data" bordered />
</template>
<script lang="ts">
import { defineComponent, watch, ref, onMounted } from 'vue';
import type { TableColumnType } from 'ant-design-vue';
import { inject } from 'vue';
// let data: any[] = [];
export default defineComponent({
name: 'EnvironmentTable',
setup() {
let data = ref<any[]>([]);
let columns = ref<TableColumnType[]>([]);
interface PageData {
tableList: any[];
tableColumns: any[];
graphList: any[];
}
const pageData = inject<PageData>('pageData');
if (!pageData) {
throw new Error('pageData is not provided');
}
// pageData
watch(
() => pageData as PageData,
(_newValue, _oldValue) => {
data.value = pageData.tableList;
let columnA: any[] = [...column];
columnA.push(...pageData.tableColumns);
columns.value = columnA;
// pageData.graphList;
//
},
{ deep: true },
);
const getRowSpan = (dataIndex: string, record: any, data: any, dependents: string[] = []) => {
let rowSpan = 1;
for (let i = data.indexOf(record) + 1; i < data.length; i++) {
let shouldMerge = true;
for (const dependent of dependents) {
if (data[i][dependent] !== record[dependent]) {
shouldMerge = false;
break;
}
}
if (shouldMerge && data[i][dataIndex] === record[dataIndex]) {
rowSpan++;
} else {
break;
}
}
return rowSpan;
};
const column: TableColumnType[] = [
{
title: '序号',
dataIndex: 'key',
customCell: (record, rowIndex) => {
if (rowIndex == undefined) {
return {
rowSpan: 0,
colSpan: 0,
};
}
const rowSpan = getRowSpan('name', record, data.value);
if (rowIndex != 0 && data.value[rowIndex - 1].key == record.key) {
return {
rowSpan: 0,
colSpan: 0,
};
}
return {
rowSpan: rowSpan,
};
},
},
{
title: '设备名称',
dataIndex: 'name',
customCell: (record, rowIndex) => {
if (rowIndex == undefined) {
return {
rowSpan: 0,
colSpan: 0,
};
}
const rowSpan = getRowSpan('name', record, data.value);
if (rowIndex != 0 && data.value[rowIndex - 1].name == record.name) {
return {
rowSpan: 0,
colSpan: 0,
};
}
return {
rowSpan: rowSpan,
};
},
},
{
title: '设备点位',
dataIndex: 'position',
customCell: (record, rowIndex) => {
if (rowIndex == undefined) {
return {
rowSpan: 0,
colSpan: 0,
};
}
const rowSpan = getRowSpan('position', record, data.value, ['name']);
if (
rowIndex != 0 &&
data.value[rowIndex - 1].name == record.name &&
data.value[rowIndex - 1].position == record.position
) {
return {
rowSpan: 0,
colSpan: 0,
};
}
return {
rowSpan: rowSpan,
};
},
},
{
title: '计量单位',
dataIndex: 'unit',
customCell: (record, rowIndex) => {
if (rowIndex == undefined) {
return {
rowSpan: 0,
colSpan: 0,
};
}
const rowSpan = getRowSpan('unit', record, data.value, ['name', 'position']);
if (
rowIndex != 0 &&
data.value[rowIndex - 1].name == record.name &&
data.value[rowIndex - 1].position == record.position &&
data.value[rowIndex - 1].unit == record.unit
) {
return {
rowSpan: 0,
colSpan: 0,
};
}
return {
rowSpan: rowSpan,
};
},
},
];
onMounted(() => {
data.value = pageData.tableList;
let columnA: any[] = [...column];
columnA.push(...pageData.tableColumns);
columns.value = columnA;
});
return {
data,
column,
columns,
pageData,
};
},
});
</script>
<style lang="less" scoped></style>

136
hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/carbonEmissions/index.vue

@ -1,13 +1,13 @@
<template>
<div>
<a-table
:columns="tableColumns"
:columns="column"
:data-source="data"
bordered
:pagination="false"
:scroll="{ x: 2000 }">
<template #title>
<a-date-picker v-model:value="selectYear" picker="year" @change="changeYearData" />
<a-date-picker v-model:value="selectYear" picker="year" @change="changeYearData" valueFormat="YYYY" />
</template>
</a-table>
<a-pagination
@ -24,36 +24,146 @@
import { ref } from 'vue';
import { http } from '/nerv-lib/util/http';
import { Pagination } from 'ant-design-vue';
import { tableColumns } from '../config';
import { energyConsumption } from '/@/api/carbonEmissionFactorLibrary';
import dayjs, { Dayjs } from 'dayjs';
import { carbonEmission } from '/@/api/carbonEmissionFactorLibrary';
defineOptions({
energyType: 'CarbonEmissions', // name
components: {
'a-pagination': Pagination,
},
});
const data = ref([]);
const selectYear = ref<Dayjs>();
const total = ref<number>()
const queryParams = ref({
pageNum: 1,
pageSize: 10,
})
const orgId = ref('');
const result = JSON.parse(sessionStorage.getItem('ORGID')!);
orgId.value = result;
const fetch = (api, params = { orgId } ) => {
return http.post(api, params);
};
const data = ref([]);
const selectYear = ref<Dayjs>(dayjs( new Date().getFullYear().toString()));
const total = ref<number>()
const queryParams = ref({
pageNum: 1,
pageSize: 10,
year: selectYear.value.format('YYYY'),
orgId: orgId.value
})
//
const changeYearData = () => {
queryParams.value.year = selectYear.value.format('YYYY')
queryParams.value.year = selectYear.value
getTableList()
}
//
const column: TableColumnsType [] = [
{
title: '排放类型',
dataIndex: 'cnValue',
customCell: (record, rowIndex) => {
if (rowIndex == undefined) {
return {
rowSpan: 0,
colSpan: 0,
};
}
const rowSpan = getRowSpan('cnValue', record, data.value);
if (rowIndex != 0 && data.value[rowIndex - 1].name == record.name) {
return {
rowSpan: 0,
colSpan: 0,
};
}
return {
rowSpan: rowSpan,
};
},
},
{
title: '能源种类',
dataIndex: 'energyType',
},
{
title: '计量单位',
dataIndex: 'unit',
},
{
title: '加权平均',
dataIndex: 'averageFactorValue',
},
{
title: '全年',
dataIndex: 'carbonYearly',
},
{
title: '1月',
dataIndex: 'jan',
},
{
title: '2月',
dataIndex: 'feb',
},
{
title: '3月',
dataIndex: 'mar',
},
{
title: '4月',
dataIndex: 'apr',
},
{
title: '5月',
dataIndex: 'may',
},
{
title: '6月',
dataIndex: 'jun',
},
{
title: '7月',
dataIndex: 'jul',
},
{
title: '8月',
dataIndex: 'aug',
},
{
title: '9月',
dataIndex: 'sep',
},
{
title: '10月',
dataIndex: 'oct',
},
{
title: '11月',
dataIndex: 'nov',
},
{
title: '12月',
dataIndex: 'dec',
},
];
//
const getRowSpan = (dataIndex: string, record: any, data: any, dependents: string[] = []) => {
let rowSpan = 1;
for (let i = data.indexOf(record) + 1; i < data.length; i++) {
let shouldMerge = true;
for (const dependent of dependents) {
if (data[i][dependent] !== record[dependent]) {
shouldMerge = false;
break;
}
}
if (shouldMerge && data[i][dataIndex] === record[dataIndex]) {
rowSpan++;
} else {
break;
}
}
return rowSpan;
};
//
const getTableList = () => {
fetch(energyConsumption.pageList , queryParams.value).then((res) => {
fetch(carbonEmission.carbonEmissionStatistics , queryParams.value).then((res) => {
data.value = res.data.records
total.value = res.data.total
});

3
hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/config.ts

@ -1,3 +1,4 @@
// 能耗统计表表头
export const tableColumns = [
{
title: '序号',
@ -78,6 +79,7 @@ export const tableColumns = [
width: 130
},
];
// 碳排速算表表头
export const columns = [
{
title: '序号',
@ -120,6 +122,7 @@ export const columns = [
width: 130
},
];
// 碳排速算新增页中表头
export const drawerColumns = [
{
title: '名称',

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

@ -16,7 +16,7 @@
</template>
</template>
<template #title>
<a-date-picker v-model:value="selectYear" picker="year" @change="changeYearData" />
<a-date-picker v-model:value="selectYear" picker="year" @change="changeYearData" valueFormat="YYYY" />
<div class="buttonGroup">
<a-button type="primary" @click="addNewData">新增</a-button>
<a-button type="primary">导入</a-button>
@ -54,14 +54,13 @@
<a-input v-model:value="formState.energyType" placeholder="请输入能源种类" />
</a-form-item>
<a-form-item label="计量单位" name="unit">
<a-cascader v-model:value="formState.unit" :options="options" />
<a-cascader v-model:value="formState.unit" :options="measurementUnit" />
</a-form-item>
<a-form-item label="自动采集节点" name="collectionNode">
<a-tree-select
v-model:value="formState.collectionNode"
:tree-line="true"
:tree-data="treeData"
tree-node-filter-prop="title"
>
</a-tree-select>
</a-form-item>
@ -73,7 +72,7 @@
</a-form-item>
<a-form-item label="排放类型" name="emissionType" :required="isRequired">
<a-select v-model:value="formState.emissionType" placeholder="请选择排放类型">
<a-select-option v-for="(item, index) in emissionTypeDic" :key="index" :value="item.cnValue">
<a-select-option v-for="(item, index) in emissionTypeDic" :key="index" :value="item.id">
{{ item.cnValue }}
</a-select-option>
</a-select>
@ -159,10 +158,11 @@
import { Pagination,message,Modal } from 'ant-design-vue';
import { InboxOutlined } from '@ant-design/icons-vue';
import type { CascaderProps,TreeSelectProps,UploadChangeParam } from 'ant-design-vue';
import type { Dayjs } from 'dayjs';
import dayjs, { Dayjs } from 'dayjs';
import { http } from '/nerv-lib/util/http';
import { tableColumns } from '../config';
import { energyConsumption } from '/@/api/carbonEmissionFactorLibrary';
import { energyConsumption,carbonEmissionFactorLibrary } from '/@/api/carbonEmissionFactorLibrary';
import { group } from '/@/api/deviceManage';
import { dict } from '/@/api';
defineOptions({
energyType: 'EnergyConsumption', // name
@ -176,12 +176,13 @@
const fetch = (api, params = { orgId } ) => {
return http.post(api, params);
};
const selectYear = ref<Dayjs>();
const selectYear = ref<Dayjs>(dayjs( new Date().getFullYear().toString()));
const total = ref<number>()
const queryParams = ref({
pageNum: 1,
pageSize: 10,
orgId: orgId.value,
year: selectYear.value.format('YYYY')
})
const isRequired = ref(false);
const visible = ref(false);
@ -217,74 +218,15 @@
energyType: [{ required: true, message: '请输入能源种类', trigger: 'change' }],
isComputeCarbon: [{ required: true, message: '请选择是否计算碳排', trigger: 'change' }]
};
//
const options: CascaderProps['options'] = [
{
value: 'zhejiang',
label: 'Zhejiang',
children: [
{
value: 'hangzhou',
label: 'Hangzhou',
children: [
{
value: 'xihu',
label: 'West Lake',
},
],
},
],
},
{
value: 'jiangsu',
label: 'Jiangsu',
children: [
{
value: 'nanjing',
label: 'Nanjing',
children: [
{
value: 'zhonghuamen',
label: 'Zhong Hua Men',
},
],
},
],
},
];
// const options = ref([])
//
const emissionTypeDic = ref()
//
const measurementUnit = ref([])
//
const treeData = ref<TreeSelectProps['treeData']>([
{
title: 'parent 1',
value: 'parent 1',
children: [
{
title: 'parent 1-0',
value: 'parent 1-0',
children: [
{
title: 'my leaf',
value: 'leaf1',
},
{
title: 'your leaf',
value: 'leaf2',
},
],
},
{
title: 'parent 1-1',
value: 'parent 1-1',
},
],
},
]);
const treeData = ref<TreeSelectProps['treeData']>([]);
//
const changeYearData = () => {
queryParams.value.year = selectYear.value.format('YYYY')
queryParams.value.year = selectYear.value
getTableList()
}
//
@ -326,9 +268,19 @@
});
}else{
fetch(energyConsumption.creat , formState.value).then((res) => {
if(res.data === '新增数据已存在'){
visible.value = false
queryParams.value = formState.value
queryParams.value.pageNum = 1,
queryParams.value.pageSize = 10,
queryParams.value.orgId = orgId.value,
queryParams.value.year = selectYear.value.format('YYYY')
getTableList()
}else{
visible.value = false
message.success('操作成功!');
getTableList()
}
});
}
})
@ -338,12 +290,34 @@
};
//
const getDictList = () => {
//
fetch(energyConsumption.getDicList , {grp: 'EMISSION_TYPE'}).then((res) => {
emissionTypeDic.value = res.data
});
// fetch(energyConsumption.getDicList , {grp: 'MEASUREMENT_UNIT'}).then((res) => {
// options.value = res.data
// });
//
fetch(carbonEmissionFactorLibrary.dictionaryUnitManagement, { grp: 'MEASUREMENT_UNIT'}).then((res) => {
measurementUnit.value = res.data
measurementUnit.value = measurementUnit.value.map(item => ({
value: item.cnValue,
label: item.cnValue,
children: item.children ? item.children.map(child => ({
value: child.cnValue,
label: child.cnValue
})) : []
}));
});
//
fetch(group.queryDeviceGroupTree, { energyType: 'ELECTRICITY_USAGE',orgId: orgId.value }).then((res) => {
treeData.value = res.data
treeData.value = treeData.value.map(item => ({
value: item.pointName,
label: item.pointName,
children: item.children ? item.children.map(child => ({
value: child.pointName,
label: child.pointName
})) : []
}));
});
}
//
const addNewData = () => {

54
hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/quickCalculation/index.vue

@ -20,6 +20,7 @@
v-if="gData && gData.length > 0"
:expanded-keys="expandedKeys"
:auto-expand-parent="autoExpandParent"
:selectedKeys="selectedKeys"
:tree-data="gData"
show-line
@expand="onExpand"
@ -84,12 +85,12 @@
>
<a-row>
<a-col :span="12">
<a-form-item ref="name" label="能源种类" name="energyType">
<a-range-picker v-model:value="formState.energyType" picker="month" style="width:200px;" />
<a-form-item ref="name" label="日期范围" name="dateRange">
<a-range-picker v-model:value="formState.dateRange" picker="month" valueFormat="YYYY-MM" />
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item ref="name" label="排放因子" name="energyType">
<a-form-item ref="name" label="排放因子" name="emissionFactors">
<ns-input v-model:value="formState.emissionFactors" disabled />
</a-form-item>
</a-col>
@ -197,7 +198,8 @@
}
return parentKey;
};
const expandedKeys = ref<(string | number)[]>([]);
const expandedKeys = ref<(string | number)[]>(['0-0']);
const selectedKeys = ref<string[]>(['0-0-0']);
const searchValue = ref<string>('');
const autoExpandParent = ref<boolean>(true);
const gData = ref<TreeProps['treeData']>(genData);
@ -207,9 +209,11 @@
autoExpandParent.value = false;
};
//
const onSelect = (selectedKeys: string[], info: any) => {
const onSelect = (selectedKey: string[], info: any) => {
selectedKeys.value = selectedKey;
if(info.selected){
queryParams.value.energyType = info.node.id
statsId.value = info.node.id
getTableList()
}
};
@ -230,10 +234,15 @@
//
const onSearchTreeData = () => {
};
const statsId = ref()
//
const getTreeData = () => {
fetch(quickCalculation.carbonQuickTree).then((res) => {
gData.value = res.data
debugger
queryParams.value.energyType = gData.value[0].children[0].id
statsId.value = gData.value[0].children[0].id
getTableList()
});
};
getTreeData()
@ -242,7 +251,7 @@
const queryParams = ref({
pageNum: 1,
pageSize: 10,
orgId: orgId.value,
orgId: orgId.value
})
const tableData = ref([]);
//
@ -252,7 +261,6 @@
total.value = res.data.total
});
};
getTableList()
//
const onChange = (pageNumber: number,size: number) => {
queryParams.value.pageNum = pageNumber;
@ -268,7 +276,8 @@
// form
const rules: Record<string, Rule[]> = {
energyType: [{ required: true, message: '请输入能源种类', trigger: 'change' }],
dateRange: [{ required: true, message: '请选择日期范围', trigger: 'change' }],
emissionFactors: [{ required: true, message: '请输入能源种类', trigger: 'change' }],
};
//
const addNewData = () => {
@ -280,6 +289,7 @@
const onSelectionChange = (selectedKeys, selectedRows) => {
selectedRowKeys.value = selectedKeys;
formState.value.emissionFactors = selectedRows[0].emissionFactors
formState.value.carbonId = selectedRows[0].id
};
const queryData = ref({
orgId: orgId.value,
@ -294,18 +304,41 @@
};
//
const editData = (record) =>{
selectedRowKeys.value = [record.carbonId];
formState.value.id = record.id
formState.value.emissionFactors = record.emissionFactors
formState.value.dateRange = [record.startTime, record.endTime];
formState.value.carbonId = record.carbonId
visible.value = true
getNewTable()
};
//
const onSubmit = () => {
formRef.value
.validate()
.then(() => {
formState.value.statsId = statsId.value
formState.value.startTime = formState.value.dateRange[0]
formState.value.endTime = formState.value.dateRange[1]
console.log('values', formState, toRaw(formState));
debugger
if(formState.value.id){
fetch(quickCalculation.update,formState.value).then((res) => {
visible.value = false
selectedRowKeys.value = [];
formState.value = {}
formRef.value.resetFields();
getTableList()
});
}else{
fetch(quickCalculation.creat,formState.value).then((res) => {
console.log(res);
visible.value = false
selectedRowKeys.value = [];
formState.value = {}
formRef.value.resetFields();
getTableList()
});
}
})
.catch(error => {
console.log('error', error);
@ -334,6 +367,7 @@
const onClose = () => {
visible.value = false;
selectedRowKeys.value = [];
formState.value = {}
formRef.value.resetFields();
};
</script>

Loading…
Cancel
Save