add subtable
This commit is contained in:
@@ -24,10 +24,6 @@ export const conditionList: ConditionItem[] = [
|
||||
{ value: 'not_contain', label: '次のいずれも含まない', type: 'input' },
|
||||
];
|
||||
|
||||
export const isDateTimeType = (field: OneOf) => {
|
||||
return isType.DATETIME(field) || isType.TIME(field) || isType.DATE(field) || isType.CREATED_TIME(field) || isType.UPDATED_TIME(field);
|
||||
}
|
||||
|
||||
// search from conditionList
|
||||
// conditionItem = conditionMap[conditionValue]
|
||||
export const conditionMap: Record<ConditionValue, ConditionItem> = conditionList.reduce(
|
||||
@@ -42,7 +38,7 @@ type FieldConditions = Partial<Record<FieldType, ConditionValue[]>>;
|
||||
|
||||
const textCondition: ConditionValue[] = ['eq', 'ne', 'contains', 'not_contain'];
|
||||
const numberCondition: ConditionValue[] = ['eq', 'ne', 'le', 'ge'];
|
||||
const timeCondition: ConditionValue[] = [...numberCondition, 'lt', 'gt'];
|
||||
const timeCondition: ConditionValue[] = ['eq', 'ne', 'le', 'lt', 'ge', 'gt'];
|
||||
const containsCondition: ConditionValue[] = ['contains', 'not_contain'];
|
||||
|
||||
// FieldType -> ConditionValue[]
|
||||
@@ -87,11 +83,15 @@ export const getAvailableCondition = (fieldCode: string, fieldsInfo: FieldsInfo,
|
||||
const component = {
|
||||
input: 'kuc-text',
|
||||
select: 'kuc-combobox',
|
||||
time: 'time',
|
||||
time: 'kuc-time',
|
||||
date: 'date',
|
||||
datetime: 'datetime',
|
||||
};
|
||||
|
||||
export const isDateTimeType = (field: OneOf) => {
|
||||
return field.type in dateTimeComponent;
|
||||
}
|
||||
|
||||
const dateTimeComponent: Partial<Record<FieldType, ComponentType>> = {
|
||||
TIME: 'time',
|
||||
DATE: 'date',
|
||||
@@ -101,7 +101,8 @@ const dateTimeComponent: Partial<Record<FieldType, ComponentType>> = {
|
||||
}
|
||||
|
||||
export type ComponentType = keyof typeof component;
|
||||
export const getComponent = (value: ConditionValue) => {
|
||||
export const getComponent = (value: ConditionValue, fieldObj: OneOf) => {
|
||||
if (!value) return;
|
||||
return component[conditionMap[value].type];
|
||||
const condition = conditionMap[value].type;
|
||||
return component[typeof condition === 'function' ? condition(fieldObj) : condition];
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user