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转换为树形结构 */