Browse Source

碳排管理 代码规范

temp
fks-xuxinyue 4 months ago
parent
commit
dd7c417f81
  1. 4
      hx-ai-intelligent/src/api/carbonEmissionFactorLibrary.ts
  2. 20
      hx-ai-intelligent/src/router/carbonEmissionManage.ts
  3. 2
      hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionFactorLibrary/config.ts
  4. 411
      hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionFactorLibrary/index.vue
  5. 56
      hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/carbonEmissions/index.vue
  6. 1
      hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/index.vue
  7. 239
      hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/quickCalculation/index.vue
  8. 1021
      hx-ai-intelligent/src/view/carbonEmissionManage/carbonInventoryCheck/fillInPage/index.vue

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

@ -55,4 +55,6 @@ export enum carbonInventoryCheck {
findUnitById = '/carbon-smartapi/carbon/inventory/findById',
getDetailsList = '/carbon-smart/api/carbon/inventory/details/getDetailsList',
updateTable = '/carbon-smart/api/carbon/inventory/details/update',
}
// 排放统计接口
emissionStatistic = '/carbon-smart/api/carbon/inventory/emissionStatistic',
}

20
hx-ai-intelligent/src/router/carbonEmissionManage.ts

@ -65,6 +65,26 @@ const equipment = {
},
],
},
{
path: 'carbonInventoryCheck',
name: 'CarbonInventoryCheck',
meta: { title: '碳资产', hideChildren: true, icon: 'tanpaiguanli' },
component: Base,
redirect: { name: 'CarbonInventoryCheckIndex' },
children: [
{
path: 'index',
name: 'CarbonInventoryCheckIndex',
// component: () => import('/nerv-lib/saas/view/menuManage/index.vue'),
component: () => import('/@/view/carbonEmissionManage/carbonInventoryCheck/index.vue'),
meta: {
title: '碳资产',
keepAlive: false,
// backApi: [],
},
},
],
},
],
};
export default equipment;

2
hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionFactorLibrary/config.ts

@ -196,7 +196,7 @@ export const formConfig = (disabled) => {
componentProps: {
placeholder: '请输入参考文献',
maxLength: 300,
showCount:true
showCount: true,
},
},
],

411
hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionFactorLibrary/index.vue

@ -4,16 +4,15 @@
<div class="main">
<div class="left">
<div class="top">
<a-form style="width: 100%;margin: 0 auto;">
<a-form style="width: 100%; margin: 0 auto">
<div class="ns-form-title"><div class="title">排放分类</div></div>
<div style="padding: 0 16px !important;width: 100%;">
<div style="padding: 0 16px !important; width: 100%">
<a-row>
<a-col :span="24" style="margin-bottom: 16px;">
<a-col :span="24" style="margin-bottom: 16px">
<a-input-search
v-model:value="selectTreeDataValue"
placeholder="请输入关键词"
@search="onSearchTreeData"
/>
@search="onSearchTreeData" />
</a-col>
</a-row>
</div>
@ -21,7 +20,7 @@
<a-tree
v-if="gData && gData.length > 0"
class="draggable-tree"
style="padding: 0 16px !important;"
style="padding: 0 16px !important"
draggable
show-line
checkable
@ -39,10 +38,21 @@
<template #title="data">
<div class="treeRow">
<div>
<span v-if="data.emissionName && selectTreeDataValue && data.emissionName.indexOf(selectTreeDataValue) > -1">
{{ data.emissionName.substring(0, data.emissionName.indexOf(selectTreeDataValue)) }}
<span style="color: #f50" >{{ selectTreeDataValue }}</span>
{{ data.emissionName.substring(data.emissionName.indexOf(selectTreeDataValue) + selectTreeDataValue.length) }}
<span
v-if="
data.emissionName &&
selectTreeDataValue &&
data.emissionName.indexOf(selectTreeDataValue) > -1
">
{{
data.emissionName.substring(0, data.emissionName.indexOf(selectTreeDataValue))
}}
<span style="color: #f50">{{ selectTreeDataValue }}</span>
{{
data.emissionName.substring(
data.emissionName.indexOf(selectTreeDataValue) + selectTreeDataValue.length,
)
}}
</span>
<span v-else>{{ data.emissionName }}</span>
</div>
@ -62,12 +72,12 @@
</template>
</a-tree>
<div class="addTreeNode">
<a-button type="primary" style="width:100%;" @click="addTreeNodeData">新增</a-button>
<a-button type="primary" style="width: 100%" @click="addTreeNodeData">新增</a-button>
</div>
</div>
</div>
<div class="right">
<ns-view-list-table v-bind="tableConfig" :model="data" ref="mainRef" :scroll="{ x: 2000}">
<ns-view-list-table v-bind="tableConfig" :model="data" ref="mainRef" :scroll="{ x: 2000 }">
<template #bodyCell="{ record, column }">
<template v-if="column.dataIndex === 'emissionGas'">
{{ record.emissionGas.label }}
@ -77,10 +87,7 @@
</div>
<!-- 新增树节点 -->
<ns-modal :visible="treeNodeAdd" :title="operationTree" @ok="handleOk" @cancel="handleCancel">
<ns-input
v-model:value="addTreeNode"
class="input"
placeholder="请输入排放类型"/>
<ns-input v-model:value="addTreeNode" class="input" placeholder="请输入排放类型" />
</ns-modal>
<!-- 新增数据库数据 -->
<a-drawer
@ -117,15 +124,21 @@
<a-button type="primary" @click="addUnit">新增单位</a-button>
</div>
<div class="treePart">
<div style="width: 100%;height: 7%;display: flex;justify-content: center;align-items: center;">
<div
style="
width: 100%;
height: 7%;
display: flex;
justify-content: center;
align-items: center;
">
<a-select
ref="select"
:value="unitTreeParams.id"
allowClear
style="width: 96%"
placeholder="选择分组"
@change="handleChange"
>
@change="handleChange">
<a-select-option v-for="(item, index) in groupData" :key="index" :value="item.id">
{{ item.cnValue }}
</a-select-option>
@ -146,8 +159,11 @@
<div class="actionMore">
<EditOutlined v-if="!data.parentId" @click="editGroup(data)" />
<EditOutlined v-else @click="editUnit(data)" />
<MinusCircleOutlined style="margin-left: 6px;" @click="delUnit(data)" />
<PlusCircleOutlined v-if="!data.parentId" style="margin-left: 6px;" @click="addUnit(data)" />
<MinusCircleOutlined style="margin-left: 6px" @click="delUnit(data)" />
<PlusCircleOutlined
v-if="!data.parentId"
style="margin-left: 6px"
@click="addUnit(data)" />
</div>
</div>
</template>
@ -158,31 +174,32 @@
</template>
</a-drawer>
<!-- 新增分组管理 -->
<ns-modal :visible="addGroupManage" :title="addGroupTitle" @ok="unitOrGroupOk" @cancel="groupCancel">
<a-form
ref="unitFormRef"
:model="formState"
:label-col="labelCol"
:wrapper-col="wrapperCol"
>
<ns-modal
:visible="addGroupManage"
:title="addGroupTitle"
@ok="unitOrGroupOk"
@cancel="groupCancel">
<a-form ref="unitFormRef" :model="formState" :label-col="labelCol" :wrapper-col="wrapperCol">
<a-form-item label="分组名称" name="cnValue" :required="true">
<a-input v-model:value="formState.cnValue" placeholder="请输入分组名称" />
</a-form-item>
</a-form>
</ns-modal>
<!-- 新增单位 -->
<ns-modal :visible="addUnitManage" :title="addUnitTitle" @ok="unitOrGroupOk" @cancel="unitCancel">
<a-form
ref="unitFormRef"
:model="formState"
:label-col="labelCol"
:wrapper-col="wrapperCol"
>
<ns-modal
:visible="addUnitManage"
:title="addUnitTitle"
@ok="unitOrGroupOk"
@cancel="unitCancel">
<a-form ref="unitFormRef" :model="formState" :label-col="labelCol" :wrapper-col="wrapperCol">
<a-form-item label="单位名称" name="cnValue" :required="true">
<a-input v-model:value="formState.cnValue" placeholder="请输入单位名称" />
</a-form-item>
<a-form-item label="选择分组" name="parentId" :required="true">
<a-select v-model:value="formState.parentId" placeholder="请选择所属分组" :disabled="canSelect">
<a-select
v-model:value="formState.parentId"
placeholder="请选择所属分组"
:disabled="canSelect">
<a-select-option v-for="(item, index) in groupData" :key="index" :value="item.id">
{{ item.cnValue }}
</a-select-option>
@ -193,12 +210,17 @@
</div>
</template>
<script lang="ts" setup>
import { MoreOutlined,ExclamationCircleOutlined,EditOutlined,PlusCircleOutlined,MinusCircleOutlined } from '@ant-design/icons-vue';
import {
ExclamationCircleOutlined,
EditOutlined,
PlusCircleOutlined,
MinusCircleOutlined,
} from '@ant-design/icons-vue';
import { Modal } from 'ant-design-vue';
import { computed, createVNode, defineComponent, reactive, ref, watchEffect,watch,toRaw } from 'vue';
import { computed, createVNode, reactive, ref, watchEffect, watch, toRaw } from 'vue';
import { http } from '/nerv-lib/util/http';
import { NsMessage, NsModal } from '/nerv-lib/component';
import { formConfig, formConfig2 } from './config';
import { NsMessage } from '/nerv-lib/component';
import { formConfig } from './config';
import { carbonEmissionFactorLibrary } from '/@/api/carbonEmissionFactorLibrary';
import type {
AntTreeNodeDragEnterEvent,
@ -220,7 +242,7 @@
const disabled = ref(false);
const treeNodeAdd = ref<boolean>(false);
const operationTree = ref<string>('新增');
const showOperation = ref(false)
const showOperation = ref(false);
const opMap: any = ref({
type: 'add',
@ -358,7 +380,7 @@
for (let i = 0; i < tree.length; i++) {
const node = tree[i];
if (node.children) {
if (node.children.some(item => item.key === key)) {
if (node.children.some((item) => item.key === key)) {
parentKey = node.key;
} else if (getParentKey(key, node.children)) {
parentKey = getParentKey(key, node.children);
@ -374,7 +396,7 @@
expandedKeys.value = keys;
autoExpandParent.value = false;
};
watch(selectTreeDataValue, value => {
watch(selectTreeDataValue, (value) => {
const expanded = dataList
.map((item: TreeProps['treeData'][number]) => {
if (item.title.indexOf(value) > -1) {
@ -393,70 +415,70 @@
console.log('or use this.value', value.value);
};
//
const checkedIds = ref([])
const emissionType = ref()
const checkedIds = ref([]);
const emissionType = ref();
const checkTreeNode = (checkedKeys, info) => {
checkedTreeNodeKeys.value = checkedKeys
checkedIds.value = []
info.checkedNodes.forEach(item=>{
checkedIds.value.push(item.id)
})
checkedTreeNodeKeys.value = checkedKeys;
checkedIds.value = [];
info.checkedNodes.forEach((item) => {
checkedIds.value.push(item.id);
});
sessionStorage.setItem('checkedTreeNode', checkedIds.value);
emissionType.value = checkedIds.value.join(',')
emissionType.value = checkedIds.value.join(',');
mainRef.value?.nsTableRef.reload();
}
};
//
const addTreeNodeData = () => {
operationTree.value='新增'
operationTree.value = '新增';
treeNodeAdd.value = true;
editTreeNode.value.type = 'create'
editTreeNode.value.type = 'create';
};
//
const editTreeNodeData = (data) => {
operationTree.value='编辑'
operationTree.value = '编辑';
treeNodeAdd.value = true;
editTreeNode.value.type = 'update'
addTreeNode.value = data.emissionName
}
editTreeNode.value.type = 'update';
addTreeNode.value = data.emissionName;
};
//
const deleteTreeNode = () => {
Modal.confirm({
title: '警告',
icon: createVNode(ExclamationCircleOutlined),
content: '确定要删除么?',
okText: '确认',
okType: 'primary',
cancelText: '取消',
onOk() {
http.post(carbonEmissionFactorLibrary.delTreeNode,editTreeNode.value).then(() => {
getOrgTree()
NsMessage.success('操作成功');
});
},
onCancel() {
console.log('Cancel');
},
});
}
title: '警告',
icon: createVNode(ExclamationCircleOutlined),
content: '确定要删除么?',
okText: '确认',
okType: 'primary',
cancelText: '取消',
onOk() {
http.post(carbonEmissionFactorLibrary.delTreeNode, editTreeNode.value).then(() => {
getOrgTree();
NsMessage.success('操作成功');
});
},
onCancel() {
console.log('Cancel');
},
});
};
// /
const addTreeNode =ref()
const addTreeNode = ref();
const handleOk = (e: MouseEvent) => {
editTreeNode.value.emissionName = addTreeNode.value
http.post(carbonEmissionFactorLibrary.creat,editTreeNode.value).then(() => {
getOrgTree()
editTreeNode.value.emissionName = addTreeNode.value;
http.post(carbonEmissionFactorLibrary.creat, editTreeNode.value).then(() => {
getOrgTree();
NsMessage.success('操作成功');
addTreeNode.value = ''
addTreeNode.value = '';
treeNodeAdd.value = false;
});
};
const handleCancel = () => {
addTreeNode.value = ''
addTreeNode.value = '';
treeNodeAdd.value = false;
};
//
const getOrgTree = (params?) => {
fetch(carbonEmissionFactorLibrary.getCarbonFactorTree, params).then((res) => {
gData.value = res.data
gData.value = res.data;
//
// const selectedNodes = [];
// checkedTreeNodeKeys.value.forEach(key => {
@ -469,31 +491,31 @@
// getDefaultIds(selectedNodes)
});
};
const defaultIds = ref([])
const defaultIds = ref([]);
const getDefaultIds = (selectedNodes) => {
selectedNodes.forEach(items => {
defaultIds.value.push(items.id)
if(items.children){
getDefaultIds(items.children)
selectedNodes.forEach((items) => {
defaultIds.value.push(items.id);
if (items.children) {
getDefaultIds(items.children);
}
})
emissionType.value = defaultIds.value.join(',')
checkedIds.value = defaultIds.value
});
emissionType.value = defaultIds.value.join(',');
checkedIds.value = defaultIds.value;
sessionStorage.setItem('checkedTreeNode', checkedIds.value);
}
};
getOrgTree();
//
const editTreeNode = ref({})
const editTreeNode = ref({});
const onSelect = (selectedKeys: string[], info: any) => {
if(info.selected){
showOperation.value = true
if (info.selected) {
showOperation.value = true;
editTreeNode.value = {
id:info.selectedNodes[0].id,
level:info.selectedNodes[0].level,
dataNumber:info.selectedNodes[0].dataNumber,
sortNumber:info.selectedNodes[0].sortNumber,
parentEmissionId:info.selectedNodes[0].parentEmissionId,
}
id: info.selectedNodes[0].id,
level: info.selectedNodes[0].level,
dataNumber: info.selectedNodes[0].dataNumber,
sortNumber: info.selectedNodes[0].sortNumber,
parentEmissionId: info.selectedNodes[0].parentEmissionId,
};
}
};
@ -516,13 +538,14 @@
};
const handleSelect = (selectedKeys: any, info: any) => {
fetch(carbonEmissionFactorLibrary.queryDeptTree, { orgId: info.node?.orgInfo.orgId }).then((res) => {
treeData2.value = res.data;
});
fetch(carbonEmissionFactorLibrary.queryDeptTree, { orgId: info.node?.orgInfo.orgId }).then(
(res) => {
treeData2.value = res.data;
},
);
tableFetch({ orgId: info.node?.orgInfo.orgId });
};
const onClose = () => {
visible.value = false;
formData.value = {};
@ -530,8 +553,8 @@
};
const closeUnitManag = () => {
unitTreeParams.value = {
grp: 'MEASUREMENT_UNIT'
}
grp: 'MEASUREMENT_UNIT',
};
unitManagement.value = false;
};
const onEdit = () => {
@ -542,8 +565,7 @@
// return;
// }
opMap.value.fuc &&
opMap.value.fuc({ ...formData.value });
opMap.value.fuc && opMap.value.fuc({ ...formData.value });
});
};
const tableConfig = ref({
@ -551,7 +573,7 @@
api: carbonEmissionFactorLibrary.getTableList,
params: {
orgId,
emissionType
emissionType,
},
headerActions: [
{
@ -562,13 +584,13 @@
opMap.value.type = 'add';
setTimeout(() => {
formData.value = {
carbonEmissionPrefix:'t',
numberOfReferences:'10'
carbonEmissionPrefix: 't',
numberOfReferences: '10',
};
userAuthList.value.splice(0);
});
opMap.value.fuc = (formData: any) => {
formData.emissionType = formData.emissionType[formData.emissionType.length - 1]
formData.emissionType = formData.emissionType[formData.emissionType.length - 1];
return http.post(carbonEmissionFactorLibrary.creatOrUpdate, formData).then(() => {
mainRef.value?.nsTableRef.reload();
visible.value = false;
@ -607,11 +629,13 @@
type: 'primary',
name: 'userAdd',
handle: () => {
unitManagement.value = true,
fetch(carbonEmissionFactorLibrary.findOutermost,{grp:'MEASUREMENT_UNIT'}).then((res) => {
groupData.value = res.data
});
getUnitTree()
(unitManagement.value = true),
fetch(carbonEmissionFactorLibrary.findOutermost, { grp: 'MEASUREMENT_UNIT' }).then(
(res) => {
groupData.value = res.data;
},
);
getUnitTree();
},
},
],
@ -672,14 +696,14 @@
handle: (record: any) => {
userAuthList.value.splice(0);
setTimeout(() => {
const measurementUnit = ref([])
http.post(carbonEmissionFactorLibrary.getCarbonFactorTree,{}).then((res) => {
measurementUnit.value = res.data
http.post(carbonEmissionFactorLibrary.findById,{ id: record.id } ).then((res) => {
const measurementUnit = ref([]);
http.post(carbonEmissionFactorLibrary.getCarbonFactorTree, {}).then((res) => {
measurementUnit.value = res.data;
http.post(carbonEmissionFactorLibrary.findById, { id: record.id }).then((res) => {
if (res.data.emissionType) {
let selectDevice = ref([Number(res.data.emissionType)]);
findParentIds(measurementUnit.value, res.data.emissionType, selectDevice.value);
res.data.emissionType = selectDevice
res.data.emissionType = selectDevice;
}
formData.value = res.data;
});
@ -687,9 +711,9 @@
}, 10);
opMap.value.type = 'edit';
opMap.value.fuc = (formData: any) => {
formData.emissionType = formData.emissionType[formData.emissionType.length - 1]
if(formData.emissionGas.value){
formData.emissionGas = formData.emissionGas.value
formData.emissionType = formData.emissionType[formData.emissionType.length - 1];
if (formData.emissionGas.value) {
formData.emissionGas = formData.emissionGas.value;
}
return http.post(carbonEmissionFactorLibrary.creatOrUpdate, formData).then(() => {
mainRef.value?.nsTableRef.reload();
@ -756,7 +780,7 @@
},
{
label: 'SF6',
value:3,
value: 3,
},
{
label: 'CH4',
@ -815,9 +839,9 @@
result.unshift(item.id); // id
findParentIds(tree, item.id, result); // id
break; // 退
}else{
for(let childsItem of item.children){
if(childsItem.children && childsItem.children.length > 0){
} else {
for (let childsItem of item.children) {
if (childsItem.children && childsItem.children.length > 0) {
if (childsItem.children.some((child: any) => child.id === Number(targetId))) {
result.unshift(childsItem.id); // id
findParentIds(tree, childsItem.id, result); // id
@ -829,24 +853,26 @@
}
}
}
//
const unitExpandedKeys = ref<string[]>();
const unitSelectedKeys = ref<string[]>([]);
const unitTreeParams = ref({
grp: 'MEASUREMENT_UNIT'
})
const groupData = ref([])
const unitTreeParams = ref({
grp: 'MEASUREMENT_UNIT',
});
const groupData = ref([]);
const unitTreeData = ref<TreeProps['treeData']>(genData);
const handleChange = (value: string) => {
unitTreeParams.value.id = value
getUnitTree()
unitTreeParams.value.id = value;
getUnitTree();
};
const getUnitTree = () => {
fetch(carbonEmissionFactorLibrary.dictionaryUnitManagement, unitTreeParams.value).then((res) => {
unitTreeData.value = res.data
});
}
fetch(carbonEmissionFactorLibrary.dictionaryUnitManagement, unitTreeParams.value).then(
(res) => {
unitTreeData.value = res.data;
},
);
};
//
const labelCol = { span: 5 };
const wrapperCol = { span: 19 };
@ -857,100 +883,100 @@
const formState = ref({
grp: 'MEASUREMENT_UNIT',
grpDesc: '计量单位',
})
});
const addGroupTitle = ref<string>('新增分组');
const addUnitTitle = ref<string>('新增单位');
const addGroup = () => {
addGroupTitle.value = '新增分组'
addGroupManage.value = true
addGroupTitle.value = '新增分组';
addGroupManage.value = true;
};
const editGroup = (data) => {
addGroupTitle.value = '编辑分组'
addGroupManage.value = true
formState.value.id = data.id
formState.value.cnValue = data.cnValue
addGroupTitle.value = '编辑分组';
addGroupManage.value = true;
formState.value.id = data.id;
formState.value.cnValue = data.cnValue;
};
const groupCancel = () => {
addGroupManage.value = false
addGroupManage.value = false;
unitFormRef.value.resetFields();
formState.value = {
grp: 'MEASUREMENT_UNIT',
grpDesc: '计量单位',
}
};
};
const addUnit = (data) => {
if(data.id){
canSelect.value = true
formState.value.parentId = data.id
}else{
canSelect.value = false
if (data.id) {
canSelect.value = true;
formState.value.parentId = data.id;
} else {
canSelect.value = false;
}
fetch(carbonEmissionFactorLibrary.findOutermost).then((res) => {
groupData.value = res.data
groupData.value = res.data;
});
addUnitTitle.value = '新增单位'
addUnitManage.value = true
addUnitTitle.value = '新增单位';
addUnitManage.value = true;
};
const editUnit = (data) => {
addUnitTitle.value = '编辑单位'
addUnitManage.value = true
canSelect.value = true
formState.value.parentId = data.parentId
formState.value.id = data.id
formState.value.cnValue = data.cnValue
addUnitTitle.value = '编辑单位';
addUnitManage.value = true;
canSelect.value = true;
formState.value.parentId = data.parentId;
formState.value.id = data.id;
formState.value.cnValue = data.cnValue;
};
const unitCancel = () => {
addUnitManage.value = false
addUnitManage.value = false;
unitFormRef.value.resetFields();
formState.value = {
grp: 'MEASUREMENT_UNIT',
grpDesc: '计量单位',
}
};
};
const unitOrGroupOk = () => {
unitFormRef.value
.validate()
.then(() => {
console.log('values', formState, toRaw(formState));
if(formState.value.id){
if (formState.value.id) {
fetch(carbonEmissionFactorLibrary.updateDictionary, formState.value).then((res) => {
unitTreeData.value = res.data
if(formState.value.parentId){
addUnitManage.value = false
}else{
addGroupManage.value = false
unitTreeData.value = res.data;
if (formState.value.parentId) {
addUnitManage.value = false;
} else {
addGroupManage.value = false;
}
unitFormRef.value.resetFields();
formState.value = {
grp: 'MEASUREMENT_UNIT',
grpDesc: '计量单位',
}
getUnitTree()
};
getUnitTree();
});
}else{
} else {
fetch(carbonEmissionFactorLibrary.createDictionary, formState.value).then((res) => {
unitTreeData.value = res.data
if(formState.value.parentId){
addUnitManage.value = false
}else{
addGroupManage.value = false
unitTreeData.value = res.data;
if (formState.value.parentId) {
addUnitManage.value = false;
} else {
addGroupManage.value = false;
}
unitFormRef.value.resetFields();
formState.value = {
grp: 'MEASUREMENT_UNIT',
grpDesc: '计量单位',
}
getUnitTree()
};
getUnitTree();
});
}
})
.catch(error => {
.catch((error) => {
console.log('error', error);
});
};
//
const delUnit = (data) => {
formState.value.id = data.id
formState.value.id = data.id;
Modal.confirm({
title: '警告',
content: '确定要删除吗?',
@ -958,9 +984,9 @@
okType: 'primary',
cancelText: '取消',
onOk() {
fetch(carbonEmissionFactorLibrary.delDictionary , formState.value).then((res) => {
fetch(carbonEmissionFactorLibrary.delDictionary, formState.value).then((res) => {
message.success('操作成功!');
getUnitTree()
getUnitTree();
});
},
onCancel() {
@ -968,7 +994,6 @@
},
});
};
</script>
<style lang="less" scoped>
.main {
@ -988,9 +1013,9 @@
}
display: flex;
flex-direction: column;
.top{
.top {
position: relative;
.addTreeNode{
.addTreeNode {
width: 100%;
padding: 16px;
position: absolute;
@ -1008,7 +1033,7 @@
// border-bottom: 5px solid rgb(229, 235, 240);
// overflow-y: auto;
}
.ns-form-title{
.ns-form-title {
font-weight: bold;
user-select: text;
padding: 16px;
@ -1016,7 +1041,7 @@
padding-bottom: 10px;
border-bottom: 1px solid #e9e9e9;
}
.title{
.title {
text-align: left;
height: 32px;
line-height: 32px;
@ -1034,21 +1059,21 @@
height: 13px;
width: 3px;
border-radius: 1px;
background-color: #2778FF;
background-color: #2778ff;
}
.treeRow {
display: flex;
justify-content: space-between;
align-items: center;
}
.addButton{
.addButton {
width: 70%;
height: 5vh;
display: flex;
align-items: center;
justify-content: space-evenly;
}
.treePart{
.treePart {
width: 70%;
height: 100%;
display: flex;

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

@ -1,20 +1,24 @@
<template>
<div>
<a-table
:columns="column"
:data-source="data"
<a-table
:columns="column"
:data-source="data"
bordered
:pagination="false"
:scroll="{ x: 2000,y:480 }">
:scroll="{ x: 2000, y: 480 }">
<template #title>
<a-date-picker v-model:value="selectYear" picker="year" @change="changeYearData" valueFormat="YYYY" />
<a-date-picker
v-model:value="selectYear"
picker="year"
@change="changeYearData"
valueFormat="YYYY" />
</template>
</a-table>
<a-pagination
<a-pagination
:current="queryParams.pageNum"
:total="total"
:page-size="queryParams.pageSize"
style="display: flex;justify-content: center;margin-top: 16px;"
style="display: flex; justify-content: center; margin-top: 16px"
:show-size-changer="true"
:show-quick-jumper="true"
@change="onChange" />
@ -35,26 +39,26 @@
const orgId = ref('');
const result = JSON.parse(sessionStorage.getItem('ORGID')!);
orgId.value = result;
const fetch = (api, params = { orgId } ) => {
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 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
})
orgId: orgId.value,
});
//
const changeYearData = () => {
queryParams.value.year = selectYear.value
getTableList()
}
queryParams.value.year = selectYear.value;
getTableList();
};
//
const column: TableColumnsType [] = [
const column: TableColumnsType[] = [
{
title: '排放类型',
dataIndex: 'cnValue',
@ -163,24 +167,24 @@
};
//
const getTableList = () => {
fetch(carbonEmission.carbonEmissionStatistics , queryParams.value).then((res) => {
data.value = res.data
total.value = res.data.length
fetch(carbonEmission.carbonEmissionStatistics, queryParams.value).then((res) => {
data.value = res.data;
total.value = res.data.length;
});
};
getTableList()
getTableList();
//
const onChange = (pageNumber: number,size: number) => {
const onChange = (pageNumber: number, size: number) => {
queryParams.value.pageNum = pageNumber;
queryParams.value.pageSize = size;
getTableList()
getTableList();
};
</script>
<style scoped lang="less">
:deep(.ant-table-title){
:deep(.ant-table-title) {
display: flex;
}
:deep(.ant-table-container){
:deep(.ant-table-container) {
padding: 0px 16px;
}
</style>
@ -189,4 +193,4 @@
td.column-money {
text-align: right !important;
}
</style>
</style>

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

@ -31,4 +31,3 @@
// }
};
</script>

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

@ -2,16 +2,15 @@
<div class="main">
<div class="left">
<div class="top">
<a-form style="width: 100%;margin: 0 auto;">
<a-form style="width: 100%; margin: 0 auto">
<div class="ns-form-title"><div class="title">因子分类</div></div>
<div style="padding: 0 16px !important;width: 100%;">
<div style="padding: 0 16px !important; width: 100%">
<a-row>
<a-col :span="24" style="margin-bottom: 16px;">
<a-col :span="24" style="margin-bottom: 16px">
<a-input-search
v-model:value="searchValue"
placeholder="请输入关键词"
@search="onSearchTreeData"
/>
@search="onSearchTreeData" />
</a-col>
</a-row>
</div>
@ -25,13 +24,15 @@
show-line
@expand="onExpand"
@select="onSelect"
style="padding: 0 16px !important;"
>
style="padding: 0 16px !important">
<template #title="data">
<span v-if="data.energyType && searchValue && data.energyType.indexOf(searchValue) > -1">
<span
v-if="data.energyType && searchValue && data.energyType.indexOf(searchValue) > -1">
{{ data.energyType.substring(0, data.energyType.indexOf(searchValue)) }}
<span style="color: #f50">{{ searchValue }}</span>
{{ data.energyType.substring(data.energyType.indexOf(searchValue) + searchValue.length) }}
{{
data.energyType.substring(data.energyType.indexOf(searchValue) + searchValue.length)
}}
</span>
<span v-else>{{ data.energyType }}</span>
</template>
@ -61,33 +62,35 @@
</template>
</a-table> -->
<ns-view-list-table v-bind="tableConfig" :model="tableData" ref="mainRef" />
<a-pagination
<a-pagination
:current="queryParams.pageNum"
:total="total"
:page-size="queryParams.pageSize"
style="display: flex;justify-content: center;margin-top: 16px;"
style="display: flex; justify-content: center; margin-top: 16px"
:show-size-changer="true"
:show-quick-jumper="true"
@change="onChange" />
<!-- 新增/编辑 -->
<a-drawer
:width="700"
:visible="visible"
:body-style="{ paddingBottom: '80px' }"
:footer-style="{ textAlign: 'right' }"
destroyOnClose
@close="onClose">
<a-form
ref="formRef"
:model="formState"
:rules="rules"
:label-col="labelCol"
:wrapper-col="wrapperCol"
>
<!-- 新增/编辑 -->
<a-drawer
:width="700"
:visible="visible"
:body-style="{ paddingBottom: '80px' }"
:footer-style="{ textAlign: 'right' }"
destroyOnClose
@close="onClose">
<a-form
ref="formRef"
:model="formState"
:rules="rules"
:label-col="labelCol"
:wrapper-col="wrapperCol">
<a-row>
<a-col :span="12">
<a-form-item ref="name" label="日期范围" name="dateRange">
<a-range-picker v-model:value="formState.dateRange" picker="month" valueFormat="YYYY-MM" />
<a-range-picker
v-model:value="formState.dateRange"
picker="month"
valueFormat="YYYY-MM" />
</a-form-item>
</a-col>
<a-col :span="12">
@ -103,20 +106,24 @@
</a-form-item>
</a-col>
</a-row>
</a-form>
<a-table
:columns="drawerColumns"
:data-source="newTableData"
bordered
rowKey="id"
:rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectionChange, type: 'radio' }"
:pagination="false">
</a-table>
<template #footer>
<a-button style="margin-right: 8px" @click="onClose">取消</a-button>
<a-button type="primary" @click="onSubmit">确定</a-button>
</template>
</a-drawer>
</a-form>
<a-table
:columns="drawerColumns"
:data-source="newTableData"
bordered
rowKey="id"
:rowSelection="{
selectedRowKeys: selectedRowKeys,
onChange: onSelectionChange,
type: 'radio',
}"
:pagination="false">
</a-table>
<template #footer>
<a-button style="margin-right: 8px" @click="onClose">取消</a-button>
<a-button type="primary" @click="onSubmit">确定</a-button>
</template>
</a-drawer>
</div>
</div>
</template>
@ -124,10 +131,13 @@
<script lang="ts" setup>
import { ref, watch, toRaw } from 'vue';
import type { TreeProps } from 'ant-design-vue';
import { Pagination,Modal } from 'ant-design-vue';
import { columns,drawerColumns } from '../config';
import { Pagination, Modal } from 'ant-design-vue';
import { columns, drawerColumns } from '../config';
import { http } from '/nerv-lib/util/http';
import { quickCalculation,carbonEmissionFactorLibrary } from '/@/api/carbonEmissionFactorLibrary';
import {
quickCalculation,
carbonEmissionFactorLibrary,
} from '/@/api/carbonEmissionFactorLibrary';
defineOptions({
energyType: 'quickCalculation', // name
components: {
@ -137,7 +147,7 @@
const orgId = ref('');
const result = JSON.parse(sessionStorage.getItem('ORGID')!);
orgId.value = result;
const fetch = (api, params = { orgId } ) => {
const fetch = (api, params = { orgId }) => {
return http.post(api, params);
};
const mainRef = ref();
@ -191,7 +201,7 @@
for (let i = 0; i < tree.length; i++) {
const node = tree[i];
if (node.children) {
if (node.children.some(item => item.key === key)) {
if (node.children.some((item) => item.key === key)) {
parentKey = node.key;
} else if (getParentKey(key, node.children)) {
parentKey = getParentKey(key, node.children);
@ -211,17 +221,17 @@
autoExpandParent.value = false;
};
//
const energyType = ref()
const energyType = ref();
const onSelect = (selectedKey: string[], info: any) => {
selectedKeys.value = selectedKey;
if(info.selected){
energyType.value = info.node.id
statsId.value = info.node.id
selectedKeys.value = selectedKey;
if (info.selected) {
energyType.value = info.node.id;
statsId.value = info.node.id;
mainRef.value?.nsTableRef.reload();
}
};
watch(searchValue, value => {
watch(searchValue, (value) => {
const expanded = dataList
.map((item: TreeProps['treeData'][number]) => {
if (item.title.indexOf(value) > -1) {
@ -235,34 +245,33 @@
autoExpandParent.value = true;
});
//
const onSearchTreeData = () => {
};
const statsId = ref()
const onSearchTreeData = () => {};
const statsId = ref();
//
const getTreeData = () => {
fetch(quickCalculation.carbonQuickTree).then((res) => {
gData.value = res.data
energyType.value = gData.value[0].children[0].id
statsId.value = gData.value[0].children[0].id
gData.value = res.data;
energyType.value = gData.value[0].children[0].id;
statsId.value = gData.value[0].children[0].id;
mainRef.value?.nsTableRef.reload();
});
};
getTreeData()
getTreeData();
//
const total = ref<number>()
const total = ref<number>();
const queryParams = ref({
pageNum: 1,
pageSize: 10,
orgId: orgId.value
})
orgId: orgId.value,
});
const tableData = ref([]);
const tableConfig = ref({
title: '排放因子库',
api: quickCalculation.queryCarbonEmissionPage,
params: {
orgId,
energyType
energyType,
},
headerActions: [
{
@ -270,8 +279,8 @@
name: 'userAdd',
type: 'primary',
handle: () => {
visible.value = true
getNewTable()
visible.value = true;
getNewTable();
},
},
],
@ -320,12 +329,12 @@
name: 'userEdit',
handle: (record: any) => {
selectedRowKeys.value = [record.factorId];
formState.value.id = record.id
formState.value.emissionFactors = record.emissionFactors
formState.value.id = record.id;
formState.value.emissionFactors = record.emissionFactors;
formState.value.dateRange = [record.startTime, record.endTime];
formState.value.factorId = record.factorId
visible.value = true
getNewTable()
formState.value.factorId = record.factorId;
visible.value = true;
getNewTable();
},
},
{
@ -342,13 +351,13 @@
});
//
const getTableList = () => {
fetch(quickCalculation.queryCarbonEmissionPage,queryParams.value).then((res) => {
tableData.value = res.data.records
total.value = res.data.total
fetch(quickCalculation.queryCarbonEmissionPage, queryParams.value).then((res) => {
tableData.value = res.data.records;
total.value = res.data.total;
});
};
//
const onChange = (pageNumber: number,size: number) => {
const onChange = (pageNumber: number, size: number) => {
queryParams.value.pageNum = pageNumber;
queryParams.value.pageSize = size;
mainRef.value?.nsTableRef.reload();
@ -357,9 +366,9 @@
const formRef = ref();
const labelCol = { span: 6 };
const wrapperCol = { span: 18 };
const formState = ref({})
const formState = ref({});
const visible = ref(false);
// form
const rules: Record<string, Rule[]> = {
dateRange: [{ required: true, message: '请选择日期范围', trigger: 'change' }],
@ -367,65 +376,65 @@
};
//
const addNewData = () => {
visible.value = true
getNewTable()
visible.value = true;
getNewTable();
};
//
const selectedRowKeys = ref([]);
const onSelectionChange = (selectedKeys, selectedRows) => {
selectedRowKeys.value = selectedKeys;
formState.value.emissionFactors = selectedRows[0].emissionFactors
formState.value.factorId = selectedRows[0].id
formState.value.emissionFactors = selectedRows[0].emissionFactors;
formState.value.factorId = selectedRows[0].id;
};
const queryData = ref({
orgId: orgId.value,
pageNum: 1,
pageSize: 999
})
const newTableData = ref([])
pageSize: 999,
});
const newTableData = ref([]);
const getNewTable = () => {
fetch(carbonEmissionFactorLibrary.getTableList,queryData.value).then((res) => {
newTableData.value = res.data.records
fetch(carbonEmissionFactorLibrary.getTableList, queryData.value).then((res) => {
newTableData.value = res.data.records;
});
};
//
const editData = (record) =>{
const editData = (record) => {
selectedRowKeys.value = [record.factorId];
formState.value.id = record.id
formState.value.emissionFactors = record.emissionFactors
formState.value.id = record.id;
formState.value.emissionFactors = record.emissionFactors;
formState.value.dateRange = [record.startTime, record.endTime];
formState.value.factorId = record.factorId
visible.value = true
getNewTable()
formState.value.factorId = record.factorId;
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]
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));
if(formState.value.id){
fetch(quickCalculation.update,formState.value).then((res) => {
visible.value = false
if (formState.value.id) {
fetch(quickCalculation.update, formState.value).then((res) => {
visible.value = false;
selectedRowKeys.value = [];
formState.value = {}
formState.value = {};
formRef.value.resetFields();
mainRef.value?.nsTableRef.reload();
});
}else{
fetch(quickCalculation.creat,formState.value).then((res) => {
visible.value = false
} else {
fetch(quickCalculation.creat, formState.value).then((res) => {
visible.value = false;
selectedRowKeys.value = [];
formState.value = {}
formState.value = {};
formRef.value.resetFields();
mainRef.value?.nsTableRef.reload();
});
}
})
.catch(error => {
.catch((error) => {
console.log('error', error);
});
};
@ -438,9 +447,9 @@
okType: 'primary',
cancelText: '取消',
onOk() {
fetch(quickCalculation.del , {id : record.id }).then((res) => {
fetch(quickCalculation.del, { id: record.id }).then((res) => {
message.success('操作成功!');
getTableList()
getTableList();
});
},
onCancel() {
@ -452,7 +461,7 @@
const onClose = () => {
visible.value = false;
selectedRowKeys.value = [];
formState.value = {}
formState.value = {};
formRef.value.resetFields();
};
</script>
@ -474,9 +483,9 @@
display: flex;
flex-direction: column;
.top{
.top {
position: relative;
.addTreeNode{
.addTreeNode {
width: 100%;
padding: 16px;
position: absolute;
@ -499,7 +508,7 @@
.top {
overflow: auto;
}
.ns-form-title{
.ns-form-title {
font-weight: bold;
user-select: text;
padding: 16px;
@ -507,7 +516,7 @@
padding-bottom: 10px;
border-bottom: 1px solid #e9e9e9;
}
.title{
.title {
text-align: left;
height: 32px;
line-height: 32px;
@ -525,17 +534,17 @@
height: 13px;
width: 3px;
border-radius: 1px;
background-color: #2778FF;
background-color: #2778ff;
}
:deep(.ant-table-title) {
display: flex;
height: 100%;
align-items: center;
}
.ns-table-title{
.ns-table-title {
font-weight: bold;
}
.buttonGroup{
.buttonGroup {
margin-left: 1vw;
width: 5vw;
display: flex;
@ -547,4 +556,4 @@
td.column-money {
text-align: right !important;
}
</style>
</style>

1021
hx-ai-intelligent/src/view/carbonEmissionManage/carbonInventoryCheck/fillInPage/index.vue

File diff suppressed because it is too large
Loading…
Cancel
Save