提交 bfc30869 编写于 作者: Shine-zwj's avatar Shine-zwj

update:更新

上级 da19e89b
{{#*inline "FORMPAGE"}}{{>@macro/components/form-page.hbs}}{{/inline}}
{{#*inline "GROUPPANEL"}}{{>@macro/components/form-group.hbs}}{{/inline}}
{{#*inline "FORMITEM"}}{{>@macro/components/form-item.hbs}}{{/inline}}
{{#*inline "TEXTBOX"}}{{>@macro/components/input.hbs}}{{/inline}}
{{#*inline "NUMBER"}}{{>@macro/components/input.hbs}}{{/inline}}
{{#*inline "PASSWORD"}}{{>@macro/components/input.hbs}}{{/inline}}
{{#*inline "TEXTAREA"}}{{>@macro/components/input.hbs}}{{/inline}}
{{#*inline "SPAN"}}{{>@macro/components/span.hbs}}{{/inline}}
{{#*inline "DROPDOWNLIST"}}{{>@macro/components/dropdownList.hbs}}{{/inline}}
\ No newline at end of file
<AppDropdownList
name="{{item.codeName}}"
{{!-- :value="data.{{item.psEditor.name}}" --}}
:data="data"
{{#if item.psEditor.codeList}}
codeListTag="{{item.psEditor.codeList.codeListTag}}"
codeListType="{{item.psEditor.codeList.codeListType}}"
valueSeparator="{{item.psEditor.codeList.valueSeparator}}"
{{/if}}
{{#if item.psEditor.getPlaceHolder}}
placeholder="{{item.psEditor.getPlaceHolder}}"
{{/if}}
{{#if item.psEditor.disabled}}
disabled="{{item.psEditor.disabled}}"
{{/if}}
{{#if item.psEditor.getEditorParams.multiple}}
:multiple="{{item.psEditor.getEditorParams.multiple}}"
{{/if}}
{{#if item.psEditor.getPSNavigateContexts}}
localContext="{{item.psEditor.getPSNavigateContexts}}"
{{/if}}
{{#if item.psEditor.getPSNavigateParams}}
localParam="{{item.psEditor.getPSNavigateParams}}"
{{/if}}
:contextProp="state.context"
:viewParamsProp="state.viewParams"/>
{{#*inline "FORMPAGE"}}{{>@macro/form-detail/form-page.hbs}}{{/inline}}
{{#*inline "GROUPPANEL"}}{{>@macro/form-detail/form-group.hbs}}{{/inline}}
{{#*inline "FORMITEM"}}{{>@macro/form-detail/form-item.hbs}}{{/inline}}
{{#*inline "TEXTBOX"}}{{>@macro/form-detail/input.hbs}}{{/inline}}
{{#*inline "NUMBER"}}{{>@macro/form-detail/input.hbs}}{{/inline}}
{{#*inline "PASSWORD"}}{{>@macro/form-detail/input.hbs}}{{/inline}}
{{#*inline "TEXTAREA"}}{{>@macro/form-detail/input.hbs}}{{/inline}}
{{#*inline "SPAN"}}{{>@macro/form-detail/span.hbs}}{{/inline}}
{{#*inline "DROPDOWNLIST"}}{{>@macro/form-detail/dropdownList.hbs}}{{/inline}}
\ No newline at end of file
<AppInput
{{#if item.psEditor.getPlaceHolder}}
placeholder="{{item.psEditor.getPlaceHolder}}"
{{/if}}
{{#if item.psEditor.disabled}}
disabled="{{item.psEditor.disabled}}"
{{/if}}
{{#if item.psEditor.isReadOnly}}
:readonly="{{item.psEditor.isReadOnly}}"
{{/if}}
{{#if item.psEditor.getEditorParams.max}}
:max="{{item.psEditor.getEditorParams.max}}"
{{/if}}
{{#if item.psEditor.getEditorParams.min}}
:max="{{item.psEditor.getEditorParams.min}}"
{{/if}}
{{#if item.psEditor.getEditorParams.precision}}
:precision="{{item.psEditor.getEditorParams.precision}}"
{{/if}}
{{#if item.psEditor.getEditorParams.maxLength}}
:maxLength="{{item.psEditor.maxLength}}"
{{/if}}
{{#eq item.psEditor.editorType "TEXTBOX"}}
type="text"
{{/eq}}
{{#eq item.psEditor.editorType "NUMBER"}}
type="number"
{{/eq}}
{{#eq item.psEditor.editorType "PASSWORD"}}
type="password"
{{/eq}}
{{#eq item.psEditor.editorType "TEXTAREA"}}
type="textarea"
{{/eq}}
{{!-- :value="data.{{item.psEditor.name}}" --}}
name="{{item.codeName}}"/>
<AppSpan
name="{{item.codeName}}"
{{!-- :value="data.{{item.psEditor.name}}" --}}
value="标签测试"
{{#if item.psEditor.codeList}}
codeListTag="{{item.psEditor.codeList.codeListTag}}"
codeListType="{{item.psEditor.codeList.codeListType}}"
{{/if}}
{{#if item.getDataType}}
dataType="{{item.getDataType}}"
{{/if}}
{{#if item.psEditor.getEditorParams.unitName}}
unitName="{{item.psEditor.getEditorParams.unitName}}"
{{/if}}
{{#if item.psEditor.getEditorParams.valueFormat}}
valueFormat="{{item.psEditor.getEditorParams.valueFormat}}"
{{/if}}
{{#if item.psEditor.getPrecision}}
:precision="{{item.psEditor.getPrecision}}"
{{/if}}
{{#if item.psEditor.getPSNavigateContexts}}
localContext="{{item.psEditor.getPSNavigateContexts}}"
{{/if}}
{{#if item.psEditor.getPSNavigateParams}}
localParam="{{item.psEditor.getPSNavigateParams}}"
{{/if}}
:contextProp="state.context"
:viewParamsProp="state.viewParams"/>
{{#*inline "MENUITEM"}}{{>@macro/menu-detail/menu-item.hbs}}{{/inline}}
{
name: {{item.name}},
caption: {{item.caption}},
itemType: {{item.itemType}},
expanded: {{item.expanded}},
tooltip: {{item.tooltip}},
funcTag: {{#if item.pSAppFunc}}{{item.pSAppFunc.id}}{{else}}''{{/if}},
hidden: {{#if item.hidden}}true{{else}}false{{/if}},
disableClose: {{#if item.disableClose}}true{{else}}false{{/if}},
{{#if item.counterId}}
counterId: {{item.counterId}},
{{/if}}
{{#if item.accessKey}}
resourceTag: {{item.accessKey}},
{{/if}}
{{#if item.pSSysImage}}
{{#if item.pSSysImage.cssClass}}
iconCls: {{item.pSSysImage.cssClass}},
{{/if}}
{{#if item.pSSysImage.imagePath}}
icon: {{item.pSSysImage.imagePath}},
{{/if}}
{{/if}}
{{#if item.pSNavigateContexts}}
navContext: {{item.pSNavigateContexts}},
{{/if}}
{{#if item.pSAppMenuItems}}
items: [
{{#each item.pSAppMenuItems as | item |}}
{{>(lookup . 'MENUITEM') item=item}}
{{/each}}
],
{{/if}}
},
\ No newline at end of file
<script setup lang="ts">
// This starter template is using Vue 3 <script setup> SFCs
// Check out https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup
import { JobsInfoEditView } from '@page/jobs-info/jobs-info-edit-view';
import { PlatformIndexView } from '@page/default/platform-index-view';
</script>
<template>
<JobsInfoEditView :context="{}"/>
<PlatformIndexView :context="{}"/>
</template>
<style>
......
......@@ -10,21 +10,21 @@ const props = withDefaults(defineProps<MenuItemProps>(), {});
</script>
<template>
<template v-for="item in items" :key="item.id">
<template v-for="item in items" :key="item.name">
<template v-if="!item.items">
<a-menu-item v-if="!item.hidden" :key="item.id">
<a-menu-item v-if="!item.hidden" :key="item.name">
<template #icon>
<UserOutlined />
</template>
{{ item.title }}
{{ item.caption }}
</a-menu-item>
</template>
<template v-else>
<a-sub-menu v-if="!item.hidden" :key="item.id">
<a-sub-menu v-if="!item.hidden" :key="item.name">
<template #icon>
<UserOutlined />
</template>
<template #title>{{ item.title }}</template>
<template #title>{{ item.caption }}</template>
<app-menu-item :items="item.items" />
</a-sub-menu>
</template>
......
import { ViewPropsBase } from "@ibiz-core";
/**
* @description 首页视图props
* @export
* @interface IndexViewProps
* @extends {ViewPropsBase}
*/
export interface IndexViewProps extends ViewPropsBase {
}
\ No newline at end of file
import { ViewStateBase } from "@ibiz-core";
/**
* @description 首页视图state
* @export
* @interface IndexViewState
* @extends {ViewStateBase}
*/
export interface IndexViewState extends ViewStateBase {
}
\ No newline at end of file
import { IndexViewProps, IndexViewState, ViewBase } from '@ibiz-core';
/**
* @description 首页视图
* @export
* @class IndexView
* @extends {ViewBase}
*/
export class IndexView extends ViewBase {
/**
* 视图状态
*/
public declare viewState: IndexViewState;
/**
* 使用加载功能模块
* @param props 传入的props
*/
public useLoad(props: IndexViewProps){
const { viewSubject } = this.viewState;
onMounted(()=>{
viewSubject.next({tag: 'menu', action: "load", data: {}})
})
}
/**
* 安装视图所有功能模块的方法
* @param props 传入的Props
* @param [emit] 事件
*/
public moduleInstall(props: IndexViewProps, emit?: Function) {
const superParams = super.moduleInstall(props, emit);
this.useLoad(props);
return {
...superParams,
state: this.viewState,
};
}
}
export * from './index-view-prop'
export * from './index-view-state'
export * from './index-view'
\ No newline at end of file
export * from './view-base'
export * from './main-view'
export * from './edit-view'
\ No newline at end of file
export * from './edit-view'
export * from './index-view'
\ No newline at end of file
export * from './control-base'
export * from './main-control'
export * from './form-control'
\ No newline at end of file
export * from './form-control'
export * from './menu-control'
\ No newline at end of file
export * from './menu-control-prop'
export * from './menu-control-state'
export * from './menu-control'
\ No newline at end of file
import { ControlPropsBase, IParam } from "@ibiz-core";
/**
* @description 菜单部件props
* @export
* @interface MenuControlProps
* @extends {ControlPropsBase}
*/
export interface MenuControlProps extends ControlPropsBase {
/**
* @description 菜单方向
* @type {("LEFT" | "TOP" | "CENTER" | "TABEXP_LEFT" | "TABEXP_TOP" | "TABEXP_RIGHT" | "TABEXP_BOTTOM" | "NONE")}
* @memberof MenuControlProps
*/
menuAlign: "LEFT" | "TOP" | "CENTER" | "TABEXP_LEFT" | "TABEXP_TOP" | "TABEXP_RIGHT" | "TABEXP_BOTTOM" | "NONE";
/**
* @description 默认视图
* @type {string}
* @memberof MenuControlProps
*/
defaultView: string;
/**
* @description 菜单收缩状态
* @type {boolean}
* @memberof MenuControlProps
*/
collapsed: boolean;
}
\ No newline at end of file
import { IParam, ControlStateBase } from '@ibiz-core';
/**
* @description 菜单部件state
* @export
* @interface MenuControlState
* @extends {ControlStateBase}
*/
export interface MenuControlState extends ControlStateBase {
/**
* @description 菜单集合
* @type {IParam[]}
* @memberof MenuControlState
*/
menus: IParam[];
/**
* @description 应用功能集合
* @type {IParam[]}
* @memberof MenuControlState
*/
funcs: IParam[];
/**
* @description 菜单默认展开集合
* @type {string[]}
* @memberof MenuControlState
*/
defaultOpens: string[];
/**
* @description 菜单默认选中集合
* @type {string[]}
* @memberof MenuControlState
*/
defaultSelect: string[];
/**
* @description 权限服务
* @type {IParam}
* @memberof MenuControlState
*/
authService: IParam;
/**
* @description 默认打开视图
* @type {string}
* @memberof MenuControlState
*/
defaultView: string;
/**
* @description 菜单方向
* @type {("LEFT" | "TOP" | "CENTER" | "TABEXP_LEFT" | "TABEXP_TOP" | "TABEXP_RIGHT" | "TABEXP_BOTTOM" | "NONE")}
* @memberof MenuControlState
*/
menuAlign: "LEFT" | "TOP" | "CENTER" | "TABEXP_LEFT" | "TABEXP_TOP" | "TABEXP_RIGHT" | "TABEXP_BOTTOM" | "NONE";
}
import { MenuControlProps, MenuControlState, IActionParam, ControlBase, IParam } from '@ibiz-core';
/**
* @description 菜单部件
* @export
* @class MenuControl
* @extends {ControlBase}
*/
export class MenuControl extends ControlBase {
/**
* 部件状态
*/
public declare controlState: MenuControlState;
/**
* @description 根据props调整设置部分部件基类
* @param {MenuControlProps} props
* @memberof MenuControl
*/
public setState(props: MenuControlProps) {
super.setState(props);
this.controlState.defaultView = toRef(props, 'defaultView') as any;
this.controlState.menuAlign = toRef(props, 'menuAlign') as any;
}
/**
* 修改表单的数据对象的某一属性的值。
* 可通过模块扩展增加一系列相关后续操作。
* @param name 属性名称
* @param value 属性值
*/
public async formDataChange(name: string, value: any){
this.controlState.data[name] = value;
}
/**
* @description 计算有效菜单项
* @param {IParam[]} items 菜单项集合
* @memberof MenuControl
*/
public computedEffectiveMenus(items: IParam[]) {
items.forEach((item: IParam) => {
const { authService } = this.controlState;
if (!authService?.getMenusPermission?.(item)) {
item.hidden = true;
}
if (item.items?.length > 0) {
this.computedEffectiveMenus(item.items);
}
})
}
/**
* @description 处理默认展开项
* @param {IParam[]} items
* @memberof MenuControl
*/
public handleDefaultOpens(items: IParam[], defaultOpens: string[]) {
items.forEach((item: any) => {
if (item.expanded) {
defaultOpens = [...defaultOpens,item.id];
}
if (item.items?.length > 0) {
this.handleDefaultOpens(item.items, defaultOpens);
}
});
}
/**
* @description 处理菜单默认选中
* @memberof MenuControl
*/
public handleDefaultSelect() {
const { route, funcs, defaultView, menuAlign } = this.controlState;
const defaultSelectRef = toRef(this.controlState, 'defaultSelect');
const dataRef = toRef(this.controlState, 'menus');
if (route?.matched?.length == 2) {
const [{ }, matched] = route.matched;
const appFunc: any = funcs.find((func: any) => Object.is(func.routePath, matched.path) && Object.is(func.funcType, 'APPVIEW'));
if (appFunc) {
this.computeMenuSelect(dataRef.value, appFunc.funcTag);
}
return;
} else if (defaultView) {
const appFunc: any = funcs.find((func: any) => Object.is(func.appView, defaultView) && Object.is(func.funcType, 'APPVIEW'));
if (appFunc) {
this.computeMenuSelect(dataRef.value, appFunc.funcTag);
}
if (!defaultSelectRef.value[0] && Object.is(menuAlign, "NONE")) {
// TODO
return;
}
} else {
this.computeMenuSelect(dataRef.value, '');
}
let item = this.compute(dataRef.value, defaultSelectRef.value[0]);
if (Object.keys(item).length > 0 && !item.hidden) {
this.menuClick(item);
}
}
/**
* @description 计算菜单选中项
* @param {IParam[]} menus 菜单及he
* @param {string} funcTag 应用标识
* @return {*}
* @memberof MenuControl
*/
public computeMenuSelect(menus: IParam[], funcTag: string) {
const { funcs } = this.controlState;
const defaultSelectRef = toRef(this.controlState, 'defaultSelect');
const defaultOpensRef = toRef(this.controlState, 'defaultOpens');
return menus.some((item: any) => {
if (Object.is(funcTag, '') && item.funcTag && item.openDefault && !item.hidden) {
const appFunc = funcs?.find((func: any) => Object.is(func.funcTag, item.funcTag));
if (appFunc) {
defaultSelectRef.value = [item.id];
return true;
}
}
if (item.funcTag && Object.is(item.funcTag, funcTag)) {
defaultSelectRef.value = [item.id];
return true;
}
if (item.items?.length > 0) {
const state = this.computeMenuSelect(item.items, funcTag);
if (state) {
const defaultOpen = defaultOpensRef.value?.find((open: string) => Object.is(item.id, open));
if (!defaultOpen) {
defaultOpensRef.value = [...defaultOpensRef.value, item.id];
}
return true;
}
}
return false;
});
}
/**
* @description 获取指定菜单项数据
* @param {IParam[]} menus 菜单集合
* @param {string} id 指定菜单标识
* @return {*}
* @memberof MenuControl
*/
public compute(menus: IParam[], id: string) {
const item: any = {};
menus.some((_item: any) => {
if (Object.is(_item.id, id)) {
Object.assign(item, _item);
return true;
}
if (_item.items?.length > 0) {
const subItem = this.compute(_item.items, id);
if (Object.keys(subItem).length > 0) {
Object.assign(item, subItem);
return true;
}
}
return false;
});
return item;
}
/**
* @description 菜单项点击
* @param {IParam} item 菜单项数据
* @memberof MenuControl
*/
public menuClick(item: IParam) {
console.log(item);
}
/**
* 使用加载功能模块
* @param props 传入的props
*/
public useLoad(props: MenuControlProps){
const { viewSubject, controlName } = this.controlState;
/**
* 加载方法
* @param [opt={}]
*/
const load = async (opt: any = {})=>{
const dataRef = toRef(this.controlState, 'menus');
const defaultOpensRef = toRef(this.controlState, 'defaultOpens');
this.computedEffectiveMenus(dataRef.value);
this.handleDefaultOpens(dataRef.value, defaultOpensRef.value);
this.handleDefaultSelect();
}
// 订阅viewSubject,监听load行为
if(viewSubject){
let subscription = viewSubject.subscribe(({ tag, action, data }: IActionParam)=>{
if(Object.is(controlName, tag) && Object.is("load", action) ){
load(data);
}
})
// 部件卸载时退订viewSubject
onUnmounted(()=>{
subscription.unsubscribe();
})
}
return {
load: load
}
}
public menuSelect($event: any) {
console.log($event);
const dataRef = toRef(this.controlState, 'menus');
let item = this.compute(dataRef.value, '');
if (Object.keys(item).length > 0) {
this.menuClick(item);
}
}
/**
* 安装部件所有功能模块的方法
* @param props 传入的Props
* @param [emit] 事件
*/
public moduleInstall(props: MenuControlProps, emit?: Function) {
const superParams = super.moduleInstall(props, emit);
const { load } = this.useLoad(props)
const menuSelect = this.menuSelect.bind(this);
this.menuSelect =($event: any) => {
menuSelect($event)
}
return {
...superParams,
state: this.controlState,
load,
menuSelect: this.menuSelect,
};
}
}
<script setup lang="ts">
import { Subject } from 'rxjs'
import { EditView, IActionParam, IParam } from '@ibiz-core'
import { ViewConfig } from './{{page.codeName.spinalCase}}-config'
import { Ref } from 'vue';
import { IndexView, IActionParam, IParam } from '@ibiz-core';
import { ViewConfig } from './{{page.codeName.spinalCase}}-config';
import { IbizDefaultIndexViewLayout } from '@components';
{{#page.ctrls}}
{{#eq controlType "APPMENU"}}
......@@ -17,11 +18,9 @@ interface Props {
}
const props = withDefaults(defineProps<Props>(), {
// 设定默认值,可选属性可以在这初始化
viewSubject: () => new Subject<IActionParam>()
})
// emit声明
interface ViewEmit {
(name: "CLOSE", value: IActionParam): void;
(name: "VIEWCHANGE", value: IActionParam): void;
......@@ -30,15 +29,17 @@ interface ViewEmit {
const emit = defineEmits<ViewEmit>();
// 安装功能模块,提供状态和能力方法
//const { state } = new EditView(ViewConfig).moduleInstall(props);
const { state } = new IndexView(ViewConfig).moduleInstall(props, emit);
const collapsed: Ref<boolean> = ref(false);
</script>
<template>
<IbizDefaultIndexViewLayout class="ibiz-index-view" menuAlign="LEFT" :collapsed="collapsed">
<IbizDefaultIndexViewLayout class="ibiz-index-view" :menuAlign="state.menuAlign" :collapsed="collapsed">
<template #header>
<div class="index-view-header">
{{{{raw-loud}}}}
{{state.viewCaption}}
{{{{/raw-loud}}}}
<MenuUnfoldOutlined
v-if="collapsed"
class="trigger"
......@@ -52,13 +53,13 @@ const collapsed: Ref<boolean> = ref(false);
</template>
<template #menu>
<{{#page.ctrls}}{{#eq controlType "APPMENU"}}{{codeName}}Menu{{/eq}}{{/page.ctrls}}
ref="menu"
name="menu"
menuAlign="LEFT"
:viewState="viewState"
:contextProp="context"
:viewParamsProp="viewParams">
</{{#page.ctrls}}{{#eq controlType "APPMENU"}}{{codeName}}Menu{{/eq}}{{/page.ctrls}}>
:context="state.context"
:collapsed="collapsed"
:menuAlign="state.menuAlign"
:defaultView="state.defaultView"
:viewParams="state.viewParams"
:viewSubject="state.viewSubject"
></{{#page.ctrls}}{{#eq controlType "APPMENU"}}{{codeName}}Menu{{/eq}}{{/page.ctrls}}>
</template>
<template #content>
<router-view />
......
{{>@macro/menu-detail/include-menu.hbs}}
export const CtrlConfig = {
ctrlCodeName: '{{ctrl.codeName}}',
ctrlName: '{{ctrl.name}}',
ctrlCaption: '{{ctrl.caption}}',
controlCodeName: '{{ctrl.codeName}}',
controlName: '{{ctrl.name}}',
menus: [
{{#each ctrl.pSAppMenuItems as | item |}}
{{>(lookup . 'MENUITEM') item=item}},
{{/each}}
],
funcs: [
],
};
\ No newline at end of file
<script setup lang="ts">
import { getCurrentInstance, onBeforeMount, onUnmounted, Ref, ref } from "vue";
import { Subject, Subscription } from "rxjs";
import { CtrlConfig } from './{{ctrl.codeName.spinalCase}}-menu-config';
import { useContextParams, handleMenusResource, menuSelect } from "@core";
import { IParam, IActionParam } from "@ibiz-core";
import { Subject } from "rxjs";
import { CtrlConfig } from "./{{ctrl.codeName.spinalCase}}-menu-config";
import { IParam, IActionParam, MenuControl } from "@ibiz-core";
import { IbizMenuItem } from "@components";
import { useRoute, useRouter } from "vue-router";
interface MenuProps{
/**
* @description 部件名称
*/
name: string;
/**
* @description 传入上下文
*/
contextProp: IParam;
/**
* @description 传入视图参数
*/
viewParamsProp?: IParam;
/**
* @description 视图状态
*/
viewState: Subject<IActionParam>;
/**
* @description 菜单方向
*/
menuAlign: "LEFT" | "TOP" | "CENTER" | "TABEXP_LEFT" | "TABEXP_TOP" | "TABEXP_RIGHT" | "TABEXP_BOTTOM" | "NONE";
/**
* @description 默认视图
*/
interface Props{
context: IParam;
defaultView: string;
collapsed: boolean;
menuAlign: "LEFT" | "TOP" | "CENTER" | "TABEXP_LEFT" | "TABEXP_TOP" | "TABEXP_RIGHT" | "TABEXP_BOTTOM" | "NONE";
viewParams?: IParam;
viewSubject: Subject<IActionParam>;
}
const props = withDefaults(defineProps<MenuProps>(), {
const props = withDefaults(defineProps<Props>(), {
menuAlign: "LEFT",
collapsed: false,
});
const { context, viewParams } = useContextParams(props);
let viewStateEvent: Subscription | undefined;
const menu = getCurrentInstance()?.vnode;
defineExpose({
menu
})
/**
* @description 菜单项集合
*/
const menus: Ref<IParam[]> = ref([
{
id: "1",
title: "菜单项1",
expanded: true,
items: [
{
id: "3",
title: "菜单项3",
},
{
id: "4",
title: "编辑视图",
openDefault: true,
funcTag: "1",
},
]
},
{
id: "2",
title: "菜单项2",
}
]);
const defaultOpens: Ref<string[]> = ref([]);
const defaultSelect: Ref<string[]>= ref([]);
const router = useRouter();
const route = useRoute();
/**
* @description 应用功能集合
*/
const funcs: IParam[] = [{
funcTag: "1",
}];
const modelParam = {
funcs: funcs,
interface CtrlEmit {
(name: "Ctrl", value: IActionParam): void;
}
const emit = defineEmits<CtrlEmit>();
const runtimeParam = {
menus: menus,
context: context,
defaultView: props.defaultView,
authService: {},
defaultOpens: defaultOpens,
defaultSelect: defaultSelect,
viewParams: viewParams,
mode: props.menuAlign,
router: router,
route: route,
}
const onSelect = (item: any, key: any, selectedKeys: any) => {
menuSelect(modelParam, runtimeParam);
}
onBeforeMount(() => {
if (props.viewState) {
viewStateEvent = props.viewState.subscribe(({ tag, action, data }: IActionParam) => {
if (Object.is(tag, props.name)) {
switch (action) {
case 'load':
handleMenusResource(modelParam, runtimeParam);
break;
}
}
});
}
})
onUnmounted(() => {
if (viewStateEvent) {
viewStateEvent.unsubscribe();
}
})
const { state, menuSelect } = new MenuControl(CtrlConfig).moduleInstall(props, emit);
</script>
<template>
<a-menu
v-model:openKeys="defaultOpens"
v-model:selectedKeys="defaultSelect"
:mode="Object.is('LEFT', menuAlign) ? 'inline' : 'horizontal'"
@select="onSelect">
<IbizMenuItem :items="menus" />
v-model:openKeys="state.defaultOpens"
v-model:selectedKeys="state.defaultSelect"
:mode="Object.is('LEFT', state.menuAlign) ? 'inline' : 'horizontal'"
@select="menuSelect">
<IbizMenuItem :items="state.menus" />
</a-menu>
</template>
......
export const CtrlConfig = {
ctrlCodeName: '{{ctrl.codeName}}',
ctrlName: '{{ctrl.name}}',
ctrlCaption: '{{ctrl.caption}}',
controlCodeName: '{{ctrl.codeName}}',
controlName: '{{ctrl.name}}',
};
\ No newline at end of file
{{>@macro/components/include-ctrls.hbs}}
{{>@macro/form-detail/include-form.hbs}}
<script setup lang="ts">
import { Subject } from 'rxjs';
import { CtrlConfig } from './{{ctrl.codeName.spinalCase}}-form-config';
......@@ -10,7 +10,7 @@ interface Props {
viewParams?: IParam;
controlAction: ControlAction;
showBusyIndicator?: boolean;
viewSubject?: Subject<IActionParam>;
viewSubject: Subject<IActionParam>;
}
const props = withDefaults(defineProps<Props>(), {
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册