update
This commit is contained in:
38
vue-project/my-kintone-plugin/src/js/conditions.ts
Normal file
38
vue-project/my-kintone-plugin/src/js/conditions.ts
Normal 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];
|
||||
};
|
||||
Reference in New Issue
Block a user