提交 e74dc6ef 编写于 作者: tony001's avatar tony001

add:新增上下文、视图参数处理

上级 e754676d
...@@ -10,10 +10,10 @@ ...@@ -10,10 +10,10 @@
:context="state.context" :context="state.context"
:viewParams="state.viewParams" :viewParams="state.viewParams"
{{#if item.psEditor.psNavigateContexts}} {{#if item.psEditor.psNavigateContexts}}
localContext="{{item.psEditor.psNavigateContexts}}" localContext="{{> @macro/front-end/common/navparam.hbs appNavParams=item.psEditor.psNavigateContexts}}"
{{/if}} {{/if}}
{{#if item.psEditor.psNavigateParams}} {{#if item.psEditor.psNavigateParams}}
localParam="{{item.psEditor.psNavigateParams}}" localParam="{{> @macro/front-end/common/navparam.hbs appNavParams=item.psEditor.psNavigateParams}}"
{{/if}} {{/if}}
{{#if item.psEditor.psAppDataEntity}} {{#if item.psEditor.psAppDataEntity}}
{{!-- deMajorField="getDeMajorField({{item.psEditor.psAppDataEntity.codeName}})" --}} {{!-- deMajorField="getDeMajorField({{item.psEditor.psAppDataEntity.codeName}})" --}}
......
...@@ -13,10 +13,10 @@ ...@@ -13,10 +13,10 @@
valueSeparator="{{item.psEditor.codeList.valueSeparator}}" valueSeparator="{{item.psEditor.codeList.valueSeparator}}"
{{/if}} {{/if}}
{{#if item.psEditor.psNavigateContexts}} {{#if item.psEditor.psNavigateContexts}}
localContext="{{item.psEditor.psNavigateContexts}}" localContext="{{> @macro/front-end/common/navparam.hbs appNavParams=item.psEditor.psNavigateContexts}}"
{{/if}} {{/if}}
{{#if item.psEditor.psNavigateParams}} {{#if item.psEditor.psNavigateParams}}
localParam="{{item.psEditor.psNavigateParams}}" localParam="{{> @macro/front-end/common/navparam.hbs appNavParams=item.psEditor.psNavigateParams}}"
{{/if}} {{/if}}
:context="state.context" :context="state.context"
:viewParams="state.viewParams" :viewParams="state.viewParams"
......
...@@ -11,10 +11,10 @@ ...@@ -11,10 +11,10 @@
disabled="{{item.psEditor.disabled}}" disabled="{{item.psEditor.disabled}}"
{{/if}} {{/if}}
{{#if item.psEditor.psNavigateContexts}} {{#if item.psEditor.psNavigateContexts}}
localContext="{{item.psEditor.psNavigateContexts}}" localContext="{{> @macro/front-end/common/navparam.hbs appNavParams=item.psEditor.psNavigateContexts}}"
{{/if}} {{/if}}
{{#if item.psEditor.psNavigateParams}} {{#if item.psEditor.psNavigateParams}}
localParam="{{item.psEditor.psNavigateParams}}" localParam="{{> @macro/front-end/common/navparam.hbs appNavParams=item.psEditor.psNavigateParams}}"
{{/if}} {{/if}}
:context="state.context" :context="state.context"
:viewParams="state.viewParams" :viewParams="state.viewParams"
......
...@@ -11,10 +11,10 @@ ...@@ -11,10 +11,10 @@
disabled="{{item.psEditor.disabled}}" disabled="{{item.psEditor.disabled}}"
{{/if}} {{/if}}
{{#if item.psEditor.psNavigateContexts}} {{#if item.psEditor.psNavigateContexts}}
localContext="{{item.psEditor.psNavigateContexts}}" localContext="{{> @macro/front-end/common/navparam.hbs appNavParams=item.psEditor.psNavigateContexts}}"
{{/if}} {{/if}}
{{#if item.psEditor.psNavigateParams}} {{#if item.psEditor.psNavigateParams}}
localParam="{{item.psEditor.psNavigateParams}}" localParam="{{> @macro/front-end/common/navparam.hbs appNavParams=item.psEditor.psNavigateParams}}"
{{/if}} {{/if}}
:context="state.context" :context="state.context"
:viewParams="state.viewParams" :viewParams="state.viewParams"
......
...@@ -16,10 +16,10 @@ ...@@ -16,10 +16,10 @@
:multiple="{{item.psEditor.editorParams.multiple}}" :multiple="{{item.psEditor.editorParams.multiple}}"
{{/if}} {{/if}}
{{#if item.psEditor.psNavigateContexts}} {{#if item.psEditor.psNavigateContexts}}
localContext="{{item.psEditor.psNavigateContexts}}" localContext="{{> @macro/front-end/common/navparam.hbs appNavParams=item.psEditor.psNavigateContexts}}"
{{/if}} {{/if}}
{{#if item.psEditor.psNavigateParams}} {{#if item.psEditor.psNavigateParams}}
localParam="{{item.psEditor.psNavigateParams}}" localParam="{{> @macro/front-end/common/navparam.hbs appNavParams=item.psEditor.psNavigateParams}}"
{{/if}} {{/if}}
{{#eq item.psEditor.editorType "MDROPDOWNLIST"}} {{#eq item.psEditor.editorType "MDROPDOWNLIST"}}
:multiple="true" :multiple="true"
......
...@@ -13,10 +13,10 @@ ...@@ -13,10 +13,10 @@
:readonly="{{item.psEditor.isReadOnly}}" :readonly="{{item.psEditor.isReadOnly}}"
{{/if}} {{/if}}
{{#if item.psEditor.psNavigateContexts}} {{#if item.psEditor.psNavigateContexts}}
localContext="{{item.psEditor.psNavigateContexts}}" localContext="{{> @macro/front-end/common/navparam.hbs appNavParams=item.psEditor.psNavigateContexts}}"
{{/if}} {{/if}}
{{#if item.psEditor.psNavigateParams}} {{#if item.psEditor.psNavigateParams}}
localParam="{{item.psEditor.psNavigateParams}}" localParam="{{> @macro/front-end/common/navparam.hbs appNavParams=item.psEditor.psNavigateParams}}"
{{/if}} {{/if}}
:context="state.context" :context="state.context"
:viewParams="state.viewParams" :viewParams="state.viewParams"
......
...@@ -17,10 +17,10 @@ ...@@ -17,10 +17,10 @@
:precision="{{item.psEditor.precision}}" :precision="{{item.psEditor.precision}}"
{{/if}} {{/if}}
{{#if item.psEditor.psNavigateContexts}} {{#if item.psEditor.psNavigateContexts}}
localContext="{{item.psEditor.psNavigateContexts}}" localContext="{{> @macro/front-end/common/navparam.hbs appNavParams=item.psEditor.psNavigateContexts}}"
{{/if}} {{/if}}
{{#if item.psEditor.psNavigateParams}} {{#if item.psEditor.psNavigateParams}}
localParam="{{item.psEditor.psNavigateParams}}" localParam="{{> @macro/front-end/common/navparam.hbs appNavParams=item.psEditor.psNavigateParams}}"
{{/if}} {{/if}}
{{#if (or (eq ctrlType 'form') (eq ctrlType 'panel'))}} {{#if (or (eq ctrlType 'form') (eq ctrlType 'panel'))}}
:value="state.data.{{item.psEditor.name}}" :value="state.data.{{item.psEditor.name}}"
......
{ {{#appNavParams}}'{{lowerCase getKey}}':{{#if (eq isRawValue true)}}'{{lowerCase getValue}}'{{else}}'%{{lowerCase getValue}}%'{{/if}}{{#unless @last}},{{/unless}}{{/appNavParams}} }
\ No newline at end of file
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
showCaptionBar: '{{page.viewStyle}}', showCaptionBar: '{{page.viewStyle}}',
xDataControlName:'{{page.xDataControlName}}', xDataControlName:'{{page.xDataControlName}}',
openDataViewName:'ExampleEditorEditView', openDataViewName:'ExampleEditorEditView',
appViewNavContexts:{{> @macro/front-end/common/navparam.hbs appNavParams=page.psAppViewNavContexts}},
appViewNavParams:{{> @macro/front-end/common/navparam.hbs appNavParams=page.getPSAppViewNavParams}},
viewToolbarModel: [ viewToolbarModel: [
{{#page.viewToolBarItems}} {{#page.viewToolBarItems}}
{{#items}} {{#items}}
......
import { Ref } from 'vue'; import { Ref } from 'vue';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import { ViewPropsBase, ViewStateBase, UIBase, IParam } from '@core'; import { ViewPropsBase, ViewStateBase, UIBase, IParam, UIUtil } from '@core';
/** /**
* @description 视图基类 * @description 视图基类
...@@ -8,7 +8,7 @@ import { ViewPropsBase, ViewStateBase, UIBase, IParam } from '@core'; ...@@ -8,7 +8,7 @@ import { ViewPropsBase, ViewStateBase, UIBase, IParam } from '@core';
* @class ViewBase * @class ViewBase
*/ */
export class ViewBase { export class ViewBase {
/** /**
* @description 视图状态 * @description 视图状态
* @type {ViewStateBase} * @type {ViewStateBase}
...@@ -44,27 +44,48 @@ export class ViewBase { ...@@ -44,27 +44,48 @@ export class ViewBase {
* @param viewParams 视图参数 * @param viewParams 视图参数
*/ */
public handleViewContextParams(props: ViewPropsBase, context: Ref<IParam | undefined>, viewParams: Ref<IParam | undefined>) { public handleViewContextParams(props: ViewPropsBase, context: Ref<IParam | undefined>, viewParams: Ref<IParam | undefined>) {
if (!context.value) context.value = {}; if (!context.value) context.value = {};
if (!viewParams.value) viewParams.value = {}; if (!viewParams.value) viewParams.value = {};
if (Object.is(props.openType, 'ROUTE')) { if (Object.is(props.openType, 'ROUTE')) {
const appContext = {}; // 应用上下文
Object.assign(context.value, appContext); const appContext = App.getAppData();
const pageContext = useRoute().params; Object.assign(context.value, appContext);
Object.assign(context.value, pageContext); // 视图应用上下文
const pageCustomContext = {}; const pageContext = {};
Object.assign(context.value, pageCustomContext); const routeParams = useRoute().params;
console.log(context); if (routeParams && (Object.keys(routeParams).length > 0)) {
const pageViewParams = useRoute().query; Object.keys(routeParams).forEach((key: string) => {
Object.assign(viewParams.value, pageViewParams); if (routeParams[key]) {
const pageCustomViewParams = {}; Object.assign(pageContext, { [key]: decodeURIComponent(routeParams[key] as string) });
Object.assign(viewParams.value, pageCustomViewParams); }
console.log(viewParams); })
} else { }
const customContext = {}; Object.assign(context.value, pageContext);
Object.assign(context.value, customContext); // 视图参数
const pageCustomViewParams = {}; const pageViewParams = {};
Object.assign(viewParams.value, pageCustomViewParams); const routeQuerys = useRoute().query;
if (routeQuerys && (Object.keys(routeQuerys).length > 0)) {
Object.keys(routeQuerys).forEach((key: string) => {
if (routeQuerys[key]) {
Object.assign(pageViewParams, { [key]: routeQuerys[key] });
}
})
} }
Object.assign(viewParams.value, pageViewParams);
// 视图自定义应用上下文
const pageCustomContext = UIUtil.computedNavData(null, context.value, viewParams.value, this.viewState.appViewNavContexts);
Object.assign(context.value, pageCustomContext);
// 视图自定义视图参数
const pageCustomViewParams = UIUtil.computedNavData(null, context.value, viewParams.value, this.viewState.appViewNavParams);
Object.assign(viewParams.value, pageCustomViewParams);
} else {
// 视图自定义应用上下文
const customContext = UIUtil.computedNavData(null, context.value, viewParams.value, this.viewState.appViewNavContexts);
Object.assign(context.value, customContext);
// 视图自定义视图参数
const pageCustomViewParams = UIUtil.computedNavData(null, context.value, viewParams.value, this.viewState.appViewNavParams);
Object.assign(viewParams.value, pageCustomViewParams);
}
} }
/** /**
...@@ -79,7 +100,7 @@ export class ViewBase { ...@@ -79,7 +100,7 @@ export class ViewBase {
// 导航视图参数处理 // 导航视图参数处理
this.handleViewContextParams(props, context, viewParams); this.handleViewContextParams(props, context, viewParams);
watch(context, (newVal: any, oldVal: any) => { watch(context, (newVal: any, oldVal: any) => {
this.handleViewContextParams(props, newVal,viewParams); this.handleViewContextParams(props, newVal, viewParams);
}); });
// 把Ref赋值到State上进行解包 // 把Ref赋值到State上进行解包
this.viewState.context = context; this.viewState.context = context;
...@@ -92,7 +113,7 @@ export class ViewBase { ...@@ -92,7 +113,7 @@ export class ViewBase {
* @param {ViewPropsBase} props 传入参数 * @param {ViewPropsBase} props 传入参数
* @memberof ViewBase * @memberof ViewBase
*/ */
public useCounterService(props: ViewPropsBase){} public useCounterService(props: ViewPropsBase) { }
/** /**
* @description 安装视图所有功能模块的方法 * @description 安装视图所有功能模块的方法
......
...@@ -7,7 +7,7 @@ import { IActionParam, IParam } from '@core'; ...@@ -7,7 +7,7 @@ import { IActionParam, IParam } from '@core';
* @interface ViewStateBase * @interface ViewStateBase
*/ */
export interface ViewStateBase { export interface ViewStateBase {
/** /**
* @description 视图名称 * @description 视图名称
* @type {string} * @type {string}
...@@ -50,6 +50,22 @@ export interface ViewStateBase { ...@@ -50,6 +50,22 @@ export interface ViewStateBase {
*/ */
viewToolbarModel: IParam[]; viewToolbarModel: IParam[];
/**
* 自定义视图导航上下文
*
* @type {IParam}
* @memberof ViewStateBase
*/
appViewNavContexts: IParam;
/**
* 自定义视图参数
*
* @type {IParam}
* @memberof ViewStateBase
*/
appViewNavParams: IParam;
// 声明任意属性 // 声明任意属性
[propName: string]: any; [propName: string]: any;
} }
...@@ -77,7 +77,6 @@ export class Interceptors { ...@@ -77,7 +77,6 @@ export class Interceptors {
if (!Object.is(Environment.BaseUrl, "") && !config.url.startsWith('https://') && !config.url.startsWith('http://') && !config.url.startsWith('./assets')) { if (!Object.is(Environment.BaseUrl, "") && !config.url.startsWith('https://') && !config.url.startsWith('http://') && !config.url.startsWith('./assets')) {
config.url = Environment.BaseUrl + config.url; config.url = Environment.BaseUrl + config.url;
} }
console.log(config);
return config; return config;
}, (error: any) => { }, (error: any) => {
return Promise.reject(error); return Promise.reject(error);
......
...@@ -60,15 +60,15 @@ export class UIUtil { ...@@ -60,15 +60,15 @@ export class UIUtil {
/** /**
* @description 计算导航数据 * @description 计算导航数据
* 先从当前数据目标计算,然后再从当前上下文计算,最后从当前视图参数计算,没有则为null * 先从当前激活数据计算,然后再从当前上下文计算,最后从当前视图参数计算,没有则为null
* @export * @export
* @param {*} data 当前数据目标 * @param {*} activedata 当前激活数据
* @param {*} parentContext 当前上下文 * @param {*} context 当前上下文
* @param {*} parentParam 当前视图参数 * @param {*} viewParam 当前视图参数
* @param {*} params 导航参数 * @param {*} params 导航参数
* @return {*} * @return {*}
*/ */
public static computedNavData(data: any, parentContext: any, parentParam: any, params: any): any { public static computedNavData(activedata: any, context: any, viewParam: any, params: any): any {
const _data: any = {}; const _data: any = {};
if (params && Object.keys(params).length > 0) { if (params && Object.keys(params).length > 0) {
Object.keys(params).forEach((name: string) => { Object.keys(params).forEach((name: string) => {
...@@ -78,12 +78,12 @@ export class UIUtil { ...@@ -78,12 +78,12 @@ export class UIUtil {
let value: string | null = params[name]; let value: string | null = params[name];
if (value && value.toString().startsWith('%') && value.toString().endsWith('%')) { if (value && value.toString().startsWith('%') && value.toString().endsWith('%')) {
const key = value.substring(1, value.length - 1).toLowerCase(); const key = value.substring(1, value.length - 1).toLowerCase();
if (data && data.hasOwnProperty(key)) { if (activedata && activedata.hasOwnProperty(key)) {
value = data[key]; value = activedata[key];
} else if (parentContext && parentContext[key]) { } else if (context && context[key]) {
value = parentContext[key]; value = context[key];
} else if (parentParam && parentParam[key]) { } else if (viewParam && viewParam[key]) {
value = parentParam[key]; value = viewParam[key];
} else { } else {
value = null; value = null;
} }
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册