mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-07-01 10:42:19 +08:00
fix: indexof
This commit is contained in:
parent
ec7a5fb534
commit
82a82e9230
@ -141,6 +141,7 @@ export class TableModel extends DataBlockModel<TableModelStructure> {
|
||||
color: #1890ff;
|
||||
margin-left: 8px;
|
||||
cursor: pointer;
|
||||
z-index: 100;
|
||||
top: 50%;
|
||||
right: 8px;
|
||||
transform: translateY(-50%);
|
||||
@ -157,6 +158,9 @@ export class TableModel extends DataBlockModel<TableModelStructure> {
|
||||
<EditOutlined
|
||||
className="edit-icon"
|
||||
onClick={async (e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
// 阻止事件冒泡,避免触发行选中
|
||||
try {
|
||||
await QuickEditForm.open({
|
||||
target: ref.current,
|
||||
@ -266,7 +270,7 @@ export class TableModel extends DataBlockModel<TableModelStructure> {
|
||||
selectedRowKeys: this.resource.getSelectedRows().map((row) => row.id),
|
||||
}}
|
||||
virtual={this.props.virtual}
|
||||
scroll={{ x: 'max-content', y: 'calc(100vh - 200px)' }}
|
||||
scroll={{ x: 'max-content', y: 600 }}
|
||||
dataSource={this.resource.getData()}
|
||||
columns={this.getColumns()}
|
||||
pagination={{
|
||||
@ -276,9 +280,9 @@ export class TableModel extends DataBlockModel<TableModelStructure> {
|
||||
}}
|
||||
onChange={(pagination) => {
|
||||
console.log('onChange pagination:', pagination);
|
||||
this.resource.loading = true;
|
||||
this.resource.setPage(pagination.current);
|
||||
this.resource.setPageSize(pagination.pageSize);
|
||||
this.resource.loading = true;
|
||||
this.resource.refresh();
|
||||
}}
|
||||
/>
|
||||
|
@ -20,7 +20,7 @@ import {
|
||||
MultiRecordResource,
|
||||
} from '@nocobase/flow-engine';
|
||||
import { tval } from '@nocobase/utils/client';
|
||||
import { Button, Card, Pagination, Skeleton, Space } from 'antd';
|
||||
import { Button, Card, Pagination, Skeleton, Space, Spin } from 'antd';
|
||||
import _ from 'lodash';
|
||||
import React from 'react';
|
||||
import { ColumnDefinition, TabulatorFull as Tabulator } from 'tabulator-tables';
|
||||
@ -262,51 +262,60 @@ export class TabulatorModel extends DataBlockModel<S> {
|
||||
render() {
|
||||
return (
|
||||
<Card>
|
||||
<DndProvider>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 16 }}>
|
||||
<Space>
|
||||
{this.mapSubModels('actions', (action) => {
|
||||
// @ts-ignore
|
||||
if (action.props.position === 'left') {
|
||||
return (
|
||||
<FlowModelRenderer model={action} showFlowSettings={{ showBackground: false, showBorder: false }} />
|
||||
);
|
||||
}
|
||||
<Spin spinning={this.resource.loading}>
|
||||
<DndProvider>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 16 }}>
|
||||
<Space>
|
||||
{this.mapSubModels('actions', (action) => {
|
||||
// @ts-ignore
|
||||
if (action.props.position === 'left') {
|
||||
return (
|
||||
<FlowModelRenderer
|
||||
model={action}
|
||||
showFlowSettings={{ showBackground: false, showBorder: false }}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
})}
|
||||
{/* 占位 */}
|
||||
<span></span>
|
||||
</Space>
|
||||
<Space>
|
||||
{this.mapSubModels('actions', (action) => {
|
||||
// @ts-ignore
|
||||
if (action.props.position !== 'left') {
|
||||
return (
|
||||
<FlowModelRenderer model={action} showFlowSettings={{ showBackground: false, showBorder: false }} />
|
||||
);
|
||||
}
|
||||
return null;
|
||||
})}
|
||||
{/* 占位 */}
|
||||
<span></span>
|
||||
</Space>
|
||||
<Space>
|
||||
{this.mapSubModels('actions', (action) => {
|
||||
// @ts-ignore
|
||||
if (action.props.position !== 'left') {
|
||||
return (
|
||||
<FlowModelRenderer
|
||||
model={action}
|
||||
showFlowSettings={{ showBackground: false, showBorder: false }}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
})}
|
||||
<AddActionButton model={this} subModelBaseClass="GlobalActionModel" subModelKey="actions" />
|
||||
</Space>
|
||||
</div>
|
||||
</DndProvider>
|
||||
<div ref={this.tabulatorRef} />
|
||||
<Pagination
|
||||
style={{ marginTop: 16 }}
|
||||
align="end"
|
||||
defaultCurrent={this.resource.getMeta('page')}
|
||||
defaultPageSize={this.resource.getMeta('pageSize')}
|
||||
total={this.resource.getMeta('count')}
|
||||
showSizeChanger
|
||||
onChange={async (page, pageSize) => {
|
||||
this.resource.setPage(page);
|
||||
this.resource.setPageSize(pageSize);
|
||||
await this.resource.refresh();
|
||||
}}
|
||||
/>
|
||||
return null;
|
||||
})}
|
||||
<AddActionButton model={this} subModelBaseClass="GlobalActionModel" subModelKey="actions" />
|
||||
</Space>
|
||||
</div>
|
||||
</DndProvider>
|
||||
<div ref={this.tabulatorRef} />
|
||||
<Pagination
|
||||
style={{ marginTop: 16 }}
|
||||
align="end"
|
||||
defaultCurrent={this.resource.getMeta('page')}
|
||||
defaultPageSize={this.resource.getMeta('pageSize')}
|
||||
total={this.resource.getMeta('count')}
|
||||
showSizeChanger
|
||||
onChange={async (page, pageSize) => {
|
||||
this.resource.loading = true;
|
||||
this.resource.setPage(page);
|
||||
this.resource.setPageSize(pageSize);
|
||||
await this.resource.refresh();
|
||||
}}
|
||||
/>
|
||||
</Spin>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
@ -361,20 +361,19 @@ export class FlowEngine {
|
||||
const subModelValue = modelInstance.parent.subModels[subKey];
|
||||
|
||||
if (Array.isArray(subModelValue)) {
|
||||
const index = subModelValue.indexOf(modelInstance);
|
||||
const index = subModelValue.findIndex((subModel) => subModel.uid === modelInstance.uid);
|
||||
if (index !== -1) {
|
||||
subModelValue.splice(index, 1);
|
||||
modelInstance.parent.emitter.emit('onSubModelRemoved', modelInstance);
|
||||
break;
|
||||
}
|
||||
} else if (subModelValue === modelInstance) {
|
||||
} else if (subModelValue && subModelValue.uid === modelInstance.uid) {
|
||||
delete modelInstance.parent.subModels[subKey];
|
||||
modelInstance.parent.emitter.emit('onSubModelRemoved', modelInstance);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
modelInstance['onRemove']?.();
|
||||
this.modelInstances.delete(uid);
|
||||
return false;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user