Merge branch 'master' of http://192.168.1.22:3000/Web/admin-sjzx
# Conflicts: # src/components/PreviewFile/index.vue
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
:options="excelOptions"
|
||||
/>
|
||||
<!-- <vue-office-pdf v-if="url.includes('.pdf')" :src="url" /> -->
|
||||
<iframe v-if="urlKey.includes('.pdf')" :src="url" style="width: 100%; height: 99%"></iframe>
|
||||
<iframe v-if="urlKey.includes('.pdf')||urlKey.includes('.txt')" :src="url" style="width: 100%; height: 99%"></iframe>
|
||||
<img
|
||||
v-if="
|
||||
urlKey.includes('.png') || urlKey.includes('.jpg') || urlKey.includes('.gif') || urlKey.includes('.bmp')
|
||||
@@ -35,18 +35,21 @@ const VITE_FLAG = import.meta.env.VITE_NAME == 'jibei'
|
||||
const url = ref('')
|
||||
const excelOptions = ref({})
|
||||
const urlKey = currentRoute.value?.href?.split('?')[1]
|
||||
|
||||
if (VITE_FLAG) {
|
||||
url.value = '/api-docx/excelreport' + currentRoute.value?.href?.split('?')[1]
|
||||
excelOptions.value = ref({
|
||||
xls: currentRoute.value.href?.split('?')[1].split('.')[1] == 'xls' ? true : false
|
||||
})
|
||||
} else {
|
||||
console.log('🚀 ~ urlKey:', urlKey)
|
||||
setTimeout(async () => {
|
||||
const previewUrl = await previewFile(currentRoute.value?.href?.split('?')[1])
|
||||
url.value = previewUrl
|
||||
excelOptions.value = ref({
|
||||
xls: currentRoute.value.href?.split('?')[1].split('.')[1] == 'xls' ? true : false
|
||||
})
|
||||
}, 0)
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
// 从路由参数获取文件路径
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user