Commit ffd8373e authored by 杨子龙's avatar 杨子龙

表格组件

- 增加列固定配置 - 增加行点击事件
parent b132ca42
...@@ -4857,20 +4857,6 @@ const advancedWidgets = [ ...@@ -4857,20 +4857,6 @@ const advancedWidgets = [
type: 'string', type: 'string',
widget: 'htmlInput', widget: 'htmlInput',
}, },
optionWidth: {
title: "操作栏宽度",
type: "number",
default: 120
},
optionRender: {
title: '',
name: '操作栏内容配置',
type: 'array',
default: [
{ type: "icon", value: 'DeleteOutlined' , action: "delete"},
],
widget: 'OptionRender',
},
pagination: { pagination: {
title: '是否启用分页(关闭分页后,需要配制滚动)', title: '是否启用分页(关闭分页后,需要配制滚动)',
type: 'boolean', type: 'boolean',
...@@ -4882,14 +4868,40 @@ const advancedWidgets = [ ...@@ -4882,14 +4868,40 @@ const advancedWidgets = [
type: 'number', type: 'number',
widget: "inputNumber", widget: "inputNumber",
hidden: '{{formData.pagination}}', hidden: '{{formData.pagination}}',
required: true
}, },
scrollY: { scrollY: {
title: 'y轴滚动', title: 'y轴滚动',
type: 'number', type: 'number',
widget: "inputNumber", widget: "inputNumber",
hidden: '{{formData.pagination}}', hidden: '{{formData.pagination}}',
required: true },
optionWidth: {
title: "操作栏宽度",
type: "number",
default: 120
},
optionFixed: {
title: "操作栏固定",
type: "string",
default: "false",
widget: 'select',
enum: ['false', 'left', 'right'],
enumNames: ['关闭固定', '靠左', '靠右'],
},
optionRender: {
title: '',
name: '操作栏内容配置',
type: 'array',
default: [
{ type: "icon", value: 'DeleteOutlined' , action: "delete"},
],
widget: 'OptionRender',
},
isOpenRowEvent: {
title: '是否启动行点击事件',
type: 'boolean',
widget: "switch",
default: true,
}, },
hiddenCondition: { hiddenCondition: {
title: '隐藏条件', title: '隐藏条件',
......
...@@ -21,7 +21,9 @@ const DataTable = props => { ...@@ -21,7 +21,9 @@ const DataTable = props => {
scrollY, scrollY,
statusOption, statusOption,
areaTaskShine, areaTaskShine,
optionWidth optionWidth,
optionFixed,
isOpenRowEvent
} = schema; } = schema;
const [dataSource, setDataSource] = useState([]); const [dataSource, setDataSource] = useState([]);
...@@ -243,6 +245,7 @@ const DataTable = props => { ...@@ -243,6 +245,7 @@ const DataTable = props => {
dataIndex, dataIndex,
key: dataIndex, key: dataIndex,
width: item.width || 120, width: item.width || 120,
fixed: item.fixed || false,
render: (_, row, index) => { render: (_, row, index) => {
return ( return (
<Fragment> <Fragment>
...@@ -263,6 +266,7 @@ const DataTable = props => { ...@@ -263,6 +266,7 @@ const DataTable = props => {
dataIndex: '', dataIndex: '',
key: '', key: '',
width: optionWidth || 120, width: optionWidth || 120,
fixed: optionFixed,
render: (_, row, index) => { render: (_, row, index) => {
return getOptionRender(_, row, index); return getOptionRender(_, row, index);
}, },
...@@ -323,6 +327,17 @@ const DataTable = props => { ...@@ -323,6 +327,17 @@ const DataTable = props => {
window.relationForm.data = data; window.relationForm.data = data;
}; };
const rowClickEvent = (record) => {
return {
onClick: () => {
eventEmitter.emit(`${addons?.dataPath}_event`, {
...record,
action: "rowOnClick",
});
}
}
}
useEffect(() => { useEffect(() => {
eventEmitter.removeAllListeners(addons?.dataPath); eventEmitter.removeAllListeners(addons?.dataPath);
...@@ -378,6 +393,9 @@ const DataTable = props => { ...@@ -378,6 +393,9 @@ const DataTable = props => {
y: scrollY, y: scrollY,
} }
} }
onRow={
record => isOpenRowEvent && rowClickEvent(record)
}
dataSource={dataSource} dataSource={dataSource}
/> />
) : ( ) : (
......
...@@ -62,12 +62,14 @@ const StatusOption = props => { ...@@ -62,12 +62,14 @@ const StatusOption = props => {
item.parseStr = currentItem.parseStr; item.parseStr = currentItem.parseStr;
item.isMapped = currentItem.isMapped || false; item.isMapped = currentItem.isMapped || false;
item.width = currentItem.width || 120; item.width = currentItem.width || 120;
item.fixed = currentItem.fixed;
} else { } else {
item.type = showType(current?.Widget) ? current ? current.Widget : "文本" : '文本'; item.type = showType(current?.Widget) ? current ? current.Widget : "文本" : '文本';
item.editType = current ? current.Widget : "文本"; item.editType = current ? current.Widget : "文本";
item.color = 'rgb(65,68,69)'; item.color = 'rgb(65,68,69)';
item.isMapped = false; item.isMapped = false;
item.width = 120; item.width = 120;
item.fixed = false;
} }
}); });
...@@ -211,6 +213,34 @@ const StatusOption = props => { ...@@ -211,6 +213,34 @@ const StatusOption = props => {
); );
}, },
}, },
{
title: '列固定',
dataIndex: 'fixed',
width: 80,
render: (r, _, i) => {
return (
<Select value={r || "false"}
options={[
{
label: "靠左",
value: "left"
},
{
label: "靠右",
value: "right"
},
{
label: "关闭列固定",
value: "false"
}
]}
style={{
width: '100%',
}}
onChange={e => inputChange(e, i, 'fixed', _)} />
);
},
},
{ {
title: '样式映射', title: '样式映射',
dataIndex: 'isMapped', dataIndex: 'isMapped',
...@@ -389,7 +419,7 @@ const StatusOption = props => { ...@@ -389,7 +419,7 @@ const StatusOption = props => {
ItemTypes="stadingOrder" ItemTypes="stadingOrder"
color={color} color={color}
scroll={{ scroll={{
x: 500, x: 600,
}} }}
columns={columns} columns={columns}
pagination={false} pagination={false}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment