xuziqiang 9 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

@ -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',
}

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

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

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

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

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

@ -44,7 +44,7 @@
width: 5px; width: 5px;
height: 15px; height: 15px;
background: inherit; background: inherit;
background-color: rgba(251, 156, 67, 1); background-color: #2778ff;
border: none; border: none;
border-radius: 5px; border-radius: 5px;
-moz-box-shadow: none; -moz-box-shadow: none;
@ -66,6 +66,9 @@
:scroll="{ x: 800, y: 700 }" :scroll="{ x: 800, y: 700 }"
:pagination="pagination"> :pagination="pagination">
<template #bodyCell="{ record, column }"> <template #bodyCell="{ record, column }">
<template v-if="column.dataIndex === 'address'">
{{ record.userRoleInfos?.[0].deptRoleInfoList }}
</template>
<template v-if="column.dataIndex === 'operation'"> <template v-if="column.dataIndex === 'operation'">
<a style="color: rgb(210, 0, 5)" @click="remove(record)">移除</a> <a style="color: rgb(210, 0, 5)" @click="remove(record)">移除</a>
</template> </template>
@ -93,7 +96,7 @@
const columns = [ const columns = [
{ {
title: '序号', title: '序号',
dataIndex: 'address', dataIndex: 'index',
width: 80, width: 80,
fixed: 'left', fixed: 'left',
customRender: (text: any) => { customRender: (text: any) => {
@ -102,7 +105,7 @@
}, },
{ {
title: '姓名', title: '姓名',
dataIndex: 'deviceName', dataIndex: 'realName',
width: 80, width: 80,
fixed: 'left', fixed: 'left',
key: 'deviceName', key: 'deviceName',
@ -115,13 +118,13 @@
}, },
{ {
title: '组织关系', title: '组织关系',
dataIndex: 'site', dataIndex: 'orgName',
key: 'site', key: 'site',
}, },
{ {
title: '部门', title: '部门',
dataIndex: 'department', dataIndex: 'address',
key: 'department', key: 'address',
}, },
{ {
title: '操作', title: '操作',
@ -155,7 +158,7 @@
visibleModel.value = true; visibleModel.value = true;
let ids = []; let ids = [];
dataSource.value.forEach((item) => { dataSource.value.forEach((item) => {
ids.push(item.id); ids.push(item.userId);
}); });
linkPeoples.value.getData({ id: ids, data: dataSource }); linkPeoples.value.getData({ id: ids, data: dataSource });
}; };
@ -223,7 +226,7 @@
// //
const remove = (data: any) => { const remove = (data: any) => {
dataSource.value.forEach((item, index) => { dataSource.value.forEach((item, index) => {
if (item.id === data.id) { if (item.userId === data.userId) {
dataSource.value.splice(index, 1); dataSource.value.splice(index, 1);
} }
}); });
@ -236,7 +239,7 @@
obj.selectList = []; obj.selectList = [];
dataSource.value.forEach((item) => { dataSource.value.forEach((item) => {
obj.selectList.push({ obj.selectList.push({
people: item.id, userId: item.userId,
}); });
}); });
console.log(obj, '数据'); 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" /> 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"> <div style="width: 100%; height: 370px; overflow-y: auto">
<a-tree <a-tree
:expanded-keys="expandedKeys" v-model:selectedKeys="selectedKeys"
:auto-expand-parent="autoExpandParent" v-model:expandedKeys="expandedKeys"
:tree-data="gData" :tree-data="deptTreeData"
@select="onSelect" @select="onSelect"
@expand="onExpand"
/></div> /></div>
<!-- <ns-tree-api v-bind="config" @select="treeSelect" /> -->
</div> </div>
<div class="box-right"> <div class="box-right">
<div style="width: 100%; display: flex; position: relative"> <div style="width: 100%; display: flex; position: relative">
<div class="border-card"></div> <div class="border-card"></div>
<span style="margin-left: 24px; color: #333333">人员列表 </span> <span style="margin-left: 24px; color: #333333">人员列表 </span>
<a-input-search <a-input-search
v-model:value="name" v-model:value="realName"
style="margin-bottom: 8px; width: 280px; position: absolute; right: 20px" style="margin-bottom: 8px; width: 280px; position: absolute; right: 20px"
placeholder="请输入" placeholder="请输入"
allowClear="true" allowClear="true"
@ -54,11 +52,18 @@
onChange: onSelectChange, onChange: onSelectChange,
}" }"
:columns="columns" :columns="columns"
:loading="loading"
:data-source="dataSource" :data-source="dataSource"
:rowKey="(record: any) => record.id" :rowKey="(record: any) => record.userId"
:pagination="pagination" :pagination="pagination"
:bordered="true" :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> </div>
</div> </div>
@ -69,51 +74,23 @@
import { ref, watch, computed } from 'vue'; import { ref, watch, computed } from 'vue';
import { defineComponent } from 'vue'; import { defineComponent } from 'vue';
import type { TreeProps } from 'ant-design-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 { http } from '/nerv-lib/util';
// import { editTreeConfig } from './config'; // 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 dataList: TreeProps['treeData'] = [];
const generateList = (data: TreeProps['treeData']) => { const generateList = (data: TreeProps['treeData']) => {
for (let i = 0; i < data.length; i++) { for (let i = 0; i < data.length; i++) {
const node = data[i]; const node = data[i];
const key = node.key; const key = node.key;
dataList.push({ key, title: key }); dataList.push({ key, title: node.title });
if (node.children) { if (node.children) {
generateList(node.children); generateList(node.children);
} }
} }
}; };
generateList(genData);
const getParentKey = ( const getParentKey = (
key: string | number, key: string | number,
tree: TreeProps['treeData'], tree: TreeProps['treeData'],
@ -133,55 +110,101 @@
}; };
export default defineComponent({ export default defineComponent({
setup(props, { emit }) { setup(props, { emit }) {
// const config = computed(() => {
// return editTreeConfig(result);
// });
// //
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 dataSource = ref([]); const dataSource = ref([]);
const loading = ref(false);
const selectedRowKey = ref([]); const selectedRowKey = ref([]);
const selectedRow = 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 = () => { const onSearch = () => {
http pagination.value.current = 1;
.post(device.queryDevicePage, { getList();
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;
});
}; };
const onSelect = (selectedKeys: any, info: any) => { 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; 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; const getDepartList = (params) => {
pagination.value.pageSize = pageSize; 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 http
.post(device.queryDevicePage, { .post(origanizemanage.userList, {
pageNum: pagination.value.current, pageNum: pagination.value.current,
pageSize: pagination.value.pageSize, pageSize: pagination.value.pageSize,
orgId: orgId.value, orgId: selectOrgId.value,
deptId: selectDeptId.value,
realName: realName.value,
}) })
.then((res) => { .then((res) => {
dataSource.value = res.data.records; dataSource.value = res.data.records;
pagination.value.total = res.data.total; pagination.value.total = res.data.total;
loading.value = false;
}); });
console.log(selectedRowKey.value, selectedRow.value);
}; };
const onSelectChange = (selectedRowKeys: any, selectedRows: any) => { const handleChangePage = (current: number, pageSize: number) => {
console.log(selectedRowKeys, selectedRows); pagination.value.current = current;
console.log(selectedRows, '数据'); pagination.value.pageSize = pageSize;
getList();
};
const onSelectChange = (selectedRowKeys: any, selectedRows: any) => {
selectedRowKey.value = selectedRowKeys; selectedRowKey.value = selectedRowKeys;
selectedRow.value = selectedRows; selectedRow.value = selectedRows;
}; };
@ -200,14 +223,14 @@
const columns = [ const columns = [
{ {
title: '序号', title: '序号',
dataIndex: 'address', dataIndex: 'index',
customRender: (text: any) => { customRender: (text: any) => {
return text.index + 1; return text.index + 1;
}, },
}, },
{ {
title: '姓名', title: '姓名',
dataIndex: 'deviceName', dataIndex: 'realName',
}, },
{ {
title: '性别', title: '性别',
@ -215,7 +238,7 @@
}, },
{ {
title: '组织关系', title: '组织关系',
dataIndex: 'address', dataIndex: 'orgName',
}, },
{ {
title: '部门 ', title: '部门 ',
@ -227,48 +250,32 @@
emit('handleOk', { id: selectedRowKey.value, data: selectedRow.value }); emit('handleOk', { id: selectedRowKey.value, data: selectedRow.value });
show.value = false; show.value = false;
pagination.value.current = 1; pagination.value.current = 1;
realName.value = null;
searchValue.value = '';
}; };
const getData = (data: any) => { const getData = (data: any) => {
selectedRow.value = data.data; selectedRow.value = data.data;
selectedRowKey.value = data.id; selectedRowKey.value = data.id;
show.value = true; show.value = true;
http //
.post(device.queryDevicePage, { getList();
pageNum: pagination.value.current, //
pageSize: pagination.value.pageSize, getTreeData();
orgId: orgId.value,
})
.then((res) => {
dataSource.value = res.data.records;
pagination.value.total = res.data.total;
});
}; };
const show = ref(false); const show = ref(false);
const handleCancel = () => { const handleCancel = () => {
// //
pagination.value.current = 1; pagination.value.current = 1;
realName.value = null;
emit('handleCancel', null); emit('handleCancel', null);
show.value = false; 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) => { watch(searchValue, (value) => {
console.log(gData.value, '数据');
const expanded = dataList const expanded = dataList
.map((item: TreeProps['treeData'][number]) => { .map((item: TreeProps['treeData'][number]) => {
if (item.title.indexOf(value) > -1) { 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; return null;
}) })
@ -276,30 +283,35 @@
expandedKeys.value = expanded; expandedKeys.value = expanded;
searchValue.value = value; searchValue.value = value;
autoExpandParent.value = true; autoExpandParent.value = true;
console.log(expandedKeys.value, '数据');
}); });
return { return {
columns, columns,
name, realName,
orgId, orgId,
// config, processDepartmentTree,
onSearch, onSearch,
getList,
loading,
dataSource, dataSource,
onSelect, onSelect,
gData, deptTreeData,
onExpand,
selectedRow, selectedRow,
selectedRowKey, selectedRowKey,
autoExpandParent, autoExpandParent,
expandedKeys, expandedKeys,
selectedKeys,
onSelectChange, onSelectChange,
pagination, pagination,
handleOk, handleOk,
show, show,
getData, getData,
getTreeData,
getDepartList,
searchValue, searchValue,
deviceName, deviceName,
handleCancel, handleCancel,
selectDeptId,
selectOrgId,
}; };
}, },
}); });
@ -313,7 +325,7 @@
width: 5px; width: 5px;
height: 15px; height: 15px;
background: inherit; background: inherit;
background-color: rgba(251, 156, 67, 1); background-color: @primary-color;
border: none; border: none;
border-radius: 5px; border-radius: 5px;
-moz-box-shadow: none; -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> <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
}); });

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

@ -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: '名称',

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

@ -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) => {
visible.value = false if(res.data === '新增数据已存在'){
message.success('操作成功!'); visible.value = false
getTableList() 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 = () => { 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 = () => {

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

@ -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>

Loading…
Cancel
Save