From 85cd1834933abe4ef9fc12c36f9049670e6e78c9 Mon Sep 17 00:00:00 2001
From: fks-xuxinyue <2822784518@qq.com>
Date: Wed, 17 Jul 2024 15:54:10 +0800
Subject: [PATCH 1/2] taskid:088 remark:"commit"
---
.../src/api/carbonEmissionFactorLibrary.ts | 4 +
.../carbonEmissions/index copy.vue | 179 ------------------
.../carbonEmissions/index.vue | 136 +++++++++++--
.../carbonEmissionStatistics/config.ts | 7 +-
.../energyConsumption/index.vue | 126 +++++-------
.../quickCalculation/index.vue | 58 ++++--
6 files changed, 228 insertions(+), 282 deletions(-)
delete mode 100644 hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/carbonEmissions/index copy.vue
diff --git a/hx-ai-intelligent/src/api/carbonEmissionFactorLibrary.ts b/hx-ai-intelligent/src/api/carbonEmissionFactorLibrary.ts
index aaad9c2..5d666ad 100644
--- a/hx-ai-intelligent/src/api/carbonEmissionFactorLibrary.ts
+++ b/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',
}
\ No newline at end of file
diff --git a/hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/carbonEmissions/index copy.vue b/hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/carbonEmissions/index copy.vue
deleted file mode 100644
index c205a2d..0000000
--- a/hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/carbonEmissions/index copy.vue
+++ /dev/null
@@ -1,179 +0,0 @@
-
-
-
-
-
-
-
diff --git a/hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/carbonEmissions/index.vue b/hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/carbonEmissions/index.vue
index be5bf5b..9298666 100644
--- a/hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/carbonEmissions/index.vue
+++ b/hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/carbonEmissions/index.vue
@@ -1,13 +1,13 @@
-
+
();
- const total = ref()
- 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( new Date().getFullYear().toString()));
+ const total = ref()
+ 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
});
diff --git a/hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/config.ts b/hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/config.ts
index 6c8fd15..6f69329 100644
--- a/hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/config.ts
+++ b/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: '名称',
diff --git a/hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/energyConsumption/index.vue b/hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/energyConsumption/index.vue
index 7026fdb..78ff753 100644
--- a/hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/energyConsumption/index.vue
+++ b/hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/energyConsumption/index.vue
@@ -16,7 +16,7 @@
-
+
人员列表
+ :size="'middle'">
+
+
+ {{ record.userRoleInfos?.[0].deptRoleInfoList }}
+
+
+
@@ -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('');
+ const deviceName = ref('');
+ const autoExpandParent = ref(true);
+ const deptTreeData = ref([]);
+ //选择 组织
+ const selectOrgId = ref('');
+ selectOrgId.value = result;
+ //选择部门
+ const selectDeptId = ref('');
+
const onSearch = () => {
+ pagination.value.current = 1;
+ getList();
+ };
+ const onSelect = (selectedKeys: any, info: any) => {
+ 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;
+ 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 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,
- deviceName: name.value,
- 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;
});
};
- const onSelect = (selectedKeys: any, info: any) => {
- console.log('selected', selectedKeys, info.node.dataRef);
- pagination.value.current = 1;
- onSearch();
- };
-
const handleChangePage = (current: number, pageSize: number) => {
pagination.value.current = current;
pagination.value.pageSize = pageSize;
- 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;
- });
- console.log(selectedRowKey.value, selectedRow.value);
+ getList();
};
- const onSelectChange = (selectedRowKeys: any, selectedRows: any) => {
- console.log(selectedRowKeys, selectedRows);
- console.log(selectedRows, '数据');
+ 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('');
- const deviceName = ref('');
- const autoExpandParent = ref(true);
- const gData = ref(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;