提交 88e37e90 编写于 作者: Mosher's avatar Mosher

update:更新

1、视图state中实体标识调整
2、增加部件父容器传递
3、调整表格操作列执行逻辑
4、表格列值格式化、代码表支持
5、表格快速工具栏、批操作工具栏模型支持
6、表格快速工具栏绘制及行为调用
上级 811ad2e8
...@@ -12,7 +12,8 @@ ...@@ -12,7 +12,8 @@
height: '{{page.height}}', height: '{{page.height}}',
width: '{{page.width}}', width: '{{page.width}}',
appEntityCodeName: '{{page.appEntity.codeName}}', appEntityCodeName: '{{page.appEntity.codeName}}',
keyPSDEField: '{{lowerCase page.appEntity.codeName}}', appDeKeyFieldName: '{{lowerCase page.appEntity.keyPSAppDEField.codeName}}',
appDeMajorFieldName: '{{lowerCase page.appEntity.majorPSAppDEField.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}},
appViewNavContexts:{{> @macro/front-end/common/navparam.hbs appNavParams=page.psAppViewNavContexts}}, appViewNavContexts:{{> @macro/front-end/common/navparam.hbs appNavParams=page.psAppViewNavContexts}},
appViewNavParams:{{> @macro/front-end/common/navparam.hbs appNavParams=page.psAppViewNavParams}}, appViewNavParams:{{> @macro/front-end/common/navparam.hbs appNavParams=page.psAppViewNavParams}},
......
...@@ -7,15 +7,15 @@ ...@@ -7,15 +7,15 @@
:value="text" :value="text"
:viewParams="state.viewParams" :viewParams="state.viewParams"
></AppCodelist> ></AppCodelist>
{{else if (and item.enableLinkView item.linkPSAppView)}} {{else if (and item.enableLinkView item.linkPSAppView (not isLink))}}
{{!-- 链接视图暂未支持 --}} {{!-- 链接视图暂未支持 --}}
<app-column-link <app-column-link
:context="state.context" :context="state.context"
:viewParams="state.viewParams" :viewParams="state.viewParams"
:linkView="column.linkView" :linkView="column.linkView"
:valueItem="column.linkValueItem" :valueItem="column.linkValueItem"
:data="record" > :data="record" >
<span>\{{text}}</span> {{> COLUMNTEXT isLink=true}}
</app-column-link> </app-column-link>
{{else}} {{else}}
{{#if item.valueFormat}} {{#if item.valueFormat}}
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
</div> </div>
<div v-else class="text-cell"> <div v-else class="text-cell">
{{#if (and item.psDEUIAction item.psDEUIAction.uIActionTag)}} {{#if (and item.psDEUIAction item.psDEUIAction.uIActionTag)}}
<a style="{ display: 'block' }" @click="columnUIAction"> <a style="{ display: 'block' }" @click="onActionColEvent($event, record)">
{{> COLUMNTEXT}} {{> COLUMNTEXT}}
</a> </a>
{{else}} {{else}}
...@@ -69,7 +69,7 @@ ...@@ -69,7 +69,7 @@
{{else}} {{else}}
<div class="text-cell"> <div class="text-cell">
{{#if (and item.psDEUIAction item.psDEUIAction.uIActionTag)}} {{#if (and item.psDEUIAction item.psDEUIAction.uIActionTag)}}
<a style="{ display: 'block' }" @click="columnUIAction"> <a style="{ display: 'block' }" @click="onActionColEvent($event, record)">
{{> COLUMNTEXT}} {{> COLUMNTEXT}}
</a> </a>
{{else}} {{else}}
...@@ -82,7 +82,7 @@ ...@@ -82,7 +82,7 @@
mode="link" mode="link"
name="{{lowerCase item.codeName}}" name="{{lowerCase item.codeName}}"
:actionModel="record.{{lowerCase item.codeName}}" :actionModel="record.{{lowerCase item.codeName}}"
@onToolbarEvent="onToolbarEvent($event, record)"/> @onToolbarEvent="onActionColEvent($event, record)"/>
{{/if}} {{/if}}
</div> </div>
{{/unless}} {{/unless}}
......
import { hasFunction, IContext, IParam, isExist, ViewUtil } from '@core'; import { hasFunction, IContext, IParam, isExist, isExistAndNotEmpty, ViewUtil } from '@core';
/** /**
* 界面行为参数对象 * 界面行为参数对象
...@@ -104,10 +104,29 @@ export class AppSysAction { ...@@ -104,10 +104,29 @@ export class AppSysAction {
public static edit(params: IUIActionParams) { public static edit(params: IUIActionParams) {
const { actionEnvironment, data } = params; const { actionEnvironment, data } = params;
// 准备视图参数 // 准备视图参数
if (!actionEnvironment?.state?.viewLogics?.openData?.openDataViewName) { if (!actionEnvironment || !actionEnvironment.state) {
return;
}
let viewName: string = '';
// 获取视图名称
const getOpenViewName = (state: any) => {
if (
state.viewLogics
&& state.viewLogics.openData
&& state.viewLogics.openData.openDataViewName
) {
viewName = state.viewLogics.openData.openDataViewName;
return;
}
// 在父容器中查找openData逻辑
if (state.parent && state.parent.state) {
getOpenViewName(state.parent.state);
}
}
getOpenViewName(actionEnvironment.state);
if (!isExistAndNotEmpty(viewName)) {
return; return;
} }
const viewName = actionEnvironment?.state.viewLogics.openData.openDataViewName;
const view = App.getViewInfo(viewName); const view = App.getViewInfo(viewName);
if (!view) { if (!view) {
console.warn("视图参数不足"); console.warn("视图参数不足");
...@@ -118,7 +137,7 @@ export class AppSysAction { ...@@ -118,7 +137,7 @@ export class AppSysAction {
console.warn("数据参数不足"); console.warn("数据参数不足");
return; return;
} }
Object.assign(params.context, { [actionEnvironment.state.keyPSDEField]: data[0].srfkey }) Object.assign(params.context, { [actionEnvironment.state.appDeKeyFieldName]: data[0].srfkey })
ViewUtil.openData(view, params); ViewUtil.openData(view, params);
} }
...@@ -129,12 +148,31 @@ export class AppSysAction { ...@@ -129,12 +148,31 @@ export class AppSysAction {
* @return {*} * @return {*}
*/ */
public static new(params: IUIActionParams) { public static new(params: IUIActionParams) {
const { actionEnvironment } = params; const { actionEnvironment, data } = params;
// 准备视图参数 // 准备视图参数
if (!actionEnvironment?.state?.viewLogics?.newData?.newDataViewName) { if (!actionEnvironment || !actionEnvironment.state) {
return;
}
let viewName: string = '';
// 获取视图名称
const getNewViewName = (state: any) => {
if (
state.viewLogics
&& state.viewLogics.newData
&& state.viewLogics.newData.newDataViewName
) {
viewName = state.viewLogics.newData.newDataViewName;
return;
}
// 在父容器中查找openData逻辑
if (state.parent && state.parent.state) {
getNewViewName(state.parent.state);
}
}
getNewViewName(actionEnvironment.state);
if (!isExistAndNotEmpty(viewName)) {
return; return;
} }
const viewName = actionEnvironment?.state.viewLogics.newData.newDataViewName;
const view = App.getViewInfo(viewName); const view = App.getViewInfo(viewName);
if (!view) { if (!view) {
return; return;
...@@ -143,7 +181,7 @@ export class AppSysAction { ...@@ -143,7 +181,7 @@ export class AppSysAction {
Object.assign(params.viewParams, { w: new Date().getTime() }); Object.assign(params.viewParams, { w: new Date().getTime() });
ViewUtil.newData(view, params); ViewUtil.newData(view, params);
} }
/** /**
* 行编辑 * 行编辑
* *
......
...@@ -35,14 +35,14 @@ export class EditView extends MainView { ...@@ -35,14 +35,14 @@ export class EditView extends MainView {
onMounted(() => { onMounted(() => {
// 初始化数据能力部件 // 初始化数据能力部件
this.xDataControl = this.getForm(); this.xDataControl = this.getForm();
const { isLoadDefault, context, viewparams, keyPSDEField } = this.state; const { isLoadDefault, context, viewparams, appDeKeyFieldName } = this.state;
if (this.getForm() && isLoadDefault) { if (this.getForm() && isLoadDefault) {
const tag = this.getForm().name; const tag = this.getForm().name;
let action: string = ''; let action: string = '';
if ( if (
keyPSDEField && appDeKeyFieldName &&
context[keyPSDEField] && context[appDeKeyFieldName] &&
!Object.is(context[keyPSDEField], '') !Object.is(context[appDeKeyFieldName], '')
) { ) {
action = 'load'; action = 'load';
} else { } else {
......
...@@ -23,11 +23,27 @@ export interface MainViewState extends ViewStateBase { ...@@ -23,11 +23,27 @@ export interface MainViewState extends ViewStateBase {
*/ */
appEntityCodeName: string; appEntityCodeName: string;
/**
* 视图实体主属性CodeName
*
* @type {string}
* @memberof MainViewState
*/
appDeKeyFieldName: string;
/**
* 视图实体主信息属性CodeName
*
* @type {string}
* @memberof MainViewState
*/
appDeMajorFieldName: string;
/** /**
* 视图逻辑配置 * 视图逻辑配置
* *
* @type {*} * @type {*}
* @memberof MainViewState * @memberof MainViewState
*/ */
viewLogics: IViewLogics; viewLogics: IViewLogics;
} }
...@@ -244,7 +244,7 @@ export class MDView extends MainView { ...@@ -244,7 +244,7 @@ export class MDView extends MainView {
} }
// 准备参数 // 准备参数
const tempContext = {}; const tempContext = {};
Object.assign(tempContext, { [this.state.keyPSDEField]: args[0].srfkey }); Object.assign(tempContext, { [this.state.appDeKeyFieldName]: args[0].srfkey });
Object.assign(tempContext, this.state.context); Object.assign(tempContext, this.state.context);
const params = { const params = {
context: tempContext, context: tempContext,
......
...@@ -51,6 +51,7 @@ export class ControlBase { ...@@ -51,6 +51,7 @@ export class ControlBase {
public setState() { public setState() {
this.state.viewSubject = toRef(this.props, 'viewSubject') as any; this.state.viewSubject = toRef(this.props, 'viewSubject') as any;
this.state.controlName = this.props.name; this.state.controlName = this.props.name;
this.state.parent = this.props.parent;
} }
/** /**
......
...@@ -43,6 +43,14 @@ export interface ControlStateBase { ...@@ -43,6 +43,14 @@ export interface ControlStateBase {
*/ */
viewSubject: Subject<IActionParam>; viewSubject: Subject<IActionParam>;
/**
* 父容器
*
* @type {*}
* @memberof ControlStateBase
*/
parent: any;
// 声明任意属性 // 声明任意属性
[propName: string]: any; [propName: string]: any;
} }
\ No newline at end of file
...@@ -198,9 +198,14 @@ export class GridControl extends MDControl { ...@@ -198,9 +198,14 @@ export class GridControl extends MDControl {
* @param {IParam} record * @param {IParam} record
* @memberof GridControl * @memberof GridControl
*/ */
public onToolbarEvent(actionParam: IActionParam, record: IParam) { public onToolbarEvent(actionParam: IActionParam) {
const { data } = actionParam; const { data } = actionParam;
if (!record || !data) { if (!data) {
console.warn("工具栏执行参数不足");
return;
}
const { uIAction } = data;
if (!uIAction) {
console.warn("工具栏执行参数不足"); console.warn("工具栏执行参数不足");
return; return;
} }
...@@ -208,23 +213,36 @@ export class GridControl extends MDControl { ...@@ -208,23 +213,36 @@ export class GridControl extends MDControl {
const inputParam = { const inputParam = {
context: this.state.context, context: this.state.context,
viewParams: this.state.viewParams, viewParams: this.state.viewParams,
data: record, data: this.getData(),
event: data.event, event: data.event,
actionEnvironment: this actionEnvironment: this
}; };
// 执行行为 // 执行行为
App.getAppActionService().execute(data, inputParam); App.getAppActionService().execute(uIAction, inputParam);
} }
/** /**
* @description 处理表格操作列事件 * @description 处理表格行事件(操作列,界面行为)
* @param {IActionParam} actionParam 行为参数 * @param {IActionParam} actionParam 行为参数
* @param {IParam} [row] 表格行数据 * @param {IParam} [row] 表格行数据
* @memberof GridControl * @memberof GridControl
*/ */
public onActionColEvent(actionParam: IActionParam, row?: IParam) { public onActionColEvent(actionParam: IActionParam, row?: IParam) {
const { tag, action, data } = actionParam; const { data } = actionParam;
console.log('触发界面行为', actionParam, row); if (!row || !data) {
console.warn("工具栏执行参数不足");
return;
}
// 准备参数
const inputParam = {
context: this.state.context,
viewParams: this.state.viewParams,
data: [row],
event: data.event,
actionEnvironment: this
};
// 执行行为
App.getAppActionService().execute(data, inputParam);
} }
/** /**
...@@ -674,8 +692,9 @@ export class GridControl extends MDControl { ...@@ -674,8 +692,9 @@ export class GridControl extends MDControl {
return { return {
...superParams, ...superParams,
useCustom: this.useCustom(), useCustom: this.useCustom(),
onEditorEvent: this.onEditorEvent, onEditorEvent: this.onEditorEvent.bind(this),
onToolbarEvent: this.onToolbarEvent.bind(this) onToolbarEvent: this.onToolbarEvent.bind(this),
onActionColEvent: this.onActionColEvent.bind(this)
}; };
} }
} }
...@@ -16,38 +16,38 @@ const routes = [ ...@@ -16,38 +16,38 @@ const routes = [
children: [ children: [
{{#each app.appEntityResources as |appEntityResource|}} {{#each app.appEntityResources as |appEntityResource|}}
{{#if appEntityResource.appDataEntity.allPSAppViews}} {{#if appEntityResource.appDataEntity.allPSAppViews}}
{{#each appEntityResource.appDataEntity.allPSAppViews as |appView|}} {{#each appEntityResource.appDataEntity.allPSAppViews as |appView|}}
{{#if (eq appView.refFlag true)}} {{#if (eq appView.refFlag true)}}
{{#if (or {{#if (or
(eq appView.viewType 'DEEDITVIEW') (eq appView.viewType 'DEEDITVIEW')
(eq appView.viewType 'DEGRIDVIEW') (eq appView.viewType 'DEGRIDVIEW')
(eq appView.viewType 'DETREEEXPVIEW') (eq appView.viewType 'DETREEEXPVIEW')
(eq appView.viewType 'DETREEVIEW') (eq appView.viewType 'DETREEVIEW')
(eq appView.viewType 'DETABEXPVIEW') (eq appView.viewType 'DETABEXPVIEW')
) }} ) }}
{ {
path: "{{appEntityResource.path}}/views/{{lowerCase appView.codeName}}", path: "{{appEntityResource.path}}/views/{{lowerCase appView.codeName}}",
meta: { meta: {
tag:'{{appView.codeName}}' tag:'{{appView.codeName}}'
}, },
component: () => import("@views/{{spinalCase appView.psAppModule.codeName}}/{{spinalCase appView.codeName}}"), component: () => import("@views/{{spinalCase appView.psAppModule.codeName}}/{{spinalCase appView.codeName}}"),
}, },
{{/if}} {{/if}}
{{/if}} {{/if}}
{{/each}} {{/each}}
{{/if}} {{/if}}
{{/each}} {{/each}}
{{#each app.allPSAppViews as | appView |}} {{#each app.allPSAppViews as | appView |}}
{{!-- 临时只支持首页视图、应用看板视图 --}} {{!-- 临时只支持首页视图、应用看板视图 --}}
{{#if (or (eq appView.viewType 'APPINDEXVIEW') (eq appView.viewType 'APPPORTALVIEW'))}} {{#if (or (eq appView.viewType 'APPINDEXVIEW') (eq appView.viewType 'APPPORTALVIEW'))}}
{{#unless (or appView.psAppDataEntity appView.defaultPage)}} {{#unless (or appView.psAppDataEntity appView.defaultPage)}}
{ {
path: "views/{{lowerCase appView.codeName}}", path: "views/{{lowerCase appView.codeName}}",
meta: { meta: {
tag:'{{appView.codeName}}' tag:'{{appView.codeName}}'
}, },
component: () => import("@views/{{spinalCase appView.psAppModule.codeName}}/{{spinalCase appView.codeName}}"), component: () => import("@views/{{spinalCase appView.psAppModule.codeName}}/{{spinalCase appView.codeName}}"),
}, },
{{/unless}} {{/unless}}
{{/if}} {{/if}}
{{/each}} {{/each}}
......
...@@ -140,6 +140,24 @@ export const ctrlState = { ...@@ -140,6 +140,24 @@ export const ctrlState = {
{{/if}} {{/if}}
{{/each}} {{/each}}
], ],
{{#if ctrl.quickToolBarItems}}
{{#ctrl.quickToolBarItems}}
quickToolbar: [
{{#items}}
{ id:'{{id}}',name:'{{name}}',caption:'{{caption}}',groupExtractMode:'{{groupExtractMode}}',itemType:'{{itemType}}',noPrivDisplayMode:'{{noPrivDisplayMode}}',showIcon:{{showIcon}},showCaption:{{showCaption}},tooltip:'{{tooltip}}',disabled: false, visible: true, imgPath: '{{imgPath}}',iconClass: '{{iconClass}}',xDataControlName:'{{xDataControlName}}',{{#if uIAction}}uIAction:{codeName:'{{uIAction.codeName}}',fullCodeName:'{{uIAction.fullCodeName}}',uIActionMode:'{{uIAction.uIActionMode}}',actionTarget:'{{uIAction.actionTarget}}',uIActionTag:'{{uIAction.uIActionTag}}',dataAccessAction:'{{uIAction.dataAccessAction}}',uIActionType:'{{uIAction.uIActionType}}'}{{/if}} },
{{/items}}
],
{{/ctrl.quickToolBarItems}}
{{/if}}
{{#if ctrl.batchToolBarItems}}
{{#ctrl.batchToolBarItems}}
batchToolbar: [
{{#items}}
{ id:'{{id}}',name:'{{name}}',caption:'{{caption}}',groupExtractMode:'{{groupExtractMode}}',itemType:'{{itemType}}',noPrivDisplayMode:'{{noPrivDisplayMode}}',showIcon:{{showIcon}},showCaption:{{showCaption}},tooltip:'{{tooltip}}',disabled: false, visible: true, imgPath: '{{imgPath}}',iconClass: '{{iconClass}}',xDataControlName:'{{xDataControlName}}',{{#if uIAction}}uIAction:{codeName:'{{uIAction.codeName}}',fullCodeName:'{{uIAction.fullCodeName}}',uIActionMode:'{{uIAction.uIActionMode}}',actionTarget:'{{uIAction.actionTarget}}',uIActionTag:'{{uIAction.uIActionTag}}',dataAccessAction:'{{uIAction.dataAccessAction}}',uIActionType:'{{uIAction.uIActionType}}'}{{/if}} },
{{/items}}
],
{{/ctrl.batchToolBarItems}}
{{/if}}
rules:{ rules:{
{{#each ctrl.psDEGridEditItemVRs as | ruleItem |}} {{#each ctrl.psDEGridEditItemVRs as | ruleItem |}}
{{#if (eq ruleItem.valueRuleType 'SYSVALUERULE')}} {{#if (eq ruleItem.valueRuleType 'SYSVALUERULE')}}
......
...@@ -37,7 +37,7 @@ interface CtrlEmit { ...@@ -37,7 +37,7 @@ interface CtrlEmit {
const emit = defineEmits<CtrlEmit>(); const emit = defineEmits<CtrlEmit>();
// 安装功能模块,提供状态和能力 // 安装功能模块,提供状态和能力
const { name, state, useCustom, onEditorEvent, onToolbarEvent, newRow, remove, save, load, refresh, getData } = new GridControl(ctrlState, props, emit).moduleInstall(); const { name, state, useCustom, onEditorEvent, onToolbarEvent, onActionColEvent, newRow, remove, save, load, refresh, getData } = new GridControl(ctrlState, props, emit).moduleInstall();
const { useScrollOption, useRowKey, useRowClassName, useCustomRow, useRowSelectionOption, onResizeColumn, onGridChange } = useCustom; const { useScrollOption, useRowKey, useRowClassName, useCustomRow, useRowSelectionOption, onResizeColumn, onGridChange } = useCustom;
// 暴露内部状态及能力 // 暴露内部状态及能力
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册