Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
T
topsun-baoshen-excel
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
何远江
topsun-baoshen-excel
Commits
7b002171
Commit
7b002171
authored
Jan 11, 2024
by
何远江
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改excel解析结果字段显示顺序
parent
e260bef9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
70 additions
and
45 deletions
+70
-45
ExcelOperate.vue
...ws/comment-excel/components/ExcelOperate/ExcelOperate.vue
+70
-45
No files found.
src/views/comment-excel/components/ExcelOperate/ExcelOperate.vue
View file @
7b002171
...
@@ -134,6 +134,7 @@
...
@@ -134,6 +134,7 @@
ref=
"runDataTable"
ref=
"runDataTable"
size=
"mini"
size=
"mini"
show-overflow=
"tooltip"
show-overflow=
"tooltip"
show-header-overflow=
"tooltip"
:data=
"runResultData"
:data=
"runResultData"
border
border
:expand-config=
"expandConfig"
:expand-config=
"expandConfig"
...
@@ -144,19 +145,40 @@
...
@@ -144,19 +145,40 @@
<
template
#
content=
"{ row, rowIndex }"
>
<
template
#
content=
"{ row, rowIndex }"
>
<div
style=
"padding: 10px"
>
<div
style=
"padding: 10px"
>
<template
v-for=
"attchName of filterObjKeys(row.expendData)"
>
<template
v-for=
"attchName of filterObjKeys(row.expendData)"
>
<el-descriptions
<p>
{{
attchName
}}
</p>
direction=
"vertical"
<vxe-table
:data=
"row.expendData[attchName]"
header-row-class-name=
"expandTableHeader"
min-height=
"72"
height=
"72"
size=
"mini"
show-overflow=
"tooltip"
show-header-overflow=
"tooltip"
style=
"width: 70vw;"
border
border
:column=
"filterObjKeys(row.expendData[attchName]).length"
size=
"small"
:title=
"attchName"
>
>
<el-descriptions-item
<vxe-column
v-for=
"pro in filterObjKeys(row.expendData[attchName])"
v-for=
"key in filterObjKeys(row.expendData[attchName][0])"
:label=
"pro"
:title=
"key"
>
{{
row
.
expendData
[
attchName
][
pro
]
}}
</el-descriptions-item
:field=
"key"
width=
"140"
></vxe-column>
</vxe-table>
<!--
<el-scrollbar>
<el-descriptions
direction=
"vertical"
border
:column=
"filterObjKeys(row.expendData[attchName]).length"
size=
"small"
:title=
"attchName"
>
>
</el-descriptions>
<el-descriptions-item
v-for=
"pro in filterObjKeys(row.expendData[attchName])"
:label=
"pro"
>
{{
row
.
expendData
[
attchName
][
pro
]
}}
</el-descriptions-item
>
</el-descriptions>
</el-scrollbar>
-->
</
template
>
</
template
>
</div>
</div>
</template>
</template>
...
@@ -618,8 +640,8 @@ const setSheetAreaMark = (sheet: any) => {
...
@@ -618,8 +640,8 @@ const setSheetAreaMark = (sheet: any) => {
}
}
}
}
const
runResultData
=
ref
([])
const
runResultData
=
ref
<
any
[]
>
([])
const
runResultTitle
=
ref
([])
const
runResultTitle
=
ref
<
any
[]
>
([])
const
runResultVisible
=
ref
(
false
)
const
runResultVisible
=
ref
(
false
)
const
toRun
=
async
()
=>
{
const
toRun
=
async
()
=>
{
const
loadingInstance
=
ElLoading
.
service
({
const
loadingInstance
=
ElLoading
.
service
({
...
@@ -639,19 +661,14 @@ const toRun = async () => {
...
@@ -639,19 +661,14 @@ const toRun = async () => {
if
(
!
data
.
result
.
length
)
return
if
(
!
data
.
result
.
length
)
return
const
tableData
:
any
[]
=
[]
const
{
res
,
titles
}
=
filterTableData
(
data
.
result
)
data
.
result
.
forEach
((
item
:
any
)
=>
{
tableData
.
push
(
filterTableData
(
item
))
})
runResultData
.
value
=
tableData
runResultData
.
value
=
res
runResultTitle
.
value
=
filterRunDataTitle
(
tableData
)
.
filter
((
field
)
=>
{
runResultTitle
.
value
=
titles
.
filter
((
field
)
=>
{
return
field
!=
'sortNum'
&&
field
!=
'数据区'
&&
field
!=
'expendData'
return
field
!=
'sortNum'
&&
field
!=
'数据区'
&&
field
!=
'expendData'
})
})
// const idx = runResultTitle.value.findIndex((v) => v == 'sortNum')
// runResultTitle.value.splice(idx, 1)
runResultVisible
.
value
=
true
runResultVisible
.
value
=
true
console
.
log
(
'runResultData.value'
,
runResultData
.
value
)
}
catch
{
}
catch
{
nextTick
(()
=>
{
nextTick
(()
=>
{
// Loading should be closed asynchronously
// Loading should be closed asynchronously
...
@@ -660,39 +677,44 @@ const toRun = async () => {
...
@@ -660,39 +677,44 @@ const toRun = async () => {
}
}
}
}
const
filterTableData
=
(
row
:
any
)
=>
{
const
filterTableData
=
(
data
:
any
[])
=>
{
const
res
:
Recordable
=
{}
const
res
:
Recordable
[]
=
[]
row
.
order
.
forEach
((
itm
)
=>
{
const
titles
:
string
[]
=
[]
res
[
itm
.
title
]
=
itm
.
value
data
.
forEach
((
row
)
=>
{
})
const
rw
=
{}
// 是否有附加信息
row
.
order
.
forEach
((
itm
)
=>
{
if
(
row
?.
groups
?.
length
)
{
Reflect
.
set
(
rw
,
itm
.
title
,
itm
.
value
)
res
[
'expendData'
]
=
{}
if
(
!
titles
.
includes
(
itm
.
title
))
{
row
.
groups
.
forEach
((
itm
)
=>
{
titles
.
push
(
itm
.
title
)
res
[
'expendData'
][
itm
.
title
]
=
{}
}
itm
.
item
.
forEach
((
v
)
=>
{
res
[
'expendData'
][
itm
.
title
][
v
.
title
]
=
v
.
value
})
})
})
}
// 是否有附加信息
if
(
row
?.
groups
?.
length
)
{
Reflect
.
set
(
rw
,
'expendData'
,
{})
row
.
groups
.
forEach
((
itm
)
=>
{
rw
[
'expendData'
][
itm
.
title
]
=
[]
const
r
=
{}
itm
.
item
.
forEach
((
v
)
=>
{
r
[
v
.
title
]
=
v
.
value
})
rw
[
'expendData'
][
itm
.
title
].
push
(
r
)
})
}
return
res
res
.
push
(
rw
)
}
})
const
filterRunDataTitle
=
(
data
:
any
)
=>
{
return
{
const
titles
=
[]
res
,
for
(
const
row
of
data
)
{
titles
titles
.
push
(...
Object
.
keys
(
row
))
}
}
return
Array
.
from
(
new
Set
(
titles
))
}
}
const
filterObjKeys
=
(
data
:
any
)
=>
{
const
filterObjKeys
=
(
data
:
any
)
=>
{
return
Object
.
keys
(
data
)
return
Object
.
keys
(
data
)
.
filter
((
v
)
=>
v
!==
'_X_ROW_KEY'
)
}
}
const
expandConfig
=
reactive
({
const
expandConfig
=
reactive
({
visibleMethod
({
row
})
{
visibleMethod
({
row
})
{
console
.
log
(
'row'
,
row
)
if
(
typeof
row
.
expendData
===
'object'
)
{
if
(
typeof
row
.
expendData
===
'object'
)
{
return
true
return
true
}
}
...
@@ -721,4 +743,7 @@ onUnmounted(() => {
...
@@ -721,4 +743,7 @@ onUnmounted(() => {
width
:
8em
;
width
:
8em
;
}
}
}
}
.expandTableHeader
{
background
:
#ccc
;
}
</
style
>
</
style
>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment