diff --git a/packages/app/src/components/actions/Destroy.tsx b/packages/app/src/components/actions/Destroy.tsx index bbc9195e2..11c961b4c 100644 --- a/packages/app/src/components/actions/Destroy.tsx +++ b/packages/app/src/components/actions/Destroy.tsx @@ -1,16 +1,20 @@ import React, { useRef } from 'react'; -import { Button } from 'antd'; +import { Button, Popconfirm } from 'antd'; import ViewFactory from '@/components/views'; export function Destroy(props) { console.log(props); - const { title, viewId } = props.schema; + const { onTrigger } = props; + const { title, viewId, isBulk = true } = props.schema; const drawerRef = useRef(); return ( <> - + { + console.log('destroy', onTrigger); + onTrigger && onTrigger(); + }}> + + ) } diff --git a/packages/app/src/components/actions/index.tsx b/packages/app/src/components/actions/index.tsx index f059b8192..b079651ba 100644 --- a/packages/app/src/components/actions/index.tsx +++ b/packages/app/src/components/actions/index.tsx @@ -25,15 +25,23 @@ export function Action(props) { const { schema = {} } = props; // cnsole.log(schema); const { type } = schema; - const Action = getAction(type); - return Action && ; + const Component = getAction(type); + return Component && ; } export function Actions(props) { - const { style, schema, actions = [] } = props; + const { onTrigger = {}, style, schema, actions = [], ...restProps } = props; + console.log(onTrigger); return actions.length > 0 && ( - {actions.map(action => )} + {actions.map(action => ( + + ))} ); } diff --git a/packages/app/src/components/views/SimpleTable.tsx b/packages/app/src/components/views/SimpleTable.tsx index 710c0d7e1..26eb239a1 100644 --- a/packages/app/src/components/views/SimpleTable.tsx +++ b/packages/app/src/components/views/SimpleTable.tsx @@ -71,6 +71,18 @@ export function SimpleTable(props: SimpleTableProps) { onFinish={() => { refresh(); }} + onTrigger={{ + async destroy() { + await api.resource(name).destroy({ + associatedKey, + filter: { + [`${rowKey}.in`]: selectedRowKeys, + }, + }); + await refresh(); + console.log('destroy.onTrigger', selectedRowKeys); + } + }} /> { refresh(); }} + onTrigger={{ + async destroy() { + await api.resource(name).destroy({ + associatedKey, + filter: { + [`${rowKey}.in`]: selectedRowKeys, + }, + }); + await refresh(); + console.log('destroy.onTrigger', selectedRowKeys); + } + }} />