initHeader

This commit is contained in:
2024-08-22 11:27:06 +08:00
parent fe895bd37c
commit e0aaa7a30d
178 changed files with 5726 additions and 4999 deletions

View File

@@ -1,4 +1,5 @@
import { isArray } from "@/utils/is";
import { FieldNamesProps } from "@/components/ProTable/interface";
const mode = import.meta.env.VITE_ROUTER_MODE;
@@ -275,6 +276,28 @@ export function handleProp(prop: string) {
return propArr[propArr.length - 1];
}
/**
* @description 根据枚举列表查询当需要的数据(如果指定了 label 和 value 的 key值会自动识别格式化
* @param {String} callValue 当前单元格值
* @param {Array} enumData 字典列表
* @param {Array} fieldNames label && value && children 的 key 值
* @param {String} type 过滤类型(目前只有 tag
* @returns {String}
* */
export function filterEnum(callValue: any, enumData?: any, fieldNames?: FieldNamesProps, type?: "tag") {
const value = fieldNames?.value ?? "value";
const label = fieldNames?.label ?? "label";
const children = fieldNames?.children ?? "children";
let filterData: { [key: string]: any } = {};
// 判断 enumData 是否为数组
if (Array.isArray(enumData)) filterData = findItemNested(enumData, callValue, value, children);
// 判断是否输出的结果为 tag 类型
if (type == "tag") {
return filterData?.tagType ? filterData.tagType : "";
} else {
return filterData ? filterData[label] : "--";
}
}
/**
* @description 递归查找 callValue 对应的 enum 值