From f74290bddad30584dad000e2758fe9d93bf7b780 Mon Sep 17 00:00:00 2001 From: LiuJiaNan <15703339975@163.com> Date: Tue, 30 Dec 2025 15:32:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86getSelectAppointItemList=E9=87=8D?= =?UTF-8?q?=E5=91=BD=E5=90=8DgetMatchedItems=20=E6=96=B0=E5=A2=9EgetUnmatc?= =?UTF-8?q?hedItems?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/index.d.ts | 18 +++++++++++++++--- src/utils/index.js | 12 ++++++++++-- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/utils/index.d.ts b/src/utils/index.d.ts index 020f302..f8a1e40 100644 --- a/src/utils/index.d.ts +++ b/src/utils/index.d.ts @@ -201,13 +201,25 @@ export function calculateFileSize(size: number | string): string; export function idCardGetDateAndGender(idCard: string): { sex: "1" | "0"; date: string }; /** - * 获取select中指定项组成的数组 + * 获取匹配项 */ -export function getSelectAppointItemList(options: { +export function getMatchedItems(options: { /** 获取的数组 */ list: any[]; /** 获取的值 */ - value: any[]; + value: (number | string)[]; + /** 获取的id字段名 */ + idKey?: string; +}): T[]; + +/** + * 获取未匹配项 + */ +export function getUnmatchedItems(options: { + /** 获取的数组 */ + list: any[]; + /** 获取的值 */ + value: (number | string)[]; /** 获取的id字段名 */ idKey?: string; }): T[]; diff --git a/src/utils/index.js b/src/utils/index.js index c6687cd..2d46aa0 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -343,13 +343,21 @@ export function idCardGetDateAndGender(idCard) { } /** - * 获取select中指定项组成的数组 + * 获取匹配项 */ -export function getSelectAppointItemList(options) { +export function getMatchedItems(options) { const { list, value, idKey = "bianma" } = options; return list.filter(item => value.includes(item[idKey])); } +/** + * 获取未匹配项 + */ +export function getUnmatchedItems(options) { + const { list, value, idKey = "bianma" } = options; + return list.filter(item => !value.includes(item[idKey])); +} + /** * json转换为树形结构 */