@ibiz-template/runtime 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +167 -121
- package/dist/index.system.min.js +1 -1
- package/dist/index.system.min.js.map +1 -1
- package/out/application.js +1 -1
- package/out/controller/common/view/view.controller.d.ts.map +1 -1
- package/out/controller/common/view/view.controller.js +3 -0
- package/out/controller/control/data-view/data-view.controller.d.ts +7 -0
- package/out/controller/control/data-view/data-view.controller.d.ts.map +1 -1
- package/out/controller/control/data-view/data-view.controller.js +41 -0
- package/out/controller/control/grid/grid-column/grid-field-column/grid-field-column.controller.js +4 -1
- package/out/de-logic/utils/handle-src-val.d.ts.map +1 -1
- package/out/de-logic/utils/handle-src-val.js +9 -4
- package/out/interface/common/i-sort-item/i-sort-item.d.ts +24 -0
- package/out/interface/common/i-sort-item/i-sort-item.d.ts.map +1 -0
- package/out/interface/common/i-sort-item/i-sort-item.js +1 -0
- package/out/interface/common/index.d.ts +1 -0
- package/out/interface/common/index.d.ts.map +1 -1
- package/out/interface/controller/state/control/i-data-view-control.state.d.ts +8 -0
- package/out/interface/controller/state/control/i-data-view-control.state.d.ts.map +1 -1
- package/out/model/view/view.d.ts.map +1 -1
- package/out/model/view/view.js +9 -1
- package/out/service/service/control/control.service.d.ts.map +1 -1
- package/out/service/service/control/control.service.js +2 -1
- package/out/service/service/entity/method/de-action.d.ts.map +1 -1
- package/out/service/service/entity/method/de-action.js +2 -1
- package/out/service/vo/control.vo.d.ts +7 -7
- package/out/service/vo/control.vo.d.ts.map +1 -1
- package/out/service/vo/control.vo.js +54 -74
- package/out/ui-action/provider/ui-action-provider-base.d.ts.map +1 -1
- package/out/ui-action/provider/ui-action-provider-base.js +4 -2
- package/out/ui-logic/utils/handle-src-val.d.ts.map +1 -1
- package/out/ui-logic/utils/handle-src-val.js +9 -4
- package/package.json +3 -3
- package/src/application.ts +2 -2
- package/src/controller/common/view/view.controller.ts +2 -0
- package/src/controller/control/data-view/data-view.controller.ts +46 -0
- package/src/controller/control/grid/grid-column/grid-field-column/grid-field-column.controller.ts +4 -4
- package/src/de-logic/utils/handle-src-val.ts +12 -8
- package/src/interface/common/i-sort-item/i-sort-item.ts +25 -0
- package/src/interface/common/index.ts +1 -0
- package/src/interface/controller/state/control/i-data-view-control.state.ts +9 -0
- package/src/model/view/view.ts +9 -1
- package/src/service/service/control/control.service.ts +2 -2
- package/src/service/service/entity/method/de-action.ts +2 -1
- package/src/service/vo/control.vo.ts +69 -25
- package/src/ui-action/provider/ui-action-provider-base.ts +7 -2
- package/src/ui-logic/utils/handle-src-val.ts +12 -8
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
MDCtrlLoadParams,
|
|
13
13
|
IMDControlGroupState,
|
|
14
14
|
CodeListItem,
|
|
15
|
+
ISortItem,
|
|
15
16
|
} from '../../../interface';
|
|
16
17
|
import { ControlVO } from '../../../service';
|
|
17
18
|
import { UIActionUtil } from '../../../ui-action';
|
|
@@ -65,6 +66,7 @@ export class DataViewControlController<
|
|
|
65
66
|
this.state.noSort = this.model.noSort === true;
|
|
66
67
|
this.state.size = this.model.pagingSize || 20;
|
|
67
68
|
this.state.singleSelect = this.model.singleSelect === true;
|
|
69
|
+
this.state.sortItems = [];
|
|
68
70
|
}
|
|
69
71
|
|
|
70
72
|
/**
|
|
@@ -77,6 +79,7 @@ export class DataViewControlController<
|
|
|
77
79
|
protected async onCreated(): Promise<void> {
|
|
78
80
|
await super.onCreated();
|
|
79
81
|
await this.initControlService();
|
|
82
|
+
this.initSortItems();
|
|
80
83
|
}
|
|
81
84
|
|
|
82
85
|
/**
|
|
@@ -454,4 +457,47 @@ export class DataViewControlController<
|
|
|
454
457
|
event,
|
|
455
458
|
});
|
|
456
459
|
}
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* 初始化排序项集合
|
|
463
|
+
* @author lxm
|
|
464
|
+
* @date 2023-10-24 06:11:02
|
|
465
|
+
* @return {*} {void}
|
|
466
|
+
*/
|
|
467
|
+
initSortItems(): void {
|
|
468
|
+
if (!this.model.dedataViewItems?.length) {
|
|
469
|
+
return;
|
|
470
|
+
}
|
|
471
|
+
const sortItems: ISortItem[] = [];
|
|
472
|
+
const { minorSortAppDEFieldId, minorSortDir } = this.model;
|
|
473
|
+
const hasDefaultSort = minorSortAppDEFieldId && minorSortDir;
|
|
474
|
+
this.model.dedataViewItems.forEach(item => {
|
|
475
|
+
if (!item.enableSort) {
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
let { caption } = item;
|
|
480
|
+
if (item.capLanguageRes) {
|
|
481
|
+
caption = ibiz.i18n.t(item.capLanguageRes.lanResTag!, item.caption);
|
|
482
|
+
}
|
|
483
|
+
if (!item.appDEFieldId) {
|
|
484
|
+
throw new RuntimeModelError(item, '启用排序的项必须关联实体属性');
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
const tempItem: ISortItem = {
|
|
488
|
+
caption: caption!,
|
|
489
|
+
key: item.appDEFieldId,
|
|
490
|
+
};
|
|
491
|
+
|
|
492
|
+
// 默认排序
|
|
493
|
+
if (hasDefaultSort && minorSortAppDEFieldId === item.appDEFieldId) {
|
|
494
|
+
tempItem.order = minorSortDir.toLowerCase() as 'asc' | 'desc';
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
sortItems.push(tempItem);
|
|
498
|
+
});
|
|
499
|
+
if (sortItems.length > 0) {
|
|
500
|
+
this.state.sortItems = sortItems;
|
|
501
|
+
}
|
|
502
|
+
}
|
|
457
503
|
}
|
package/src/controller/control/grid/grid-column/grid-field-column/grid-field-column.controller.ts
CHANGED
|
@@ -64,10 +64,10 @@ export class GridFieldColumnController extends GridColumnController<IDEGridField
|
|
|
64
64
|
await super.onInit();
|
|
65
65
|
|
|
66
66
|
// 加载代码表防抖
|
|
67
|
-
this.loadCodeList = debounce(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
) as typeof this.loadCodeList;
|
|
67
|
+
this.loadCodeList = debounce(this.loadCodeList, 300, {
|
|
68
|
+
leading: true,
|
|
69
|
+
trailing: false,
|
|
70
|
+
}) as typeof this.loadCodeList;
|
|
71
71
|
|
|
72
72
|
// 默认加载一次代码表
|
|
73
73
|
this.loadCodeList();
|
|
@@ -80,14 +80,18 @@ export function handleSrcVal(
|
|
|
80
80
|
|
|
81
81
|
if (value && srcField) {
|
|
82
82
|
try {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
83
|
+
if (Array.isArray(value)) {
|
|
84
|
+
value = value[Number(srcField)];
|
|
85
|
+
} else {
|
|
86
|
+
value = ScriptFactory.execScriptFn(
|
|
87
|
+
{ srcValue: value },
|
|
88
|
+
`srcValue.${srcField}`,
|
|
89
|
+
{
|
|
90
|
+
singleRowReturn: true,
|
|
91
|
+
isAsync: false,
|
|
92
|
+
},
|
|
93
|
+
);
|
|
94
|
+
}
|
|
91
95
|
} catch (error) {
|
|
92
96
|
ibiz.log.error(`从源参数取属性${srcField}报错,源参数:`, value);
|
|
93
97
|
throw error;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface ISortItem {
|
|
2
|
+
/**
|
|
3
|
+
* 唯一标识
|
|
4
|
+
* @author lxm
|
|
5
|
+
* @date 2023-10-24 05:55:30
|
|
6
|
+
* @type {string}
|
|
7
|
+
*/
|
|
8
|
+
key: string;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 显示标题
|
|
12
|
+
* @author lxm
|
|
13
|
+
* @date 2023-10-24 05:55:36
|
|
14
|
+
* @type {string}
|
|
15
|
+
*/
|
|
16
|
+
caption: string;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* 排序顺序
|
|
20
|
+
* @author lxm
|
|
21
|
+
* @date 2023-10-24 05:55:45
|
|
22
|
+
* @type {('asc' | 'desc')}
|
|
23
|
+
*/
|
|
24
|
+
order?: 'asc' | 'desc';
|
|
25
|
+
}
|
|
@@ -31,3 +31,4 @@ export type {
|
|
|
31
31
|
export type { IOpenViewOptions } from './i-open-view-options/i-open-view-options';
|
|
32
32
|
export type { IErrorHandler } from './i-error-handler/i-error-handler';
|
|
33
33
|
export type { IFloatWindowOptions } from './i-float-window-options/i-float-window-options';
|
|
34
|
+
export type { ISortItem } from './i-sort-item/i-sort-item';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ISortItem } from '../../../common';
|
|
1
2
|
import { IButtonContainerState } from '../../common';
|
|
2
3
|
import { IMDControlState } from './i-md-control.state';
|
|
3
4
|
|
|
@@ -16,4 +17,12 @@ export interface IDataViewControlState extends IMDControlState {
|
|
|
16
17
|
* @memberof PortletPartState
|
|
17
18
|
*/
|
|
18
19
|
groupActionGroupState?: IButtonContainerState;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 排序栏项集合
|
|
23
|
+
* @author lxm
|
|
24
|
+
* @date 2023-10-24 05:57:37
|
|
25
|
+
* @type {ISortItem[]}
|
|
26
|
+
*/
|
|
27
|
+
sortItems: ISortItem[];
|
|
19
28
|
}
|
package/src/model/view/view.ts
CHANGED
|
@@ -53,5 +53,13 @@ export function getViewEngines(view: IAppView): IAppViewEngine[] {
|
|
|
53
53
|
if (viewLayoutPanel) {
|
|
54
54
|
appViewEngines.push(...(viewLayoutPanel.appViewEngines || []));
|
|
55
55
|
}
|
|
56
|
-
return appViewEngines
|
|
56
|
+
return appViewEngines.filter(engine => {
|
|
57
|
+
switch (engine.engineCat) {
|
|
58
|
+
case 'CTRL':
|
|
59
|
+
ibiz.log.warn(`未支持的引擎分类:${engine.engineType}`);
|
|
60
|
+
return false;
|
|
61
|
+
default:
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
});
|
|
57
65
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IHttpResponse } from '@ibiz-template/core';
|
|
1
|
+
import { IHttpResponse, clone } from '@ibiz-template/core';
|
|
2
2
|
import { IControl } from '@ibiz/model-core';
|
|
3
3
|
import { ControlVO } from '../../vo/control.vo';
|
|
4
4
|
import { UIMapField } from '../../vo/ui-map-field';
|
|
@@ -92,7 +92,7 @@ export class ControlService<T extends IControl = IControl> {
|
|
|
92
92
|
*/
|
|
93
93
|
handleResponse(res: IHttpResponse): IHttpResponse {
|
|
94
94
|
// 公共处理
|
|
95
|
-
return res;
|
|
95
|
+
return clone(res);
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
/**
|
|
@@ -50,7 +50,8 @@ export class DEActionMethod extends Method {
|
|
|
50
50
|
data: IData | IData[],
|
|
51
51
|
): Promise<IData | IData[]> {
|
|
52
52
|
if (isArray(data)) {
|
|
53
|
-
|
|
53
|
+
// 多项数据不做dto转换
|
|
54
|
+
return data;
|
|
54
55
|
}
|
|
55
56
|
return this.input.handle(context, data);
|
|
56
57
|
}
|
|
@@ -2,6 +2,8 @@ import { clone, isNil } from 'ramda';
|
|
|
2
2
|
import { Srfuf } from '../constant';
|
|
3
3
|
import { UIMapField } from './ui-map-field';
|
|
4
4
|
|
|
5
|
+
const unEnumerableKeys = ['srfkey', 'srfmajortext'];
|
|
6
|
+
|
|
5
7
|
/**
|
|
6
8
|
* 部件UI显示层数据转换
|
|
7
9
|
*
|
|
@@ -41,12 +43,7 @@ export class ControlVO {
|
|
|
41
43
|
* @date 2022-09-06 22:09:24
|
|
42
44
|
* @type {Srfuf}
|
|
43
45
|
*/
|
|
44
|
-
|
|
45
|
-
if (isNil(this.$origin.srfuf)) {
|
|
46
|
-
return this.srfkey ? Srfuf.UPDATE : Srfuf.CREATE;
|
|
47
|
-
}
|
|
48
|
-
return this.$origin.srfuf;
|
|
49
|
-
}
|
|
46
|
+
declare srfuf: Srfuf;
|
|
50
47
|
|
|
51
48
|
/**
|
|
52
49
|
* 主键
|
|
@@ -55,9 +52,7 @@ export class ControlVO {
|
|
|
55
52
|
* @date 2022-09-07 19:09:42
|
|
56
53
|
* @type {string}
|
|
57
54
|
*/
|
|
58
|
-
|
|
59
|
-
return this.$origin.srfkey;
|
|
60
|
-
}
|
|
55
|
+
declare srfkey: string;
|
|
61
56
|
|
|
62
57
|
/**
|
|
63
58
|
* 主信息
|
|
@@ -66,9 +61,7 @@ export class ControlVO {
|
|
|
66
61
|
* @date 2022-09-07 19:09:42
|
|
67
62
|
* @type {string}
|
|
68
63
|
*/
|
|
69
|
-
|
|
70
|
-
return this.$origin.srfmajortext;
|
|
71
|
-
}
|
|
64
|
+
declare srfmajortext: string;
|
|
72
65
|
|
|
73
66
|
/**
|
|
74
67
|
* 实体模型标识
|
|
@@ -77,9 +70,7 @@ export class ControlVO {
|
|
|
77
70
|
* @date 2022-09-07 19:09:42
|
|
78
71
|
* @type {string}
|
|
79
72
|
*/
|
|
80
|
-
|
|
81
|
-
return this.$origin.srfdeid;
|
|
82
|
-
}
|
|
73
|
+
declare srfdeid: string;
|
|
83
74
|
|
|
84
75
|
/**
|
|
85
76
|
* 实体模型代码名称
|
|
@@ -88,9 +79,7 @@ export class ControlVO {
|
|
|
88
79
|
* @date 2022-09-07 19:09:42
|
|
89
80
|
* @type {string}
|
|
90
81
|
*/
|
|
91
|
-
|
|
92
|
-
return this.$origin.srfdecodename;
|
|
93
|
-
}
|
|
82
|
+
declare srfdecodename: string;
|
|
94
83
|
|
|
95
84
|
/**
|
|
96
85
|
* 实体主键属性
|
|
@@ -99,9 +88,7 @@ export class ControlVO {
|
|
|
99
88
|
* @date 2022-09-07 19:09:42
|
|
100
89
|
* @type {string}
|
|
101
90
|
*/
|
|
102
|
-
|
|
103
|
-
return this.$origin.srfkeyfile;
|
|
104
|
-
}
|
|
91
|
+
declare srfkeyfile: string;
|
|
105
92
|
|
|
106
93
|
/**
|
|
107
94
|
* 实体主信息属性
|
|
@@ -110,9 +97,7 @@ export class ControlVO {
|
|
|
110
97
|
* @date 2022-09-07 19:09:42
|
|
111
98
|
* @type {string}
|
|
112
99
|
*/
|
|
113
|
-
|
|
114
|
-
return this.$origin.srfmajorfile;
|
|
115
|
-
}
|
|
100
|
+
declare srfmajorfile: string;
|
|
116
101
|
|
|
117
102
|
/**
|
|
118
103
|
* Creates an instance of ControlVO.
|
|
@@ -137,6 +122,65 @@ export class ControlVO {
|
|
|
137
122
|
value: $dataUIMap || new Map(),
|
|
138
123
|
});
|
|
139
124
|
|
|
125
|
+
Object.defineProperty(this, 'srfuf', {
|
|
126
|
+
get() {
|
|
127
|
+
if (isNil(this.$origin.srfuf)) {
|
|
128
|
+
return this.srfkey ? Srfuf.UPDATE : Srfuf.CREATE;
|
|
129
|
+
}
|
|
130
|
+
return this.$origin.srfuf;
|
|
131
|
+
},
|
|
132
|
+
enumerable: false,
|
|
133
|
+
configurable: true,
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
Object.defineProperty(this, 'srfkey', {
|
|
137
|
+
get() {
|
|
138
|
+
return this.$origin.srfkey;
|
|
139
|
+
},
|
|
140
|
+
enumerable: false,
|
|
141
|
+
configurable: true,
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
Object.defineProperty(this, 'srfmajortext', {
|
|
145
|
+
get() {
|
|
146
|
+
return this.$origin.srfmajortext;
|
|
147
|
+
},
|
|
148
|
+
enumerable: false,
|
|
149
|
+
configurable: true,
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
Object.defineProperty(this, 'srfdeid', {
|
|
153
|
+
get() {
|
|
154
|
+
return this.$origin.srfdeid;
|
|
155
|
+
},
|
|
156
|
+
enumerable: false,
|
|
157
|
+
configurable: true,
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
Object.defineProperty(this, 'srfdecodename', {
|
|
161
|
+
get() {
|
|
162
|
+
return this.$origin.srfdecodename;
|
|
163
|
+
},
|
|
164
|
+
enumerable: false,
|
|
165
|
+
configurable: true,
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
Object.defineProperty(this, 'srfkeyfile', {
|
|
169
|
+
get() {
|
|
170
|
+
return this.$origin.srfkeyfile;
|
|
171
|
+
},
|
|
172
|
+
enumerable: false,
|
|
173
|
+
configurable: true,
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
Object.defineProperty(this, 'srfmajorfile', {
|
|
177
|
+
get() {
|
|
178
|
+
return this.$origin.srfmajorfile;
|
|
179
|
+
},
|
|
180
|
+
enumerable: false,
|
|
181
|
+
configurable: true,
|
|
182
|
+
});
|
|
183
|
+
|
|
140
184
|
// 先转换映射的属性
|
|
141
185
|
this.$dataUIMap.forEach((mapField, key) => {
|
|
142
186
|
const value = mapField.dataKey;
|
|
@@ -182,7 +226,7 @@ export class ControlVO {
|
|
|
182
226
|
Object.prototype.hasOwnProperty.call(this.$origin, uiKey)
|
|
183
227
|
) {
|
|
184
228
|
Object.defineProperty(this, uiKey, {
|
|
185
|
-
enumerable:
|
|
229
|
+
enumerable: !unEnumerableKeys.includes(uiKey),
|
|
186
230
|
configurable: true,
|
|
187
231
|
get() {
|
|
188
232
|
// srfkey 视图id优先,拿不到实体属性则拿界面属性(前端id)
|
|
@@ -192,6 +192,11 @@ export abstract class UIActionProviderBase implements IUIActionProvider {
|
|
|
192
192
|
|
|
193
193
|
// 准备实体名称
|
|
194
194
|
const deName = calcDeCodeNameById(action.appDataEntityId!);
|
|
195
|
+
const entity = await ibiz.hub.getAppDataEntity(
|
|
196
|
+
action.appDataEntityId!,
|
|
197
|
+
context.srfappid,
|
|
198
|
+
);
|
|
199
|
+
const keyField = entity.keyAppDEFieldId!; // 主键属性名称
|
|
195
200
|
|
|
196
201
|
// 根据数据目标处理数据集合
|
|
197
202
|
switch (action.actionTarget) {
|
|
@@ -211,7 +216,7 @@ export abstract class UIActionProviderBase implements IUIActionProvider {
|
|
|
211
216
|
case 'MULTIKEY':
|
|
212
217
|
resultData =
|
|
213
218
|
deName && data.length > 0
|
|
214
|
-
? data.map(item => ({ [
|
|
219
|
+
? data.map(item => ({ [keyField]: item.srfkey || item[keyField] }))
|
|
215
220
|
: [{}];
|
|
216
221
|
break;
|
|
217
222
|
// 单项数据主键,传递包含一个对象的数组,对象里只含有一个主键
|
|
@@ -219,7 +224,7 @@ export abstract class UIActionProviderBase implements IUIActionProvider {
|
|
|
219
224
|
{
|
|
220
225
|
const originData = data[0] || {};
|
|
221
226
|
resultData = deName
|
|
222
|
-
? [{ [
|
|
227
|
+
? [{ [keyField]: originData.srfkey || originData[keyField] }]
|
|
223
228
|
: [{}];
|
|
224
229
|
}
|
|
225
230
|
break;
|
|
@@ -76,14 +76,18 @@ export function handleSrcVal(
|
|
|
76
76
|
|
|
77
77
|
if (value && srcField) {
|
|
78
78
|
try {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
79
|
+
if (Array.isArray(value)) {
|
|
80
|
+
value = value[Number(srcField)];
|
|
81
|
+
} else {
|
|
82
|
+
value = ScriptFactory.execScriptFn(
|
|
83
|
+
{ srcValue: value },
|
|
84
|
+
`srcValue.${srcField}`,
|
|
85
|
+
{
|
|
86
|
+
singleRowReturn: true,
|
|
87
|
+
isAsync: false,
|
|
88
|
+
},
|
|
89
|
+
);
|
|
90
|
+
}
|
|
87
91
|
} catch (error) {
|
|
88
92
|
ibiz.log.error(`从源参数取属性${srcField}报错,源参数:`, value);
|
|
89
93
|
throw error;
|