From b835c80e6a18885b843baa1ec87d519ca601dea5 Mon Sep 17 00:00:00 2001 From: zhujiamin <1147570162@qq.com> Date: Tue, 23 May 2023 10:24:41 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81captionBar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../caption-bar/caption-bar.controller.ts | 36 +++++++++++++++++++ .../caption-bar/caption-bar.provider.ts | 14 ++++++++ src/control/caption-bar/caption-bar.scss | 5 +++ src/control/caption-bar/caption-bar.tsx | 32 +++++++++++++++++ src/control/caption-bar/index.ts | 21 +++++++++++ src/control/index.ts | 1 + src/index.ts | 2 ++ 7 files changed, 111 insertions(+) create mode 100644 src/control/caption-bar/caption-bar.controller.ts create mode 100644 src/control/caption-bar/caption-bar.provider.ts create mode 100644 src/control/caption-bar/caption-bar.scss create mode 100644 src/control/caption-bar/caption-bar.tsx create mode 100644 src/control/caption-bar/index.ts diff --git a/src/control/caption-bar/caption-bar.controller.ts b/src/control/caption-bar/caption-bar.controller.ts new file mode 100644 index 00000000..3c46d8a7 --- /dev/null +++ b/src/control/caption-bar/caption-bar.controller.ts @@ -0,0 +1,36 @@ +import { + ControlController, + ICaptionBarState, + ICaptionBarEvent, + ICaptionBarController, +} from '@ibiz-template/runtime'; +import { ICaptionBar } from '@ibiz/model-core'; + +/** + * 标题栏控制器 + * + * @author chitanda + * @date 2022-07-24 15:07:07 + * @export + * @class CaptionBarController + * @extends {ControlController} + */ +export class CaptionBarController + extends ControlController + implements ICaptionBarController +{ + protected initState(): void { + super.initState(); + this.state.caption = ''; + } + + protected async doCreated(): Promise { + await super.doCreated(); + this.state.caption = this.view.model.caption!; + this.view.evt.on('onViewInfoChange', ({ caption: _caption, dataInfo }) => { + if (dataInfo) { + this.state.caption = `${this.state.caption}-${dataInfo}`; + } + }); + } +} diff --git a/src/control/caption-bar/caption-bar.provider.ts b/src/control/caption-bar/caption-bar.provider.ts new file mode 100644 index 00000000..16e89389 --- /dev/null +++ b/src/control/caption-bar/caption-bar.provider.ts @@ -0,0 +1,14 @@ +import { IControlProvider } from '@ibiz-template/runtime'; + +/** + * 标题栏适配器 + * + * @author lxm + * @date 2022-10-25 18:10:57 + * @export + * @class CaptionBarProvider + * @implements {IControlProvider} + */ +export class CaptionBarProvider implements IControlProvider { + component: string = 'IBizCaptionBarControl'; +} diff --git a/src/control/caption-bar/caption-bar.scss b/src/control/caption-bar/caption-bar.scss new file mode 100644 index 00000000..5aa2aead --- /dev/null +++ b/src/control/caption-bar/caption-bar.scss @@ -0,0 +1,5 @@ +@include b(control-captionbar) { + @include b(control-captionbar-caption) { + @include utils-ellipsis; + } +} diff --git a/src/control/caption-bar/caption-bar.tsx b/src/control/caption-bar/caption-bar.tsx new file mode 100644 index 00000000..6dc01fb6 --- /dev/null +++ b/src/control/caption-bar/caption-bar.tsx @@ -0,0 +1,32 @@ +import { useControlController, useNamespace } from '@ibiz-template/vue3-util'; +import { defineComponent, PropType } from 'vue'; +import { ICaptionBar } from '@ibiz/model-core'; +import { CaptionBarController } from './caption-bar.controller'; +import './caption-bar.scss'; + +export const CaptionBarControl = defineComponent({ + name: 'IBizCaptionBarControl', + props: { + modelData: { + type: Object as PropType, + required: true, + }, + context: { type: Object as PropType, required: true }, + params: { type: Object as PropType, default: () => ({}) }, + }, + setup() { + const c = useControlController( + (...args) => new CaptionBarController(...args), + ); + const ns = useNamespace(`control-${c.model.controlType!.toLowerCase()}`); + + return { c, ns }; + }, + render() { + return ( + +
{this.c.state.caption}
+
+ ); + }, +}); diff --git a/src/control/caption-bar/index.ts b/src/control/caption-bar/index.ts new file mode 100644 index 00000000..be964172 --- /dev/null +++ b/src/control/caption-bar/index.ts @@ -0,0 +1,21 @@ +import { ControlType, registerControlProvider } from '@ibiz-template/runtime'; +import { App } from 'vue'; +import { withInstall } from '@ibiz-template/vue3-util'; +import { CaptionBarControl } from './caption-bar'; +import { CaptionBarProvider } from './caption-bar.provider'; + +export * from './caption-bar.provider'; +export * from './caption-bar.controller'; + +export const IBizCaptionBarControl = withInstall( + CaptionBarControl, + function (v: App) { + v.component(CaptionBarControl.name, CaptionBarControl); + registerControlProvider( + ControlType.CAPTIONBAR, + () => new CaptionBarProvider(), + ); + }, +); + +export default IBizCaptionBarControl; diff --git a/src/control/index.ts b/src/control/index.ts index 4207c5d6..00b23308 100644 --- a/src/control/index.ts +++ b/src/control/index.ts @@ -4,3 +4,4 @@ export * from './list'; export * from './form'; export * from './toolbar'; export * from './panel'; +export * from './caption-bar'; diff --git a/src/index.ts b/src/index.ts index aad1c16c..a441799e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -10,6 +10,7 @@ import { IBizFormControl, IBizSearchFormControl, IBizListControl, + IBizCaptionBarControl, } from './control'; import IBizEditor from './editor'; import { IBizView } from './view'; @@ -37,6 +38,7 @@ export default { v.use(IBizFormControl); v.use(IBizSearchFormControl); v.use(IBizEditFormControl); + v.use(IBizCaptionBarControl); // 编辑器 v.use(IBizEditor); }, -- Gitee