You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
1.0 KiB

  1. import { Button, Popconfirm } from 'antd'
  2. import { useAtomValue } from 'jotai'
  3. import { batchIdsAtom, deleteMenuAtom } from '../store.ts'
  4. import { useTranslation } from '@/i18n.ts'
  5. const BatchButton = () => {
  6. const { t } = useTranslation()
  7. const { isPending, mutate, } = useAtomValue(deleteMenuAtom)
  8. const ids = useAtomValue(batchIdsAtom)
  9. if (ids.length === 0) {
  10. return null
  11. }
  12. return (
  13. <Popconfirm
  14. onConfirm={()=>{
  15. mutate(ids as number[])
  16. }}
  17. title={t('system.menus.batchDel.confirm', '确定要删除所选数据吗?')}>
  18. <Button
  19. type="primary"
  20. danger={true}
  21. size={'small'}
  22. disabled={ids.length === 0}
  23. loading={isPending}
  24. >{t('t.system.menus.batchDel', '批量删除')}</Button>
  25. </Popconfirm>
  26. )
  27. }
  28. export default BatchButton