提交 19a9d975 编写于 作者: Mosher's avatar Mosher

add:新增选择视图支持

上级 2349b784
......@@ -3,3 +3,4 @@ export * from './main-view'
export * from './edit-view'
export * from './index-view'
export * from './grid-view'
export * from './pickup-view'
\ No newline at end of file
export { PickupView } from './pickup-view';
export { PickupViewProps } from './pickup-view-prop';
export { PickupViewState } from './pickup-view-state';
\ No newline at end of file
import { MainViewProps } from "@ibiz-core";
/**
* @description 选择视图props
* @export
* @interface PickupViewProps
* @extends {MainViewProps}
*/
export interface PickupViewProps extends MainViewProps { }
\ No newline at end of file
import { ControlAction, MainViewState } from '@ibiz-core';
/**
* @description 选择视图状态
* @export
* @interface MainViewState
* @extends {ViewStateBase}
*/
export interface PickupViewState extends MainViewState {
}
import { MainView } from "../main-view";
import { PickupViewProps } from "./pickup-view-prop";
import { PickupViewState } from "./pickup-view-state";
/**
* @description 选择视图
* @export
* @class PickupView
* @extends {MainView}
*/
export class PickupView extends MainView {
/**
* @description 视图状态
* @type {PickupViewState}
* @memberof PickupView
*/
public declare viewState: PickupViewState;
/**
* @description 使用加载功能模块
* @param {PickupViewProps} props 传入的props
* @memberof PickupView
*/
public useLoad(props: PickupViewProps) {
const { viewSubject } = this.viewState;
onMounted(() => {
viewSubject.next({ tag: 'grid', action: "load", data: {} })
})
}
/**
* @description 安装视图所有功能模块的方法
* @param {PickupViewProps} props 传入的Props
* @param {Function} [emit] [emit] 事件
* @return {*}
* @memberof PickupView
*/
public moduleInstall(props: PickupViewProps, emit?: Function) {
const superParams = super.moduleInstall(props, emit);
this.useLoad(props);
return {
...superParams,
state: this.viewState,
};
}
}
\ No newline at end of file
......@@ -3,3 +3,4 @@ export * from './main-control'
export * from './form-control'
export * from './menu-control'
export * from './grid-control'
export * from './pickupviewpanel-control'
\ No newline at end of file
export { PickupViewPanelControlProps } from './pickupviewpanel-control-prop';
export { PickupViewPanelControlState } from './pickupviewpanel-control-state';
export { PickupViewPanelControl } from './pickupviewpanel-control';
\ No newline at end of file
import { MainControlProps } from "@ibiz-core";
/**
* @description 选择视图面板部件参数
* @export
* @interface PickupViewPanelControlProps
* @extends {MainControlProps}
*/
export interface PickupViewPanelControlProps extends MainControlProps {
}
\ No newline at end of file
import { IParam, MainControlState } from '@ibiz-core';
/**
* @description 选择视图面板通讯对象
* @export
* @interface PickupViewPanelControlState
* @extends {MainControlState}
*/
export interface PickupViewPanelControlState extends MainControlState {
/**
* @description 是否单选
* @type {boolean}
* @memberof PickupViewPanelControlState
*/
isSingleSelect: boolean;
/**
* @description 是否显示按钮
* @type {boolean}
* @memberof PickupViewPanelControlState
*/
isShowButton: boolean;
/**
* @description 选中数据字符
* @type {string}
* @memberof PickupViewPanelControlState
*/
selectedData: string;
}
\ No newline at end of file
import { Ref, ref } from 'vue';
import { IActionParam, MainControl } from '@ibiz-core';
import { PickupViewPanelControlProps } from './pickupviewpanel-control-prop';
import { PickupViewPanelControlState } from './pickupviewpanel-control-state';
/**
* @description 选择视图面板部件
* @export
* @class PickupViewPanelControl
* @extends {MainControl}
*/
export class PickupViewPanelControl extends MainControl {
/**
* @description 部件状态
* @type {FormControlState}
* @memberof FormControl
*/
public declare controlState: PickupViewPanelControlState;
/**
* @description 是否初始化完成
* @type {Ref<boolean>}
* @memberof PickupViewPanelControl
*/
public inited: Ref<boolean> = ref(false);
public viewdata: string = '';
public viewparam: string = '';
/**
* @description 根据props设置部件state
* @param {PickupViewPanelControlProps} props
* @memberof PickupViewPanelControl
*/
public setState(props: PickupViewPanelControlProps) {
super.setState(props);
this.controlState.isSingleSelect = toRef(props, 'isSingleSelect');
this.controlState.isShowButton = toRef(props, 'isShowButton');
this.controlState.selectedData = toRef(props, 'selectedData');
}
/**
* @description
* @param {PickupViewPanelControlProps} props
* @memberof PickupViewPanelControl
*/
public useLoad(props: PickupViewPanelControlProps) {
const { viewSubject, controlName, context, viewParams } = this.controlState;
// 订阅viewSubject,监听load行为
if(viewSubject){
let subscription = viewSubject.subscribe(({ tag, action, data }: IActionParam)=>{
if(Object.is(controlName, tag) && Object.is("load", action) ){
this.viewdata = JSON.stringify(context);
this.viewparam = JSON.stringify(viewParams);
this.inited.value = true;
}
})
// 部件卸载时退订viewSubject
onUnmounted(()=>{
subscription.unsubscribe();
})
}
}
/**
* @description 安装部件所有功能模块的方法
* @param {PickupViewPanelControlProps} props 传入的Props
* @param {Function} [emit]
* @return {*}
* @memberof FormControl [emit] 事件
*/
public moduleInstall(props: PickupViewPanelControlProps, emit?: Function) {
const superParams = super.moduleInstall(props, emit);
return {
...superParams,
inited: this.inited,
viewdata: this.viewdata,
viewparam: this.viewparam,
state: this.controlState
};
}
}
\ No newline at end of file
export const ViewConfig = {
viewCodeName: '{{page.codeName}}',
viewName: '{{page.name}}',
viewCaption: '{{page.caption}}',
{{#page.ctrls}}
{{#eq controlType "TOOLBAR"}}
{{lowerCase codeName}}:{
name:'{{name}}',
items:[
{{#pSDEToolbarItems}}
{ name:'{{name}}',caption:'{{caption}}',groupExtractMode:'{{groupExtractMode}}',itemType:'{{itemType}}',noPrivDisplayMode:'{{noPrivDisplayMode}}',showIcon:{{showIcon}},showCaption:{{showCaption}},tooltip:'{{tooltip}}' },
{{/pSDEToolbarItems}}
]
},
{{/eq}}
{{#eq controlType "PICKUPVIEWPANEL"}}
{{lowerCase codeName}}:{
name:'{{name}}',
codeName:'{{codeName}}',
action:{
'createAction': 'Create'
}
},
{{/eq}}
{{/page.ctrls}}
};
\ No newline at end of file
<script setup lang="ts">
import { Subject } from 'rxjs';
import { PickupView, IActionParam, IParam } from '@ibiz-core';
import { ViewConfig } from './{{page.codeName.spinalCase}}-config';
// props声明和默认值处理
interface Props {
context: IParam;
viewParams?: IParam;
openType?: "ROUTE" | "MODAL" | "EMBED";
viewSubject?: Subject<IActionParam>;
}
const props = withDefaults(defineProps<Props>(), {
// 设定默认值,可选属性可以在这初始化
viewSubject: () => new Subject<IActionParam>()
})
// emit声明
interface ViewEmit {
(name: "viewEvent", value: IActionParam): void;
}
const emit = defineEmits<ViewEmit>();
// 安装功能模块,提供状态和能力方法
const { state } = new PickupView(ViewConfig).moduleInstall(props);
</script>
<template>
<IbizDefaultViewLayout class="ibiz-pickup-view">
<template v-slot:header-left>
<IbizIconText class="ibiz-view__caption" size="large" :text="state.viewCaption" />
</template>
<template v-slot:header-right>
{{#page.ctrls}}
{{#eq controlType "TOOLBAR"}}
<IbizToolbar
:toolbarModel="state.{{lowerCase codeName}}"
@toolbarEvent="handleToolbarEvent"
:context="state.context"
:viewParams="state.viewParams"/>
{{/eq}}
{{/page.ctrls}}
</template>
</IbizDefaultViewLayout>
</template>
\ No newline at end of file
import {{ctrl.codeName}}PickupViewPanel from "./{{ctrl.codeName.spinalCase}}-pickupviewpanel.vue";
export { {{ctrl.codeName}}PickupViewPanel };
export const CtrlConfig = {
controlCodeName: '{{ctrl.codeName}}',
controlName: '{{ctrl.name}}',
data: {},
embeddedView: {
{{#if ctrl.embeddedPSAppDEView}}
viewName: '{{ctrl.embeddedPSAppDEView.codeName}}'
{{/if}}
}
};
\ No newline at end of file
<script setup lang="ts">
import { Subject } from 'rxjs';
import { IActionParam, IParam, ControlAction, PickupViewPanelControl } from '@ibiz-core';
import { CtrlConfig } from './{{ctrl.codeName.spinalCase}}-pickupviewpanel-config';
interface Props {
context: IParam;
viewParams?: IParam;
controlAction: ControlAction;
showBusyIndicator?: boolean;
isSingleSelect?: boolean;
viewMode?: number;
selectedData?: string;
isShowButton?: boolean;
viewSubject: Subject<IActionParam>;
}
const props = withDefaults(defineProps < Props > (), {
viewSubject: () => new Subject < IActionParam > (),
viewMode: 0,
isSingleSelect: false,
isShowButton: true,
showBusyIndicator: true,
})
// emit声明
interface CtrlEmit {
(name: "ctrlEvent", value: IActionParam): void;
}
const emit = defineEmits < CtrlEmit > ();
// 安装功能模块,提供状态和能力方法
const { state, inited, viewdata, viewparam } = new PickupViewPanelControl(CtrlConfig).moduleInstall(props);
</script>
<template>
<div class="ibiz-pickupviewpanel">
<component
v-if="inited && state.embeddedView && state.embeddedView.viewName"
:if="state.embeddedView.viewName"
:viewdata="viewdata"
:viewparam="viewparam"
:isSingleSelect="state.isSingleSelect"
:isShowButton="state.isShowButton"
:selectedData="state.selectedData"
></component>
</div>
</template>
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册