From f92523c333fb9a6f4baa66329f577148bf13cf1a Mon Sep 17 00:00:00 2001 From: callmeyan Date: Sun, 22 Dec 2024 23:11:17 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E5=85=A8=E9=80=89=E9=80=BB=E8=BE=91,?= =?UTF-8?q?=E6=89=B9=E9=87=8F=E6=93=8D=E4=BD=9C=E6=8C=89=E9=92=AE=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/button-batch.tsx | 1 + src/components/form/tag-select.tsx | 18 ++++++++++++++++-- .../news/components/button-delete-batch.tsx | 3 ++- .../components/button-push-news2article.tsx | 3 ++- .../news/components/button-push2video.tsx | 3 ++- src/pages/news/components/edit-search-form.tsx | 17 ++++++++++++----- src/pages/news/edit.tsx | 2 +- .../video/components/button-push2room.tsx | 1 + src/routes/layout/dashboard-layout.tsx | 4 ++-- 9 files changed, 39 insertions(+), 13 deletions(-) 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 (