| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- import React, { useMemo } from 'react'
- import { Button, Popconfirm } from 'antd'
- import { defaultPassWord } from '@/utils/http'
- type Props = {
- txtK: '删除' | '删除2' | '取消' | '返回' | '重置密码' | '退出登录' | '重新提交' | '撤回'
- onConfirm: () => void
- Dom?: React.ReactNode
- loc?: 'bottom'
- disabled?: boolean
- }
- function MyPopconfirm({ txtK, onConfirm, Dom, loc, disabled }: Props) {
- const txt = useMemo(() => {
- const obj = {
- 删除: ['删除后无法恢复,是否删除?', '删除'],
- 删除2: ['确定删除吗?', '确定'],
- 取消: ['放弃编辑后,信息将不会保存!', '放弃'],
- 返回: ['放弃编辑后,信息将不会保存!', '放弃'],
- 重置密码: [`密码重制后为${defaultPassWord},是否重置?`, '重置'],
- 退出登录: ['确定退出吗?', '确定'],
- 重新提交: ['确定重新提交吗?', '确定'],
- 撤回: ['确定撤回吗?', '确定']
- }
- return Reflect.get(obj, txtK) || ['', '']
- }, [txtK])
- return (
- <Popconfirm
- placement={loc}
- title={txt[0]}
- okText={txt[1]}
- cancelText='取消'
- onConfirm={onConfirm}
- okButtonProps={{ loading: false }}
- >
- {Dom ? (
- Dom
- ) : txtK === '删除' ? (
- <Button disabled={disabled} size='small' type='text' danger={!disabled}>
- {txtK}
- </Button>
- ) : (
- <Button>{txtK}</Button>
- )}
- </Popconfirm>
- )
- }
- const MemoMyPopconfirm = React.memo(MyPopconfirm)
- export default MemoMyPopconfirm
|