Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xform
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
田翔
xform
Commits
f7d3ebf3
Commit
f7d3ebf3
authored
Apr 18, 2023
by
田翔
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 解析json
parent
476da5c3
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
36 deletions
+53
-36
index.js
src/core/TableRender/components/SearchGroup/index.js
+0
-0
search.less
src/core/TableRender/components/SearchGroup/search.less
+0
-0
index.js
src/core/TableRender/components/TablePack/index.js
+3
-28
index.js
src/core/TableRender/index.js
+50
-8
No files found.
src/core/TableRender/components/Search/index.js
→
src/core/TableRender/components/Search
Group
/index.js
View file @
f7d3ebf3
File moved
src/core/TableRender/components/Search/search.less
→
src/core/TableRender/components/Search
Group
/search.less
View file @
f7d3ebf3
File moved
src/core/TableRender/components/TablePack/index.js
View file @
f7d3ebf3
...
...
@@ -3,37 +3,12 @@ import { Table, Tooltip } from 'antd'
const
TablePack
=
(
props
)
=>
{
const
{
loading
,
showField
,
formJson
,
dataSource
}
=
props
const
{
}
=
props
const
columns
=
useMemo
(()
=>
{
let
array
=
[]
showField
.
forEach
(
v
=>
{
array
.
push
({
key
:
new
Date
().
getTime
(),
title
:
v
,
dataIndex
:
v
,
width
:
120
,
ellipsis
:
true
,
render
:
(
value
,
r
)
=>
{
return
(
<
Tooltip
placement
=
"top"
title
=
{
value
}
>
{
value
}
<
/Tooltip
>
)
}
})
})
return
array
},
[
showField
])
// console.log('props', props)
return
(
<
Table
size
=
'small'
bordered
loading
=
{
loading
}
columns
=
{
columns
}
dataSource
=
{
dataSource
}
pagination
=
{
false
}
scroll
=
{{
y
:
'calc(100% - 50px)'
}}
/
>
<
div
>
{
JSON
.
stringify
(
props
)}
<
/div
>
)
}
...
...
src/core/TableRender/index.js
View file @
f7d3ebf3
import
React
,
{
useEffect
,
useMemo
,
useState
}
from
'react'
import
styles
from
'./index.less'
import
Search
from
'./components/Search'
import
{
Table
,
Tooltip
}
from
'antd'
import
SearchGroup
from
'./components/SearchGroup'
import
TablePack
from
'./components/TablePack'
import
{
GetAccountConfigInfo
,
GetAccountPageList
,
getStationListByUserID
,
GetTableJson
}
from
'../../apis/process'
import
{
isJson
,
isObject
}
from
'../../utils/index'
import
{
query
}
from
'express'
const
getFileInfo
=
(
formJson
)
=>
{
let
obj
=
{}
let
json
=
isJson
(
formJson
)
?
JSON
.
parse
(
formJson
)
:
{}
let
parent
=
json
?.
properties
if
(
isObject
(
parent
))
{
for
(
let
v
in
parent
)
{
let
child
=
parent
[
v
]?.
properties
if
(
isObject
(
child
))
{
for
(
let
s
in
child
)
{
obj
[
s
]
=
child
[
s
]
}
}
}
}
console
.
log
(
'obj'
,
obj
)
return
obj
}
const
TableRender
=
(
props
)
=>
{
...
...
@@ -12,9 +33,27 @@ const TableRender = (props) => {
const
[
config
,
setConfig
]
=
useState
({
webShowFieldGroup
:
''
,
formJson
:
''
})
const
[
dataSource
,
setDataSource
]
=
useState
([])
const
showField
=
useMemo
(()
=>
{
const
{
webShowFieldGroup
}
=
config
return
webShowFieldGroup
.
split
(
','
).
filter
(
v
=>
v
)
const
columns
=
useMemo
(()
=>
{
const
{
webShowFieldGroup
,
formJson
}
=
config
let
showField
=
webShowFieldGroup
?
webShowFieldGroup
.
split
(
','
).
filter
(
v
=>
v
)
:
[]
let
json
=
getFileInfo
(
formJson
)
let
array
=
[]
showField
.
forEach
(
v
=>
{
array
.
push
({
key
:
new
Date
().
getTime
(),
title
:
json
[
v
]?.
title
||
v
,
dataIndex
:
v
,
width
:
120
,
ellipsis
:
true
,
render
:
(
value
,
r
)
=>
{
let
props
=
{
...
json
[
v
],
value
}
return
(
<
TablePack
{...
props
}
/
>
)
}
})
})
return
array
},
[
config
])
const
getConfig
=
async
()
=>
{
...
...
@@ -58,14 +97,17 @@ const TableRender = (props) => {
return
(
<
div
className
=
{
styles
.
tableRender
}
>
<
div
className
=
{
styles
.
top
}
>
<
Search
/>
<
Search
Group
/>
<
/div
>
<
div
className
=
{
styles
.
bottom
}
>
<
TablePack
<
Table
size
=
'small'
bordered
loading
=
{
loading
}
showField
=
{
showField
}
formJson
=
{
config
.
formJson
}
columns
=
{
columns
}
dataSource
=
{
dataSource
}
pagination
=
{
false
}
scroll
=
{{
y
:
'calc(100% - 50px)'
}}
/
>
<
/div
>
<
/div
>
...
...
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