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

update:更新

1、视图state中实体标识调整
2、增加部件父容器传递
3、调整表格操作列执行逻辑
4、表格列值格式化、代码表支持
5、表格快速工具栏、批操作工具栏模型支持
6、表格快速工具栏绘制及行为调用
上级 811ad2e8
......@@ -12,7 +12,8 @@
height: '{{page.height}}',
width: '{{page.width}}',
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}},
appViewNavContexts:{{> @macro/front-end/common/navparam.hbs appNavParams=page.psAppViewNavContexts}},
appViewNavParams:{{> @macro/front-end/common/navparam.hbs appNavParams=page.psAppViewNavParams}},
......
......@@ -7,7 +7,7 @@
:value="text"
:viewParams="state.viewParams"
></AppCodelist>
{{else if (and item.enableLinkView item.linkPSAppView)}}
{{else if (and item.enableLinkView item.linkPSAppView (not isLink))}}
{{!-- 链接视图暂未支持 --}}
<app-column-link
:context="state.context"
......@@ -15,7 +15,7 @@
:linkView="column.linkView"
:valueItem="column.linkValueItem"
:data="record" >
<span>\{{text}}</span>
{{> COLUMNTEXT isLink=true}}
</app-column-link>
{{else}}
{{#if item.valueFormat}}
......@@ -59,7 +59,7 @@
</div>
<div v-else class="text-cell">
{{#if (and item.psDEUIAction item.psDEUIAction.uIActionTag)}}
<a style="{ display: 'block' }" @click="columnUIAction">
<a style="{ display: 'block' }" @click="onActionColEvent($event, record)">
{{> COLUMNTEXT}}
</a>
{{else}}
......@@ -69,7 +69,7 @@
{{else}}
<div class="text-cell">
{{#if (and item.psDEUIAction item.psDEUIAction.uIActionTag)}}
<a style="{ display: 'block' }" @click="columnUIAction">
<a style="{ display: 'block' }" @click="onActionColEvent($event, record)">
{{> COLUMNTEXT}}
</a>
{{else}}
......@@ -82,7 +82,7 @@
mode="link"
name="{{lowerCase item.codeName}}"
:actionModel="record.{{lowerCase item.codeName}}"
@onToolbarEvent="onToolbarEvent($event, record)"/>
@onToolbarEvent="onActionColEvent($event, record)"/>
{{/if}}
</div>
{{/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 {
public static edit(params: IUIActionParams) {
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;
}
const viewName = actionEnvironment?.state.viewLogics.openData.openDataViewName;
const view = App.getViewInfo(viewName);
if (!view) {
console.warn("视图参数不足");
......@@ -118,7 +137,7 @@ export class AppSysAction {
console.warn("数据参数不足");
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);
}
......@@ -129,12 +148,31 @@ export class AppSysAction {
* @return {*}
*/
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;
}
const viewName = actionEnvironment?.state.viewLogics.newData.newDataViewName;
const view = App.getViewInfo(viewName);
if (!view) {
return;
......
......@@ -35,14 +35,14 @@ export class EditView extends MainView {
onMounted(() => {
// 初始化数据能力部件
this.xDataControl = this.getForm();
const { isLoadDefault, context, viewparams, keyPSDEField } = this.state;
const { isLoadDefault, context, viewparams, appDeKeyFieldName } = this.state;
if (this.getForm() && isLoadDefault) {
const tag = this.getForm().name;
let action: string = '';
if (
keyPSDEField &&
context[keyPSDEField] &&
!Object.is(context[keyPSDEField], '')
appDeKeyFieldName &&
context[appDeKeyFieldName] &&
!Object.is(context[appDeKeyFieldName], '')
) {
action = 'load';
} else {
......
......@@ -23,6 +23,22 @@ export interface MainViewState extends ViewStateBase {
*/
appEntityCodeName: string;
/**
* 视图实体主属性CodeName
*
* @type {string}
* @memberof MainViewState
*/
appDeKeyFieldName: string;
/**
* 视图实体主信息属性CodeName
*
* @type {string}
* @memberof MainViewState
*/
appDeMajorFieldName: string;
/**
* 视图逻辑配置
*
......
......@@ -244,7 +244,7 @@ export class MDView extends MainView {
}
// 准备参数
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);
const params = {
context: tempContext,
......
......@@ -51,6 +51,7 @@ export class ControlBase {
public setState() {
this.state.viewSubject = toRef(this.props, 'viewSubject') as any;
this.state.controlName = this.props.name;
this.state.parent = this.props.parent;
}
/**
......
......@@ -43,6 +43,14 @@ export interface ControlStateBase {
*/
viewSubject: Subject<IActionParam>;
/**
* 父容器
*
* @type {*}
* @memberof ControlStateBase
*/
parent: any;
// 声明任意属性
[propName: string]: any;
}
\ No newline at end of file
......@@ -198,9 +198,14 @@ export class GridControl extends MDControl {
* @param {IParam} record
* @memberof GridControl
*/
public onToolbarEvent(actionParam: IActionParam, record: IParam) {
public onToolbarEvent(actionParam: IActionParam) {
const { data } = actionParam;
if (!record || !data) {
if (!data) {
console.warn("工具栏执行参数不足");
return;
}
const { uIAction } = data;
if (!uIAction) {
console.warn("工具栏执行参数不足");
return;
}
......@@ -208,23 +213,36 @@ export class GridControl extends MDControl {
const inputParam = {
context: this.state.context,
viewParams: this.state.viewParams,
data: record,
data: this.getData(),
event: data.event,
actionEnvironment: this
};
// 执行行为
App.getAppActionService().execute(data, inputParam);
App.getAppActionService().execute(uIAction, inputParam);
}
/**
* @description 处理表格操作列事件
* @description 处理表格行事件(操作列,界面行为)
* @param {IActionParam} actionParam 行为参数
* @param {IParam} [row] 表格行数据
* @memberof GridControl
*/
public onActionColEvent(actionParam: IActionParam, row?: IParam) {
const { tag, action, data } = actionParam;
console.log('触发界面行为', actionParam, row);
const { data } = actionParam;
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 {
return {
...superParams,
useCustom: this.useCustom(),
onEditorEvent: this.onEditorEvent,
onToolbarEvent: this.onToolbarEvent.bind(this)
onEditorEvent: this.onEditorEvent.bind(this),
onToolbarEvent: this.onToolbarEvent.bind(this),
onActionColEvent: this.onActionColEvent.bind(this)
};
}
}
......@@ -140,6 +140,24 @@ export const ctrlState = {
{{/if}}
{{/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:{
{{#each ctrl.psDEGridEditItemVRs as | ruleItem |}}
{{#if (eq ruleItem.valueRuleType 'SYSVALUERULE')}}
......
......@@ -37,7 +37,7 @@ interface 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;
// 暴露内部状态及能力
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册