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
import { MDViewBase } from './mdview-base';
import { IndexPickupDataViewInterface, ModelTool } from 'ibiz-core';
import { IPSAppDEDataView, IPSDEDataView } from '@ibiz/dynamic-model-api';
/**
* 索引关系选择视图基类
*
* @export
* @class IndexPickupDataViewBase
* @extends {MDViewBase}
* @implements {IndexPickupDataViewInterface}
*/
export class IndexPickupDataViewBase extends MDViewBase implements IndexPickupDataViewInterface {
/**
* 实体索引关系选择数据视图(部件视图)
*
* @type {IPSAppDEDataView}
* @memberof IndexPickupDataViewBase
*/
public declare viewInstance: IPSAppDEDataView;
/**
* 数据视图部件实例对象
*
* @type {IPSDEDataView}
* @memberof IndexPickupDataViewBase
*/
private dataviewInstance!: IPSDEDataView;
/**
* 是否单选
*
* @type {boolean}
* @memberof IndexPickupDataViewBase
*/
public isSingleSelect: boolean = false;
/**
* 引擎初始化
*
* @param {*} opts
* @return {*}
* @memberof IndexPickupDataViewBase
*/
public engineInit(opts: any) {
if (this.Environment && this.Environment.isPreviewMode) {
return;
}
if (this.engine && this.dataviewInstance) {
let engineOpts = Object.assign({
view: this,
p2k: '0',
isLoadDefault: this.viewInstance?.loadDefault,
keyPSDEField: this.appDeCodeName.toLowerCase(),
majorPSDEField: this.appDeMajorFieldName.toLowerCase(),
opendata: (args: any[], fullargs?: any[], params?: any, $event?: any, xData?: any) => {
this.opendata(args, fullargs, params, $event, xData);
},
newdata: (args: any[], fullargs?: any[], params?: any, $event?: any, xData?: any) => {
this.newdata(args, fullargs, params, $event, xData);
},
dataview: (this.$refs[this.dataviewInstance?.name] as any).ctrl,
}, opts)
if (this.searchFormInstance?.name && this.$refs[this.searchFormInstance.name]) {
engineOpts.searchform = ((this.$refs[this.searchFormInstance.name] as any).ctrl);
}
if (this.quickSearchFormInstance?.name && this.$refs[this.quickSearchFormInstance.name]) {
engineOpts.quicksearchform = ((this.$refs[this.quickSearchFormInstance.name] as any).ctrl);
}
if (this.searchBarInstance?.name && this.$refs[this.searchBarInstance.name]) {
engineOpts.searchbar = ((this.$refs[this.searchBarInstance.name] as any).ctrl);
}
this.engine.init(engineOpts);
}
}
/**
* 初始化表单选择数据视图实例
*
* @memberof IndexPickupDataViewBase
*/
public async viewModelInit() {
this.viewInstance = (this.staticProps?.modeldata) as IPSAppDEDataView;
await super.viewModelInit();
this.dataviewInstance = ModelTool.findPSControlByType("DATAVIEW", this.viewInstance.getPSControls());
}
/**
* 监听视图静态参数变化
*
* @param {*} newVal
* @param {*} oldVal
* @memberof IndexPickupDataViewBase
*/
public onStaticPropsChange(newVal: any, oldVal: any) {
this.isSingleSelect = newVal.isSingleSelect;
super.onStaticPropsChange(newVal, oldVal);
}
/**
* 渲染视图主体内容区
*
* @memberof IndexPickupDataViewBase
*/
public renderMainContent() {
let { targetCtrlName, targetCtrlParam, targetCtrlEvent } = this.computeTargetCtrlData(this.dataviewInstance);
return this.$createElement(targetCtrlName, { props: targetCtrlParam, ref: this.dataviewInstance?.name, on: targetCtrlEvent });
}
/**
* 计算目标部件所需参数
*
* @param {string} [controlType]
* @returns
* @memberof IndexPickupDataViewBase
*/
public computeTargetCtrlData(controlInstance: any, args?: any) {
const { targetCtrlName, targetCtrlParam, targetCtrlEvent } = super.computeTargetCtrlData(controlInstance, args);
Object.assign(targetCtrlParam.staticProps, {
isSingleSelect: this.isSingleSelect
});
return { targetCtrlName, targetCtrlParam, targetCtrlEvent };
}
}