fix: 修复由#8822引入的crud多选问题 (#8852)

Co-authored-by: wanglinfang <wanglinfang@baidu.com>
This commit is contained in:
wanglinfang2014 2023-11-22 19:16:08 +08:00 committed by GitHub
parent 73ef317e2c
commit e3527b376e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 26 deletions

View File

@ -1050,13 +1050,7 @@ export const TableStore = iRendererStore
);
}
if (config.multiple !== undefined) {
self.multiple = config.multiple;
} else {
// 如果通过crud或pickermultiple始终设置了true或false
// 如果仅使用table默认multiple为true但props未设置multiple的情况下其实是展示单选
self.multiple = false;
}
config.multiple !== undefined && (self.multiple = config.multiple);
config.footable !== undefined && (self.footable = config.footable);
config.expandConfig !== undefined &&
(self.expandConfig = config.expandConfig);

View File

@ -958,19 +958,7 @@ describe('Renderer:table selectable & itemCheckableOn', () => {
]
};
test('radio style', async () => {
const {container} = render(amisRender(schema, {}, makeEnv({})));
await waitFor(() => {
expect(container.querySelector('[type=radio]')).toBeInTheDocument();
});
expect(
container.querySelector('[data-id="1"] [type=radio][disabled=""]')!
).toBeInTheDocument();
});
test('checkbox style', async () => {
schema.multiple = true;
const {container} = render(amisRender(schema, {}, makeEnv({})));
await waitFor(() => {
expect(container.querySelector('[type=checkbox]')).toBeInTheDocument();
@ -980,6 +968,18 @@ describe('Renderer:table selectable & itemCheckableOn', () => {
container.querySelector('[data-id="1"] [type=checkbox][disabled=""]')!
).toBeInTheDocument();
});
test('radio style', async () => {
schema.multiple = false;
const {container} = render(amisRender(schema, {}, makeEnv({})));
await waitFor(() => {
expect(container.querySelector('[type=radio]')).toBeInTheDocument();
});
expect(
container.querySelector('[data-id="1"] [type=radio][disabled=""]')!
).toBeInTheDocument();
});
});
describe('dbClick', () => {

View File

@ -1760,8 +1760,6 @@ export default class Table extends React.Component<TableProps, object> {
store,
query,
onQuery,
multiple,
env,
render,
classPrefix: ns,
resizable,
@ -1805,7 +1803,7 @@ export default class Table extends React.Component<TableProps, object> {
style={style}
className={cx(column.pristine.className, stickyClassName)}
>
{store.rows.length && multiple ? (
{store.rows.length && store.multiple ? (
<Checkbox
classPrefix={ns}
partial={store.someChecked && !store.allChecked}
@ -2038,11 +2036,8 @@ export default class Table extends React.Component<TableProps, object> {
const {
render,
store,
multiple,
classPrefix: ns,
classnames: cx,
checkOnItemClick,
popOverContainer,
canAccessSuperData,
itemBadge,
translate
@ -2058,7 +2053,7 @@ export default class Table extends React.Component<TableProps, object> {
ignoreDrag={ignoreDrag}
render={render}
store={store}
multiple={multiple}
multiple={store.multiple}
canAccessSuperData={canAccessSuperData}
classnames={cx}
classPrefix={ns}