interface OptionsItem extends Record { label?: string | number; value?: string | number | null; } /** * map 结构转 array * @param map * @param useAllSelect 全部默认选项 * @param allSelectLabel 全部项默认lable * @param allSelectValue 全部项默认value * @returns OptionsItem[] */ export const translateMapToArray = ( map: Map, useAllSelect: boolean = false, allSelectLabel: string = '全部', allSelectValue: any = null, ): OptionsItem[] => { // 全部项 const allSelect = { label: allSelectLabel, value: allSelectValue }; let array: OptionsItem[] = useAllSelect ? [allSelect] : []; for (const [key, value] of map.entries()) { array.push({ label: value, value: key, }); } return array; };