diff --git a/CHANGELOG.md b/CHANGELOG.md index b264adb8ec6ff97b0092af08dbf1c13c9484fa22..55da5f4a89322cf98944499d85ce8044761e3d32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ ### Change +- 日历支持底部弹窗选择年月日 - 富文本支持图片预览 - 工具栏支持项显示模型 - 返回顶部按钮样式对齐 diff --git a/src/control/calendar/calendar.scss b/src/control/calendar/calendar.scss index 9094fd36941d8508cc941df42fdfba0364688bff..37a09d7bd804f839c3798eb20d4aa5ec0761b03c 100644 --- a/src/control/calendar/calendar.scss +++ b/src/control/calendar/calendar.scss @@ -148,11 +148,28 @@ $control-calendar: (text-color: getCssVar(color-text-0), border: rem(1px) getCssVar(color, border) solid; box-shadow: none; } - - - span { top: 0; left: 0; } +} + +@include b(control-calendar-header-toolbar){ + width: 100%; + display: flex; + @include e('select-day'){ + padding: getCssVar(spacing,base) getCssVar(spacing,tight); + background-color: getCssVar(color,bg,1);; + border-radius: 2px; + font-weight: getCssVar(font-weight,bold); + } + @include e('switch-toolbar'){ + flex: 1; + align-items: center; + display: flex; + justify-content: end; + color: getCssVar(color,primary); + gap: getCssVar(spacing,base); + padding-right: getCssVar(spacing,base); + } } \ No newline at end of file diff --git a/src/control/calendar/calendar.tsx b/src/control/calendar/calendar.tsx index 553eed036ae113d2d0f943073bc683e280cad2be..62413de7ad9b80212d118f5b1e5b0d463f22cf0c 100644 --- a/src/control/calendar/calendar.tsx +++ b/src/control/calendar/calendar.tsx @@ -33,6 +33,15 @@ export const CalendarControl = defineComponent({ const loadItems: Ref = ref([]); + // 显示底部弹窗 + const visible = ref(false); + + // 日历 + const calendar = ref(); + + // 弹窗选择时间 + const currentDate = ref(); + // 存储月加载缓存 const markDateItems: Ref = ref({}); // 加载的标记数据 @@ -160,13 +169,41 @@ export const CalendarControl = defineComponent({ loadMarkerData(c.state.selectedDate); }; + // 自定义选择日期 + const onCustom = () => { + const temptime = dayjs(c.state.selectedDate) + .format('YYYY-MM-DD') + .split('-'); + currentDate.value = temptime; + visible.value = true; + }; + + // 跳转今天 + const toDay = () => { + calendar.value.today(); + }; + + // 确认选择日期 + const onConfirm = () => { + const date = currentDate.value.join('-'); + const time = new Date(date); + calendar.value.reset(time); + visible.value = false; + }; + return { c, ns, markerData, loadItems, + visible, + calendar, + currentDate, + onConfirm, calcItemStyle, dateChange, + onCustom, + toDay, }; }, render() { @@ -288,11 +325,37 @@ export const CalendarControl = defineComponent({ return renderCalendarList(list); }; + // 绘制顶部工具栏 + const renderHeaderToolbar = () => { + return ( +
+
+ {dayjs(this.c.state.selectedDate).format('YYYY年MM月DD日')} +
+
+
+ {ibiz.i18n.t('control.calendar.customPicker')} +
+
+ {ibiz.i18n.t('control.calendar.today')} +
+
+
+ ); + }; + return ( this.c.state.isCreated && (
{ @@ -308,6 +371,9 @@ export const CalendarControl = defineComponent({
); }, + action: () => { + return renderHeaderToolbar(); + }, }} @@ -331,6 +397,17 @@ export const CalendarControl = defineComponent({ })} + + +
) ); diff --git a/src/locale/en/index.ts b/src/locale/en/index.ts index 0d69429f87578de11f1223e0b28d42aa3d9205c1..b056ef568da2914b9cded8336e730da6eb8a0c8f 100644 --- a/src/locale/en/index.ts +++ b/src/locale/en/index.ts @@ -86,6 +86,11 @@ export default { next: 'Next', finish: 'Finish', }, + calendar: { + today: 'Today', + pickerDate: 'Picker Date', + customPicker: 'Custom Picker', + }, }, // 编辑器 editor: { diff --git a/src/locale/zh-CN/index.ts b/src/locale/zh-CN/index.ts index 9328c60ced4e1aea2e4ba26ba9dbd70896ed3af5..4e007877a5c315202f4f3b83e842010b1bc76ddb 100644 --- a/src/locale/zh-CN/index.ts +++ b/src/locale/zh-CN/index.ts @@ -84,6 +84,11 @@ export default { next: '下一步', finish: '完成', }, + calendar: { + today: '今天', + pickerDate: '选择日期', + customPicker: '自定义选择日期', + }, }, // 编辑器 editor: {