Browse Source

taskid:067 remark:commit

deploy-dev
fks-xuxinyue 5 months ago
parent
commit
060ac6d486
  1. 14
      hx-ai-intelligent/src/api/carbonEmissionFactorLibrary.ts
  2. 2
      hx-ai-intelligent/src/icon/tanpaiguanli.svg
  3. 109
      hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionFactorLibrary/config.ts
  4. 183
      hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionFactorLibrary/index.vue
  5. 12
      hx-ai-intelligent/src/view/carbonEmissionManage/carbonEmissionStatistics/config.ts

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

@ -1,12 +1,10 @@
export enum carbonEmissionFactorLibrary {
getTableList = '/carbon-smart/api/carbon/emission/factor/queryCarbonFactorPage',
addNewData = '/carbon-smart/api/carbon/emission/factor/creatOrUpdate',
editUser = '/carbon-smart/api/user/edit',
frozen = '/carbon-smart/api/user/frozen',
resetPwd = '/carbon-smart/api/user/resetPwd',
del = '/carbon-smart/api/user/del',
batchDel = '/carbon-smart/api/user/batchDel',
creatOrUpdate = '/carbon-smart/api/carbon/emission/factor/creatOrUpdate',
del = '/carbon-smart/api/carbon/emission/factor/del',
getEmissionProcess = '/carbon-smart/api/carbon/emission/factor/getEmissionProcess',
findById = '/carbon-smart/api/carbon/emission/factor/findById',
getCarbonFactorTree = '/carbon-smart/api/carbon/emission/type/getCarbonFactorTree',
queryDeptTree = '/carbon-smart/api/user/queryDeptTree',
queryUserPerList = '/carbon-smart/api/user/queryUserPerList',
creat = '/carbon-smart/api/carbon/emission/type/creatOrUpdate',
delTreeNode = '/carbon-smart/api/carbon/emission/type/del',
}

2
hx-ai-intelligent/src/icon/tanpaiguanli.svg

@ -1,4 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="14.5244140625" height="14.5294189453125" viewBox="0 0 14.5244140625 14.5294189453125" fill="none">
<path d="M6.61912 12.2301C6.6032 12.5346 6.44482 12.8138 6.19166 12.9837L3.73703 14.4259C3.46877 14.5639 3.15036 14.5639 2.8821 14.4259L0.427467 12.9837C0.174295 12.8138 0.0159187 12.5346 0 12.2301L0 9.34584C0.0162582 9.04147 0.174555 8.76241 0.427467 8.59227L2.88209 7.15012C3.15031 7.01189 3.46881 7.01189 3.73703 7.15012L6.19165 8.59337C6.44482 8.76326 6.6032 9.04247 6.61912 9.34694L6.61912 12.2301ZM14.5239 12.2301C14.508 12.5346 14.3497 12.8138 14.0965 12.9837L11.6419 14.4259C11.3736 14.5639 11.0552 14.5639 10.7869 14.4259L8.33231 12.9837C8.079 12.814 7.92058 12.5347 7.90484 12.2301L7.90484 9.34584C7.92075 9.04137 8.07913 8.76217 8.33231 8.59227L10.7869 7.14902C11.0551 7.01079 11.3736 7.01079 11.6419 7.14902L14.0965 8.59117C14.3495 8.76118 14.5079 9.04031 14.524 9.34475L14.5239 12.2301ZM10.5842 5.18465C10.5683 5.48912 10.4099 5.76833 10.1567 5.93822L7.70211 7.38147C7.43394 7.51988 7.11535 7.51988 6.84718 7.38147L4.39256 5.93822C4.13938 5.76833 3.981 5.48912 3.96508 5.18465L3.96508 2.30036C3.98117 1.99594 4.13951 1.7168 4.39256 1.54678L6.84718 0.103527C7.11544 -0.0345116 7.43386 -0.0345116 7.70212 0.103527L10.1567 1.54568C10.41 1.71546 10.5685 1.99473 10.5842 2.29926L10.5842 5.18465Z" fill="#8D96A3" >
<path d="M6.61912 12.2301C6.6032 12.5346 6.44482 12.8138 6.19166 12.9837L3.73703 14.4259C3.46877 14.5639 3.15036 14.5639 2.8821 14.4259L0.427467 12.9837C0.174295 12.8138 0.0159187 12.5346 0 12.2301L0 9.34584C0.0162582 9.04147 0.174555 8.76241 0.427467 8.59227L2.88209 7.15012C3.15031 7.01189 3.46881 7.01189 3.73703 7.15012L6.19165 8.59337C6.44482 8.76326 6.6032 9.04247 6.61912 9.34694L6.61912 12.2301ZM14.5239 12.2301C14.508 12.5346 14.3497 12.8138 14.0965 12.9837L11.6419 14.4259C11.3736 14.5639 11.0552 14.5639 10.7869 14.4259L8.33231 12.9837C8.079 12.814 7.92058 12.5347 7.90484 12.2301L7.90484 9.34584C7.92075 9.04137 8.07913 8.76217 8.33231 8.59227L10.7869 7.14902C11.0551 7.01079 11.3736 7.01079 11.6419 7.14902L14.0965 8.59117C14.3495 8.76118 14.5079 9.04031 14.524 9.34475L14.5239 12.2301ZM10.5842 5.18465C10.5683 5.48912 10.4099 5.76833 10.1567 5.93822L7.70211 7.38147C7.43394 7.51988 7.11535 7.51988 6.84718 7.38147L4.39256 5.93822C4.13938 5.76833 3.981 5.48912 3.96508 5.18465L3.96508 2.30036C3.98117 1.99594 4.13951 1.7168 4.39256 1.54678L6.84718 0.103527C7.11544 -0.0345116 7.43386 -0.0345116 7.70212 0.103527L10.1567 1.54568C10.41 1.71546 10.5685 1.99473 10.5842 2.29926L10.5842 5.18465Z" fill="currentColor" >
</path>
</svg>

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

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

@ -1,21 +1,21 @@
import { ref } from 'vue';
import { http } from '/nerv-lib/util';
import { origanizemanage } from '/@/api/origanizemanage';
import { carbonEmissionFactorLibrary } from '/@/api/carbonEmissionFactorLibrary';
export const formConfig = (disabled) => {
return ref([
{
field: 'field111',
field: 'fields',
component: 'NsChildForm',
componentProps: {
schemas: [
{
label: '排放源',
field: 'accountNo',
field: 'emissionSources',
component: 'NsInput',
componentProps: {
placeholder: '请输入排放源',
maxLength: 20,
disabled,
},
rules: [
{
@ -25,7 +25,25 @@ export const formConfig = (disabled) => {
],
},
{
field: 'userStatus',
field: 'emissionType',
label: '排放分类',
component: 'NsCascader',
fieldMap: ['emissionType'],
componentProps: {
placeholder: '请选择排放分类',
api: carbonEmissionFactorLibrary.getCarbonFactorTree,
fieldNames: { label: 'emissionName', value: 'id' },
showSearch: true,
},
rules: [
{
required: true,
message: '请选择排放分类',
},
],
},
{
field: 'emissionGas',
label: '排放气体',
component: 'NsSelect',
componentProps: {
@ -33,12 +51,28 @@ export const formConfig = (disabled) => {
placeholder: '请选择排放气体',
options: [
{
label: '正常',
value: 0,
label: 'CO2',
value: 'CO2',
},
{
label: 'CO2e',
value: 'CO2e',
},
{
label: 'SF6',
value:'SF6',
},
{
label: 'CH4',
value: 'CH4',
},
{
label: '冻结',
value: 1,
label: 'PFCs',
value: 'PFCs',
},
{
label: 'HFCs',
value: 'HFCs',
},
],
},
@ -50,55 +84,61 @@ export const formConfig = (disabled) => {
],
},
{
field: 'userStatus',
field: 'emissionProcess',
label: '排放环节',
component: 'NsSelect',
component: 'NsSelectApi',
componentProps: {
allowClear: true,
placeholder: '请选择排放环节',
options: [
{
label: '正常',
value: 0,
},
{
label: '冻结',
value: 1,
},
],
api: carbonEmissionFactorLibrary.getEmissionProcess,
params: {
emissionType: sessionStorage.getItem('checkedTreeNode'),
},
resultField: 'data',
labelField: 'emissionProcess',
valueField: 'emissionProcess',
immediate: true,
autoSelectFirst: false,
filterOption:false,
showSearch:true,
autoClearSearchValue:false
},
},
{
label: '排放因子',
field: 'accountNo',
component: 'NsInput',
field: 'emissionFactors',
component: 'NsInputNumber',
componentProps: {
placeholder: '请输入排放因子值',
maxLength: 20,
disabled,
},
rules: [
{
required: true,
message: '请输入排放因子值',
trigger: 'change',
},
],
},
{
field: 'userStatus',
field: 'carbonEmissionPrefix',
label: '碳排前缀',
component: 'NsSelect',
componentProps: {
disabled: true,
allowClear: true,
defaultValue: 't',
placeholder: '请选择碳排前缀',
options: [
{
label: '正常',
value: 0,
label: 'g',
value: 'g',
},
{
label: 'kg',
value: 'kg',
},
{
label: '冻结',
value: 1,
label: 't',
value: 't',
},
],
},
@ -111,12 +151,11 @@ export const formConfig = (disabled) => {
},
{
label: '碳排后缀',
field: 'accountNo',
field: 'carbonEmissionSuffix',
component: 'NsInput',
componentProps: {
placeholder: '请输入碳排后缀',
maxLength: 20,
disabled,
},
rules: [
{
@ -127,21 +166,21 @@ export const formConfig = (disabled) => {
},
{
label: '已引用数',
field: 'accountNo',
field: 'numberOfReferences',
component: 'NsInput',
componentProps: {
defaultValue: 10,
disabled: true,
maxLength: 20,
},
},
{
label: '参考文献',
field: 'accountNo',
field: 'reference',
component: 'NsTextarea',
componentProps: {
placeholder: '请输入参考文献',
maxLength: 20,
disabled,
},
},
],

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

@ -19,6 +19,7 @@
</div>
</a-form>
<a-tree
v-if="gData && gData.length > 0"
class="draggable-tree"
style="padding: 0 16px !important;"
draggable
@ -26,12 +27,15 @@
checkable
block-node
:tree-data="gData"
:checkedKeys="checkedTreeNodeKeys"
:selectedKeys="selectedKeys"
@dragenter="onDragEnter"
@drop="onDrop"
@check="checkTreeNode"
@select="onSelect"
:expanded-keys="expandedKeys"
:auto-expand-parent="autoExpandParent"
@expand="onExpand"
>
@expand="onExpand">
<template #title="{ emissionName }">
<span v-if="emissionName && selectTreeDataValue && emissionName.indexOf(selectTreeDataValue) > -1">
{{ emissionName.substring(0, emissionName.indexOf(selectTreeDataValue)) }}
@ -41,12 +45,14 @@
<span v-else>{{ emissionName }}</span>
</template>
</a-tree>
<a-popover placement="rightTop" trigger="focus">
<a-popover v-if="showOperation" placement="rightTop" trigger="focus">
<template #content>
<div style="display: flex;flex-direction: column;">
<a-button type="text">编辑</a-button>
<a-button type="text">新增子节点</a-button>
<a-button type="text">删除</a-button>
<a-button type="text" @click="editTreeNodeData">编辑</a-button>
<a-button type="text" @click="addTreeNodeData">新增子节点</a-button>
<a-button type="text">上移</a-button>
<a-button type="text">下移</a-button>
<a-button type="text" @click="deleteTreeNode">删除</a-button>
</div>
</template>
<MoreOutlined style="position: absolute;right: 0;top: 16%;font-size: 25px;cursor: pointer;" />
@ -62,10 +68,9 @@
<!-- 新增树节点 -->
<ns-modal :visible="treeNodeAdd" :title="operationTree" @ok="handleOk" @cancel="handleCancel">
<ns-input
v-model:value="latitude1"
v-model:value="addTreeNode"
class="input"
placeholder="请输入排放类型"
/>
placeholder="请输入排放类型"/>
</ns-modal>
<!-- 新增数据库数据 -->
<a-drawer
@ -90,7 +95,8 @@
</div>
</template>
<script lang="ts" setup>
import { MoreOutlined } from '@ant-design/icons-vue';
import { MoreOutlined,ExclamationCircleOutlined } from '@ant-design/icons-vue';
import { Modal } from 'ant-design-vue';
import { computed, createVNode, defineComponent, reactive, ref, watchEffect,watch } from 'vue';
import { http } from '/nerv-lib/util/http';
import { NsMessage, NsModal } from '/nerv-lib/component';
@ -115,6 +121,7 @@ import { log } from 'node:console';
const disabled = ref(false);
const treeNodeAdd = ref<boolean>(false);
const operationTree = ref<string>('新增');
const showOperation = ref(false)
const opMap: any = ref({
type: 'add',
@ -141,6 +148,7 @@ import { log } from 'node:console';
const y = 2;
const z = 1;
const genData: TreeProps['treeData'] = [];
const checkedTreeNodeKeys = ref<string[]>(['0-0']);
const generateData = (_level: number, _preKey?: string, _tns?: TreeProps['treeData']) => {
const preKey = _preKey || '0';
@ -265,7 +273,6 @@ import { log } from 'node:console';
expandedKeys.value = keys;
autoExpandParent.value = false;
};
watch(selectTreeDataValue, value => {
const expanded = dataList
.map((item: TreeProps['treeData'][number]) => {
@ -284,24 +291,107 @@ import { log } from 'node:console';
console.log('use value', selectTreeDataValue);
console.log('or use this.value', value.value);
};
//
const checkedIds = ref([])
const emissionType = ref()
const checkTreeNode = (checkedKeys, info) => {
checkedTreeNodeKeys.value = checkedKeys
checkedIds.value = []
info.checkedNodes.forEach(item=>{
checkedIds.value.push(item.id)
})
sessionStorage.setItem('checkedTreeNode', checkedIds.value);
emissionType.value = checkedIds.value.join(',')
mainRef.value?.nsTableRef.reload();
}
//
const addTreeNodeData = () => {
treeNodeAdd.value = true;
editTreeNode.value.type = 'create'
};
//
const editTreeNodeData = () => {
operationTree.value='编辑'
treeNodeAdd.value = true;
editTreeNode.value.type = 'update'
}
//
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');
},
});
}
// /
const addTreeNode =ref()
const handleOk = (e: MouseEvent) => {
console.log(e);
treeNodeAdd.value = false;
editTreeNode.value.emissionName = addTreeNode.value
http.post(carbonEmissionFactorLibrary.creat,editTreeNode.value).then(() => {
getOrgTree()
NsMessage.success('操作成功');
addTreeNode.value = ''
treeNodeAdd.value = false;
});
};
const handleCancel = () => {
addTreeNode.value = ''
treeNodeAdd.value = false;
};
//
//
const getOrgTree = (params?) => {
fetch(carbonEmissionFactorLibrary.getCarbonFactorTree, params).then((res) => {
gData.value = res
gData.value = res.data
//
const selectedNodes = [];
checkedTreeNodeKeys.value.forEach(key => {
const [parentId, childId] = key.split('-').map(Number);
if (parentId >= 0 && childId >= 0 && gData.value[parentId]?.children?.[childId]) {
selectedNodes.push(gData.value[parentId]);
}
});
// id
getDefaultIds(selectedNodes)
});
};
const defaultIds = ref([])
const getDefaultIds = (selectedNodes) => {
selectedNodes.forEach(items => {
defaultIds.value.push(items.id)
if(items.children){
getDefaultIds(items.children)
}
})
emissionType.value = defaultIds.value.join(',')
checkedIds.value = defaultIds.value
sessionStorage.setItem('checkedTreeNode', checkedIds.value);
}
getOrgTree();
//
const editTreeNode = ref({})
const onSelect = (selectedKeys: string[], info: any) => {
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,
}
}
};
const onSearch = () => {
console.log(searchValue.value);
@ -338,21 +428,21 @@ import { log } from 'node:console';
const onEdit = () => {
formRef.value?.triggerSubmit().then(() => {
console.log(formData.value, 'formData.value');
if (!userAuthList.value.length) {
NsMessage.error('请添加用户权限');
return;
}
// if (!userAuthList.value.length) {
// NsMessage.error('');
// return;
// }
opMap.value.fuc &&
opMap.value.fuc({ ...formData.value, userRoleList: userAuthList.value, orgId });
opMap.value.fuc({ ...formData.value });
});
};
const tableConfig = ref({
title: '数据库',
api: carbonEmissionFactorLibrary.getTableList,
params: {
orgId,
emissionType
},
headerActions: [
{
@ -363,12 +453,14 @@ import { log } from 'node:console';
opMap.value.type = 'add';
setTimeout(() => {
formData.value = {
// orgName: JSON.parse(sessionStorage.getItem('userInfo')).orgName,
carbonEmissionPrefix:'t',
numberOfReferences:'10'
};
userAuthList.value.splice(0);
});
opMap.value.fuc = (formData: any) => {
return http.post(carbonEmissionFactorLibrary.addNewData, formData).then(() => {
formData.emissionType = formData.emissionType[formData.emissionType.length - 1]
return http.post(carbonEmissionFactorLibrary.creatOrUpdate, formData).then(() => {
mainRef.value?.nsTableRef.reload();
visible.value = false;
NsMessage.success('操作成功');
@ -398,14 +490,13 @@ import { log } from 'node:console';
confirm: true,
isReload: true,
isClearCheck: true,
api: carbonEmissionFactorLibrary.batchDel,
dynamicParams: { userIds: 'userId[]' },
api: carbonEmissionFactorLibrary.del,
dynamicParams: { id: 'id[]' },
},
],
columns: [
{
title: 'id',
dataIndex: 'address',
customRender: (text: any) => {
return text.index + 1;
},
@ -416,7 +507,7 @@ import { log } from 'node:console';
},
{
title: '排放类型',
dataIndex: 'emissionType',
dataIndex: 'emissionTypeColumn',
},
{
title: '排放气体',
@ -460,12 +551,15 @@ import { log } from 'node:console';
handle: (record: any) => {
userAuthList.value.splice(0);
setTimeout(() => {
formData.value = record;
userAuthList.value.push(...record.userRoleInfos);
console.log(record.id);
http.post(carbonEmissionFactorLibrary.findById,{ id: record.id } ).then((res) => {
formData.value = res.data;
});
}, 10);
opMap.value.type = 'edit';
opMap.value.fuc = (formData: any) => {
return http.post(carbonEmissionFactorLibrary.editUser, formData).then(() => {
return http.post(carbonEmissionFactorLibrary.creatOrUpdate, formData).then(() => {
mainRef.value?.nsTableRef.reload();
visible.value = false;
NsMessage.success('操作成功');
@ -477,7 +571,7 @@ import { log } from 'node:console';
{
label: '删除',
name: 'userDelete',
dynamicParams: 'userId',
dynamicParams: 'id',
confirm: true,
isReload: true,
api: carbonEmissionFactorLibrary.del,
@ -497,7 +591,7 @@ import { log } from 'node:console';
},
},
{
field: 'userStatus',
field: 'emissionProcess',
label: '排放环节',
component: 'NsSelect',
componentProps: {
@ -505,18 +599,14 @@ import { log } from 'node:console';
placeholder: '请选择排放环节',
options: [
{
label: '正常',
label: '消费环节',
value: 0,
},
{
label: '冻结',
value: 1,
},
}
],
},
},
{
field: 'userStatus',
field: 'emissionGas',
label: '排放气体',
component: 'NsSelect',
componentProps: {
@ -524,37 +614,38 @@ import { log } from 'node:console';
placeholder: '请选择排放气体',
options: [
{
label: '正常',
label: 'CO2',
value: 0,
},
{
label: '冻结',
label: 'CO2e',
value: 1,
},
],
},
},
{
field: 'userStatus',
field: 'carbonDatabase',
label: '数据库名称',
component: 'NsSelect',
componentProps: {
allowClear: true,
placeholder: '请选择数据库名称',
showSearch: true,
options: [
{
label: '正常',
value: 0,
value: '正常',
},
{
label: '冻结',
value: 1,
value: '冻结',
},
],
},
},
{
field: 'accountNo',
field: 'reference',
label: '文献关键字',
component: 'NsInput',
componentProps: {
@ -566,7 +657,7 @@ import { log } from 'node:console';
params: {},
},
// pagination: { defaultPageSize: 10 },
rowKey: 'userId',
rowKey: 'id',
});
</script>
<style lang="less" scoped>

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

@ -11,15 +11,21 @@ export const tableConfig = {
rowSelection: null,
columns: [
{
title: '设备名称',
title: '序号',
customRender: (text: any) => {
return text.index + 1;
},
},
{
title: '能源种类',
dataIndex: 'id',
},
{
title: '设备型号',
title: '计量单位',
dataIndex: 'deviceCode',
},
{
title: 'SN码',
title: '全年',
dataIndex: 'deviceName',
textNumber: 8,
textEllipsis: true,

Loading…
Cancel
Save