123456789101112131415161718192021222324252627282930313233343536 |
- import XEUtils from "xe-utils";
- export function ArrayIsEqual(arr1: any[], arr2: any[]) {
- return JSON.stringify(arr1) === JSON.stringify(arr2);
- }
- const isEnglish = (str: string) => {
- return /^[a-zA-Z]+$/.test(str);
- }
- export const notNullAndLike = (data: any, likeValue: string, keyName: string[] = ['pyCode', 'dcode', 'code', 'name', 'value', 'label']) => {
- for (let i = 0; i < keyName.length; i++) {
- let itemKey = keyName[i];
- let tempVal = data[itemKey]
- if (isEnglish(likeValue)) {
- likeValue = likeValue.toUpperCase();
- }
- if (tempVal) {
- try {
- // 去除前后空格
- tempVal = XEUtils.trim(tempVal)
- if (tempVal.indexOf(likeValue) > -1) {
- return true
- }
- } catch {
- }
- }
- }
- return false
- }
- export function listFilter(data: any[], likeValue: string, keyName: string[] = ['pyCode', 'dcode', 'code', 'name', 'value', 'label']) {
- return XEUtils.filter(data, (item) => {
- return notNullAndLike(item, likeValue, keyName)
- });
- }
|