修改报表
This commit is contained in:
@@ -31,4 +31,11 @@ export function getCldTree() {
|
||||
method: 'POST'
|
||||
})
|
||||
}
|
||||
//报表树
|
||||
export function lineTree() {
|
||||
return createAxios({
|
||||
url: '/cs-device-boot/csLedger/lineTree',
|
||||
method: 'POST'
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
179
src/components/tree/govern/csLedgerLineTree.vue
Normal file
179
src/components/tree/govern/csLedgerLineTree.vue
Normal file
@@ -0,0 +1,179 @@
|
||||
<template>
|
||||
<Tree ref="treRef" :width="width" :showPush="props.showPush" :data="tree" default-expand-all @changePointType="changePointType" @onAdd="onAdd"/>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, nextTick, onMounted, defineProps } from 'vue'
|
||||
import Tree from '../index.vue'
|
||||
import { getLineTree,lineTree } from '@/api/cs-device-boot/csLedger'
|
||||
import { useConfig } from '@/stores/config'
|
||||
import { querySysExcel } from '@/api/harmonic-boot/luckyexcel'
|
||||
import { useDictData } from '@/stores/dictData'
|
||||
|
||||
interface Props {
|
||||
template?: boolean
|
||||
showPush?: boolean
|
||||
}
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
template: false,
|
||||
showPush: false
|
||||
})
|
||||
defineOptions({
|
||||
name: 'govern/deviceTree'
|
||||
})
|
||||
|
||||
const emit = defineEmits(['init', 'checkChange', 'pointTypeChange', 'Policy','onAdd'])
|
||||
const config = useConfig()
|
||||
const tree = ref()
|
||||
const dictData = useDictData()
|
||||
const treRef = ref()
|
||||
const width = ref('')
|
||||
|
||||
|
||||
const info = (selectedNodeId?: string) => {
|
||||
tree.value = []
|
||||
let arr1: any[] = []
|
||||
lineTree().then(res => {
|
||||
try {
|
||||
// 检查响应数据结构
|
||||
let rootData = null;
|
||||
if (Array.isArray(res.data)) {
|
||||
// 旧的数据结构 - 数组
|
||||
rootData = res.data.find((item: any) => item.name == '监测设备');
|
||||
} else if (res.data && res.data.name == '监测设备') {
|
||||
// 新的数据结构 - 单个对象
|
||||
rootData = res.data;
|
||||
}
|
||||
|
||||
// 治理设备
|
||||
if (rootData) {
|
||||
rootData.icon = 'el-icon-Menu'
|
||||
rootData.level = 0
|
||||
rootData.color = config.getColorVal('elementUiPrimary')
|
||||
// 确保根节点的 children 是数组
|
||||
if (!Array.isArray(rootData.children)) {
|
||||
rootData.children = []
|
||||
}
|
||||
rootData.children.forEach((item: any) => {
|
||||
item.icon = 'el-icon-HomeFilled'
|
||||
item.level = 1
|
||||
item.color = config.getColorVal('elementUiPrimary')
|
||||
// 确保 children 是数组
|
||||
if (!Array.isArray(item.children)) {
|
||||
item.children = []
|
||||
}
|
||||
item.children.forEach((item2: any) => {
|
||||
item2.icon = 'el-icon-List'
|
||||
item2.level = 2
|
||||
item2.color = config.getColorVal('elementUiPrimary')
|
||||
|
||||
// 确保 children 是数组
|
||||
if (!Array.isArray(item2.children)) {
|
||||
item2.children = []
|
||||
}
|
||||
item2.children.forEach((item3: any) => {
|
||||
item3.icon = 'el-icon-Platform'
|
||||
item3.level = 3
|
||||
item3.color =
|
||||
item3.comFlag === 2 ? config.getColorVal('elementUiPrimary') : '#e26257 !important'
|
||||
|
||||
// 确保 children 是数组
|
||||
if (!Array.isArray(item3.children)) {
|
||||
item3.children = []
|
||||
}
|
||||
|
||||
item3.children.forEach((item4: any) => {
|
||||
item4.icon = 'el-icon-Platform'
|
||||
item4.level = 4
|
||||
item4.color =
|
||||
item4.comFlag === 2 ? config.getColorVal('elementUiPrimary') : '#e26257 !important'
|
||||
arr1.push(item4)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
tree.value = [rootData] // 确保 tree.value 是数组
|
||||
} else {
|
||||
tree.value = []
|
||||
}
|
||||
nextTick(() => {
|
||||
|
||||
if (arr1.length) {
|
||||
// 安全检查 treRef 和 treeRef 是否存在
|
||||
console.log("🚀 ~ info ~ treRef.value && treRef.value.treeRef && treRef.value.treeRef.setCurrentKey:", treRef.value && treRef.value.treeRef1 && treRef.value.treeRef1.setCurrentKey)
|
||||
|
||||
if (treRef.value && treRef.value.treeRef && treRef.value.treeRef.setCurrentKey) {
|
||||
// 如果传入了要选中的节点ID,则选中该节点,否则选中第一个节点
|
||||
console.log('selectedNodeId:', selectedNodeId);
|
||||
if (selectedNodeId) {
|
||||
treRef.value.treeRef.setCurrentKey(selectedNodeId);
|
||||
// 查找对应的节点数据并触发事件
|
||||
let selectedNode = null;
|
||||
const findNode = (nodes: any[]) => {
|
||||
for (const node of nodes) {
|
||||
if (node.id === selectedNodeId) {
|
||||
selectedNode = node;
|
||||
return true;
|
||||
}
|
||||
if (node.children && findNode(node.children)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
findNode(tree.value);
|
||||
|
||||
if (selectedNode) {
|
||||
emit('init', {
|
||||
level: selectedNode.level,
|
||||
...selectedNode
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// 初始化选中第一个节点
|
||||
treRef.value.treeRef.setCurrentKey(arr1[0].id);
|
||||
emit('init', {
|
||||
level: 2,
|
||||
...arr1[0]
|
||||
});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
})
|
||||
} catch (error) {
|
||||
console.error('Error in processing getCldTree response:', error)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
const changePointType = (val: any, obj: any) => {
|
||||
emit('pointTypeChange', val, obj)
|
||||
}
|
||||
|
||||
const onAdd = () => {
|
||||
emit('onAdd')
|
||||
}
|
||||
if (props.template) {
|
||||
querySysExcel({ id: dictData.state.area[0]?.id })
|
||||
.then((res: any) => {
|
||||
emit('Policy', res.data)
|
||||
info()
|
||||
})
|
||||
.catch(err => {
|
||||
info()
|
||||
})
|
||||
} else {
|
||||
info()
|
||||
}
|
||||
|
||||
// 暴露 info 方法给父组件调用
|
||||
defineExpose({
|
||||
info
|
||||
})
|
||||
|
||||
onMounted(() => {})
|
||||
</script>
|
||||
@@ -2,11 +2,12 @@
|
||||
<div class="default-main" :style="height">
|
||||
<splitpanes style="height: 100%" id="navigation-splitpanes">
|
||||
<pane :size="size">
|
||||
<CloudDeviceEntryTree
|
||||
<pointTree
|
||||
ref="TerminalRef"
|
||||
@node-click="handleNodeClick"
|
||||
@init="handleNodeClick"
|
||||
></CloudDeviceEntryTree>
|
||||
@pointTypeChange="pointTypeChange"
|
||||
></pointTree>
|
||||
</pane>
|
||||
<pane style="background: #fff" :style="height">
|
||||
<TableHeader ref="TableHeaderRef" date-picker :show-search="false">
|
||||
@@ -134,14 +135,14 @@ import { onMounted, ref, provide } from 'vue'
|
||||
import 'splitpanes/dist/splitpanes.css'
|
||||
import { Splitpanes, Pane } from 'splitpanes'
|
||||
import TableStore from '@/utils/tableStore'
|
||||
import PointTree from '@/components/tree/pqs/pointTree.vue'
|
||||
|
||||
import TableHeader from '@/components/table/header/index.vue'
|
||||
import { useDictData } from '@/stores/dictData'
|
||||
import { mainHeight } from '@/utils/layout'
|
||||
import pointTreeWx from '@/components/tree/govern/pointTreeWx.vue'
|
||||
|
||||
import { genFileId, ElMessage, ElNotification } from 'element-plus'
|
||||
import type { UploadProps, UploadUserFile } from 'element-plus'
|
||||
import CloudDeviceEntryTree from '@/components/tree/govern/cloudDeviceEntryTree.vue'
|
||||
import pointTree from '@/components/tree/govern/pointTree.vue'
|
||||
import { getLineExport } from '@/api/harmonic-boot/cockpit/cockpit'
|
||||
defineOptions({
|
||||
name: 'TransientReport/monitoringpointReport'
|
||||
@@ -189,8 +190,10 @@ onMounted(() => {
|
||||
size.value = Math.round((180 / dom.offsetHeight) * 100)
|
||||
}
|
||||
})
|
||||
|
||||
const handleNodeClick = (data: any, node: any) => {
|
||||
const pointTypeChange = (val: any, obj: any) => {
|
||||
handleNodeClick(obj)
|
||||
}
|
||||
const handleNodeClick = (data: any,) => {
|
||||
dotList.value = data
|
||||
}
|
||||
// 上传
|
||||
@@ -209,7 +212,7 @@ const choose = (files: any) => {
|
||||
|
||||
//生成报告
|
||||
const exportEvent = () => {
|
||||
if (dotList.value?.level != 4) {
|
||||
if (dotList.value?.level != 3) {
|
||||
return ElMessage.warning('请选择监测点进行报告生成!')
|
||||
}
|
||||
let a = ''
|
||||
|
||||
@@ -2,11 +2,12 @@
|
||||
<div class="default-main" :style="height">
|
||||
<splitpanes style="height: 100%" id="navigation-splitpanes">
|
||||
<pane :size="size">
|
||||
<CloudDeviceEntryTree
|
||||
<pointTree
|
||||
ref="TerminalRef"
|
||||
@node-click="handleNodeClick"
|
||||
@init="handleNodeClick"
|
||||
></CloudDeviceEntryTree>
|
||||
@pointTypeChange="pointTypeChange"
|
||||
></pointTree>
|
||||
</pane>
|
||||
<pane style="background: #fff" :style="height">
|
||||
<TableHeader ref="TableHeaderRef" datePicker :show-search="false">
|
||||
@@ -67,14 +68,14 @@ import { onMounted, ref, provide } from 'vue'
|
||||
import 'splitpanes/dist/splitpanes.css'
|
||||
import { Splitpanes, Pane } from 'splitpanes'
|
||||
import TableStore from '@/utils/tableStore'
|
||||
import PointTree from '@/components/tree/pqs/pointTree.vue'
|
||||
|
||||
import TableHeader from '@/components/table/header/index.vue'
|
||||
import { useDictData } from '@/stores/dictData'
|
||||
import { mainHeight } from '@/utils/layout'
|
||||
import pointTreeWx from '@/components/tree/govern/pointTreeWx.vue'
|
||||
|
||||
import { genFileId, ElMessage, ElNotification } from 'element-plus'
|
||||
import type { UploadProps, UploadUserFile } from 'element-plus'
|
||||
import CloudDeviceEntryTree from '@/components/tree/govern/cloudDeviceEntryTree.vue'
|
||||
import pointTree from '@/components/tree/govern/pointTree.vue'
|
||||
import { exportModel } from '@/api/cs-harmonic-boot/datatrend'
|
||||
defineOptions({
|
||||
name: 'harmonic-boot/report/word'
|
||||
@@ -104,8 +105,10 @@ onMounted(() => {
|
||||
size.value = Math.round((180 / dom.offsetHeight) * 100)
|
||||
}
|
||||
})
|
||||
|
||||
const handleNodeClick = (data: any, node: any) => {
|
||||
const pointTypeChange = (val: any, obj: any) => {
|
||||
handleNodeClick(obj)
|
||||
}
|
||||
const handleNodeClick = (data: any) => {
|
||||
dotList.value = data
|
||||
}
|
||||
// 上传
|
||||
@@ -124,7 +127,7 @@ const choose = (files: any) => {
|
||||
// 生成
|
||||
const exportEvent = () => {
|
||||
console.log('🚀 ~ exportEvent ~ dotList.value:', dotList.value)
|
||||
if (dotList.value?.level != 4) {
|
||||
if (dotList.value?.level != 3) {
|
||||
return ElMessage.warning('请选择监测点进行报告生成!')
|
||||
}
|
||||
let form = new FormData()
|
||||
|
||||
@@ -5,13 +5,14 @@
|
||||
<!-- <pointTreeWx :default-expand-all="false" template @node-click="handleNodeClick" @init="handleNodeClick"
|
||||
@Policy="stencil">
|
||||
</pointTreeWx> -->
|
||||
<CloudDeviceEntryTree
|
||||
<pointTree
|
||||
ref="TerminalRef"
|
||||
template
|
||||
@Policy="stencil"
|
||||
@node-click="handleNodeClick"
|
||||
@init="handleNodeClick"
|
||||
></CloudDeviceEntryTree>
|
||||
@pointTypeChange="pointTypeChange"
|
||||
></pointTree>
|
||||
</pane>
|
||||
<pane :size="100 - size" style="background: #fff" :style="height">
|
||||
<TableHeader datePicker ref="TableHeaderRef" :showReset="false">
|
||||
@@ -66,7 +67,7 @@ import { exportExcel } from '@/views/system/reportForms/export.js'
|
||||
import 'splitpanes/dist/splitpanes.css'
|
||||
import DatePicker from '@/components/form/datePicker/time.vue'
|
||||
import { Splitpanes, Pane } from 'splitpanes'
|
||||
import CloudDeviceEntryTree from '@/components/tree/govern/cloudDeviceEntryTree.vue'
|
||||
import pointTree from '@/components/tree/govern/pointTree.vue'
|
||||
// import data from './123.json'
|
||||
defineOptions({
|
||||
name: 'govern/reportCore/statisticsWx/index'
|
||||
@@ -143,7 +144,6 @@ onMounted(() => {
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
const stencil = (val: any) => {
|
||||
templatePolicy.value = val.filter((item: any) => item.excelType != '4')
|
||||
Template.value = templatePolicy.value[0]
|
||||
@@ -153,9 +153,12 @@ const stencil = (val: any) => {
|
||||
const changetype = (val: any) => {
|
||||
reportForm.value = val.reportForm
|
||||
}
|
||||
const pointTypeChange = (val: any, obj: any) => {
|
||||
handleNodeClick(obj)
|
||||
}
|
||||
|
||||
const handleNodeClick = (data: any, node: any) => {
|
||||
if (data?.level == 4) {
|
||||
const handleNodeClick = (data: any) => {
|
||||
if (data?.level == 3) {
|
||||
dotList.value = data
|
||||
setTimeout(() => {
|
||||
tableStore.index()
|
||||
|
||||
@@ -186,9 +186,11 @@ const tableStore: any = new TableStore({
|
||||
|
||||
loadCallback: () => {
|
||||
tableRef.value.getRef().setCurrentRow(tableStore.table.data[0])
|
||||
currentChange({
|
||||
row: tableStore.table.data[0]
|
||||
})
|
||||
menuListId.value = tableStore.table.data[0].id
|
||||
// currentChange({
|
||||
// row: tableStore.table.data[0]
|
||||
// })
|
||||
getTemplate()
|
||||
}
|
||||
})
|
||||
|
||||
@@ -259,10 +261,12 @@ const getTemplate = () => {
|
||||
pageSize: 10000
|
||||
}).then(res => {
|
||||
templateList.value = res.data
|
||||
currentChange({
|
||||
row: { id: menuListId.value }
|
||||
})
|
||||
})
|
||||
}
|
||||
onMounted(() => {
|
||||
getTemplate()
|
||||
tableStore.index()
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
<div style="display: flex">
|
||||
<div id="luckysheet" :style="{ height: height, flex: 1 }"></div>
|
||||
<bind style="width: 500px" class="ml10" @setValue="setValue" />
|
||||
<bind style="width: 410px" class="ml10" @setValue="setValue" />
|
||||
</div>
|
||||
<!-- 信息框 -->
|
||||
<addForm ref="formFer" @submitForm="submitForm" />
|
||||
|
||||
Reference in New Issue
Block a user