Skip to content

Commit 71343e4

Browse files
committed
feat(datatime): 时间日期选择支持区间选择,清空时保存数据类型
1 parent 12e2581 commit 71343e4

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

packages/lib/src/JsonSchemaForm/widgets/DatePickerWidget/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ export default {
1313
'value-format': isNumberValue ? 'timestamp' : 'yyyy-MM-dd',
1414
...otherProps
1515
};
16+
17+
const oldInputCall = context.data.on.input;
18+
context.data.on = {
19+
...context.data.on,
20+
input(val) {
21+
const trueVal = val === null ? (isRange ? [] : undefined) : val;
22+
oldInputCall.apply(context.data.on, [trueVal]);
23+
}
24+
};
25+
1626
return h('el-date-picker', context.data, context.children);
1727
}
1828
};

packages/lib/src/JsonSchemaForm/widgets/DateTimePickerWidget/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default {
1313
...otherProps
1414
};
1515

16-
// 字符串为 0 时区标准时间
16+
// 字符串为 0 时区ISO标准时间
1717
const oldInputCall = context.data.on.input;
1818
context.data.on = {
1919
...context.data.on,
@@ -22,7 +22,7 @@ export default {
2222
if (isRange) {
2323
trueVal = (val === null) ? [] : val.map(item => (new Date(item))[isNumberValue ? 'valueOf' : 'toISOString']());
2424
} else {
25-
trueVal = (new Date(val))[isNumberValue ? 'valueOf' : 'toISOString']();
25+
trueVal = (val === null) ? undefined : (new Date(val))[isNumberValue ? 'valueOf' : 'toISOString']();
2626
}
2727

2828
oldInputCall.apply(context.data.on, [trueVal]);

packages/lib/src/JsonSchemaForm/widgets/TimePickerWidget/index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ export default {
1010
'value-format': 'HH:mm:ss',
1111
...context.data.props
1212
};
13+
14+
const oldInputCall = context.data.on.input;
15+
context.data.on = {
16+
...context.data.on,
17+
input(val) {
18+
oldInputCall.apply(context.data.on, [val === null ? undefined : val]);
19+
}
20+
};
21+
1322
return h('el-time-picker', context.data, context.children);
1423
}
1524
};

0 commit comments

Comments
 (0)