1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
import { ViewEngine } from './view-engine';
/**
* 搜索视图引擎
*
* @export
* @class SearchViewEngine
* @extends {ViewEngine}
*/
export class SearchViewEngine extends ViewEngine {
/**
* 表单部件
*
* @protected
* @type {*}
* @memberof SearchViewEngine
*/
protected searchForm: any;
/**
* 初始化
*
* @param {*} options
* @memberof SearchViewEngine
*/
public init(options: any): void {
this.searchForm = options.searchform;
super.init(options);
}
/**
* 引擎加载
*
* @param {*} [opts={}]
* @memberof SearchViewEngine
*/
public load(opts: any = {}): void {
super.load(opts);
if (this.getSearchForm()) {
const tag = this.getSearchForm().name;
this.setViewState2({ tag: tag, action: 'loaddraft', viewdata: this.view.viewparams });
}
}
/**
* 事件处理
*
* @param {string} ctrlName
* @param {string} eventName
* @param {*} args
* @memberof SearchViewEngine
*/
public onCtrlEvent(ctrlName: string, eventName: string, args: any): void {
super.onCtrlEvent(ctrlName, eventName, args);
if (Object.is(ctrlName, 'searchform') || Object.is(ctrlName, 'quicksearchform')) {
this.searchFormEvent(eventName, args);
}
}
/**
* 搜索表单事件
*
* @param {string} eventName
* @param {*} [args={}]
* @memberof SearchViewEngine
*/
public searchFormEvent(eventName: string, args: any = {}): void {
if (Object.is(eventName, 'load')) {
this.onSearchFormLoad(args);
}
}
/**
* 搜索表单加载完成
*
* @param {*} [args={}]
* @memberof SearchViewEngine
*/
public onSearchFormLoad(args: any = {}): void {
}
/**
* 数据部件加载之前
*
* @param {*} [arg={}]
* @memberof SearchViewEngine
*/
public dataCtrlBeforeLoad(arg: any = {}): void {
if (this.view && this.view.viewparams && Object.keys(this.view.viewparams).length > 0) {
Object.assign(arg, this.view.viewparams);
}
if (this.getSearchForm()) {
Object.assign(arg, this.getSearchForm().getData());
}
if (this.view && !this.view.isExpandSearchForm) {
Object.assign(arg, { query: this.view.query });
}
// 快速分组和快速搜索栏
let otherQueryParam:any = {};
if(this.view && this.view.quickGroupData){
Object.assign(otherQueryParam,this.view.quickGroupData);
}
if(this.view && this.view.quickFormData){
Object.assign(otherQueryParam,this.view.quickFormData);
}
// 自定义查询条件
const dataCtrl:any = this.getDataCtrl();
if(dataCtrl && dataCtrl.controlInstance && dataCtrl.controlInstance.customCond){
Object.assign(otherQueryParam, { srfdsscope: dataCtrl.controlInstance.customCond });
}
Object.assign(arg,{viewparams:otherQueryParam});
}
/**
* 获取搜索表单
*
* @returns {*}
* @memberof SearchViewEngine
*/
public getSearchForm(): any {
return this.searchForm;
}
/**
* 获取数据部件
*
* @returns {*}
* @memberof SearchViewEngine
*/
public getDataCtrl(): any {}
/**
* @description 视图销毁
* @memberof SearchViewEngine
*/
public destroyed() {
super.destroyed();
this.searchForm = null;
}
}