diff --git a/src/components/button-batch.tsx b/src/components/button-batch.tsx index 1df5ab6..12bc966 100644 --- a/src/components/button-batch.tsx +++ b/src/components/button-batch.tsx @@ -41,6 +41,7 @@ export default function ButtonBatch( } } const handleBtnClick = () => { + if(loading) return; if (selected.length == 0) { showToast(emptyMessage, 'warning') return; diff --git a/src/components/form/tag-select.tsx b/src/components/form/tag-select.tsx index 68a688f..be41ad6 100644 --- a/src/components/form/tag-select.tsx +++ b/src/components/form/tag-select.tsx @@ -3,12 +3,14 @@ import {Checkbox, Popover} from "antd"; import {useBoolean, useClickAway} from "ahooks"; import {CaretUpOutlined} from "@ant-design/icons"; +type ValueType = Id[][]; +type ValueFunc = (prev:ValueType)=>ValueType; const TagSelect = (props: { options: OptionItem[]; onChange: (values: Id[][]) => void; className?: string; }) => { - const [selectValues, _setSelectValues] = React.useState([]) + const [selectValues, __setSelectValues] = React.useState([]) const [checkedAll, _setCheckedAll] = React.useState(false) const [visible, {set}] = useBoolean(false); const allValues = useMemo(()=>{ @@ -21,6 +23,18 @@ const TagSelect = (props: { }) return values },[props.options]) + const _setSelectValues = (values: (ValueType | ValueFunc)) => { + if(typeof values == 'function'){ + __setSelectValues((prev)=>{ + const data = values(prev); + props.onChange(data) + return data + }) + }else{ + __setSelectValues(values) + props.onChange(values) + } + } const handleAllChanged = (checked: boolean) => { _setCheckedAll(checked) const values:Id[][] = [] @@ -99,7 +113,7 @@ const TagSelect = (props: { set(!visible) }} > - {checkedAll ? '全部来源' : '来源'} + {checkedAll || selectValues.length == 0 ? '全部来源' : '来源'}
diff --git a/src/pages/news/components/button-delete-batch.tsx b/src/pages/news/components/button-delete-batch.tsx index 63b67ea..14912b9 100644 --- a/src/pages/news/components/button-delete-batch.tsx +++ b/src/pages/news/components/button-delete-batch.tsx @@ -21,6 +21,7 @@ export default function ButtonDeleteBatch(props: { ids: Id[]; }) { }) } const onPushClick = () => { + if(loading) return; if (props.ids.length === 0) { showToast('请选择要删除的新闻', 'warning') return @@ -35,7 +36,7 @@ export default function ButtonDeleteBatch(props: { ids: Id[]; }) { return (