|
|
@ -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 |
|
|
@ -833,20 +857,22 @@ |
|
|
|
// 单位管理 |
|
|
|
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; |
|
|
|