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
43523b78
Commit
43523b78
authored
5 months ago
by
杨子龙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化控件
parent
0921bc5c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
11 deletions
+37
-11
settings.js
src/core/FormDesigner/config/settings.js
+1
-2
index.js
src/core/widgets/coord/DataTable/index.js
+31
-9
eventEmitter.js
src/utils/eventEmitter.js
+5
-0
No files found.
src/core/FormDesigner/config/settings.js
View file @
43523b78
...
...
@@ -4795,12 +4795,11 @@ const advancedWidgets = [
icon
:
<
IconPack
.
AreaTask
/>
,
schema
:
{
title
:
'数据表格'
,
type
:
'
array
'
,
type
:
'
number
'
,
widget
:
'DataTable'
,
placeholder
:
''
,
width
:
'100%'
,
labelWidth
:
1
,
default
:
[]
},
setting
:
{
widget
:
{
...
...
This diff is collapsed.
Click to expand it.
src/core/widgets/coord/DataTable/index.js
View file @
43523b78
import
React
,
{
Fragment
,
useEffect
}
from
'react'
;
import
React
,
{
Fragment
,
useEffect
,
useState
}
from
'react'
;
import
{
Button
,
Empty
,
Table
,
Space
,
Input
}
from
'antd'
;
import
{
CheckOutlined
}
from
"@ant-design/icons"
;
import
*
as
AntdIcon
from
'@ant-design/icons'
;
import
FileView
from
'../../../Account/components/TablePack/components/FileView'
;
import
TagPack
from
'../../../components/TagPack'
import
eventEmitter
from
'../../../../utils/eventEmitter'
import
styles
from
'./index.less'
;
const
DataTable
=
props
=>
{
const
{
value
,
onChange
,
schema
}
=
props
;
const
{
value
,
onChange
,
schema
,
addons
}
=
props
;
const
{
disabled
,
fieldList
,
...
...
@@ -20,17 +21,20 @@ const DataTable = props => {
statusOption
}
=
schema
;
const
[
dataSource
,
setDataSource
]
=
useState
([]);
const
[
visible
,
setVisible
]
=
useState
(
true
);
const
hasHash
=
(
url
)
=>
{
return
url
.
includes
(
'#'
);
}
const
doAction
=
(
_
,
row
,
index
,
actionItem
)
=>
{
const
list
=
[...
valu
e
];
const
list
=
[...
dataSourc
e
];
switch
(
actionItem
.
action
)
{
case
"delete"
:
list
.
splice
(
index
,
1
);
onChang
e
(
list
);
setDataSourc
e
(
list
);
break
;
case
"update"
:
list
.
forEach
((
item
,
i
)
=>
{
...
...
@@ -43,7 +47,7 @@ const DataTable = props => {
}
}
});
onChang
e
(
list
);
setDataSourc
e
(
list
);
break
;
case
"href"
:
if
(
!
row
.
isEditable
){
...
...
@@ -78,7 +82,7 @@ const DataTable = props => {
}
const
changeValue
=
(
val
,
index
,
type
)
=>
{
const
list
=
[...
valu
e
];
const
list
=
[...
dataSourc
e
];
list
.
forEach
((
item
,
i
)
=>
{
if
(
i
===
index
){
...
...
@@ -86,7 +90,7 @@ const DataTable = props => {
}
})
onChang
e
(
list
);
setDataSourc
e
(
list
);
}
// 操作栏渲染
...
...
@@ -241,13 +245,31 @@ const DataTable = props => {
useEffect
(()
=>
{
getData
();
return
()
=>
{
eventEmitter
.
removeListener
(
addons
?.
dataPath
)
}
},
[]);
useEffect
(()
=>
{
eventEmitter
.
on
(
addons
?.
dataPath
,
(
res
)
=>
{
setVisible
(
false
);
res
.
forEach
((
item
,
index
)
=>
{
item
.
key
=
index
;
})
setDataSource
(
res
);
setVisible
(
true
);
onChange
(
res
.
length
)
})
},
[]);
return
(
<
Fragment
>
<
div
className
=
{
styles
.
dataTable
}
>
<
div
className
=
{
styles
.
tableTitle
}
>
{
titleShow
}
<
/div
>
{
columns
.
length
!==
0
?
(
{
visible
&&
columns
.
length
!==
0
?
(
<
Table
size
=
"small"
rowKey
=
{
disabled
?
'gis-设备编号'
:
'ID'
}
...
...
@@ -258,7 +280,7 @@ const DataTable = props => {
x
:
scrollX
,
y
:
scrollY
}}
dataSource
=
{
valu
e
}
dataSource
=
{
dataSourc
e
}
/
>
)
:
(
<
Empty
/>
...
...
This diff is collapsed.
Click to expand it.
src/utils/eventEmitter.js
0 → 100644
View file @
43523b78
const
events
=
require
(
"events"
)
const
eventEmitter
=
new
events
.
EventEmitter
();
export
default
eventEmitter
This diff is collapsed.
Click to expand it.
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