diff --git a/packages/runtime/CHANGELOG.md b/packages/runtime/CHANGELOG.md index b142f3fd4a80df292a271696b124136f8dd96688..e145c6c47fe68048fa5bde53155ede46da6f71c0 100644 --- a/packages/runtime/CHANGELOG.md +++ b/packages/runtime/CHANGELOG.md @@ -12,6 +12,9 @@ - 表单新增在多数据部件表单模式下,记录当前表单的数据索引 - 新增mobShowViewHeader全局参数,控制移动端视图头是否显示,默认显示 - 新增mobShowAppTitle全局参数,控制在移动端设置浏览器标题时是否添加应用标题 +- 新增全局视图参数onlyShowDataInfo,控制视图标题是否只显示数据信息栏 +- 新增mobHomeRouteMode全局参数,控制移动端路由跳转时跳转方式 +- 新增支持搜索栏计数器 ## [0.7.41-alpha.20] - 2025-08-24 diff --git a/packages/runtime/src/config/global-config.ts b/packages/runtime/src/config/global-config.ts index ab1e3ff6f1535f524ee59149be064cfa6f87ac0f..65a4d342e3e548ac09cad99d21587880e1d1a928 100644 --- a/packages/runtime/src/config/global-config.ts +++ b/packages/runtime/src/config/global-config.ts @@ -34,6 +34,7 @@ export class GlobalConfig implements IGlobalConfig { mobShowPresetBack: true, mobShowViewHeader: true, timeoutDuration: 5 * 60 * 1000, + onlyShowDataInfo: false, }; // 全局表格配置 @@ -149,5 +150,6 @@ export class GlobalConfig implements IGlobalConfig { */ mob: IGlobalMobConfig = { mobShowAppTitle: true, + mobHomeRouteMode: 'default', }; } diff --git a/packages/runtime/src/controller/control/caption-bar/caption-bar.controller.ts b/packages/runtime/src/controller/control/caption-bar/caption-bar.controller.ts index 07028bf5266d5ec0c1c7ec9af33da11808bbfdf2..631691eac21e791f19f65980a3063c3dc5198cc2 100644 --- a/packages/runtime/src/controller/control/caption-bar/caption-bar.controller.ts +++ b/packages/runtime/src/controller/control/caption-bar/caption-bar.controller.ts @@ -32,9 +32,13 @@ export class CaptionBarController this.view.evt.on('onViewInfoChange', ({ caption: _caption, dataInfo }) => { const { showDataInfoBar } = this.view.model as IData; - this.state.caption = `${this.view.model.caption}${ - showDataInfoBar && dataInfo ? `-${dataInfo}` : '' - }`; + if (ibiz.config.view.onlyShowDataInfo && dataInfo) { + this.state.caption = dataInfo; + } else { + this.state.caption = `${this.view.model.caption}${ + showDataInfoBar && dataInfo ? `-${dataInfo}` : '' + }`; + } this.setBrowserTabTitle(); }); diff --git a/packages/runtime/src/controller/control/search-bar/search-bar.controller.ts b/packages/runtime/src/controller/control/search-bar/search-bar.controller.ts index adff401940feeffaa9c02a9e0ea108e7023d73d0..76aa63bcdaa54e22d15813f77ac1adb3fa3fa0e6 100644 --- a/packages/runtime/src/controller/control/search-bar/search-bar.controller.ts +++ b/packages/runtime/src/controller/control/search-bar/search-bar.controller.ts @@ -1,5 +1,10 @@ import { mergeInLeft, recursiveIterate } from '@ibiz-template/core'; -import { IAppDataEntity, ISearchBar, ISearchBarFilter } from '@ibiz/model-core'; +import { + IAppDataEntity, + ISearchBar, + ISearchBarFilter, + ISearchBarGroup, +} from '@ibiz/model-core'; import { clone } from 'ramda'; import { isString } from 'lodash-es'; import { @@ -32,6 +37,7 @@ import { import { ItemsValueOPs, isSimpleItems } from './util'; import { SearchBarFilterSimpleItemsController } from './search-bar-filter-simple-items.controller'; import { findFieldById } from '../../../model'; +import { AppCounter, CounterService } from '../../../service'; const ScriptValueRegex = /\$\{[^}]*\}/; // 匹配${xxx}格式字符串 @@ -96,6 +102,13 @@ export class SearchBarController */ hasDefaultSelect = false; + /** + * @description 计数器对象 + * @type {AppCounter} + * @memberof SearchBarController + */ + counter?: AppCounter; + /** * 启用自定义过滤项 * @author lxm @@ -245,6 +258,7 @@ export class SearchBarController await this.initByEntitySchema(); await super.onCreated(); + await this.initCounter(); if (this.model.appDataEntityId) { const appDataEntity = await ibiz.hub.getAppDataEntity( @@ -644,6 +658,8 @@ export class SearchBarController order: (index + 1) * 100, defaultSelect: false, noEdit: true, + counterId: item.counterId, + counterMode: item.counterMode, }; if (item.data) { try { @@ -1022,4 +1038,58 @@ export class SearchBarController } } } + + /** + * @description 计算计数器显示状态 + * @param {(IBackendSearchBarGroup | ISearchBarGroup)} item + * @returns {*} {boolean} + * @memberof SearchBarController + */ + public calcCountVisible( + item: IBackendSearchBarGroup | ISearchBarGroup, + ): boolean { + if (!this.counter) { + return true; + } + const { counterId, counterMode } = item; + if (counterId) { + // 显示模式为1,且计数器数据为0时隐藏 + const count = this.counter.getCounter(counterId); + if (counterMode === 1 && count === 0) { + return false; + } + } + return true; + } + + /** + * @description 初始化计数器 + * @protected + * @returns {*} {Promise} + * @memberof SearchBarController + */ + protected async initCounter(): Promise { + const { appCounterRefs } = this.model as IData; + const appCounterRef = appCounterRefs?.[0]; + if (appCounterRef) { + this.counter = await CounterService.getCounterByRef( + appCounterRef, + this.context, + { ...this.params }, + ); + } + } + + /** + * @description 监听组件销毁 + * @protected + * @returns {*} {Promise} + * @memberof SearchBarController + */ + protected async onDestroyed(): Promise { + await super.onDestroyed(); + if (this.counter) { + this.counter.destroy(); + } + } } diff --git a/packages/runtime/src/interface/api/common/global-config/i-api-global-mob-config.ts b/packages/runtime/src/interface/api/common/global-config/i-api-global-mob-config.ts index d40db0448edad448e3a83016039915b2a4d68c68..6fbeb8ac0b993355b7bf971bef4abf0b49fd3b26 100644 --- a/packages/runtime/src/interface/api/common/global-config/i-api-global-mob-config.ts +++ b/packages/runtime/src/interface/api/common/global-config/i-api-global-mob-config.ts @@ -11,4 +11,12 @@ export interface IApiGlobalMobConfig { * @memberof IApiGlobalConfig */ mobShowAppTitle: boolean; + + /** + * @description 移动端home视图路由替换模式,为replace时将会使用router.replace进行路由跳转,为default时使用router.push进行路由跳转 + * @type {('default' | 'replace')} + * @default default + * @memberof IApiGlobalMobConfig + */ + mobHomeRouteMode: 'default' | 'replace'; } diff --git a/packages/runtime/src/interface/api/common/global-config/i-api-global-view-config.ts b/packages/runtime/src/interface/api/common/global-config/i-api-global-view-config.ts index fd71349ce6a2af3be03840626bb405f0d1ea6be4..0990bc8c49c5ee359645caf483d2d8a4d6bf34f3 100644 --- a/packages/runtime/src/interface/api/common/global-config/i-api-global-view-config.ts +++ b/packages/runtime/src/interface/api/common/global-config/i-api-global-view-config.ts @@ -51,4 +51,12 @@ export interface IApiGlobalViewConfig { * @memberof IApiGlobalViewConfig */ timeoutDuration: number; + + /** + * @description 是否只显示信息栏,为true时,存在主数据信息则只显示信息栏,无主数据信息时显示标题 + * @type {boolean} + * @default false + * @memberof IApiGlobalViewConfig + */ + onlyShowDataInfo: boolean; } diff --git a/packages/runtime/src/interface/controller/state/control/search-bar/i-search-bar-group.ts b/packages/runtime/src/interface/controller/state/control/search-bar/i-search-bar-group.ts index 08fd80969ba02f8a2c671752ec7a1b25f2b50f84..4a8f3c364ebec78eac38f7db5f68cff5133cb1f1 100644 --- a/packages/runtime/src/interface/controller/state/control/search-bar/i-search-bar-group.ts +++ b/packages/runtime/src/interface/controller/state/control/search-bar/i-search-bar-group.ts @@ -103,4 +103,18 @@ export interface IBackendSearchBarGroup { * @memberof IBackendSearchBarGroup */ ownerType?: 'SYSTEM' | 'PERSONAL'; + + /** + * @description 计数器id + * @type {string} + * @memberof IBackendSearchBarGroup + */ + counterId?: string; + + /** + * @description 计数器显示模式 {0:默认、 1:0 值时隐藏 } + * @type {number} + * @memberof IBackendSearchBarGroup + */ + counterMode?: number; } diff --git a/packages/runtime/src/service/utils/app-counter/app-counter.ts b/packages/runtime/src/service/utils/app-counter/app-counter.ts index 21c1b579a80f1262ef0f359d45ab67b116a61341..eeb921023132e8451db18b682cc91db1a8a704bf 100644 --- a/packages/runtime/src/service/utils/app-counter/app-counter.ts +++ b/packages/runtime/src/service/utils/app-counter/app-counter.ts @@ -2,6 +2,7 @@ import { IBizContext, IPortalMessage, RuntimeError } from '@ibiz-template/core'; import { IAppCounter } from '@ibiz/model-core'; import { notNilEmpty, QXEvent } from 'qx-util'; import { clone } from 'ramda'; +import { toNumber } from 'lodash-es'; import { Application } from '../../../application'; import { IDataEntity } from '../../../interface'; import { calcDeCodeNameById } from '../../../model'; @@ -211,7 +212,8 @@ export class AppCounter { * @return {*} {number} */ getCounter(tag: string): number { - return this.data[tag.toLowerCase()] || 0; + const value = this.data[tag.toLowerCase()] || 0; + return toNumber(value); } /**