zrg
2025-12-25 7de2d9a4a7b2f97dcbda3cf9a78643854c94318f
utils/common.js
@@ -459,6 +459,41 @@
            return handler(key, match);
        });
    }
    fieldListFilterRole({FieldList, ExcludeKeys = [] ,RoleList = null}) {
        if(!RoleList) {
            RoleList = [
                /^[a-zA-Z]+$/,
                /id$/i
            ]
        }
        if(!Array.isArray(RoleList)){
            return {
                status: false,
                data: null,
                Message: "过滤字段列表失败,规则必须是数组。"
            }
        }
        let FieldListCache = Array(...FieldList)
        RoleList.forEach(role => {
            FieldListCache = FieldListCache.filter(elem => !role.test(elem.ColmCols))
        })
        FieldListCache = FieldListCache.filter(elem => !ExcludeKeys.includes(elem))
        return {
            status: true,
            data: FieldListCache,
            Message: ""
        }
    }
    emptyValueFilter(item, fieldList){
        return fieldList.filter(e => {
            return item[e.ColmCols]
        })
    }
}
export const CommonUtils = new commonUtils()