diff --git a/packages/amis-core/src/store/table.ts b/packages/amis-core/src/store/table.ts index 3f166da67..89123a711 100644 --- a/packages/amis-core/src/store/table.ts +++ b/packages/amis-core/src/store/table.ts @@ -1050,13 +1050,7 @@ export const TableStore = iRendererStore ); } - if (config.multiple !== undefined) { - self.multiple = config.multiple; - } else { - // 如果通过crud或picker,multiple始终设置了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); diff --git a/packages/amis/__tests__/renderers/Table.test.tsx b/packages/amis/__tests__/renderers/Table.test.tsx index 86d86def5..93054c7ac 100644 --- a/packages/amis/__tests__/renderers/Table.test.tsx +++ b/packages/amis/__tests__/renderers/Table.test.tsx @@ -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', () => { diff --git a/packages/amis/src/renderers/Table/index.tsx b/packages/amis/src/renderers/Table/index.tsx index ab903cf76..614a75b2f 100644 --- a/packages/amis/src/renderers/Table/index.tsx +++ b/packages/amis/src/renderers/Table/index.tsx @@ -1760,8 +1760,6 @@ export default class Table extends React.Component { store, query, onQuery, - multiple, - env, render, classPrefix: ns, resizable, @@ -1805,7 +1803,7 @@ export default class Table extends React.Component { style={style} className={cx(column.pristine.className, stickyClassName)} > - {store.rows.length && multiple ? ( + {store.rows.length && store.multiple ? ( { const { render, store, - multiple, classPrefix: ns, classnames: cx, - checkOnItemClick, - popOverContainer, canAccessSuperData, itemBadge, translate @@ -2058,7 +2053,7 @@ export default class Table extends React.Component { ignoreDrag={ignoreDrag} render={render} store={store} - multiple={multiple} + multiple={store.multiple} canAccessSuperData={canAccessSuperData} classnames={cx} classPrefix={ns}