提交 5d23a255 编写于 作者: Mosher's avatar Mosher

update:更新表格导航引擎

上级 cef56fb5
import ViewEngine from "./view-engine";
/**
* 导航视图引擎
*
* @export
* @class ExpViewEngine
* @extends {ViewEngine}
*/
export class ExpViewEngine extends ViewEngine {
/**
* 导航栏部件
*
* @protected
* @type {*}
* @memberof ExpViewEngine
*/
protected expBar: any = null;
/**
* 是否真正选中
*
* @protected
* @type {boolean}
* @memberof ExpViewEngine
*/
protected isRealSelected: boolean = false;
/**
* 是否关闭导航视图
*
* @protected
* @type {boolean}
* @memberof ExpViewEngine
*/
protected isCloseNavView: boolean = false;
/**
* 引擎加载
*
* @memberof ExpViewEngine
*/
public load() {
super.load();
if (this.getExpBar() && this.isLoadDefault) {
const tag = this.getExpBar().name;
this.setViewState2({ tag: tag, action: 'load', viewdata: this.view.viewparams });
} else {
this.isLoadDefault = true;
}
}
/**
* 搜索
*
* @param {*} data
* @memberof ExpViewEngine
*/
public search(data: any) {
const expBar = this.getExpBar();
if (expBar) {
this.setViewState2({ tag: expBar.name, action: 'load', viewdata: null });
}
}
/**
* 关闭导航视图
*
* @memberof ExpViewEngine
*/
public closeNavView() {
this.view.backSplit = this.view.split;
this.view.split = 1;
this.view.navItem = null;
this.isCloseNavView = true;
}
/**
* 处理导航视图重绘(有选中项,且导航视图需要刷新则通知嵌入导航视图执行刷新逻辑)
*
* @memberof ExpViewEngine
*/
public handleNavViewRefresh(tag: string) {
if (this.view && this.view.viewState && this.isRealSelected) {
this.setViewState2({ tag, action: 'load', viewdata: this.view.viewparams });
}
}
/**
* 事件处理
*
* @param {string} ctrlName 事件标识
* @param {string} eventName
* @param {*} args
* @memberof ExpViewEngine
*/
public onCtrlEvent(ctrlName: string, eventName: string, args: any) {
const expBar = this.getExpBar();
if (ctrlName === expBar?.name) {
this.handleExpBarEvents(eventName, args);
}
if (ctrlName === expBar?.xDataControlName) {
this.handleXDataControlEvents(eventName, args);
}
}
/**
* 处理导航栏事件
*
* @protected
* @param {string} eventName
* @param {*} args
* @memberof ExpViewEngine
*/
protected handleExpBarEvents(eventName: string, args: any) {
if (Object.is(eventName, 'load')) {
this.view.$emit('viewload', args);
}
if (Object.is(eventName, 'selectionchange')) {
if (this.isCloseNavView) {
this.isCloseNavView = false;
return;
}
if (this.view && args && args.srfnavdata && args.srfnavdata.context && args.srfnavdata.context.viewpath) {
this.view.navItem = args;
if (this.view.backSplit !== 0) {
this.view.split = this.view.backSplit;
}
// 计算真实选中值
if (args && args.data && args.data[0]) {
const selectedData = args.data[0];
const result = Object.keys(selectedData).find((key: string) => {
return selectedData[key] !== null && key !== 'srfchecked';
})
if(result){
this.isRealSelected = true;
}else{
this.isRealSelected = false;
}
}
this.view.$forceUpdate();
}
this.view.$emit('viewdataschange', args?.data);
}
if (Object.is(eventName, 'activated')) {
this.view.$emit('viewdatasactivated', args);
}
}
/**
* 处理导航栏数据部件事件
*
* @protected
* @param {string} eventName
* @param {*} args
* @memberof ExpViewEngine
*/
protected handleXDataControlEvents(eventName: string, args: any) {
if (Object.is(eventName, 'beforeload')) {
this.handleBeforeLoad(args);
}
}
/**
* 导航栏数据部件加载之前
*
* @protected
* @param {*} args
* @memberof ExpViewEngine
*/
protected handleBeforeLoad(args: any) {
if (this.view && this.view.quickGroupData) {
Object.assign(args, { viewparams: this.view.quickGroupData });
}
}
/**
* 获取导航栏
*
* @return {*}
* @memberof ExpViewEngine
*/
public getExpBar() {
return this.expBar;
}
/**
* @description 视图销毁
* @memberof ExpViewEngine
*/
public destroyed() {
this.expBar = null;
}
}
\ No newline at end of file
import ViewEngine from './view-engine';
import { ExpViewEngine } from './exp-view-engine';
/**
* 表格导航视图界面引擎
......@@ -7,24 +7,7 @@ import ViewEngine from './view-engine';
* @class GridExpViewEngine
* @extends {ViewEngine}
*/
export default class GridExpViewEngine extends ViewEngine {
/**
* 表格导航栏部件
*
* @type {*}
* @memberof GridExpViewEngine
*/
public gridExpBar: any = null;
/**
* Creates an instance of GridExpViewEngine.
*
* @memberof GridExpViewEngine
*/
constructor() {
super();
}
export default class GridExpViewEngine extends ExpViewEngine {
/**
* 初始化引擎
......@@ -33,79 +16,17 @@ export default class GridExpViewEngine extends ViewEngine {
* @memberof GridExpViewEngine
*/
public init(options: any): void {
this.gridExpBar = options.gridexpbar;
this.expBar = options.gridexpbar;
super.init(options);
}
/**
* 引擎加载
*
* @description 视图销毁
* @memberof GridExpViewEngine
*/
public load(): void {
super.load();
if (this.getGridExpBar() && this.isLoadDefault) {
const tag = this.getGridExpBar().name;
this.setViewState2({ tag: tag, action: 'load', viewdata: this.view.viewparams });
} else {
this.isLoadDefault = true;
}
}
/**
* 部件事件机制
*
* @param {string} ctrlName
* @param {string} eventName
* @param {*} args
* @memberof GridExpViewEngine
*/
public onCtrlEvent(ctrlName: string, eventName: string, args: any): void {
super.onCtrlEvent(ctrlName, eventName, args);
if (Object.is(ctrlName, 'gridexpbar')) {
this.gridExpBarEvent(eventName, args);
}
public destroyed() {
super.destroyed();
this.expBar = null;
}
/**
* 表格导航事件
*
* @param {string} eventName
* @param {*} args
* @memberof GridExpViewEngine
*/
public gridExpBarEvent(eventName: string, args: any): void {
if (Object.is(eventName, 'load')) {
this.view.$emit('viewload', args);
}
if (Object.is(eventName, 'selectionchange')) {
this.view.$emit('viewdataschange', args);
}
if (Object.is(eventName, 'activated')) {
this.view.$emit('viewdatasactivated', args);
}
}
/**
* 获取部件对象
*
* @returns {*}
* @memberof GridExpViewEngine
*/
public getGridExpBar(): any {
return this.gridExpBar;
}
/**
* @description 销毁
* @memberof GridExpViewEngine
*/
public destroy() {
super.destroy();
this.gridExpBar = null;
}
}
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册