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
d294f053
Commit
d294f053
authored
Dec 24, 2024
by
杨子龙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- 暴露事件方法
parent
8cc5fc64
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
39 deletions
+44
-39
index.js
src/core/widgets/coord/DataTable/index.js
+41
-37
index.js
src/index.js
+3
-2
No files found.
src/core/widgets/coord/DataTable/index.js
View file @
d294f053
import
React
,
{
Fragment
,
useEffect
,
useState
}
from
'react'
;
import
{
Button
,
Empty
,
Input
,
Space
,
Table
}
from
'antd'
;
import
{
Button
,
Empty
,
Input
,
Space
,
Table
,
Tooltip
}
from
'antd'
;
import
*
as
AntdIcon
from
'@ant-design/icons'
;
import
FileView
from
'../../../Account/components/TablePack/components/FileView'
;
import
TagPack
from
'../../../components/TagPack'
;
...
...
@@ -23,7 +23,7 @@ const DataTable = props => {
areaTaskShine
,
optionWidth
,
optionFixed
,
isOpenRowEvent
isOpenRowEvent
,
}
=
schema
;
const
[
dataSource
,
setDataSource
]
=
useState
([]);
...
...
@@ -35,8 +35,6 @@ const DataTable = props => {
switch
(
actionItem
.
action
)
{
case
'delete'
:
list
.
splice
(
index
,
1
);
setDataSource
(
list
);
break
;
case
'update'
:
list
.
forEach
((
item
,
i
)
=>
{
...
...
@@ -81,18 +79,27 @@ const DataTable = props => {
if (type === 'icon') {
const Icon = AntdIcon[item.value];
if
(Icon)
{
if
(Icon)
{
otherProps = {
type: 'text',
shape: 'circle',
icon: <Icon />,
};
}
}
Element = (
<Button size={'small'} key={i} onClick={() => doAction(_, row, index, item)} type={type} {...otherProps}>
<Button
size={'small'}
key={i}
onClick={e => {
e.stopPropagation();
doAction(_, row, index, item);
}}
type={type}
{...otherProps}
>
{type !== 'icon' && item.value}
</Button>
);
...
...
@@ -106,16 +113,15 @@ const DataTable = props => {
let otherProps = {};
if (type === 'icon') {
const Icon = AntdIcon[json[field]?.label];
if
(Icon)
{
if
(Icon)
{
otherProps = {
type: 'text',
shape: 'circle',
icon: <Icon style={{
color:json[_[item.value]]?.color
}} />,
icon: <Icon style={{
color: json[_[item.value]]?.color
}} />,
};
}
}
if (optionCode) {
if (field) {
const codeStr = `
return
row
[
item
.
value
]
===
"${field}"
$
{
optionCode
}
`;
...
...
@@ -180,15 +186,22 @@ const DataTable = props => {
// 字段栏显示模式渲染
const getFieldRender = (_, row, index, item) => {
let ele;
switch (item.type) {
case '文本':
if (!item.isMapped) {
ele = <span style={{ color: item.color }}>{_}</span>;
ele = (
<Tooltip placement="topLeft" title={_}>
<span style={{ color: item.color }}>{_}</span>
</Tooltip>
);
} else {
if (item.parseStr) {
const json = JSON.parse(item.parseStr);
ele = <span style={{ color: json[_]?.color }}>{json[_]?.label}</span>;
ele = (
<Tooltip placement="topLeft" title={json[_]?.label}>
<span style={{ color: json[_]?.color }}>{json[_]?.label}</span>
</Tooltip>
);
} else {
ele = <span>调试中...</span>;
}
...
...
@@ -207,19 +220,7 @@ const DataTable = props => {
}
break;
case 'FileUpload':
ele = <FileView value={_} download={true} preview={true} />;
break;
default:
if (!item.isMapped) {
ele = <span style={{ color: item.color }}>{_}</span>;
} else {
if (item.parseStr) {
const json = JSON.parse(item.parseStr);
ele = <span style={{ color: json[_]?.color }}>{json[_]?.label}</span>;
} else {
ele = <span>调试中...</span>;
}
}
ele = _ && <FileView value={_} download={true} preview={true} />;
break;
}
...
...
@@ -245,6 +246,9 @@ const DataTable = props => {
dataIndex,
key: dataIndex,
width: item.width || 120,
ellipsis: {
showTitle: false,
},
fixed: item.fixed || false,
render: (_, row, index) => {
return (
...
...
@@ -266,7 +270,7 @@ const DataTable = props => {
dataIndex: '',
key: '',
width: optionWidth || 120,
fixed: optionFixed,
fixed: optionFixed
|| false
,
render: (_, row, index) => {
return getOptionRender(_, row, index);
},
...
...
@@ -327,16 +331,18 @@ const DataTable = props => {
window.relationForm.data = data;
};
const rowClickEvent =
(record)
=> {
const rowClickEvent =
record
=> {
return {
onClick: () => {
onClick: e => {
e.stopPropagation();
eventEmitter.emit(`
$
{
addons
?.
dataPath
}
_event
`, {
...record,
action:
"rowOnClick"
,
action:
'rowOnClick'
,
});
}
}
}
}
,
}
;
}
;
useEffect(() => {
eventEmitter.removeAllListeners(addons?.dataPath);
...
...
@@ -368,7 +374,7 @@ const DataTable = props => {
useEffect(() => {
getColumns();
}, [fieldList, dataSource
, optionRender]);
}, [fieldList, dataSource, optionRender]);
useEffect(() => {
initRelationForm();
...
...
@@ -393,9 +399,7 @@ const DataTable = props => {
y: scrollY,
}
}
onRow={
record => isOpenRowEvent && rowClickEvent(record)
}
onRow={record => isOpenRowEvent && rowClickEvent(record)}
dataSource={dataSource}
/>
) : (
...
...
src/index.js
View file @
d294f053
...
...
@@ -3,6 +3,7 @@ import FormDesigner from './core/FormDesigner'
import
Account
from
'./core/Account'
import
FileView
from
'./core/Account/components/TablePack/components/FileView'
import
{
getFieldInfo
}
from
'./utils'
import
EventEmitter
from
"./utils/eventEmitter"
;
export
{
FormRender
,
...
...
@@ -10,4 +11,5 @@ export {
Account
,
FileView
,
getFieldInfo
,
}
\ No newline at end of file
EventEmitter
}
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