xuziqiang 4 months ago
parent
commit
f915dab012
  1. 4
      hx-ai-intelligent/src/api/carbonEmissionFactorLibrary.ts
  2. 3
      hx-ai-intelligent/src/view/alarmManagement/alarmSettings/equipmentAlarm/configureDeviceAlarms.vue
  3. 5
      hx-ai-intelligent/src/view/alarmManagement/alarmSettings/equipmentAlarm/editConfigureDeviceAlarm.vue
  4. 21
      hx-ai-intelligent/src/view/alarmManagement/alarmSettings/notificationManagement/index.vue
  5. 214
      hx-ai-intelligent/src/view/alarmManagement/alarmSettings/notificationManagement/linkPeople/index.vue
  6. 179
      hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/carbonEmissions/index copy.vue
  7. 136
      hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/carbonEmissions/index.vue
  8. 7
      hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/config.ts
  9. 126
      hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/energyConsumption/index.vue
  10. 58
      hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/quickCalculation/index.vue

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

@ -31,4 +31,8 @@ export enum quickCalculation {
creat = '/carbon-smart/api/carbon/energy/correlation/creat',
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',
}

3
hx-ai-intelligent/src/view/alarmManagement/alarmSettings/equipmentAlarm/configureDeviceAlarms.vue

@ -11,6 +11,9 @@
}"
@click="clickSwitch({ enableRules: record.enableRules, record: record })" />
</template>
<template v-if="column.dataIndex === 'valueType'">
{{ record.valueType.label }}
</template>
</template>
</ns-view-list-table>
<!-- 新增or编辑界面 -->

5
hx-ai-intelligent/src/view/alarmManagement/alarmSettings/equipmentAlarm/editConfigureDeviceAlarm.vue

@ -235,8 +235,8 @@
};
//
const qzOptions = ref<SelectProps['options']>([
{ value: 1, label: '实时值', code: '1' },
{ value: 2, label: '平均值', code: '2' },
{ value: 1, label: '实时值' },
{ value: 2, label: '平均值' },
]);
//
const ljOptions = ref<SelectProps['options']>([
@ -331,6 +331,7 @@
infoObject.value.alarmList = infoObject.value.hxAlarmRuleLogicList || [];
delete infoObject.value.hxAlarmRuleLogicList;
infoObject.value.deviceType = selectDevice;
infoObject.value.valueType = infoObject.value.valueType.value;
infoObject.value.ruleType = infoObject.value.ruleType + '';
}
});

21
hx-ai-intelligent/src/view/alarmManagement/alarmSettings/notificationManagement/index.vue

@ -44,7 +44,7 @@
width: 5px;
height: 15px;
background: inherit;
background-color: rgba(251, 156, 67, 1);
background-color: #2778ff;
border: none;
border-radius: 5px;
-moz-box-shadow: none;
@ -66,6 +66,9 @@
:scroll="{ x: 800, y: 700 }"
:pagination="pagination">
<template #bodyCell="{ record, column }">
<template v-if="column.dataIndex === 'address'">
{{ record.userRoleInfos?.[0].deptRoleInfoList }}
</template>
<template v-if="column.dataIndex === 'operation'">
<a style="color: rgb(210, 0, 5)" @click="remove(record)">移除</a>
</template>
@ -93,7 +96,7 @@
const columns = [
{
title: '序号',
dataIndex: 'address',
dataIndex: 'index',
width: 80,
fixed: 'left',
customRender: (text: any) => {
@ -102,7 +105,7 @@
},
{
title: '姓名',
dataIndex: 'deviceName',
dataIndex: 'realName',
width: 80,
fixed: 'left',
key: 'deviceName',
@ -115,13 +118,13 @@
},
{
title: '组织关系',
dataIndex: 'site',
dataIndex: 'orgName',
key: 'site',
},
{
title: '部门',
dataIndex: 'department',
key: 'department',
dataIndex: 'address',
key: 'address',
},
{
title: '操作',
@ -155,7 +158,7 @@
visibleModel.value = true;
let ids = [];
dataSource.value.forEach((item) => {
ids.push(item.id);
ids.push(item.userId);
});
linkPeoples.value.getData({ id: ids, data: dataSource });
};
@ -223,7 +226,7 @@
//
const remove = (data: any) => {
dataSource.value.forEach((item, index) => {
if (item.id === data.id) {
if (item.userId === data.userId) {
dataSource.value.splice(index, 1);
}
});
@ -236,7 +239,7 @@
obj.selectList = [];
dataSource.value.forEach((item) => {
obj.selectList.push({
people: item.id,
userId: item.userId,
});
});
console.log(obj, '数据');

214
hx-ai-intelligent/src/view/alarmManagement/alarmSettings/notificationManagement/linkPeople/index.vue

@ -24,20 +24,18 @@
src="https://files.axshare.com/gsc/4T0UQR/7e/5d/a2/7e5da2a277344db8af30521cefeb70cc/images/告警设置/u150.svg?pageId=1f58c1ba-b461-4fe8-a2b3-295f1e7b0aa0" />
<div style="width: 100%; height: 370px; overflow-y: auto">
<a-tree
:expanded-keys="expandedKeys"
:auto-expand-parent="autoExpandParent"
:tree-data="gData"
v-model:selectedKeys="selectedKeys"
v-model:expandedKeys="expandedKeys"
:tree-data="deptTreeData"
@select="onSelect"
@expand="onExpand"
/></div>
<!-- <ns-tree-api v-bind="config" @select="treeSelect" /> -->
</div>
<div class="box-right">
<div style="width: 100%; display: flex; position: relative">
<div class="border-card"></div>
<span style="margin-left: 24px; color: #333333">人员列表 </span>
<a-input-search
v-model:value="name"
v-model:value="realName"
style="margin-bottom: 8px; width: 280px; position: absolute; right: 20px"
placeholder="请输入"
allowClear="true"
@ -54,11 +52,18 @@
onChange: onSelectChange,
}"
:columns="columns"
:loading="loading"
:data-source="dataSource"
:rowKey="(record: any) => record.id"
:rowKey="(record: any) => record.userId"
:pagination="pagination"
:bordered="true"
:size="'middle'" />
:size="'middle'">
<template #bodyCell="{ record, column }">
<template v-if="column.dataIndex === 'address'">
{{ record.userRoleInfos?.[0].deptRoleInfoList }}
</template>
</template>
</a-table>
</div>
</div>
</div>
@ -69,51 +74,23 @@
import { ref, watch, computed } from 'vue';
import { defineComponent } from 'vue';
import type { TreeProps } from 'ant-design-vue';
import { device } from '/@/api/deviceManage';
import { origanizemanage } from '/@/api/origanizemanage';
import { department } from '/@/api/origanizemanage';
import { http } from '/nerv-lib/util';
// import { editTreeConfig } from './config';
const x = 3;
const y = 2;
const z = 1;
const genData: TreeProps['treeData'] = [];
const generateData = (_level: number, _preKey?: string, _tns?: TreeProps['treeData']) => {
const preKey = _preKey || '0';
const tns = _tns || genData;
const children = [];
for (let i = 0; i < x; i++) {
const key = `${preKey}-${i}`;
tns.push({ title: key, key });
if (i < y) {
children.push(key);
}
}
if (_level < 0) {
return tns;
}
const level = _level - 1;
children.forEach((key, index) => {
tns[index].children = [];
return generateData(level, key, tns[index].children);
});
};
generateData(z);
//
const dataList: TreeProps['treeData'] = [];
const generateList = (data: TreeProps['treeData']) => {
for (let i = 0; i < data.length; i++) {
const node = data[i];
const key = node.key;
dataList.push({ key, title: key });
dataList.push({ key, title: node.title });
if (node.children) {
generateList(node.children);
}
}
};
generateList(genData);
const getParentKey = (
key: string | number,
tree: TreeProps['treeData'],
@ -133,55 +110,101 @@
};
export default defineComponent({
setup(props, { emit }) {
// const config = computed(() => {
// return editTreeConfig(result);
// });
//
const orgId = ref('');
const result = JSON.parse(sessionStorage.getItem('ORGID')!);
orgId.value = result;
const dataSource = ref([]);
const loading = ref(false);
const selectedRowKey = ref([]);
const selectedRow = ref([]);
const name = ref(null);
const realName = ref(null);
//
const expandedKeys = ref<(string | number)[]>([]);
const selectedKeys = ref([]);
const searchValue = ref<string>('');
const deviceName = ref<string>('');
const autoExpandParent = ref<boolean>(true);
const deptTreeData = ref([]);
//
const selectOrgId = ref('');
selectOrgId.value = result;
//
const selectDeptId = ref('');
const onSearch = () => {
http
.post(device.queryDevicePage, {
pageNum: pagination.value.current,
pageSize: pagination.value.pageSize,
deviceName: name.value,
orgId: orgId.value,
})
.then((res) => {
dataSource.value = res.data.records;
pagination.value.total = res.data.total;
});
pagination.value.current = 1;
getList();
};
const onSelect = (selectedKeys: any, info: any) => {
console.log('selected', selectedKeys, info.node.dataRef);
selectedKeys.value = selectedKeys;
if (info.node.dataRef.deptInfo) {
selectDeptId.value = info.node.dataRef.deptInfo.deptId;
selectOrgId.value = info.node.dataRef.deptInfo.orgId;
}
if (info.node.dataRef.orgInfo) {
selectOrgId.value = info.node.dataRef.orgInfo.orgId;
selectDeptId.value = '';
}
pagination.value.current = 1;
onSearch();
getList();
};
//
const processDepartmentTree = (tree) => {
tree.forEach((item) => {
item.deptInfo = item.deptInfo;
item.key = item.deptInfo.deptId;
item.title = item.deptInfo.deptName;
item.children = processDepartmentTree(item.children); //
});
return tree;
};
const handleChangePage = (current: number, pageSize: number) => {
pagination.value.current = current;
pagination.value.pageSize = pageSize;
//
const getDepartList = (params) => {
return http.post(department.queryDeptTree, params).then((res) => {
const result = res.data.map((item) => ({
key: item.orgInfo.orgId,
orgInfo: item.orgInfo,
title: item.orgInfo.orgName,
children: processDepartmentTree(item.deptTrees),
}));
return result;
});
};
//
const getTreeData = () => {
getDepartList({ orgId: orgId.value }).then((res) => {
deptTreeData.value = res;
selectedKeys.value = [orgId.value];
generateList(deptTreeData.value);
});
};
//
const getList = () => {
loading.value = true;
http
.post(device.queryDevicePage, {
.post(origanizemanage.userList, {
pageNum: pagination.value.current,
pageSize: pagination.value.pageSize,
orgId: orgId.value,
orgId: selectOrgId.value,
deptId: selectDeptId.value,
realName: realName.value,
})
.then((res) => {
dataSource.value = res.data.records;
pagination.value.total = res.data.total;
loading.value = false;
});
console.log(selectedRowKey.value, selectedRow.value);
};
const onSelectChange = (selectedRowKeys: any, selectedRows: any) => {
console.log(selectedRowKeys, selectedRows);
console.log(selectedRows, '数据');
const handleChangePage = (current: number, pageSize: number) => {
pagination.value.current = current;
pagination.value.pageSize = pageSize;
getList();
};
const onSelectChange = (selectedRowKeys: any, selectedRows: any) => {
selectedRowKey.value = selectedRowKeys;
selectedRow.value = selectedRows;
};
@ -200,14 +223,14 @@
const columns = [
{
title: '序号',
dataIndex: 'address',
dataIndex: 'index',
customRender: (text: any) => {
return text.index + 1;
},
},
{
title: '姓名',
dataIndex: 'deviceName',
dataIndex: 'realName',
},
{
title: '性别',
@ -215,7 +238,7 @@
},
{
title: '组织关系',
dataIndex: 'address',
dataIndex: 'orgName',
},
{
title: '部门 ',
@ -227,48 +250,32 @@
emit('handleOk', { id: selectedRowKey.value, data: selectedRow.value });
show.value = false;
pagination.value.current = 1;
realName.value = null;
searchValue.value = '';
};
const getData = (data: any) => {
selectedRow.value = data.data;
selectedRowKey.value = data.id;
show.value = true;
http
.post(device.queryDevicePage, {
pageNum: pagination.value.current,
pageSize: pagination.value.pageSize,
orgId: orgId.value,
})
.then((res) => {
dataSource.value = res.data.records;
pagination.value.total = res.data.total;
});
//
getList();
//
getTreeData();
};
const show = ref(false);
const handleCancel = () => {
//
pagination.value.current = 1;
realName.value = null;
emit('handleCancel', null);
show.value = false;
};
//
const expandedKeys = ref<(string | number)[]>([]);
const searchValue = ref<string>('');
const deviceName = ref<string>('');
const autoExpandParent = ref<boolean>(true);
const gData = ref<TreeProps['treeData']>(genData);
const onExpand = (keys: string[]) => {
expandedKeys.value = keys;
autoExpandParent.value = false;
console.log(keys, '数据');
};
watch(searchValue, (value) => {
console.log(gData.value, '数据');
const expanded = dataList
.map((item: TreeProps['treeData'][number]) => {
if (item.title.indexOf(value) > -1) {
return getParentKey(item.key, gData.value);
console.log(item.title.indexOf(value));
return getParentKey(item.key, deptTreeData.value);
}
return null;
})
@ -276,30 +283,35 @@
expandedKeys.value = expanded;
searchValue.value = value;
autoExpandParent.value = true;
console.log(expandedKeys.value, '数据');
});
return {
columns,
name,
realName,
orgId,
// config,
processDepartmentTree,
onSearch,
getList,
loading,
dataSource,
onSelect,
gData,
onExpand,
deptTreeData,
selectedRow,
selectedRowKey,
autoExpandParent,
expandedKeys,
selectedKeys,
onSelectChange,
pagination,
handleOk,
show,
getData,
getTreeData,
getDepartList,
searchValue,
deviceName,
handleCancel,
selectDeptId,
selectOrgId,
};
},
});
@ -313,7 +325,7 @@
width: 5px;
height: 15px;
background: inherit;
background-color: rgba(251, 156, 67, 1);
background-color: @primary-color;
border: none;
border-radius: 5px;
-moz-box-shadow: none;

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
});

7
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: '序号',
@ -101,8 +103,8 @@ export const columns = [
},
{
title: '启用时间',
className: 'startTime ',
dataIndex: 'startTime ',
className: 'startTime',
dataIndex: 'startTime',
},
{
title: '结束时间',
@ -120,6 +122,7 @@ export const columns = [
width: 130
},
];
// 碳排速算新增页中表头
export const drawerColumns = [
{
title: '名称',

126
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) => {
visible.value = false
message.success('操作成功!');
getTableList()
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 = () => {

58
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));
fetch(quickCalculation.creat,formState.value).then((res) => {
console.log(res);
});
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) => {
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