This commit is contained in:
2025-01-22 17:23:20 +08:00
parent 6aba3fc065
commit 270940abca
12 changed files with 192 additions and 142 deletions

View File

@@ -0,0 +1,38 @@
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<ConditionValue, ConditionItem> = conditionList.reduce(
(map, item) => {
map[item.value] = item;
return map;
},
{} as Record<ConditionValue, ConditionItem>,
);
export const getComponent = (value: ConditionValue) => {
return component[conditionMap[value].type];
};