From f3c646e7855b18c43f323a178fe18c386d1689d3 Mon Sep 17 00:00:00 2001 From: aihe <961836564@qq.com> Date: Fri, 8 Dec 2023 23:29:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=9C=80=E5=B0=8F=E9=80=89?= =?UTF-8?q?=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/tpx-checkitems/tpx-checkitems.vue | 10 +++++++++- components/tpx-tags/tpx-tags.vue | 6 ++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/components/tpx-checkitems/tpx-checkitems.vue b/components/tpx-checkitems/tpx-checkitems.vue index 1ca48fc..4e65c6c 100644 --- a/components/tpx-checkitems/tpx-checkitems.vue +++ b/components/tpx-checkitems/tpx-checkitems.vue @@ -41,6 +41,11 @@ return [] } }, + minChecked: { + default () { + return 0 + } + }, type: { default () { return typeEnum.multiple // typeEnum | ''; 为空代表不做切换选中功能 @@ -72,7 +77,10 @@ const curVal = curItem.val const hasChked = checkedVal.indexOf(curVal) > -1 if (hasChked) { - checkedVal = checkedVal.filter(val => val != curVal) + // 取消选中前,校验最小选中个数 + if(checkedVal.length > this.minChecked) { + checkedVal = checkedVal.filter(val => val != curVal) + } } else { if (this.type == typeEnum.multiple) { checkedVal.push(curVal) diff --git a/components/tpx-tags/tpx-tags.vue b/components/tpx-tags/tpx-tags.vue index 87880f8..d3c858b 100644 --- a/components/tpx-tags/tpx-tags.vue +++ b/components/tpx-tags/tpx-tags.vue @@ -1,10 +1,10 @@