diff --git a/CHANGELOG.md b/CHANGELOG.md index c86a6b0d41e7656ab3a49ff3c25d0a4dafd93be1..cc6bf1dfa5227d787742fcac0c062ca3b6befe02 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ - 修复树表格简单模式异常 - 修复地图内置导航未默认选中第一条数据,第一条数据为区域时还需传递行政编码与行政等级参数 +- 修复日历内置导航月和自定义样式导航异常 +- 修复数据选择编辑器OBJECT和OBJECTS抛值问题 ### Changed diff --git a/src/common/control-navigation/control-navigation.tsx b/src/common/control-navigation/control-navigation.tsx index f97671207c18049a605d1c92cc3c020bb0c16ec1..bf692f9fdd06a18565e818f2968125f5d95b3dd3 100644 --- a/src/common/control-navigation/control-navigation.tsx +++ b/src/common/control-navigation/control-navigation.tsx @@ -147,14 +147,12 @@ export const IBizControlNavigation = defineComponent({ }); const renderNavView = () => { - if (navViewMsg.value) { - if (!navViewMsg.value.viewId) return; - return h(resolveComponent('IBizViewShell'), { - ...navViewMsg.value, - isEmbedCtrlNav: isEmbedCtrlNav.value, - class: ns.e('nav-view'), - }); - } + if (!navViewMsg.value?.viewId) return; + return h(resolveComponent('IBizViewShell'), { + ...navViewMsg.value, + isEmbedCtrlNav: isEmbedCtrlNav.value, + class: ns.e('nav-view'), + }); }; return { diff --git a/src/common/control-navigation/provider/calendar-navigation.provider.ts b/src/common/control-navigation/provider/calendar-navigation.provider.ts index d5a188286172c70c26e9d6749ba95401f3775c1c..06a7b160ff10269a6ed4dfd129f88ba60581d4df 100644 --- a/src/common/control-navigation/provider/calendar-navigation.provider.ts +++ b/src/common/control-navigation/provider/calendar-navigation.provider.ts @@ -1,10 +1,11 @@ +/* eslint-disable @typescript-eslint/prefer-as-const */ import { INavViewMsg, ICalendarItemData, CalendarController, + compareDateEqualByScale, } from '@ibiz-template/runtime'; import { ISysCalendar } from '@ibiz/model-core'; -import dayjs from 'dayjs'; import { NavgationBaseProvider } from './navigation-base.provider'; /** @@ -15,27 +16,40 @@ import { NavgationBaseProvider } from './navigation-base.provider'; * @extends {NavgationBaseProvider} */ export class CalendarNavigationProvider extends NavgationBaseProvider { - keyName = 'navId'; + keyName: 'navId' = 'navId'; declare controller: CalendarController; declare model: ISysCalendar; + /** + * @description 通过栈数据导航 + * - 特殊处理仅使用开始时间绘制的日历 + * @memberof CalendarNavigationProvider + */ onNavDataByStack(): void { - const { items } = this.controller.state; + const { controlParams, state, model } = this.controller; + const calendarStyle = model.calendarStyle?.toLowerCase(); + const items = state.items.filter(item => { + if ( + (calendarStyle === 'month' && controlParams.showmode !== 'daterange') || + calendarStyle === 'user' + ) + return compareDateEqualByScale( + item.beginTime, + state.selectedDate, + calendarStyle === 'user' ? 'week' : 'month', + ); + return true; + }); const navData = this.navStack - .map(key => items.find(item => item.navId === key)) + .map(key => items.find(item => item[this.keyName] === key)) .find(item => item !== undefined) || items[0]; if (navData) { - const date = new Date(navData.beginTime); - // 开始时间不是标准的时间值时,调用setSelectDate会导致日历重复加载 - if (dayjs(date).isValid()) this.controller.setSelectDate(date); - this.controller.setNavData(navData); + this.setNavData(navData); } else { - this.navStack = []; - this.controller.setSelectDate(new Date()); - this.navViewMsg.value = undefined; + this.clearNavigation(); } } diff --git a/src/common/control-navigation/provider/map-navigation.provider.ts b/src/common/control-navigation/provider/map-navigation.provider.ts index 456493108451ffc7af6022529b713c54788aeabe..4c26f2512f05d7595ab5064dc5e0db7e0e090724 100644 --- a/src/common/control-navigation/provider/map-navigation.provider.ts +++ b/src/common/control-navigation/provider/map-navigation.provider.ts @@ -1,10 +1,11 @@ +/* eslint-disable @typescript-eslint/prefer-as-const */ import { - calcDeCodeNameById, - getAreaLevelNum, IMapData, IMapEvent, INavViewMsg, MapController, + getAreaLevelNum, + calcDeCodeNameById, } from '@ibiz-template/runtime'; import { ISysMap } from '@ibiz/model-core'; import { NavgationBaseProvider } from './navigation-base.provider'; @@ -17,7 +18,7 @@ import { NavgationBaseProvider } from './navigation-base.provider'; * @extends {NavgationBaseProvider} */ export class MapNavigationProvider extends NavgationBaseProvider { - keyName = 'id'; + keyName: '_id' = '_id'; declare controller: MapController; @@ -31,7 +32,7 @@ export class MapNavigationProvider extends NavgationBaseProvider { onNavDataChange(event: IMapEvent['onNavDataChange']['event']): void { const { navData } = event; // 数据变更才重新导航 - if (this.navViewMsg.value?.key !== navData._id) { + if (this.navViewMsg.value?.key !== navData[this.keyName]) { this.navStack.unshift(navData[this.keyName]); this.navViewMsg.value = this.getNavViewMsg(navData as IMapData); } @@ -41,7 +42,7 @@ export class MapNavigationProvider extends NavgationBaseProvider { const { items } = this.controller.state; const navData = this.navStack - .map(key => items.find(item => item._id === key)) + .map(key => items.find(item => item[this.keyName] === key)) .find(item => item !== undefined) || items[0]; if (navData) { // 默认选中区域数据需传行政编码与行政等级 @@ -53,15 +54,12 @@ export class MapNavigationProvider extends NavgationBaseProvider { : Number(navData._areaCode); data.areaLevel = getAreaLevelNum(navData._areaCode); } - this.controller.evt.emit('onNavDataChange', { - navData: data, - }); + this.setNavData(data); } else { - this.controller.setNavData(navData); + this.setNavData(navData); } } else { - this.navStack = []; - this.navViewMsg.value = undefined; + this.clearNavigation(); } } @@ -93,12 +91,12 @@ export class MapNavigationProvider extends NavgationBaseProvider { return { params, context, - key: item._id, + key: item[this.keyName], viewId: itemModel.navAppViewId, }; } return { - key: item._id, + key: item[this.keyName], context: this.controller.context, params: this.controller.params, }; diff --git a/src/common/control-navigation/provider/navigation-base.provider.ts b/src/common/control-navigation/provider/navigation-base.provider.ts index b249c4282a19b0264d4d7a70fa02d0572e303dd0..55c994e69f1b4e091b452c1d495d20c5be2fc6b7 100644 --- a/src/common/control-navigation/provider/navigation-base.provider.ts +++ b/src/common/control-navigation/provider/navigation-base.provider.ts @@ -28,7 +28,7 @@ export class NavgationBaseProvider { * * @memberof NavgationBaseProvider */ - keyName = 'srfkey'; + keyName: string = 'srfkey'; /** * 模型 @@ -104,6 +104,28 @@ export class NavgationBaseProvider { return { context: tempContext, params: tempParams }; } + /** + * @description 清空导航 + * @protected + * @memberof NavgationBaseProvider + */ + protected clearNavigation(): void { + this.navStack = []; + this.controller.setSelection([]); + this.navViewMsg.value = undefined; + } + + /** + * @description 设置导航数据 + * @protected + * @param {IData} data + * @memberof NavgationBaseProvider + */ + protected setNavData(data: IData): void { + this.controller.setNavData(data); + this.controller.setSelection([data]); + } + /** * 通过栈数据导航 * @@ -115,16 +137,11 @@ export class NavgationBaseProvider { this.navStack .map(key => items.find(item => item[this.keyName] === key)) .find(item => item !== undefined) || items[0]; - setTimeout(() => { - if (navData) { - this.controller.setNavData(navData); - this.controller.setSelection([navData]); - } else { - this.navStack = []; - this.controller.setSelection([]); - this.navViewMsg.value = undefined; - } - }); + if (navData) { + this.setNavData(navData); + } else { + this.clearNavigation(); + } } /** diff --git a/src/common/control-navigation/provider/tree-navigation.provider.ts b/src/common/control-navigation/provider/tree-navigation.provider.ts index d24fe682a8a9bf421099d0b61e0753487eb37b96..f1acc7cd9f618e665be9974bf36d01b280c86b3b 100644 --- a/src/common/control-navigation/provider/tree-navigation.provider.ts +++ b/src/common/control-navigation/provider/tree-navigation.provider.ts @@ -1,7 +1,8 @@ +/* eslint-disable @typescript-eslint/prefer-as-const */ import { - TreeController, INavViewMsg, ITreeNodeData, + TreeController, MDControlController, } from '@ibiz-template/runtime'; import { IDETree } from '@ibiz/model-core'; @@ -15,7 +16,7 @@ import { NavgationBaseProvider } from './navigation-base.provider'; * @extends {NavgationBaseProvider} */ export class TreeNavigationProvider extends NavgationBaseProvider { - keyName = '_id'; + keyName: '_id' = '_id'; declare controller: TreeController; @@ -56,15 +57,12 @@ export class TreeNavigationProvider extends NavgationBaseProvider { }); const navData = this.navStack - .map(key => items.find(item => item._id === key)) + .map(key => items.find(item => item[this.keyName] === key)) .find(item => item !== undefined) || defaultNav; if (navData) { - this.controller.setSelection([navData]); - this.controller.setNavData(navData); + this.setNavData(navData); } else { - this.navStack = []; - this.controller.setSelection([]); - this.navViewMsg.value = undefined; + this.clearNavigation(); } } @@ -84,14 +82,14 @@ export class TreeNavigationProvider extends NavgationBaseProvider { _params, ); return { - key: item._id, + key: item[this.keyName], context, params, viewId: nodeModel.navAppViewId, }; } return { - key: item._id, + key: item[this.keyName], context: _context, params: _params, }; diff --git a/src/control/calendar/calendar.scss b/src/control/calendar/calendar.scss index 752ec81b3946a0ae412981d3a50e8ed0ce4ac277..a1918095026dc1f633a0d3f67d902a7796deaf62 100644 --- a/src/control/calendar/calendar.scss +++ b/src/control/calendar/calendar.scss @@ -42,6 +42,19 @@ $control-calendar-item: ( } } +.#{bem('control-calendar', 'user')} { + .#{bem('control-calendar', 'nav-icon')} { + top: 9px; + } +} +.#{bem('control-calendar', 'day')}, +.#{bem('control-calendar', 'week')} { + .#{bem('control-calendar', 'nav-icon')} { + top: 28px; + right: 10px; + } +} + @include b(control-calendar-content) { display: flex; flex-direction: column; @@ -106,7 +119,8 @@ $control-calendar-item: ( &.is-end-time { width: calc(100% - getCssVar(spacing, super-tight)); - border-radius: 0 getCssVar(spacing, extra-tight) getCssVar(spacing, extra-tight) 0; + border-radius: 0 getCssVar(spacing, extra-tight) + getCssVar(spacing, extra-tight) 0; } &.is-active { @@ -114,11 +128,19 @@ $control-calendar-item: ( border-left: none; &.is-begin-time { - border-left: solid 0.5px var(#{getCssVarName(control-calendar,item-active-border-color)}, #{getCssVar(control-calendar, border-color)}); + border-left: solid 0.5px + var( + #{getCssVarName(control-calendar, item-active-border-color)}, + #{getCssVar(control-calendar, border-color)} + ); } &.is-end-time { - border-right: solid 0.5px var(#{getCssVarName(control-calendar,item-active-border-color)}, #{getCssVar(control-calendar, border-color)}); + border-right: solid 0.5px + var( + #{getCssVarName(control-calendar, item-active-border-color)}, + #{getCssVar(control-calendar, border-color)} + ); } } @@ -153,7 +175,10 @@ $control-calendar-item: ( @include set-component-css-var(control-calendar-item, $control-calendar-item); #{getCssVarName(color, text, 2)}: getCssVar(control-calendar-item, color); - #{getCssVarName(editor, default, text, color)}: getCssVar(control-calendar-item, color); + #{getCssVarName(editor, default, text, color)}: getCssVar( + control-calendar-item, + color + ); height: 100%; padding: getCssVar(control-calendar, item-padding); margin-bottom: getCssVar(control-calendar, margin); @@ -172,7 +197,11 @@ $control-calendar-item: ( @include when(active) { background-color: getCssVar(control-calendar, active-bg-color); - border: solid 0.5px var(#{getCssVarName(control-calendar,item-active-border-color)}, #{getCssVar(control-calendar, border-color)}); + border: solid 0.5px + var( + #{getCssVarName(control-calendar, item-active-border-color)}, + #{getCssVar(control-calendar, border-color)} + ); } } @@ -214,29 +243,29 @@ $control-calendar-item: ( width: 100%; @include e('item') { - display: flex; - align-items: center; - padding: 0 getCssVar('spacing', 'tight'); - line-height: 1em; - cursor: pointer; - - @include m('tip') { - display: inline-block; - width: 1.5em; - height: 0.9em; - margin-right: getCssVar('spacing', 'extra-tight'); - border-radius: getCssVar(border, radius, extra, small); - } + display: flex; + align-items: center; + padding: 0 getCssVar('spacing', 'tight'); + line-height: 1em; + cursor: pointer; - @include m('text') { - display: inline-block; - width: auto; - max-width: 100px; - overflow: hidden; - text-align: left; - text-overflow: ellipsis; - white-space: nowrap; - } + @include m('tip') { + display: inline-block; + width: 1.5em; + height: 0.9em; + margin-right: getCssVar('spacing', 'extra-tight'); + border-radius: getCssVar(border, radius, extra, small); + } + + @include m('text') { + display: inline-block; + width: auto; + max-width: 100px; + overflow: hidden; + text-align: left; + text-overflow: ellipsis; + white-space: nowrap; + } } } @@ -248,4 +277,4 @@ $control-calendar-item: ( .el-timeline { padding-left: 0; } -} \ No newline at end of file +} diff --git a/src/control/calendar/calendar.tsx b/src/control/calendar/calendar.tsx index 8518a33bbfbb8d737e9446180376cd05e5489f74..7b24584fc6c201eeb799a498b4a7d3a2f6f0a56c 100644 --- a/src/control/calendar/calendar.tsx +++ b/src/control/calendar/calendar.tsx @@ -1,34 +1,34 @@ /* eslint-disable no-nested-ternary */ import { - hasEmptyPanelRenderer, + useUIStore, + useNamespace, IBizCustomRender, useControlController, - useNamespace, - useUIStore, + hasEmptyPanelRenderer, } from '@ibiz-template/vue3-util'; import { - defineComponent, - PropType, ref, - resolveComponent, VNode, watch, + PropType, + defineComponent, + resolveComponent, } from 'vue'; import { - IDETBGroupItem, IDETBRawItem, - IDETBUIActionItem, - IDEToolbarItem, ILayoutPanel, ISysCalendar, + IDEToolbarItem, + IDETBGroupItem, ISysCalendarItem, + IDETBUIActionItem, } from '@ibiz/model-core'; import { - CalendarController, - IButtonContainerState, IButtonState, - ICalendarItemData, IControlProvider, + ICalendarItemData, + CalendarController, + IButtonContainerState, } from '@ibiz-template/runtime'; import dayjs from 'dayjs'; import { showTitle } from '@ibiz-template/core'; @@ -954,7 +954,10 @@ export const CalendarControl = defineComponent({ return ( - + {renderCalendar()} {this.c.state.enableNavView && this.c.state.showNavIcon ? ( !this.c.state.showNavView ? ( diff --git a/src/editor/data-picker/picker-editor.controller.ts b/src/editor/data-picker/picker-editor.controller.ts index d7d9749f99640e1f1b898fee52ea58e084bcdfe6..d9df24682caa47b964bc06a9e0f623b1a3e64b77 100644 --- a/src/editor/data-picker/picker-editor.controller.ts +++ b/src/editor/data-picker/picker-editor.controller.ts @@ -422,10 +422,14 @@ export class PickerEditorController extends EditorController { }); } if (this.objectValueField) { + // 删除值回显时手动填充的前端字段srfkey和srfmajortext + const data = { + ...select, + }; + delete data.srfkey; + delete data.srfmajortext; Object.assign(object, { - [this.objectValueField]: { - ...select, - }, + [this.objectValueField]: data, }); } if (select.srfnodeid) {