数据迁移

This commit is contained in:
GGJ
2024-10-24 08:51:29 +08:00
parent 2e364d82ed
commit 1aa7e4263b
9 changed files with 559 additions and 58 deletions

View File

@@ -1,6 +1,9 @@
<template>
<TableHeader area datePicker ref="TableHeaderRef">
<template #select>
<el-form-item label="筛选">
<el-input v-model="tableStore.table.params.filterName" @keyup="searchEvent" placeholder="输入关键字筛选" />
</el-form-item>
<el-form-item label="统计类型:">
<el-select v-model="tableStore.table.params.statisticalType" value-key="id" placeholder="请选择统计类型">
<el-option v-for="item in classificationData" :key="item.id" :label="item.name"
@@ -49,9 +52,12 @@ import Table from '@/components/table/index.vue'
import TableHeader from '@/components/table/header/index.vue'
import { useDictData } from '@/stores/dictData'
import { exportModelJB } from '@/api/harmonic-boot/harmonic.ts'
import { debounce } from 'lodash-es'
import XEUtils from 'xe-utils'
const dictData = useDictData()
const tableRef = ref()
const treeDataCopy: any = ref([])
const treeData: any = ref([])
const classificationData = dictData.getBasicData('Statistical_Type', ['Report_Type'])
const voltageleveloption = dictData.getBasicData('Dev_Voltage_Stand')
const terminaloption = dictData.getBasicData('Dev_Manufacturers')
@@ -138,21 +144,15 @@ const tableStore = new TableStore({
tableStore.options.column[0].title = tableStore.table.params.statisticalType.name
},
loadCallback: () => {
let treeData = []
// tableStore.table.data.forEach((item: any) => {
// if (item.children.length > 0) {
// item.children.forEach((k: any) => {
// k.pid = item.id
// })
// }
// })
treeData = tree2List(tableStore.table.data, Math.random() * 1000)
tableStore.table.data = JSON.parse(JSON.stringify(treeData))
setTimeout(() => {
tableRef.value.getRef().setAllTreeExpand(true)
}, 0)
}, 1000)
treeData.value = tree2List(tableStore.table.data, Math.random() * 1000)
treeDataCopy.value = JSON.parse(JSON.stringify(treeData.value))
tableStore.table.data = treeData.value
tableStore.table.params.filterName=''
searchEvent()
}
})
const loading = ref(false)
@@ -188,6 +188,33 @@ const tree2List = (list: any, id: any) => {
onMounted(() => {
tableStore.index()
})
const searchEvent = debounce(() => {
const filterVal = XEUtils.toValueString(tableStore.table.params.filterName).trim().toLowerCase()
if (filterVal) {
const options = { children: 'children' }
const searchProps = ['name']
const rest = XEUtils.searchTree(
treeDataCopy.value,
(item: any) => searchProps.some(key => String(item[key]).toLowerCase().indexOf(filterVal) > -1),
options
)
console.log("🚀 ~ searchEvent ~ rest:", rest)
tableStore.table.data = rest
// 搜索之后默认展开所有子节点
} else {
tableStore.table.data = treeDataCopy.value
}
nextTick(() => {
const $table = tableRef.value.getRef()
if ($table) {
$table.setAllTreeExpand(true)
}
})
}, 500)
const exportEvent = () => {
let line = tableRef.value.getRef().getRadioRecord()
if (!line) {