提交 fe3f56b6 编写于 作者: zhangkang's avatar zhangkang

update:选择视图

上级 9d1798e6
......@@ -15,6 +15,7 @@
{{/if}}
{{#if item.psEditor.psNavigateParams}}
localParam="{{> @macro/front-end/common/navparam.hbs appNavParams=item.psEditor.psNavigateParams}}"
{{!-- localParam="{{item.psEditor.psNavigateParams}}" --}}
{{/if}}
:context="state.context"
:viewParams="state.viewParams"
......@@ -26,7 +27,10 @@
{{!-- {{/each}} --}}
{{!-- deKeyField="{{item.psEditor.psAppDataEntity.codeName}}" --}}
{{/if}}
{{!-- :pickupView="getPickupView({{item.psEditor}})" --}}
{{!-- {{#if item.psEditor.pickuppsAppView }} --}}
{{!-- :pickupView="{{item.psEditor.pickuppsAppView}}" --}}
{{!-- {{/if}} --}}
pickUpView="ChartDataPickupView"
{{!-- :linkView="getLinkView({{item.psEditor}})" --}}
{{!-- :acParams="getAcParams({{item.psEditor}})" --}}
{{#if item.psEditor.psAppDEACMode.minorSortDir}}
......
......@@ -25,7 +25,7 @@ export const AppViewConfig:IParam = {
"iconCls": "{{appView.psSysImage.cssClass}}",
{{/if}}
"viewType": "{{appView.viewType}}",
"fileDir": "@page/{{#if psAppDataEntity}}{{spinalCase psAppDataEntity.codeName}}{{else}}default{{/if}}/{{spinalCase appView.codeName}}"
"fileDir": "@page/{{lowerCase app.codeName}}/{{spinalCase appView.codeName}}"
}{{#unless @last}},{{/unless}}
{{/each}}
}
\ No newline at end of file
<script setup lang="ts">
import { onBeforeMount, Ref, ref } from 'vue';
import { SearchOutlined, ExportOutlined } from '@ant-design/icons-vue';
import { deepCopy, IParam, IActionParam, EditorBase, IContext } from '@core';
import { deepCopy, IParam, IActionParam, EditorBase, IContext, PickupView } from '@core';
interface DataPickerProps {
/**
* @description 编辑器名称
......@@ -66,7 +66,7 @@ interface DataPickerProps {
/**
* @description 选择视图
*/
pickUpView?: IParam;
pickUpView?: string;
/**
* @description 链接视图
......@@ -195,13 +195,35 @@ const onSelect = (value: any) => {
fillPickUpData(selectItem);
};
const initValue = (data: any) => {
// todo
};
// 打开视图
const openView = () => {
if (!props.pickUpView) {
return;
}
const view = App.getViewInfo(props.pickUpView);
if (!view) {
return;
}
const subject = App.getOpenViewService().openView(view, {});
const subjectEvent = subject?.subscribe((data: any) => {
if (data?.ret == 'OK' && data.resultData) {
const value = initValue(data.resultData);
emit('editorEvent', { tag: props.valueItem, action: 'valueChange', data: value });
}
subjectEvent?.unsubscribe();
});
};
</script>
<template>
<template v-if="linkOnly" :class="['app-data-picker', `app-data-picker-${name}`]">
<a @click="openLinkView">\{{ value }}</a>
<a @click="openLinkView">{{ value }}</a>
</template>
<template v-else-if="!noAc && !isDropdown">
<template v-else-if="!isAC && !isDropdown">
<a-auto-complete
:class="['app-data-picker', `app-data-picker-${name}`]"
:allowClear="true"
......@@ -214,11 +236,11 @@ const onSelect = (value: any) => {
:defaultOpen="true"
>
<template #option="option">
<div @click="onSelect(option[deKeyField])">\{{ option[deMajorField] }}</div>
<div @click="onSelect(option[deKeyField])">{{ option[deMajorField] }}</div>
</template>
<a-input :placeholder="placeholder">
<template #suffix>
<search-outlined v-if="pickUpView && showButton" class="certain-category-icon" @click="openView" />
<search-outlined v-if="pickUpView" class="certain-category-icon" @click="openView" />
<export-outlined v-if="linkView" @click="openLinkView" />
</template>
</a-input>
......@@ -245,11 +267,11 @@ const onSelect = (value: any) => {
:placeholder="placeholder"
>
<template #suffixIcon>
<search-outlined v-if="pickUpView" @click="openPickUpView" />
<search-outlined v-if="pickUpView" @click="openPickUpView" />
<select-outlined v-if="linkView" @click="openLinkView" />
</template>
<a-select-option v-for="(item, index) in items" :key="index" :value="item[deKeyField]">
\{{ item[deMajorField] }}
{{ item[deMajorField] }}
</a-select-option>
</a-select>
</template>
......
<script setup lang="ts">
</script>
<template>
<IbizViewBaseLayout>
<template v-slot:header-left>
<slot name="caption" />
</template>
<template v-slot:header-right>
<slot name="toolbar" />
</template>
<template v-slot:header-bottom>
<slot name="topMessage" />
<slot name="searchForm" />
</template>
<template v-slot:body-top>
<slot name="bodyMessage" />
</template>
<slot />
<template v-slot:footer-content>
<slot name="bottomMessage" />
<slot name="footer" />
</template>
</IbizViewBaseLayout>
</template>
<style lang="scss">
</style>
\ No newline at end of file
<script setup lang="ts"></script>
<template>
<IbizViewBaseLayout>
<template v-slot:header-left>
<slot name="caption" />
</template>
<template v-slot:header-right>
<slot name="toolbar" />
</template>
<template v-slot:header-bottom>
<slot name="topMessage" />
<slot name="searchForm" />
</template>
<template v-slot:body-top>
<slot name="bodyMessage" />
</template>
<slot />
<template v-slot:footer-content>
<slot name="bottomMessage" />
<slot name="footer" />
</template>
</IbizViewBaseLayout>
</template>
<style lang="scss">
</style>
\ No newline at end of file
......@@ -133,7 +133,7 @@ export class AppActionBase {
if (Object.is(uiAction?.uILogicAttachMode, 'AFTER')) {
this.executeUILogic(uiAction, params);
}
// 后续界面行为 todo
// 后续界面行为
if (!uiAction.nextActionCodeName) {
return;
}
......
import { IActionParam } from "@core";
import { PickupView } from "../pickup-view";
import { PickupGridViewProps } from "./pickup-grid-view-prop";
import { PickupGridViewState } from "./pickup-grid-view-state";
......@@ -17,6 +18,7 @@ export class PickupGridView extends PickupView {
*/
public declare viewState: PickupGridViewState;
/**
* @description 使用加载功能模块
* @param {PickupGridViewProps} props 传入的props
......@@ -29,6 +31,25 @@ export class PickupGridView extends PickupView {
})
}
/**
* 部件事件
*
* @param {IActionParam} actionParam
* @memberof PickupGridView
*/
public handleCtrlEvent(actionParam: IActionParam) {
const { tag, action, data } = actionParam;
if (tag !== 'grid') {
return;
}
if (action === 'selectionChange') {
this.selectData = data;
this.emit('viewEvent', actionParam)
}
}
/**
* @description 安装视图所有功能模块的方法
* @param {PickupGridViewProps} props 传入的Props
......@@ -37,10 +58,12 @@ export class PickupGridView extends PickupView {
* @memberof PickupGridView
*/
public moduleInstall(props: PickupGridViewProps, emit?: Function) {
this.emit = emit;
const superParams = super.moduleInstall(props, emit);
this.useLoad(props);
return {
...superParams,
handleCtrlEvent: this.handleCtrlEvent.bind(this),
state: this.viewState,
};
}
......
import { IActionParam } from "@core";
import { MainView } from "../main-view";
import { PickupViewProps } from "./pickup-view-prop";
import { PickupViewState } from "./pickup-view-state";
......@@ -17,6 +18,9 @@ export class PickupView extends MainView {
*/
public declare viewState: PickupViewState;
public selectData: any[] = [];
/**
* @description 使用加载功能模块
* @param {PickupViewProps} props 传入的props
......@@ -42,8 +46,24 @@ export class PickupView extends MainView {
* @memberof PickupView
*/
public confirm() {
//todo
this.emit('viewEvent', { data: this.selectData, tag: '', action: 'close' })
}
public handleCtrlEvent(actionParam: IActionParam) {
debugger
const { tag, action, data } = actionParam;
// TODO
if (action === 'selectionChange') {
this.selectData = data;
this.emit('viewEvent', { data: this.selectData, tag: '', action: 'viewDataChange' })
}
if (action === 'close') {
this.emit('viewEvent', { data: this.selectData, tag: '', action: 'viewDataChange' })
}
}
/**
* @description 安装视图所有功能模块的方法
......@@ -58,6 +78,7 @@ export class PickupView extends MainView {
return {
...superParams,
state: this.viewState,
selectData: this.selectData,
cancel: this.cancel.bind(this),
confirm: this.confirm.bind(this)
};
......
......@@ -25,6 +25,13 @@ export class ViewBase {
this.viewState = reactive(options);
}
/**
* @description 事件
* @type {*}
* @memberof ViewBase
*/
emit: any;
/**
* @description 根据props调整设置部分视图基类
* @param {ViewPropsBase} props 传入参数
......@@ -124,6 +131,7 @@ export class ViewBase {
* @memberof ViewBase
*/
public moduleInstall(props: ViewPropsBase, emit?: Function) {
this.emit = emit?.bind(this);
this.setState(props);
this.useViewContextParams(props);
this.useCounterService(props);
......
......@@ -18,16 +18,6 @@ export class PickupViewPanelControl extends MainControl {
*/
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
......@@ -36,9 +26,6 @@ export class PickupViewPanelControl extends MainControl {
*/
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');
}
/**
......@@ -49,21 +36,34 @@ export class PickupViewPanelControl extends MainControl {
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;
if (viewSubject) {
let subscription = viewSubject.subscribe(({ tag, action, data }: IActionParam) => {
if (Object.is(controlName, tag) && Object.is("load", action)) {
}
})
// 部件卸载时退订viewSubject
onUnmounted(()=>{
onUnmounted(() => {
subscription.unsubscribe();
})
}
}
/**
* 部件事件
*
* @param {IActionParam} actionParam
* @memberof PickupViewPanelControl
*/
public handleViewEvent(actionParam: IActionParam) {
const { tag, action, data } = actionParam;
const { controlName } = this.controlState;
if (Object.is("selectionChange", action)) {
this.emit('ctrlEvent', { tag: controlName, action: action, data: data });
}
}
/**
* @description 安装部件所有功能模块的方法
* @param {PickupViewPanelControlProps} props 传入的Props
......@@ -75,9 +75,7 @@ export class PickupViewPanelControl extends MainControl {
const superParams = super.moduleInstall(props, emit);
return {
...superParams,
inited: this.inited,
viewdata: this.viewdata,
viewparam: this.viewparam,
handleViewEvent: this.handleViewEvent.bind(this),
state: this.controlState
};
}
......
import {{page.codeName}} from "./{{spinalCase page.codeName}}.vue";
export default {{page.codeName}};
......@@ -2,11 +2,14 @@
import { Subject } from 'rxjs';
import { PickupGridView, IActionParam, IParam, IContext } from '@core';
import { ViewConfig } from './{{spinalCase page.codeName}}-config';
{{#page.ctrls}}
{{#eq controlType "GRID"}}
import { {{codeName}}Grid } from '@widgets/{{spinalCase appEntity.codeName}}/{{spinalCase codeName}}-grid';
{{/eq}}
{{/page.ctrls}}
// todo 表格部件拿不到目前导入固定表格
import { MainGrid } from '@widgets/chart-data/main-grid';
{{#each page.controls as |control|}}
{{#if (eq control.controlType 'GRID') }}
import { {{control.codeName}}Grid } from '@widgets/{{spinalCase appEntity.codeName}}/{{spinalCase codeName}}-grid';
{{/if}}
{{/each}}
// props声明和默认值处理
interface Props {
......@@ -29,11 +32,11 @@ interface ViewEmit {
const emit = defineEmits<ViewEmit>();
// 安装功能模块,提供状态和能力方法
const { state } = new PickupGridView(ViewConfig).moduleInstall(props, emit);
const { state, confirm, handleCtrlEvent } = new PickupGridView(ViewConfig).moduleInstall(props, emit);
</script>
<template>
<IbizDefaultViewLayout class="ibiz-pickup-grid-view">
<IbizPickerUpGridViewLayout class="ibiz-pickup-grid-view">
<template v-slot:header-left>
<IbizIconText class="ibiz-view__caption" size="large" :text="state.viewCaption" />
</template>
......@@ -51,21 +54,15 @@ const { state } = new PickupGridView(ViewConfig).moduleInstall(props, emit);
></{{codeName}}Grid>
{{/eq}}
{{/page.ctrls}}
<template v-slot:footer>
<a-space class="ibiz-pickup-grid-view--footer">
<a-button @click="cancel">取消</a-button>
<a-button @click="confirm">确认</a-button>
</a-space>
</template>
</IbizDefaultViewLayout>
<MainGrid
:context="state.context"
:rowEditState="state.rowEditState"
:rowActiveMode="state.gridRowActiveMode"
:showBusyIndicator="true"
:viewParams="state.viewParams"
:controlAction="state.controlsAction.grid"
:viewSubject="state.viewSubject"
@ctrlEvent="handleCtrlEvent"
></MainGrid>
</IbizPickerUpGridViewLayout>
</template>
<style lang="scss">
.ibiz-pickup-grid-view {
position: relative;
.ibiz-pickup-grid-view--footer {
position: absolute;
bottom: 20px;
right: 35px;
}
}
</style>
\ No newline at end of file
import {{page.codeName}} from "./{{spinalCase page.codeName}}.vue";
export default {{page.codeName}};
......@@ -2,7 +2,11 @@
import { Subject } from 'rxjs';
import { PickupView, IActionParam, IParam, IContext } from '@core';
import { ViewConfig } from './{{spinalCase page.codeName}}-config';
{{#page.ctrls}}
{{#eq controlType "PICKUPVIEWPANEL"}}
import { {{codeName}}PickUpViewPanel } from '@widgets/{{spinalCase appEntity.codeName}}/{{spinalCase codeName}}-pickup-view-panel';
{{/eq}}
{{/page.ctrls}}
// props声明和默认值处理
interface Props {
context: IContext;
......@@ -24,13 +28,53 @@ interface ViewEmit {
const emit = defineEmits<ViewEmit>();
// 安装功能模块,提供状态和能力方法
const { state } = new PickupView(ViewConfig).moduleInstall(props, emit);
const { state, cancel, confirm,handleCtrlEvent } = new PickupView(ViewConfig).moduleInstall(props, emit);
</script>
<template>
<IbizDefaultViewLayout class="ibiz-pickup-view">
<template v-slot:header-left>
<IbizIconText class="ibiz-view__caption" size="large" :text="state.viewCaption" />
<IbizPickerUpViewLayout class="ibiz-pickup-view">
<template v-slot:header-left>
<IbizIconText class="ibiz-view__caption" size="large" :text="state.viewCaption" />
</template>
{{#page.ctrls}}
{{#eq controlType "TOOLBAR"}}
<template v-slot:toolbar>
<IbizToolbar
mode="button"
name="{{lowerCase codeName}}"
:actionModel="state.viewToolbarModel"
@toolbarEvent="handleToolbarEvent"/>
</template>
{{/eq}}
{{#eq controlType "PICKUPVIEWPANEL"}}
<{{codeName}}PickUpViewPanel
:context="state.context"
:rowEditState="state.rowEditState"
:rowActiveMode="state.gridRowActiveMode"
:showBusyIndicator="true"
:viewParams="state.viewParams"
:controlAction="state.controlsAction.{{name}}"
:viewSubject="state.viewSubject"
@ctrlEvent="handleCtrlEvent"
></{{codeName}}PickUpViewPanel>
{{/eq}}
{{/page.ctrls}}
<template v-slot:footer>
<a-space class="ibiz-pickup-view--footer">
<a-button @click="cancel">取消</a-button>
<a-button @click="confirm">确认</a-button>
</a-space>
</template>
</IbizDefaultViewLayout>
</template>
\ No newline at end of file
</IbizPickerUpViewLayout>
</template>
<style lang="scss">
.ibiz-pickup-view {
position: relative;
.ibiz-pickup-view--footer {
position: absolute;
bottom: 20px;
right: 35px;
}
}
</style>
\ No newline at end of file
<script setup lang="ts">
import { IParam, ViewDetail } from '@core';
import { IActionParam, IParam, ViewDetail } from '@core';
import { Subject } from 'rxjs';
import { Ref, ref } from 'vue';
interface AppModalProps {
......@@ -31,7 +31,7 @@ interface AppModalProps {
/**
* @description 是否全屏
*/
isFullscreen:boolean;
isFullscreen: boolean;
/**
* @description 模态参数
......@@ -49,7 +49,6 @@ const props = withDefaults(defineProps<AppModalProps>(), {
*/
let isVisible: Ref<boolean> = ref(false);
/**
* 临时结果
*/
......@@ -132,8 +131,9 @@ onMounted(() => {
*/
const close = (result: any) => {
if (result && Array.isArray(result) && result.length > 0) {
Object.assign(tempResult, { ret: 'OK' }, { datas: JSON.parse(JSON.stringify(result)) });
Object.assign(tempResult, { ret: 'OK' }, { resultData: JSON.parse(JSON.stringify(result)) });
}
props.subject?.next(tempResult);
isVisible.value = false;
};
......@@ -143,7 +143,7 @@ const close = (result: any) => {
const viewDataChange = (result: any) => {
tempResult = { ret: '' };
if (result && Array.isArray(result) && result.length > 0) {
Object.assign(tempResult, { ret: 'OK' }, { datas: JSON.parse(JSON.stringify(result)) });
Object.assign(tempResult, { ret: 'OK' }, { resultData: JSON.parse(JSON.stringify(result)) });
}
};
......@@ -156,6 +156,18 @@ const viewDataActivated = (result: any) => {
}
};
const handelViewEvent = (actionParam: IActionParam) => {
const { tag, action, data } = actionParam;
switch (action) {
case 'viewDataChange':
viewDataChange(data);
break;
case 'close':
close(data);
break;
}
};
/**
* 模态显示隐藏切换回调
*/
......@@ -196,7 +208,7 @@ const handleShowState = ($event: any) => {
:viewParams="viewParams"
:viewDefaultUsage="false"
:noViewCaption="true"
@viewDataChange="viewDataChange($event)"
@viewEvent="handelViewEvent($event)"
@viewDataActivated="viewDataActivated($event)"
@close="close($event)"
:ref="viewName"
......
import {{ctrl.codeName}}PickUpViewPanel from "./{{spinalCase ctrl.codeName}}-pickup-view-panel.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, IContext } from '@core';
import { CtrlConfig } from './{{spinalCase ctrl.codeName}}-pickup-view-panel-config';
import ChartDataPickUpGridView from '../../../page/sample/chart-data-pickup-grid-view';
interface Props {
context: IContext;
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, handleViewEvent} = new PickupViewPanelControl(CtrlConfig).moduleInstall(props, emit);
</script>
<template>
<div class="ibiz-pickupviewpanel">
<ChartDataPickUpGridView
:isSingleSelect="state.isSingleSelect"
:isShowButton="state.isShowButton"
:selectedData="state.selectedData"
@viewEvent="handleViewEvent"
></ChartDataPickUpGridView>
</div>
</template>
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册