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', findUnitById = '/carbon-smartapi/carbon/inventory/findById',
getDetailsList = '/carbon-smart/api/carbon/inventory/details/getDetailsList', getDetailsList = '/carbon-smart/api/carbon/inventory/details/getDetailsList',
updateTable = '/carbon-smart/api/carbon/inventory/details/update', 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; export default equipment;

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

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

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

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

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

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

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

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