提交 08c4a700 编写于 作者: RedPig97's avatar RedPig97

add: 应用菜单中间样式支持

上级 42bc5585
...@@ -17,6 +17,9 @@ ...@@ -17,6 +17,9 @@
] ]
}, },
{{/if}} {{/if}}
{{#eq page.viewType 'APPINDEXVIEW'}}
menuAlign: '{{#if page.mainMenuAlign}}{{page.mainMenuAlign}}{{else}}LEFT{{/if}}',
{{/eq}}
appEntityName: '{{page.appEntity.codeName}}', appEntityName: '{{page.appEntity.codeName}}',
isLoadDefault: {{#if (or page.loadDefault (eq page.loadDefault false))}}{{page.loadDefault}}{{else}}true{{/if}}, isLoadDefault: {{#if (or page.loadDefault (eq page.loadDefault false))}}{{page.loadDefault}}{{else}}true{{/if}},
keyPSDEField: '{{lowerCase page.appEntity.codeName}}', keyPSDEField: '{{lowerCase page.appEntity.codeName}}',
......
...@@ -3,44 +3,55 @@ interface LayoutProps { ...@@ -3,44 +3,55 @@ interface LayoutProps {
/** /**
* @description 菜单方向 * @description 菜单方向
*/ */
menuAlign: "LEFT" | "TOP" | "CENTER" | "TABEXP_LEFT" | "TABEXP_TOP" | "TABEXP_RIGHT" | "TABEXP_BOTTOM" | "NONE", menuAlign: 'LEFT' | 'TOP' | 'CENTER' | 'TABEXP_LEFT' | 'TABEXP_TOP' | 'TABEXP_RIGHT' | 'TABEXP_BOTTOM' | 'NONE';
/** /**
* @description 收缩 * @description 收缩
*/ */
collapsed: boolean, collapsed: boolean;
/**
* @description 显示标题栏
*/
showCaptionBar: boolean;
} }
const props = withDefaults(defineProps<LayoutProps>(), { const props = withDefaults(defineProps<LayoutProps>(), {
menuAlign: "LEFT", menuAlign: 'LEFT',
collapsed: false, collapsed: false,
}) showCaptionBar: true
});
</script> </script>
<template> <template>
<AppIndexViewBaseLayout class="app-index-view-layout--default"> <div class="app-index-view-layout--default">
<template v-slot:header-left> <a-card v-if="Object.is(menuAlign, 'CENTER')" class="center-menu-card">
<slot name="caption"></slot> <template v-if="showCaptionBar" #title>
</template> <slot name="caption" />
<template v-slot:header-content> </template>
<slot name="menu" v-if="Object.is(menuAlign, 'TOP')"></slot> <slot name="menu" />
</template> </a-card>
<template v-slot:header-right> <AppIndexViewBaseLayout v-else>
<slot name="user"></slot> <template v-slot:header-left>
</template> <slot v-if="showCaptionBar" name="caption"></slot>
<template v-slot:side-left> </template>
<a-layout-sider <template v-slot:header-content>
v-if="Object.is(menuAlign, 'LEFT')" <slot name="breadcrumb" />
collapsible <slot name="menu" v-if="Object.is(menuAlign, 'TOP')"></slot>
:trigger="null" </template>
:collapsed="collapsed"> <template v-slot:header-right>
<slot name="menu"></slot> <slot name="user"></slot>
</a-layout-sider> </template>
</template> <template v-slot:side-left>
<template v-slot:content> <a-layout-sider v-if="Object.is(menuAlign, 'LEFT')" collapsible :trigger="null" :collapsed="collapsed">
<slot name="router" /> <slot name="menu"></slot>
</template> </a-layout-sider>
</AppIndexViewBaseLayout> </template>
<template v-slot:content>
<slot name="view-exp" />
<slot name="router" />
</template>
</AppIndexViewBaseLayout>
</div>
</template> </template>
<style lang="scss"> <style lang="scss"></style>
</style>
\ No newline at end of file
...@@ -163,7 +163,7 @@ export class MenuControl extends ControlBase { ...@@ -163,7 +163,7 @@ export class MenuControl extends ControlBase {
* @param {IParam} item 菜单项数据 * @param {IParam} item 菜单项数据
* @memberof MenuControl * @memberof MenuControl
*/ */
public menuClick(item: IParam) { public handleMenuClick(item: IParam) {
const { context, viewParams } = this.state; const { context, viewParams } = this.state;
App.getAppFuncService().executeAppFunc(item, deepCopy(context), deepCopy(viewParams)); App.getAppFuncService().executeAppFunc(item, deepCopy(context), deepCopy(viewParams));
} }
...@@ -204,12 +204,12 @@ export class MenuControl extends ControlBase { ...@@ -204,12 +204,12 @@ export class MenuControl extends ControlBase {
* @param {IParam} $event 选中项数据 * @param {IParam} $event 选中项数据
* @memberof MenuControl * @memberof MenuControl
*/ */
public menuSelect($event: IParam) { public onMenuSelect($event: IParam) {
const { key } = $event; const { key } = $event;
const dataRef = toRef(this.state, 'menus'); const dataRef = toRef(this.state, 'menus');
let item = this.compute(dataRef.value, key); let item = this.compute(dataRef.value, key);
if (Object.keys(item).length > 0) { if (Object.keys(item).length > 0) {
this.menuClick(item); this.handleMenuClick(item);
} }
} }
...@@ -222,15 +222,15 @@ export class MenuControl extends ControlBase { ...@@ -222,15 +222,15 @@ export class MenuControl extends ControlBase {
const superParams = super.moduleInstall(); const superParams = super.moduleInstall();
const { load } = this.useLoad(); const { load } = this.useLoad();
const menuSelect = this.menuSelect.bind(this); const onMenuSelect = this.onMenuSelect.bind(this);
this.menuSelect = ($event: IParam) => { this.onMenuSelect = ($event: IParam) => {
menuSelect($event); onMenuSelect($event);
} }
return { return {
...superParams, ...superParams,
load, load,
menuSelect: this.menuSelect, onMenuSelect: this.onMenuSelect,
}; };
} }
} }
.app-index-view-layout--default {
height: 100%;
width: 100%;
.center-menu-card {
height: 100%;
overflow: auto;
}
}
@use './app-view-base-layout.scss'; @use './app-view-base-layout.scss';
@use './app-index-view-base-layout.scss'; @use './app-index-view-base-layout.scss';
\ No newline at end of file @use './app-default-index-view-base-layout.scss';
\ No newline at end of file
.app-menu--center {
.ant-card-head-title {
text-align: left;
}
.ant-card-body {
text-align: left;
.ant-space {
flex-wrap: wrap;
.ant-btn {
width: 320px;
height: 56px;
border-radius: 4px;
border-left: 10px solid var(--app-color-primary);
}
}
}
}
\ No newline at end of file
// 部件样式汇总 // 部件样式汇总
@use './search-form.scss'; @use './search-form.scss';
\ No newline at end of file @use './app-menu.scss';
\ No newline at end of file
...@@ -39,12 +39,12 @@ const collapsedChange = () => { ...@@ -39,12 +39,12 @@ const collapsedChange = () => {
</script> </script>
<template> <template>
<AppDefaultIndexViewLayout :class="['app-index-view', state.viewSysCss]" :menuAlign="state.menuAlign" :collapsed="collapsed"> <AppDefaultIndexViewLayout :class="['app-index-view', state.viewSysCss]" :showCaptionBar="state.showCaptionBar" :menuAlign="state.menuAlign" :collapsed="collapsed">
<template #caption> <template #caption>
<div class="index-view-header"> <div class="index-view-header">
\{{state.viewCaption}} \{{state.viewCaption}}
<MenuUnfoldOutlined <MenuUnfoldOutlined
v-if="collapsed" v-if="collapsed && Object.is(state.menuAlign,'LEFT')"
class="trigger" class="trigger"
@click="collapsedChange" @click="collapsedChange"
/> />
......
...@@ -20,15 +20,22 @@ interface CtrlEmit { ...@@ -20,15 +20,22 @@ interface CtrlEmit {
} }
const emit = defineEmits <CtrlEmit> (); const emit = defineEmits <CtrlEmit> ();
const { state, menuSelect } = new MenuControl(ctrlState, props, emit).moduleInstall(); const { state, onMenuSelect } = new MenuControl(ctrlState, props, emit).moduleInstall();
// 暴露内部状态及能力 // 暴露内部状态及能力
defineExpose({ state, name: '{{ctrl.name}}' }); defineExpose({ state, name: '{{ctrl.name}}' });
</script> </script>
<template> <template>
<a-menu class="app-menu{{#if ctrl.psSysCss}} {{ctrl.psSysCss.cssName}}{{/if}}" v-model:openKeys="state.defaultOpens" v-model:selectedKeys="state.defaultSelect" <div v-if="Object.is('CENTER', state.menuAlign)" class="app-menu app-menu--center{{#if ctrl.psSysCss}} {{ctrl.psSysCss.cssName}}{{/if}}">
:mode="Object.is('LEFT', state.menuAlign) ? 'inline' : 'horizontal'" @select="menuSelect"> <a-card v-for="(menu,index) in state.menus" v-show="!menu.hidden" :key="index" class="app-menu__card" :title="menu.caption">
<a-space :size="24">
<a-button v-for="item in menu.items" size="large" @click="onMenuSelect({key: item.name})">\{{item.caption}}</a-button>
</a-space>
</a-card>
</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">
<AppMenuItem :items="state.menus" :collapsed="collapsed" /> <AppMenuItem :items="state.menus" :collapsed="collapsed" />
</a-menu> </a-menu>
</template> </template>
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册