修改实时数据导出丢失数据

修改故障录波tab页显示名称
This commit is contained in:
高云鹏 2024-11-28 15:15:14 +08:00
parent b9ded9def6
commit 8df96191b3
2 changed files with 53 additions and 44 deletions

View File

@ -190,7 +190,7 @@
</div>
</template>
</el-dialog>
<el-dialog v-model="realDataLineChartVisible" title="实时曲线" @close="closeLineChart">
<el-dialog v-model="realDataLineChartVisible" title="实时曲线" @close="closeLineChart" width="1000">
<RealDataChart
ref="realDataChartRef"
:visible="realDataLineChartVisible"
@ -648,7 +648,6 @@ const openWindTurbine = (row: TableDataObjType) => {
},
})
}
console.log(row)
router.push({
name: 'windTurbine',
@ -693,7 +692,6 @@ const openMeasure = () => {
const saveSelectPoint = () => {
const list = selectPointDialogRef.value?.getSelectList()
if (list) {
console.log(list)
const addCoulmn = list.map((item: any) => {
return {
@ -712,46 +710,57 @@ const saveSelectPoint = () => {
}
}
const downFun = () => {
const itemsWithoutAge = tableData.value.map((item) => {
const { irn, ...rest } = item
return rest
// const itemsWithoutAge = tableData.value.map((item) => {
// const { irn, ...rest } = item
// return rest
// })
// if (!tableColumn.value.length || !itemsWithoutAge.length) {
// return []
// }
// const columnSet = new Set(tableColumn.value.map((item) => item.prop))
// const result: any = []
// itemsWithoutAge.forEach((item) => {
// const newItem: any = {}
// for (const itemKey in item) {
// if (columnSet.has(itemKey)) {
// newItem[itemKey] = item[itemKey]
// }
// }
// if (Object.keys(newItem).length > 0) {
// result.push(newItem)
// }
// })
// let addobj: any = {}
// tableColumn.value.map((v, i) => {
// addobj['rowData' + i] = v.label
// })
// let tableDatadown = JSON.parse(JSON.stringify(result))
// tableDatadown.unshift(addobj)
// console.log(tableDatadown)
// debugger
// let str = ``
// for (let i = 0; i < tableDatadown.length; i++) {
// for (let item in tableDatadown[i]) {
// if (typeof tableDatadown[i][item] === 'string') {
// tableDatadown[i][item] = tableDatadown[i][item].replace(/[\n,]/g, (match: any) => (match === '\n' ? ' ' : ''))
// } else {
// console.warn(`tableDatadown[${i}][${item}] is not a string`)
// }
// str += `${tableDatadown[i][item] + '\t'},`
// }
// str += '\n'
// }
const title = tableColumn.value.map((item: any) => item.label).join('\t,') + '\n'
const titleKeyArr = tableColumn.value.map((item: any) => item.prop)
let str = ''
tableData.value.forEach((item) => {
titleKeyArr.forEach((prop: any) => {
const val = typeof item[prop] === 'string' ? item[prop] : item[prop] ? String(item[prop]) : ''
str += val + '\t' + ','
})
if (!tableColumn.value.length || !itemsWithoutAge.length) {
return []
}
const columnSet = new Set(tableColumn.value.map((item) => item.prop))
const result: any = []
itemsWithoutAge.forEach((item) => {
const newItem: any = {}
for (const itemKey in item) {
if (columnSet.has(itemKey)) {
newItem[itemKey] = item[itemKey]
}
}
if (Object.keys(newItem).length > 0) {
result.push(newItem)
}
})
let addobj: any = {}
tableColumn.value.map((v, i) => {
addobj['rowData' + i] = v.label
})
let tableDatadown = JSON.parse(JSON.stringify(result))
tableDatadown.unshift(addobj)
console.log(tableDatadown)
let str = ``
for (let i = 0; i < tableDatadown.length; i++) {
for (let item in tableDatadown[i]) {
if (typeof tableDatadown[i][item] === 'string') {
tableDatadown[i][item] = tableDatadown[i][item].replace(/[\n,]/g, (match: any) => (match === '\n' ? ' ' : ''))
} else {
console.warn(`tableDatadown[${i}][${item}] is not a string`)
}
str += `${tableDatadown[i][item] + '\t'},`
}
str += '\n'
}
})
str = title + str
let uri = 'data:text/csv;charset=utf-8,\ufeff' + encodeURIComponent(str)
let link = document.createElement('a')
link.href = uri

View File

@ -49,7 +49,7 @@
</el-header>
<el-main class="main">
<el-tabs v-model="activeName" @tab-change="checkTab" class="tabs">
<el-tab-pane label="故障录波" name="malFunction" class="tabPane">
<el-tab-pane label="故障录波文件" name="malFunction" class="tabPane">
<div class="tableMain">
<el-table :data="tableData" class="tableClass">
<el-table-column type="selection" width="55" />
@ -79,7 +79,7 @@
></el-pagination>
</div>
</el-tab-pane>
<el-tab-pane label="日志管理" name="logManage" class="tabPane">
<el-tab-pane label="运行日志文件" name="logManage" class="tabPane">
<div class="tableMain">
<el-table :data="logTableData" class="tableClass">
<el-table-column type="selection" width="55" />