修改算法库
This commit is contained in:
@@ -1,88 +1,106 @@
|
||||
<template>
|
||||
<div class="point-tree">
|
||||
<div style="flex: 1; overflow: hidden">
|
||||
<Tree
|
||||
ref="treeRef"
|
||||
:data="tree"
|
||||
:canExpand="false"
|
||||
style="width: 100%; height: 100%"
|
||||
v-bind="$attrs"
|
||||
default-expand-all
|
||||
|
||||
@onAddTree="onAddTree"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { nextTick, onMounted, ref, useAttrs } from 'vue'
|
||||
import Tree from '../index.vue'
|
||||
import { useAdminInfo } from '@/stores/adminInfo'
|
||||
import { useDictData } from '@/stores/dictData'
|
||||
import { getTerminalTreeForFive } from '@/api/device-boot/terminalTree'
|
||||
import { useConfig } from '@/stores/config'
|
||||
import { queryAllAlgorithmLibrary } from '@/api/supervision-boot/database/index'
|
||||
defineOptions({
|
||||
name: 'pms/pointTree'
|
||||
})
|
||||
const emit = defineEmits(['init', 'onAddTree'])
|
||||
const attrs = useAttrs()
|
||||
const adminInfo = useAdminInfo()
|
||||
const dictData = useDictData()
|
||||
const config = useConfig()
|
||||
const classificationData = dictData.getBasicData('Statistical_Type', ['Report_Type'])
|
||||
const tree = ref()
|
||||
const treeRef = ref()
|
||||
|
||||
const loadData = (id?: any) => {
|
||||
console.log('🚀 ~ loadData ~ id:', id)
|
||||
let nodeKey = ''
|
||||
queryAllAlgorithmLibrary().then(res => {
|
||||
res.data.forEach((item: any) => {
|
||||
item.icon = 'el-icon-FolderOpened'
|
||||
item.color = config.getColorVal('elementUiPrimary')
|
||||
item.children.forEach((item2: any) => {
|
||||
item2.icon = 'el-icon-Document'
|
||||
item2.color = config.getColorVal('elementUiPrimary')
|
||||
item2.childrens = item2.children
|
||||
item2.children = []
|
||||
if (item2.id == id) {
|
||||
emit('init', item2)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
nodeKey = res.data[0].children[0].id
|
||||
|
||||
tree.value = res.data
|
||||
if (id) {
|
||||
setTimeout(() => {
|
||||
treeRef.value.treeRef.setCurrentKey(id)
|
||||
}, 10)
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
treeRef.value.treeRef.setCurrentKey(nodeKey)
|
||||
emit('init', res.data[0].children[0])
|
||||
}, 10)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const onAddTree = () => {
|
||||
emit('onAddTree')
|
||||
}
|
||||
loadData()
|
||||
defineExpose({ loadData })
|
||||
</script>
|
||||
<style lang="scss">
|
||||
.point-tree {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background: #fff;
|
||||
border: 1px solid var(--el-border-color);
|
||||
}
|
||||
</style>
|
||||
|
||||
<template>
|
||||
<div class="point-tree">
|
||||
<div style="flex: 1; overflow: hidden">
|
||||
<Tree
|
||||
ref="treeRef"
|
||||
:data="tree"
|
||||
:canExpand="false"
|
||||
style="width: 100%; height: 100%"
|
||||
v-bind="$attrs"
|
||||
default-expand-all
|
||||
@onAddTree="onAddTree"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { nextTick, onMounted, ref, useAttrs } from 'vue'
|
||||
import Tree from '../index.vue'
|
||||
import { useAdminInfo } from '@/stores/adminInfo'
|
||||
import { useDictData } from '@/stores/dictData'
|
||||
import { getTerminalTreeForFive } from '@/api/device-boot/terminalTree'
|
||||
import { useConfig } from '@/stores/config'
|
||||
import { queryAllAlgorithmLibrary } from '@/api/supervision-boot/database/index'
|
||||
defineOptions({
|
||||
name: 'pms/pointTree'
|
||||
})
|
||||
const emit = defineEmits(['init', 'onAddTree'])
|
||||
const attrs = useAttrs()
|
||||
const adminInfo = useAdminInfo()
|
||||
const dictData = useDictData()
|
||||
const config = useConfig()
|
||||
const classificationData = dictData.getBasicData('Statistical_Type', ['Report_Type'])
|
||||
const tree = ref()
|
||||
const treeRef = ref()
|
||||
|
||||
const loadData = (id?: any) => {
|
||||
console.log('🚀 ~ loadData ~ id:', id)
|
||||
let nodeKey = ''
|
||||
queryAllAlgorithmLibrary().then(res => {
|
||||
res.data.forEach((item: any) => {
|
||||
item.icon = 'el-icon-FolderOpened'
|
||||
item.color = config.getColorVal('elementUiPrimary')
|
||||
item.children.forEach((item2: any) => {
|
||||
item2.icon = 'el-icon-Document'
|
||||
item2.color = config.getColorVal('elementUiPrimary')
|
||||
item2.childrens = item2.children
|
||||
item2.children = []
|
||||
if (item2.id == id) {
|
||||
emit('init', item2)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
nodeKey = res.data[0].children[0].id
|
||||
|
||||
tree.value = res.data
|
||||
if (id) {
|
||||
setTimeout(() => {
|
||||
treeRef.value.treeRef.setCurrentKey(id)
|
||||
}, 10)
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
treeRef.value.treeRef.setCurrentKey(nodeKey)
|
||||
emit('init', res.data[0].children[0])
|
||||
}, 10)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const onAddTree = () => {
|
||||
emit('onAddTree')
|
||||
}
|
||||
const setKey = (id: string) => {
|
||||
treeRef.value.treeRef.setCurrentKey(id)
|
||||
return findNodeById(tree.value, id)
|
||||
}
|
||||
const findNodeById = (tree1: any, targetId: any) => {
|
||||
for (const node of tree1) {
|
||||
// 1. 当前节点匹配ID,直接返回该节点
|
||||
if (node.id === targetId) {
|
||||
return node
|
||||
}
|
||||
// 2. 当前节点有子节点,递归查找子节点
|
||||
if (node.children && node.children.length > 0) {
|
||||
const result: any = findNodeById(node.children, targetId)
|
||||
// 子节点中找到结果,立即返回(终止递归)
|
||||
if (result) return result
|
||||
}
|
||||
}
|
||||
// 3. 遍历完未找到,返回null
|
||||
return null
|
||||
}
|
||||
loadData()
|
||||
defineExpose({ loadData, setKey })
|
||||
</script>
|
||||
<style lang="scss">
|
||||
.point-tree {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background: #fff;
|
||||
border: 1px solid var(--el-border-color);
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -10,9 +10,6 @@
|
||||
<el-form-item label="名称" prop="name" v-if="title == '修改算法' ? TreeList.level != 4 : TreeList.level != 3">
|
||||
<el-input v-model="form.name" placeholder="名称" clearable maxlength="32" show-word-limit @input="handleInput('name', $event)"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="绑定页面" v-if="title == '修改算法' ? TreeList.level == 3 : TreeList.level == 2">
|
||||
<el-input v-model="form.path" placeholder="请输入需要绑定的路由" clearable maxlength="32" show-word-limit @input="handleInput('name', $event)"/>
|
||||
</el-form-item>
|
||||
<!-- <div v-if="title == '修改算法' ? TreeList.level == 4 : TreeList.level == 3"> -->
|
||||
<el-form-item label="算法名称" prop="name" v-if="title == '修改算法' ? TreeList.level == 4 : TreeList.level == 3">
|
||||
<el-input v-model="form.name" placeholder="请输入算法名称" clearable maxlength="32" show-word-limit @input="handleInput('name', $event)"/>
|
||||
@@ -70,8 +67,7 @@ const form = reactive<anyObj>({
|
||||
period: '',
|
||||
definition: '',
|
||||
source: '',
|
||||
pid: '',
|
||||
path: ''
|
||||
pid: ''
|
||||
})
|
||||
const rules = {
|
||||
name: [{ required: true, message: '请输入算法名称', trigger: 'blur' }],
|
||||
@@ -136,7 +132,6 @@ const submit = async () => {
|
||||
} else {
|
||||
forms.name = form.name
|
||||
forms.pid = form.pid
|
||||
forms.path = form.path||''
|
||||
}
|
||||
await addAlgorithm(forms).then(res => {
|
||||
ElMessage.success('新增成功')
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
<div class="default-main">
|
||||
<el-tabs v-model="activeName" type="border-card">
|
||||
<el-tab-pane label="总览" name="1" v-if="tabList.includes('1')">
|
||||
<overview v-if="activeName == '1'" />
|
||||
<overview v-if="activeName == '1'" @algorithm="algorithm" />
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="算法库" name="2" v-if="tabList.includes('2')">
|
||||
<list v-if="activeName == '2'" />
|
||||
<list v-if="activeName == '2'" ref="listRef" />
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</div>
|
||||
@@ -27,6 +27,7 @@ defineOptions({
|
||||
const activeName = ref('1')
|
||||
const id = ref('')
|
||||
const key = ref('')
|
||||
const listRef = ref()
|
||||
const tabList = ref(['1', '2'])
|
||||
onMounted(() => {
|
||||
let key = window.location.href.split('?')[0].slice(-1)
|
||||
@@ -36,7 +37,12 @@ onMounted(() => {
|
||||
activeName.value = key
|
||||
}
|
||||
})
|
||||
|
||||
const algorithm = (val: any) => {
|
||||
activeName.value = '2'
|
||||
setTimeout(() => {
|
||||
listRef.value.getList(val)
|
||||
}, 100)
|
||||
}
|
||||
const layout = mainHeight(63) as any
|
||||
</script>
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
@onAddTree="onAddTree"
|
||||
></algorithmTree>
|
||||
</pane>
|
||||
<pane style="background: #fff;width: 100%;" :style="height" >
|
||||
<pane style="background: #fff; width: 100%" :style="height">
|
||||
<div class="boxTop">
|
||||
<div>
|
||||
<el-radio-group v-model="radio">
|
||||
@@ -111,13 +111,13 @@
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref, provide } from 'vue'
|
||||
import { onMounted, ref, provide, nextTick } from 'vue'
|
||||
import 'splitpanes/dist/splitpanes.css'
|
||||
import { Splitpanes, Pane } from 'splitpanes'
|
||||
import algorithmTree from '@/components/tree/pqs/algorithmTree.vue'
|
||||
import { mainHeight } from '@/utils/layout'
|
||||
import { defaultAttribute } from '@/components/table/defaultAttribute'
|
||||
import { getLineExport, getList, selectReleation } from '@/api/event-boot/report'
|
||||
import { getLineExport, selectReleation } from '@/api/event-boot/report'
|
||||
import addTree from './components/addTree.vue'
|
||||
import PopupEdit from './components/form.vue'
|
||||
import { useMonitoringPoint } from '@/stores/monitoringPoint'
|
||||
@@ -295,6 +295,19 @@ const change = (row: any) => {
|
||||
})
|
||||
})
|
||||
}
|
||||
const getList = (val: any) => {
|
||||
setTimeout(async () => {
|
||||
dotList.value = await treeRef.value.setKey(val.data.pid)
|
||||
await dotList.value?.childrens.forEach((item: any, i: number) => {
|
||||
if (item.id == val.data.id) {
|
||||
radio.value = i
|
||||
}
|
||||
})
|
||||
}, 500)
|
||||
}
|
||||
defineExpose({
|
||||
getList
|
||||
})
|
||||
</script>
|
||||
<style lang="scss">
|
||||
.splitpanes.default-theme .splitpanes__pane {
|
||||
|
||||
@@ -24,6 +24,7 @@ const adminInfo = useAdminInfo()
|
||||
defineOptions({
|
||||
name: 'database/algorithm'
|
||||
})
|
||||
const emits = defineEmits(['algorithm'])
|
||||
const height = mainHeight(20)
|
||||
const size = ref(23)
|
||||
|
||||
@@ -117,11 +118,9 @@ const info = () => {
|
||||
}
|
||||
// 点击echart
|
||||
const echartClick = (params: any) => {
|
||||
if (params.data.level == 3 && params.data.path != '') {
|
||||
router.push({
|
||||
name: params.data.path
|
||||
})
|
||||
}
|
||||
if(params.data.level == 3){
|
||||
emits('algorithm', params)
|
||||
}
|
||||
}
|
||||
const setTreeAllNodeExpand = (treeData: any) => {
|
||||
if (!treeData) return []
|
||||
|
||||
@@ -61,7 +61,7 @@ const open = (data: any) => {
|
||||
loading.value = true
|
||||
show.value = true
|
||||
setTimeout(() => {
|
||||
dataList.value = data.sort((a, b) => b.vharmonicbootValue - a.vharmonicbootValue)
|
||||
dataList.value = data.sort((a, b) => b.vharmonicValue - a.vharmonicValue)
|
||||
loading.value = false
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user