import TableCombobox from '@/components/basic/condition/TableCombobox.vue'; import TableInput from '@/components/basic/condition/TableInput.vue'; const component = { '': undefined, input: TableInput, select: TableCombobox, }; export type ComponentType = keyof typeof component; export type ConditionValue = '' | 'eq' | 'ne'; type ConditionItem = { value: ConditionValue; label: string; type: ComponentType; func: (a: string, b: string) => boolean; }; export const conditionList: ConditionItem[] = [ { value: '', label: '--------', type: '', func: (a: string, b: string) => true }, { value: 'eq', label: '=(等しい)', type: 'input', func: (a: string, b: string) => a === b }, { value: 'ne', label: '≠ (等しくない)', type: 'input', func: (a: string, b: string) => a !== b }, ]; // type ConditionItem = (typeof conditionList)[number]; export const conditionMap: Record = conditionList.reduce( (map, item) => { map[item.value] = item; return map; }, {} as Record, ); export const getComponent = (value: ConditionValue) => { return component[conditionMap[value].type]; };