提交 459e1d7c 编写于 作者: Mosher's avatar Mosher

update:更新门户部件

上级 1172dead
<AppPortletCard
name={{portlet.name}}
name="{{portlet.name}}"
:isContainer="true"
{{#if portlet.caption}}
title="{{portlet.caption}}"
......
import { IParam, MainControlState } from '@core';
import { MainControlState } from '@core';
/**
* @description 数据看板部件状态
......@@ -7,5 +7,11 @@ import { IParam, MainControlState } from '@core';
* @extends {MainControlState}
*/
export interface DashboardControlState extends MainControlState {
/**
* 门户部件标识集合
*
* @type {string[]}
* @memberof DashboardControlState
*/
portlets: string[];
}
......@@ -22,13 +22,17 @@ export class DashboardControl extends MainControl {
* @param {DashboardControlProps} props
* @memberof DashboardControl
*/
public useLoad(props: DashboardControlProps) {
const { viewSubject, controlName, context, viewParams } = this.state;
public useLoad() {
const { viewSubject, controlName, context, viewParams, portlets } = this.state;
// 订阅viewSubject,监听load行为
if (viewSubject) {
let subscription = viewSubject.subscribe(({ tag, action, data }: IActionParam) => {
if (Object.is(controlName, tag) && Object.is("load", action)) {
viewSubject.next({ tag: tag, action: "load", data: data });
if (portlets.length) {
portlets.forEach((portlet: string) => {
viewSubject.next({ tag: portlet, action: "load", data: data });
});
}
}
})
// 部件卸载时退订viewSubject
......@@ -56,9 +60,9 @@ export class DashboardControl extends MainControl {
*/
public moduleInstall() {
const superParams = super.moduleInstall();
this.useLoad();
return {
...superParams,
load:this.useLoad.bind(this),
onCtrlEvent: this.onCtrlEvent.bind(this),
};
}
......
import { IParam, MainControlState } from '@core';
import { MainControlState } from '@core';
/**
* @description 门户部件状态
......@@ -7,5 +7,11 @@ import { IParam, MainControlState } from '@core';
* @extends {MainControlState}
*/
export interface PortletControlState extends MainControlState {
/**
* 子部件标识集合
*
* @type {string[]}
* @memberof PortletControlState
*/
childControls: string[];
}
\ No newline at end of file
......@@ -22,13 +22,17 @@ export class PortletControl extends MainControl {
* @param {PortletControlProps} props
* @memberof PortletControl
*/
public useLoad(props: PortletControlProps) {
const { viewSubject, controlName, context, viewParams } = this.state;
public useLoad() {
const { viewSubject, controlName, context, viewParams, childControls } = this.state;
// 订阅viewSubject,监听load行为
if (viewSubject) {
let subscription = viewSubject.subscribe(({ tag, action, data }: IActionParam) => {
if (Object.is(controlName, tag) && Object.is("load", action)) {
viewSubject.next({ tag: tag, action: "load", data: data });
if (childControls.length) {
childControls.forEach((control: string) => {
viewSubject.next({ tag: control, action: "load", data: data });
});
}
}
})
// 部件卸载时退订viewSubject
......@@ -115,11 +119,10 @@ export class PortletControl extends MainControl {
*/
public moduleInstall() {
const superParams = super.moduleInstall();
this.useLoad();
return {
...superParams,
load: this.useLoad.bind(this),
onViewEvent: this.onViewEvent.bind(this),
onCtrlEvent: this.onCtrlEvent.bind(this),
handleItemClick: this.handleItemClick.bind(this),
handleActionClick: this.handleActionClick.bind(this),
};
......
......@@ -33,8 +33,13 @@ defineExpose({ name, state, load });
<div v-if="Object.is('CENTER', state.menuAlign)" class="app-menu app-menu--center{{#if ctrl.psSysCss}} {{ctrl.psSysCss.cssName}}{{/if}}">
<AppMenuCenter :menus="state.menus" @onMenuSelect="onMenuSelect" :counterData="counterData" />
</div>
<a-menu v-else class="app-menu{{#if ctrl.psSysCss}} {{ctrl.psSysCss.cssName}}{{/if}}" v-model:openKeys="state.defaultOpens" v-model:selectedKeys="state.defaultSelect"
:mode="Object.is('LEFT', state.menuAlign) ? 'inline' : 'horizontal'" @select="onMenuSelect">
<a-menu
v-else
v-model:openKeys="state.defaultOpens"
v-model:selectedKeys="state.defaultSelect"
:mode="Object.is('LEFT', state.menuAlign) ? 'inline' : 'horizontal'"
class="app-menu{{#if ctrl.psSysCss}} {{ctrl.psSysCss.cssName}}{{/if}}"
@select="onMenuSelect">
<AppMenuItem :items="state.menus" :collapsed="collapsed" :counterData="counterData" />
</a-menu>
</template>
......
{{#*inline "getPortlet" portlet}}
{{~#eq portlet.portletType 'CONTAINER'~}}
{{#if portlet.psControls}}
{{~#each portlet.psControls as | control |~}}
{{> getPortlet portlet=control}}{{#unless @last}},{{/unless}}
{{~/each~}}
{{/if}}
{{~else~}}
'{{portlet.name}}'
{{~/eq~}}
{{/inline}}
// 部件配置对象
export const ctrlState = {
controlCodeName: '{{ctrl.codeName}}',
controlName: '{{ctrl.name}}',
isEnableCustomized: {{ctrl.enableCustomized}},
portlets: [
{{~#each ctrl.psControls as | portlet |~}}
{{> getPortlet portlet=portlet}}{{#unless @last}},{{/unless}}
{{~/each~}}
]
};
\ No newline at end of file
......@@ -38,7 +38,7 @@ const { name, state, onCtrlEvent } = dashboardControl;
defineExpose({ name, state });
</script>
<template>
<AppRow class="app-dashboard{{#if ctrl.psSysCss}} {{ctrl.psSysCss.cssName}}{{/if}}" layoutOpts="{{> @macro/front-end/common/layoutPos.hbs layout=ctrl.psLayout layoutPos=ctrl.psLayoutPos}}">
<AppRow class="app-dashboard{{#if ctrl.psSysCss}} {{ctrl.psSysCss.cssName}}{{/if}}" :layoutOpts="{{> @macro/front-end/common/layoutPos.hbs layout=ctrl.psLayout layoutPos=ctrl.psLayoutPos}}">
<template v-if="!state.isEnableCustomized">
{{#each ctrl.psControls as |portlet|}}
{{#eq portlet.portletType 'CONTAINER'}}
......
......@@ -4,6 +4,13 @@ export const ctrlState = {
controlName: '{{ctrl.name}}',
portletType: '{{ctrl.portletType}}',
showCaption: {{ctrl.showTitleBar}},
childControls: [
{{~#if ctrl.psControls~}}
{{~#each ctrl.psControls as | control |~}}
'{{control.name}}'
{{~/each~}}
{{~/if~}}
],
{{#if ctrl.psAppDataEntity}}
// 实体名称
appEntityCodeName: '{{ctrl.psAppDataEntity.codeName}}',
......
......@@ -81,15 +81,16 @@ defineExpose({ name, state });
</template>
</span>
</template>
{{#if (eq ctrl.portletType 'VIEW')}}
{{#eq ctrl.portletType 'VIEW'}}
<{{ctrl.portletPSAppView.codeName}}
:context="state.context"
:viewParams="state.viewParams"
:viewSubject="state.viewSubject"
@viewEvent="onViewEvent"
/>
{{else if (eq ctrl.portletType 'APPMENU')}}
{{#each ctrl.psControls as | control |}}
{{/eq}}
{{#eq ctrl.portletType 'APPMENU'}}
{{#each ctrl.psControls as | control |}}
<{{control.codeName}}Menu
ref="menu"
name="{{name}}"
......@@ -100,21 +101,26 @@ defineExpose({ name, state });
:collapsed="false"
@ctrlEvent="onCtrlEvent"
></{{control.codeName}}Menu>
{{/each}}
{{else if (eq ctrl.portletType 'CUSTOM')}}
{{/each}}
{{/eq}}
{{#eq ctrl.portletType 'CUSTOM'}}
<div>暂未支持自定义绘制</div>
{{else if (eq ctrl.portletType 'ACTIONBAR')}}
{{/eq}}
{{#eq ctrl.portletType 'ACTIONBAR'}}
<app-action-bar
:viewSubject="state.viewSubject"
:uiService="state.UIService"
:items="state.actionBarModelData"
@itemClick="handleItemClick"
></app-action-bar>
{{else if (eq ctrl.portletType 'TOOLBAR')}}
{{/eq}}
{{#eq ctrl.portletType 'TOOLBAR'}}
<div>暂未支持工具栏绘制</div>
{{else if (eq ctrl.portletType 'HTML')}}
{{/eq}}
{{#eq ctrl.portletType 'HTML'}}
<iframe :src="state.pageUrl" :style="{ height: '100%', width: '100%', borderWidth: '0px' }"></iframe>
{{else if (eq ctrl.portletType 'RAWITEM')}}
{{/eq}}
{{#eq ctrl.portletType 'RAWITEM'}}
<app-raw
:name="state.controlName"
:contentType="state.contentType"
......@@ -123,8 +129,9 @@ defineExpose({ name, state });
style="{{#if ctrl.rawItemHeight}}height: {{ctrl.rawItemHeight}}px;{{/if}}{{#if ctrl.rawItemWidth}}width: {{ctrl.rawItemWidth}}px{{/if}}"
:value="state.rawContent"
></app-raw>
{{else if (eq ctrl.portletType 'LIST')}}
{{#ctrl.psControls}}
{{/eq}}
{{#eq ctrl.portletType 'LIST'}}
{{#ctrl.psControls}}
<{{codeName}}List
ref="portlet"
name="{{name}}"
......@@ -134,8 +141,8 @@ defineExpose({ name, state });
:viewSubject="state.viewSubject"
@ctrlEvent="onCtrlEvent">
</{{codeName}}List>
{{/ctrl.psControls}}
{{/if}}
{{/ctrl.psControls}}
{{/eq}}
</AppPortletCard>
</template>
<style lang="scss">
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册