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