taskid:088 remark:"commit"
This commit is contained in:
@@ -32,3 +32,7 @@ export enum quickCalculation {
|
|||||||
update = '/carbon-smart/api/carbon/energy/correlation/update',
|
update = '/carbon-smart/api/carbon/energy/correlation/update',
|
||||||
del = '/carbon-smart/api/carbon/energy/correlation/del',
|
del = '/carbon-smart/api/carbon/energy/correlation/del',
|
||||||
}
|
}
|
||||||
|
// 碳排管理-碳排统计接口
|
||||||
|
export enum carbonEmission {
|
||||||
|
carbonEmissionStatistics = '/carbon-smart/api/carbon/energy/correlation/carbonEmissionStatistics',
|
||||||
|
}
|
@@ -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>
|
|
@@ -1,13 +1,13 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<a-table
|
<a-table
|
||||||
:columns="tableColumns"
|
:columns="column"
|
||||||
:data-source="data"
|
:data-source="data"
|
||||||
bordered
|
bordered
|
||||||
:pagination="false"
|
:pagination="false"
|
||||||
:scroll="{ x: 2000 }">
|
:scroll="{ x: 2000 }">
|
||||||
<template #title>
|
<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>
|
</template>
|
||||||
</a-table>
|
</a-table>
|
||||||
<a-pagination
|
<a-pagination
|
||||||
@@ -24,36 +24,146 @@
|
|||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import { http } from '/nerv-lib/util/http';
|
import { http } from '/nerv-lib/util/http';
|
||||||
import { Pagination } from 'ant-design-vue';
|
import { Pagination } from 'ant-design-vue';
|
||||||
import { tableColumns } from '../config';
|
import dayjs, { Dayjs } from 'dayjs';
|
||||||
import { energyConsumption } from '/@/api/carbonEmissionFactorLibrary';
|
import { carbonEmission } from '/@/api/carbonEmissionFactorLibrary';
|
||||||
defineOptions({
|
defineOptions({
|
||||||
energyType: 'CarbonEmissions', // 与页面路由name一致缓存才可生效
|
energyType: 'CarbonEmissions', // 与页面路由name一致缓存才可生效
|
||||||
components: {
|
components: {
|
||||||
'a-pagination': Pagination,
|
'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 orgId = ref('');
|
||||||
const result = JSON.parse(sessionStorage.getItem('ORGID')!);
|
const result = JSON.parse(sessionStorage.getItem('ORGID')!);
|
||||||
orgId.value = result;
|
orgId.value = result;
|
||||||
const fetch = (api, params = { orgId } ) => {
|
const fetch = (api, params = { orgId } ) => {
|
||||||
return http.post(api, params);
|
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 = () => {
|
const changeYearData = () => {
|
||||||
queryParams.value.year = selectYear.value.format('YYYY')
|
queryParams.value.year = selectYear.value
|
||||||
getTableList()
|
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 = () => {
|
const getTableList = () => {
|
||||||
fetch(energyConsumption.pageList , queryParams.value).then((res) => {
|
fetch(carbonEmission.carbonEmissionStatistics , queryParams.value).then((res) => {
|
||||||
data.value = res.data.records
|
data.value = res.data.records
|
||||||
total.value = res.data.total
|
total.value = res.data.total
|
||||||
});
|
});
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
// 能耗统计表表头
|
||||||
export const tableColumns = [
|
export const tableColumns = [
|
||||||
{
|
{
|
||||||
title: '序号',
|
title: '序号',
|
||||||
@@ -78,6 +79,7 @@ export const tableColumns = [
|
|||||||
width: 130
|
width: 130
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
// 碳排速算表表头
|
||||||
export const columns = [
|
export const columns = [
|
||||||
{
|
{
|
||||||
title: '序号',
|
title: '序号',
|
||||||
@@ -101,8 +103,8 @@ export const columns = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '启用时间',
|
title: '启用时间',
|
||||||
className: 'startTime ',
|
className: 'startTime',
|
||||||
dataIndex: 'startTime ',
|
dataIndex: 'startTime',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '结束时间',
|
title: '结束时间',
|
||||||
@@ -120,6 +122,7 @@ export const columns = [
|
|||||||
width: 130
|
width: 130
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
// 碳排速算新增页中表头
|
||||||
export const drawerColumns = [
|
export const drawerColumns = [
|
||||||
{
|
{
|
||||||
title: '名称',
|
title: '名称',
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
</template>
|
</template>
|
||||||
</template>
|
</template>
|
||||||
<template #title>
|
<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">
|
<div class="buttonGroup">
|
||||||
<a-button type="primary" @click="addNewData">新增</a-button>
|
<a-button type="primary" @click="addNewData">新增</a-button>
|
||||||
<a-button type="primary">导入</a-button>
|
<a-button type="primary">导入</a-button>
|
||||||
@@ -54,14 +54,13 @@
|
|||||||
<a-input v-model:value="formState.energyType" placeholder="请输入能源种类" />
|
<a-input v-model:value="formState.energyType" placeholder="请输入能源种类" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item label="计量单位" name="unit">
|
<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>
|
||||||
<a-form-item label="自动采集节点" name="collectionNode">
|
<a-form-item label="自动采集节点" name="collectionNode">
|
||||||
<a-tree-select
|
<a-tree-select
|
||||||
v-model:value="formState.collectionNode"
|
v-model:value="formState.collectionNode"
|
||||||
:tree-line="true"
|
:tree-line="true"
|
||||||
:tree-data="treeData"
|
:tree-data="treeData"
|
||||||
tree-node-filter-prop="title"
|
|
||||||
>
|
>
|
||||||
</a-tree-select>
|
</a-tree-select>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
@@ -73,7 +72,7 @@
|
|||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item label="排放类型" name="emissionType" :required="isRequired">
|
<a-form-item label="排放类型" name="emissionType" :required="isRequired">
|
||||||
<a-select v-model:value="formState.emissionType" placeholder="请选择排放类型">
|
<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 }}
|
{{ item.cnValue }}
|
||||||
</a-select-option>
|
</a-select-option>
|
||||||
</a-select>
|
</a-select>
|
||||||
@@ -159,10 +158,11 @@
|
|||||||
import { Pagination,message,Modal } from 'ant-design-vue';
|
import { Pagination,message,Modal } from 'ant-design-vue';
|
||||||
import { InboxOutlined } from '@ant-design/icons-vue';
|
import { InboxOutlined } from '@ant-design/icons-vue';
|
||||||
import type { CascaderProps,TreeSelectProps,UploadChangeParam } from 'ant-design-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 { http } from '/nerv-lib/util/http';
|
||||||
import { tableColumns } from '../config';
|
import { tableColumns } from '../config';
|
||||||
import { energyConsumption } from '/@/api/carbonEmissionFactorLibrary';
|
import { energyConsumption,carbonEmissionFactorLibrary } from '/@/api/carbonEmissionFactorLibrary';
|
||||||
|
import { group } from '/@/api/deviceManage';
|
||||||
import { dict } from '/@/api';
|
import { dict } from '/@/api';
|
||||||
defineOptions({
|
defineOptions({
|
||||||
energyType: 'EnergyConsumption', // 与页面路由name一致缓存才可生效
|
energyType: 'EnergyConsumption', // 与页面路由name一致缓存才可生效
|
||||||
@@ -176,12 +176,13 @@
|
|||||||
const fetch = (api, params = { orgId } ) => {
|
const fetch = (api, params = { orgId } ) => {
|
||||||
return http.post(api, params);
|
return http.post(api, params);
|
||||||
};
|
};
|
||||||
const selectYear = ref<Dayjs>();
|
const selectYear = ref<Dayjs>(dayjs( new Date().getFullYear().toString()));
|
||||||
const total = ref<number>()
|
const total = ref<number>()
|
||||||
const queryParams = ref({
|
const queryParams = ref({
|
||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
orgId: orgId.value,
|
orgId: orgId.value,
|
||||||
|
year: selectYear.value.format('YYYY')
|
||||||
})
|
})
|
||||||
const isRequired = ref(false);
|
const isRequired = ref(false);
|
||||||
const visible = ref(false);
|
const visible = ref(false);
|
||||||
@@ -217,74 +218,15 @@
|
|||||||
energyType: [{ required: true, message: '请输入能源种类', trigger: 'change' }],
|
energyType: [{ required: true, message: '请输入能源种类', trigger: 'change' }],
|
||||||
isComputeCarbon: [{ 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 emissionTypeDic = ref()
|
||||||
|
// 计量单位的变量
|
||||||
|
const measurementUnit = ref([])
|
||||||
// 定义自动采集节点数的变量
|
// 定义自动采集节点数的变量
|
||||||
const treeData = ref<TreeSelectProps['treeData']>([
|
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 changeYearData = () => {
|
const changeYearData = () => {
|
||||||
queryParams.value.year = selectYear.value.format('YYYY')
|
queryParams.value.year = selectYear.value
|
||||||
getTableList()
|
getTableList()
|
||||||
}
|
}
|
||||||
// 获取表格数据
|
// 获取表格数据
|
||||||
@@ -326,9 +268,19 @@
|
|||||||
});
|
});
|
||||||
}else{
|
}else{
|
||||||
fetch(energyConsumption.creat , formState.value).then((res) => {
|
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
|
visible.value = false
|
||||||
message.success('操作成功!');
|
message.success('操作成功!');
|
||||||
getTableList()
|
getTableList()
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -338,12 +290,34 @@
|
|||||||
};
|
};
|
||||||
// 获取字典值
|
// 获取字典值
|
||||||
const getDictList = () => {
|
const getDictList = () => {
|
||||||
|
// 获取排放类型的数据
|
||||||
fetch(energyConsumption.getDicList , {grp: 'EMISSION_TYPE'}).then((res) => {
|
fetch(energyConsumption.getDicList , {grp: 'EMISSION_TYPE'}).then((res) => {
|
||||||
emissionTypeDic.value = res.data
|
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 = () => {
|
const addNewData = () => {
|
||||||
|
@@ -20,6 +20,7 @@
|
|||||||
v-if="gData && gData.length > 0"
|
v-if="gData && gData.length > 0"
|
||||||
:expanded-keys="expandedKeys"
|
:expanded-keys="expandedKeys"
|
||||||
:auto-expand-parent="autoExpandParent"
|
:auto-expand-parent="autoExpandParent"
|
||||||
|
:selectedKeys="selectedKeys"
|
||||||
:tree-data="gData"
|
:tree-data="gData"
|
||||||
show-line
|
show-line
|
||||||
@expand="onExpand"
|
@expand="onExpand"
|
||||||
@@ -84,12 +85,12 @@
|
|||||||
>
|
>
|
||||||
<a-row>
|
<a-row>
|
||||||
<a-col :span="12">
|
<a-col :span="12">
|
||||||
<a-form-item ref="name" label="能源种类" name="energyType">
|
<a-form-item ref="name" label="日期范围" name="dateRange">
|
||||||
<a-range-picker v-model:value="formState.energyType" picker="month" style="width:200px;" />
|
<a-range-picker v-model:value="formState.dateRange" picker="month" valueFormat="YYYY-MM" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="12">
|
<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 />
|
<ns-input v-model:value="formState.emissionFactors" disabled />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
@@ -197,7 +198,8 @@
|
|||||||
}
|
}
|
||||||
return parentKey;
|
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 searchValue = ref<string>('');
|
||||||
const autoExpandParent = ref<boolean>(true);
|
const autoExpandParent = ref<boolean>(true);
|
||||||
const gData = ref<TreeProps['treeData']>(genData);
|
const gData = ref<TreeProps['treeData']>(genData);
|
||||||
@@ -207,9 +209,11 @@
|
|||||||
autoExpandParent.value = false;
|
autoExpandParent.value = false;
|
||||||
};
|
};
|
||||||
// 被选中的树节点
|
// 被选中的树节点
|
||||||
const onSelect = (selectedKeys: string[], info: any) => {
|
const onSelect = (selectedKey: string[], info: any) => {
|
||||||
|
selectedKeys.value = selectedKey;
|
||||||
if(info.selected){
|
if(info.selected){
|
||||||
queryParams.value.energyType = info.node.id
|
queryParams.value.energyType = info.node.id
|
||||||
|
statsId.value = info.node.id
|
||||||
getTableList()
|
getTableList()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -230,10 +234,15 @@
|
|||||||
// 查询因子分类树数据
|
// 查询因子分类树数据
|
||||||
const onSearchTreeData = () => {
|
const onSearchTreeData = () => {
|
||||||
};
|
};
|
||||||
|
const statsId = ref()
|
||||||
// 获取因子分类树数据
|
// 获取因子分类树数据
|
||||||
const getTreeData = () => {
|
const getTreeData = () => {
|
||||||
fetch(quickCalculation.carbonQuickTree).then((res) => {
|
fetch(quickCalculation.carbonQuickTree).then((res) => {
|
||||||
gData.value = res.data
|
gData.value = res.data
|
||||||
|
debugger
|
||||||
|
queryParams.value.energyType = gData.value[0].children[0].id
|
||||||
|
statsId.value = gData.value[0].children[0].id
|
||||||
|
getTableList()
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
getTreeData()
|
getTreeData()
|
||||||
@@ -242,7 +251,7 @@
|
|||||||
const queryParams = ref({
|
const queryParams = ref({
|
||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
orgId: orgId.value,
|
orgId: orgId.value
|
||||||
})
|
})
|
||||||
const tableData = ref([]);
|
const tableData = ref([]);
|
||||||
// 获取列表数据
|
// 获取列表数据
|
||||||
@@ -252,7 +261,6 @@
|
|||||||
total.value = res.data.total
|
total.value = res.data.total
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
getTableList()
|
|
||||||
// 分页器
|
// 分页器
|
||||||
const onChange = (pageNumber: number,size: number) => {
|
const onChange = (pageNumber: number,size: number) => {
|
||||||
queryParams.value.pageNum = pageNumber;
|
queryParams.value.pageNum = pageNumber;
|
||||||
@@ -268,7 +276,8 @@
|
|||||||
|
|
||||||
// 定义form表单的必填
|
// 定义form表单的必填
|
||||||
const rules: Record<string, Rule[]> = {
|
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 = () => {
|
const addNewData = () => {
|
||||||
@@ -280,6 +289,7 @@
|
|||||||
const onSelectionChange = (selectedKeys, selectedRows) => {
|
const onSelectionChange = (selectedKeys, selectedRows) => {
|
||||||
selectedRowKeys.value = selectedKeys;
|
selectedRowKeys.value = selectedKeys;
|
||||||
formState.value.emissionFactors = selectedRows[0].emissionFactors
|
formState.value.emissionFactors = selectedRows[0].emissionFactors
|
||||||
|
formState.value.carbonId = selectedRows[0].id
|
||||||
};
|
};
|
||||||
const queryData = ref({
|
const queryData = ref({
|
||||||
orgId: orgId.value,
|
orgId: orgId.value,
|
||||||
@@ -294,18 +304,41 @@
|
|||||||
};
|
};
|
||||||
// 点击编辑按钮
|
// 点击编辑按钮
|
||||||
const editData = (record) =>{
|
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
|
visible.value = true
|
||||||
|
getNewTable()
|
||||||
};
|
};
|
||||||
// 点击确定提交
|
// 点击确定提交
|
||||||
const onSubmit = () => {
|
const onSubmit = () => {
|
||||||
formRef.value
|
formRef.value
|
||||||
.validate()
|
.validate()
|
||||||
.then(() => {
|
.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));
|
console.log('values', formState, toRaw(formState));
|
||||||
fetch(quickCalculation.creat,formState.value).then((res) => {
|
debugger
|
||||||
console.log(res);
|
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) => {
|
||||||
|
visible.value = false
|
||||||
|
selectedRowKeys.value = [];
|
||||||
|
formState.value = {}
|
||||||
|
formRef.value.resetFields();
|
||||||
|
getTableList()
|
||||||
|
});
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.log('error', error);
|
console.log('error', error);
|
||||||
@@ -334,6 +367,7 @@
|
|||||||
const onClose = () => {
|
const onClose = () => {
|
||||||
visible.value = false;
|
visible.value = false;
|
||||||
selectedRowKeys.value = [];
|
selectedRowKeys.value = [];
|
||||||
|
formState.value = {}
|
||||||
formRef.value.resetFields();
|
formRef.value.resetFields();
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
Reference in New Issue
Block a user