@ibiz-template/runtime 0.1.23 → 0.1.25
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 +184 -109
- package/dist/index.system.min.js +1 -1
- package/dist/index.system.min.js.map +1 -1
- package/out/command/app/app-func/app-func.js +2 -2
- package/out/config/global-config.d.ts.map +1 -1
- package/out/config/global-config.js +1 -0
- package/out/controller/common/control/control.controller.d.ts +4 -4
- package/out/controller/common/control/control.controller.d.ts.map +1 -1
- package/out/controller/common/control/control.controller.js +3 -2
- package/out/controller/common/control/md-control.controller.d.ts +20 -1
- package/out/controller/common/control/md-control.controller.d.ts.map +1 -1
- package/out/controller/common/control/md-control.controller.js +21 -2
- package/out/controller/common/editor/editor.controller.js +2 -2
- package/out/controller/common/view/view.controller.js +2 -2
- package/out/controller/control/exp-bar/calendar-exp-bar.controller.d.ts.map +1 -1
- package/out/controller/control/exp-bar/calendar-exp-bar.controller.js +1 -0
- package/out/controller/control/exp-bar/exp-bar.controller.d.ts +10 -0
- package/out/controller/control/exp-bar/exp-bar.controller.d.ts.map +1 -1
- package/out/controller/control/exp-bar/exp-bar.controller.js +32 -7
- package/out/controller/control/exp-bar/tree-exp-bar.controller.d.ts.map +1 -1
- package/out/controller/control/exp-bar/tree-exp-bar.controller.js +1 -0
- package/out/controller/control/form/edit-form/edit-form.controller.d.ts.map +1 -1
- package/out/controller/control/form/edit-form/edit-form.controller.js +7 -1
- package/out/controller/control/form/form-detail/form-druipart/form-druipart.controller.js +2 -2
- package/out/controller/control/grid/grid-column/grid-field-column/grid-field-column.controller.js +2 -2
- package/out/controller/control/pickup-view-panel/pickup-view-panel.controller.js +2 -2
- package/out/de-logic/de-logic.d.ts +9 -0
- package/out/de-logic/de-logic.d.ts.map +1 -1
- package/out/de-logic/de-logic.js +14 -0
- package/out/interface/common/i-global-config/i-global-view-config.d.ts +8 -0
- package/out/interface/common/i-global-config/i-global-view-config.d.ts.map +1 -1
- package/out/interface/controller/controller/control/i-exp-bar-control.controller.d.ts +10 -0
- package/out/interface/controller/controller/control/i-exp-bar-control.controller.d.ts.map +1 -1
- package/out/interface/provider/i-control.provider.d.ts +15 -0
- package/out/interface/provider/i-control.provider.d.ts.map +1 -1
- package/out/interface/provider/i-view.provider.d.ts +15 -0
- package/out/interface/provider/i-view.provider.d.ts.map +1 -1
- package/out/logic-scheduler/executor/app-ui-logic-executor.js +4 -4
- package/out/service/dto/method.dto.d.ts.map +1 -1
- package/out/service/dto/method.dto.js +4 -3
- package/out/service/service/entity/method/method.d.ts.map +1 -1
- package/out/service/service/entity/method/method.js +0 -1
- package/out/service/vo/control.vo.d.ts.map +1 -1
- package/out/service/vo/control.vo.js +9 -12
- package/out/service/vo/ui-map-field.d.ts +7 -0
- package/out/service/vo/ui-map-field.d.ts.map +1 -1
- package/out/service/vo/ui-map-field.js +24 -0
- package/out/ui-action/provider/ui-action-provider-base.js +2 -2
- package/out/utils/nav-params/calc-nav-params.js +2 -2
- package/out/utils/nav-params/nav-params.d.ts +11 -25
- package/out/utils/nav-params/nav-params.d.ts.map +1 -1
- package/out/utils/nav-params/nav-params.js +79 -84
- package/out/utils/open-redirect-view/open-redirect-view.js +2 -2
- package/package.json +3 -3
- package/src/command/app/app-func/app-func.ts +2 -2
- package/src/config/global-config.ts +1 -0
- package/src/controller/common/control/control.controller.ts +5 -4
- package/src/controller/common/control/md-control.controller.ts +34 -3
- package/src/controller/common/editor/editor.controller.ts +2 -2
- package/src/controller/common/view/view.controller.ts +2 -2
- package/src/controller/control/exp-bar/calendar-exp-bar.controller.ts +1 -0
- package/src/controller/control/exp-bar/exp-bar.controller.ts +35 -7
- package/src/controller/control/exp-bar/tree-exp-bar.controller.ts +1 -0
- package/src/controller/control/form/edit-form/edit-form.controller.ts +11 -1
- package/src/controller/control/form/form-detail/form-druipart/form-druipart.controller.ts +3 -3
- package/src/controller/control/grid/grid-column/grid-field-column/grid-field-column.controller.ts +2 -2
- package/src/controller/control/pickup-view-panel/pickup-view-panel.controller.ts +2 -2
- package/src/de-logic/de-logic.ts +24 -0
- package/src/interface/common/i-global-config/i-global-view-config.ts +9 -0
- package/src/interface/controller/controller/control/i-exp-bar-control.controller.ts +8 -0
- package/src/interface/provider/i-control.provider.ts +22 -0
- package/src/interface/provider/i-view.provider.ts +22 -0
- package/src/logic-scheduler/executor/app-ui-logic-executor.ts +4 -4
- package/src/service/dto/method.dto.ts +3 -3
- package/src/service/service/entity/method/method.ts +0 -1
- package/src/service/vo/control.vo.ts +10 -14
- package/src/service/vo/ui-map-field.ts +28 -0
- package/src/ui-action/provider/ui-action-provider-base.ts +4 -4
- package/src/utils/nav-params/calc-nav-params.ts +2 -2
- package/src/utils/nav-params/nav-params.ts +86 -91
- package/src/utils/open-redirect-view/open-redirect-view.ts +2 -2
|
@@ -256,15 +256,28 @@ export class ExpBarControlController<
|
|
|
256
256
|
const selectItem = this.xDataController?.state.items.find(
|
|
257
257
|
item => item[this.navKeyName] === this.state.srfnav,
|
|
258
258
|
);
|
|
259
|
-
|
|
260
|
-
|
|
259
|
+
|
|
260
|
+
// 是否是路由模式且有子路由
|
|
261
|
+
const routeAndHasSub =
|
|
262
|
+
this.routeDepth &&
|
|
263
|
+
window.location.hash.split('/').length > this.routeDepth * 2 + 2;
|
|
264
|
+
console.log('routeAndHasSub', routeAndHasSub);
|
|
265
|
+
|
|
266
|
+
if (routeAndHasSub) {
|
|
267
|
+
if (selectItem) {
|
|
268
|
+
// 在多数据部件里面选项设置回显。
|
|
269
|
+
this.xDataController.setSelection([selectItem]);
|
|
270
|
+
}
|
|
271
|
+
// 此时不需要导航占位push路由,只要有个key触发绘制下级视图就行。
|
|
272
|
+
this._evt.emit('onNavViewChange', {
|
|
273
|
+
navViewMsg: { key: this.state.srfnav },
|
|
274
|
+
context: this.context,
|
|
275
|
+
});
|
|
276
|
+
} else if (selectItem) {
|
|
277
|
+
// 非路由模式,或者有路由模式下有srfnav没有子路由时,需要在多数据部件里面选项设置回显。
|
|
278
|
+
this.xDataController.setActive(selectItem);
|
|
261
279
|
this.xDataController.setSelection([selectItem]);
|
|
262
280
|
}
|
|
263
|
-
// 此时不需要导航占位push路由,只要有个key触发绘制下级视图就行。
|
|
264
|
-
this._evt.emit('onNavViewChange', {
|
|
265
|
-
navViewMsg: { key: this.state.srfnav },
|
|
266
|
-
context: this.context,
|
|
267
|
-
});
|
|
268
281
|
}
|
|
269
282
|
|
|
270
283
|
/**
|
|
@@ -279,6 +292,7 @@ export class ExpBarControlController<
|
|
|
279
292
|
const data = this.xDataController.state.items[0];
|
|
280
293
|
if (!data) {
|
|
281
294
|
// 导航视图传空让他导航占位绘制空界面
|
|
295
|
+
this.state.srfnav = '';
|
|
282
296
|
this._evt.emit('onNavViewChange', { navViewMsg: { key: '' } });
|
|
283
297
|
return;
|
|
284
298
|
}
|
|
@@ -340,6 +354,7 @@ export class ExpBarControlController<
|
|
|
340
354
|
const tempContext = Object.assign(context.clone(), resultContext, {
|
|
341
355
|
currentSrfNav: data[this.navKeyName],
|
|
342
356
|
});
|
|
357
|
+
this.state.srfnav = data[this.navKeyName];
|
|
343
358
|
const tempParams = { ...resultParams };
|
|
344
359
|
return { context: tempContext, params: tempParams };
|
|
345
360
|
}
|
|
@@ -420,4 +435,17 @@ export class ExpBarControlController<
|
|
|
420
435
|
}
|
|
421
436
|
});
|
|
422
437
|
}
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* 路由变更处理回调
|
|
441
|
+
* @author lxm
|
|
442
|
+
* @date 2023-09-14 07:03:39
|
|
443
|
+
* @param {{ srfnav?: string; path: string }} info 当前系统的路由的从一级到最后一级的所有路径。
|
|
444
|
+
*/
|
|
445
|
+
onRouterChange(info: { srfnav: string; path: string }): void {
|
|
446
|
+
if (this.state.srfnav !== info.srfnav) {
|
|
447
|
+
this.state.srfnav = info.srfnav;
|
|
448
|
+
this.defaultNavBySrfnav();
|
|
449
|
+
}
|
|
450
|
+
}
|
|
423
451
|
}
|
|
@@ -119,6 +119,7 @@ export class TreeExpBarController
|
|
|
119
119
|
}
|
|
120
120
|
const result = this.prepareParams(nodeModel, deData, context, params);
|
|
121
121
|
result.context.currentSrfNav = nodeId;
|
|
122
|
+
this.state.srfnav = nodeId;
|
|
122
123
|
return {
|
|
123
124
|
key: nodeId,
|
|
124
125
|
viewId: nodeModel.navAppViewId,
|
|
@@ -186,6 +186,12 @@ export class EditFormController
|
|
|
186
186
|
this.actionNotification(`${isCreate ? 'CREATE' : 'UPDATE'}SUCCESS`, {
|
|
187
187
|
default: `${this.data.srfmajortext || ''}保存成功`,
|
|
188
188
|
});
|
|
189
|
+
if (this.view.modal.mode === 'ROUTE') {
|
|
190
|
+
ibiz.mc.command.send(
|
|
191
|
+
this.data.$origin,
|
|
192
|
+
isCreate ? 'OBJECTCREATED' : 'OBJECTUPDATED',
|
|
193
|
+
);
|
|
194
|
+
}
|
|
189
195
|
return this.data;
|
|
190
196
|
}
|
|
191
197
|
|
|
@@ -232,6 +238,10 @@ export class EditFormController
|
|
|
232
238
|
await this.evt.emit('onRemoveSuccess', undefined);
|
|
233
239
|
this.actionNotification('REMOVESUCCESS');
|
|
234
240
|
|
|
241
|
+
if (this.view.modal.mode === 'ROUTE') {
|
|
242
|
+
ibiz.mc.command.send(this.data.$origin, 'OBJECTREMOVED');
|
|
243
|
+
}
|
|
244
|
+
|
|
235
245
|
return ok;
|
|
236
246
|
}
|
|
237
247
|
|
|
@@ -275,7 +285,7 @@ export class EditFormController
|
|
|
275
285
|
|
|
276
286
|
const { appDEMethodId, defiupdateDetails, customCode, scriptCode } =
|
|
277
287
|
formItemUpdate;
|
|
278
|
-
const updateItems = defiupdateDetails
|
|
288
|
+
const updateItems = defiupdateDetails?.map(item => item.id!);
|
|
279
289
|
|
|
280
290
|
let updateData: IData; // 要修改的数据
|
|
281
291
|
if (customCode && scriptCode) {
|
|
@@ -146,9 +146,9 @@ export class FormDRUIPartController extends FormDetailController<IDEFormDRUIPart
|
|
|
146
146
|
newContext,
|
|
147
147
|
convertNavData(
|
|
148
148
|
navContexts!,
|
|
149
|
-
this.form.context,
|
|
150
|
-
this.form.params,
|
|
151
149
|
this.form.data,
|
|
150
|
+
this.form.params,
|
|
151
|
+
this.form.context,
|
|
152
152
|
),
|
|
153
153
|
);
|
|
154
154
|
}
|
|
@@ -156,9 +156,9 @@ export class FormDRUIPartController extends FormDetailController<IDEFormDRUIPart
|
|
|
156
156
|
// 处理导航视图参数
|
|
157
157
|
const newParams = convertNavData(
|
|
158
158
|
this.model.navigateParams!,
|
|
159
|
+
this.form.data,
|
|
159
160
|
this.form.params,
|
|
160
161
|
this.form.context,
|
|
161
|
-
this.form.data,
|
|
162
162
|
);
|
|
163
163
|
|
|
164
164
|
if (!this.state.viewComponentKey) {
|
package/src/controller/control/grid/grid-column/grid-field-column/grid-field-column.controller.ts
CHANGED
|
@@ -90,12 +90,12 @@ export class GridFieldColumnController extends GridColumnController<IDEGridField
|
|
|
90
90
|
const { navigateContexts, navigateParams } = parseUserParams(userParam);
|
|
91
91
|
let selfContext = {};
|
|
92
92
|
if (navigateContexts && data) {
|
|
93
|
-
selfContext = convertNavData(navigateContexts!,
|
|
93
|
+
selfContext = convertNavData(navigateContexts!, data, params, context);
|
|
94
94
|
}
|
|
95
95
|
const _context = Object.assign(context.clone(), selfContext);
|
|
96
96
|
let selfParams = {};
|
|
97
97
|
if (navigateParams && data) {
|
|
98
|
-
selfParams = convertNavData(navigateParams!,
|
|
98
|
+
selfParams = convertNavData(navigateParams!, data, params, context);
|
|
99
99
|
}
|
|
100
100
|
const _params: IParams = { ...params, ...selfParams };
|
|
101
101
|
return { context: _context, params: _params };
|
|
@@ -65,13 +65,13 @@ export class PickupViewPanelController
|
|
|
65
65
|
if (navigateContexts) {
|
|
66
66
|
Object.assign(
|
|
67
67
|
context,
|
|
68
|
-
convertNavData(navigateContexts, this.
|
|
68
|
+
convertNavData(navigateContexts, this.params, this.context),
|
|
69
69
|
);
|
|
70
70
|
}
|
|
71
71
|
if (navigateParams) {
|
|
72
72
|
Object.assign(
|
|
73
73
|
params,
|
|
74
|
-
convertNavData(navigateParams, this.
|
|
74
|
+
convertNavData(navigateParams, this.params, this.context),
|
|
75
75
|
);
|
|
76
76
|
}
|
|
77
77
|
this.state.context = context;
|
package/src/de-logic/de-logic.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* eslint-disable no-await-in-loop */
|
|
2
2
|
import { ModelError, RuntimeModelError } from '@ibiz-template/core';
|
|
3
3
|
import { IAppDELogic } from '@ibiz/model-core';
|
|
4
|
+
import { ScriptFactory, ScriptFunction } from '../utils';
|
|
4
5
|
import { DELogicContext } from './de-logic-context';
|
|
5
6
|
import {
|
|
6
7
|
AppendParamNode,
|
|
@@ -48,6 +49,15 @@ export class DELogic {
|
|
|
48
49
|
*/
|
|
49
50
|
protected params: Map<string, DELogicParam> = new Map();
|
|
50
51
|
|
|
52
|
+
/**
|
|
53
|
+
* 脚本函数
|
|
54
|
+
* @author lxm
|
|
55
|
+
* @date 2023-09-13 04:25:27
|
|
56
|
+
* @protected
|
|
57
|
+
* @type {ScriptFunction}
|
|
58
|
+
*/
|
|
59
|
+
protected scriptFn?: ScriptFunction;
|
|
60
|
+
|
|
51
61
|
/**
|
|
52
62
|
* Creates an instance of DELogic.
|
|
53
63
|
* @author lxm
|
|
@@ -55,6 +65,17 @@ export class DELogic {
|
|
|
55
65
|
* @param {IAppDELogic} model
|
|
56
66
|
*/
|
|
57
67
|
constructor(protected model: IAppDELogic) {
|
|
68
|
+
// 脚本代码模式
|
|
69
|
+
if (model.customCode) {
|
|
70
|
+
if (!model.scriptCode) {
|
|
71
|
+
throw new RuntimeModelError(model, '脚本代码模式没有配置脚本代码');
|
|
72
|
+
}
|
|
73
|
+
this.scriptFn = ScriptFactory.createScriptFn([], model.scriptCode, {
|
|
74
|
+
isAsync: true,
|
|
75
|
+
});
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
58
79
|
if (!model.delogicNodes?.length) {
|
|
59
80
|
throw new RuntimeModelError(model, '实体逻辑没有配置逻辑节点');
|
|
60
81
|
}
|
|
@@ -148,6 +169,9 @@ export class DELogic {
|
|
|
148
169
|
* @return {*} {Promise<IData>}
|
|
149
170
|
*/
|
|
150
171
|
async exec(context: IParams, data: IData, params: IParams): Promise<unknown> {
|
|
172
|
+
if (this.scriptFn) {
|
|
173
|
+
return this.scriptFn.exec({ context, data, params });
|
|
174
|
+
}
|
|
151
175
|
const ctx = new DELogicContext(this.params, context, data, params);
|
|
152
176
|
this.initLogicParams(ctx);
|
|
153
177
|
const { startDELogicNodeId } = this.model;
|
|
@@ -57,4 +57,12 @@ export interface IExpBarControlController<
|
|
|
57
57
|
* @memberof ITreeExpBarController
|
|
58
58
|
*/
|
|
59
59
|
getNavViewMsg(data: IData, context: IContext, params: IParams): INavViewMsg;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* 路由变更处理回调
|
|
63
|
+
* @author lxm
|
|
64
|
+
* @date 2023-09-14 07:03:39
|
|
65
|
+
* @param {{ srfnav?: string; path: string }} info 当前系统的路由的从一级到最后一级的所有路径。
|
|
66
|
+
*/
|
|
67
|
+
onRouterChange(info: { srfnav: string; path: string }): void;
|
|
60
68
|
}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { IControl } from '@ibiz/model-core';
|
|
2
|
+
import { CTX } from '../../controller';
|
|
3
|
+
import { IControlController } from '../controller';
|
|
4
|
+
|
|
1
5
|
/**
|
|
2
6
|
* 部件适配器的接口
|
|
3
7
|
*
|
|
@@ -16,4 +20,22 @@ export interface IControlProvider {
|
|
|
16
20
|
*/
|
|
17
21
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
22
|
component: any;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 创建部件控制器
|
|
26
|
+
*
|
|
27
|
+
* @author lxm
|
|
28
|
+
* @date 2023-09-15 11:52:22
|
|
29
|
+
* @param {IControl} model 部件模型
|
|
30
|
+
* @param {IContext} context 上下文
|
|
31
|
+
* @param {IParams} [params] 视图参数
|
|
32
|
+
* @param {CTX} [ctx]
|
|
33
|
+
* @return {*} {IControlController}
|
|
34
|
+
*/
|
|
35
|
+
createController?(
|
|
36
|
+
model: IControl,
|
|
37
|
+
context: IContext,
|
|
38
|
+
params: IParams,
|
|
39
|
+
ctx: CTX,
|
|
40
|
+
): IControlController;
|
|
19
41
|
}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { IAppView } from '@ibiz/model-core';
|
|
2
|
+
import { CTX } from '../../controller';
|
|
3
|
+
import { IViewController } from '../controller';
|
|
4
|
+
|
|
1
5
|
/**
|
|
2
6
|
* 视图适配器的接口
|
|
3
7
|
*
|
|
@@ -16,4 +20,22 @@ export interface IViewProvider {
|
|
|
16
20
|
*/
|
|
17
21
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
22
|
component: any;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 创建视图控制器
|
|
26
|
+
*
|
|
27
|
+
* @author lxm
|
|
28
|
+
* @date 2023-09-15 11:49:26
|
|
29
|
+
* @param {IAppView} model 视图模型
|
|
30
|
+
* @param {IContext} context 上下文
|
|
31
|
+
* @param {IParams} [params] 视图参数
|
|
32
|
+
* @param {CTX} [ctx]
|
|
33
|
+
* @return {*} {IViewController}
|
|
34
|
+
*/
|
|
35
|
+
createController?(
|
|
36
|
+
model: IAppView,
|
|
37
|
+
context: IContext,
|
|
38
|
+
params?: IParams,
|
|
39
|
+
ctx?: CTX,
|
|
40
|
+
): IViewController;
|
|
19
41
|
}
|
|
@@ -93,14 +93,14 @@ export class AppUILogicExecutor extends LogicExecutor {
|
|
|
93
93
|
const navContexts: INavigateParam[] = openViewRef.navigateContexts || [];
|
|
94
94
|
const tempContext = Object.assign(
|
|
95
95
|
context,
|
|
96
|
-
convertNavData(navContexts!,
|
|
96
|
+
convertNavData(navContexts!, data[0], params, context),
|
|
97
97
|
);
|
|
98
98
|
|
|
99
99
|
// 处理导航视图参数
|
|
100
100
|
let tempParams: IData = {};
|
|
101
101
|
const navParams = openViewRef.navigateParams;
|
|
102
102
|
if (notNilEmpty(navParams)) {
|
|
103
|
-
tempParams = convertNavData(navParams!, params, context
|
|
103
|
+
tempParams = convertNavData(navParams!, data[0], params, context);
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
// 打开视图
|
|
@@ -164,13 +164,13 @@ export class AppUILogicExecutor extends LogicExecutor {
|
|
|
164
164
|
const _data = data?.[0] || {};
|
|
165
165
|
const navContexts = newViewRef.navigateContexts;
|
|
166
166
|
if (notNilEmpty(navContexts)) {
|
|
167
|
-
tempContext = convertNavData(navContexts!,
|
|
167
|
+
tempContext = convertNavData(navContexts!, _data, params, context);
|
|
168
168
|
}
|
|
169
169
|
tempContext = Object.assign(context, tempContext);
|
|
170
170
|
|
|
171
171
|
const navParams = newViewRef.navigateParams;
|
|
172
172
|
if (notNilEmpty(navParams)) {
|
|
173
|
-
tempParams = convertNavData(navParams!, params, context
|
|
173
|
+
tempParams = convertNavData(navParams!, _data, params, context);
|
|
174
174
|
}
|
|
175
175
|
|
|
176
176
|
// 拷贝数据处理
|
|
@@ -74,9 +74,7 @@ export class MethodDto {
|
|
|
74
74
|
for (let j = 0; j < items.length; j++) {
|
|
75
75
|
arr.push(await dto.get(context, items[j]));
|
|
76
76
|
}
|
|
77
|
-
|
|
78
|
-
params[key] = arr;
|
|
79
|
-
}
|
|
77
|
+
params[key] = arr;
|
|
80
78
|
}
|
|
81
79
|
break;
|
|
82
80
|
}
|
|
@@ -119,6 +117,8 @@ export class MethodDto {
|
|
|
119
117
|
const items: IData[] = datum[key];
|
|
120
118
|
if (items) {
|
|
121
119
|
await dto.sets(context, items);
|
|
120
|
+
} else {
|
|
121
|
+
await dto.sets(context, []);
|
|
122
122
|
}
|
|
123
123
|
});
|
|
124
124
|
for (let i = 0; i < all.length; i++) {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { DataTypes } from '@ibiz-template/core';
|
|
2
1
|
import { clone, isNil } from 'ramda';
|
|
3
2
|
import { Srfuf } from '../constant';
|
|
4
3
|
import { UIMapField } from './ui-map-field';
|
|
@@ -142,10 +141,7 @@ export class ControlVO {
|
|
|
142
141
|
this.$dataUIMap.forEach((mapField, key) => {
|
|
143
142
|
const value = mapField.dataKey;
|
|
144
143
|
// 关联映射属性
|
|
145
|
-
|
|
146
|
-
mapField.dataType !== undefined &&
|
|
147
|
-
DataTypes.isNumber(mapField.dataType);
|
|
148
|
-
this.linkProperty(key, value, mapField.isOriginField, forceNumber);
|
|
144
|
+
this.linkProperty(key, value, mapField);
|
|
149
145
|
});
|
|
150
146
|
|
|
151
147
|
// 映射属性里没有涉及到的建立直接关联,用于使用实体属性也要取到值的场景。
|
|
@@ -172,9 +168,9 @@ export class ControlVO {
|
|
|
172
168
|
private linkProperty(
|
|
173
169
|
uiKey: string,
|
|
174
170
|
dataKey: string,
|
|
175
|
-
|
|
176
|
-
forceNumber: boolean = false,
|
|
171
|
+
mapField?: UIMapField,
|
|
177
172
|
): void {
|
|
173
|
+
const isOriginField = mapField ? mapField.isOriginField : true;
|
|
178
174
|
// srfuf和srfkey不做处理
|
|
179
175
|
if (uiKey === 'srfuf') {
|
|
180
176
|
return;
|
|
@@ -195,15 +191,15 @@ export class ControlVO {
|
|
|
195
191
|
: this.$origin[dataKey];
|
|
196
192
|
},
|
|
197
193
|
set(val) {
|
|
198
|
-
//
|
|
199
|
-
|
|
200
|
-
if (Number.isNaN(val2)) {
|
|
201
|
-
val2 = val; // NaN时还原值
|
|
202
|
-
ibiz.log.error(`${val}不能转换成数字`);
|
|
203
|
-
}
|
|
204
|
-
this.$origin[dataKey] = val2;
|
|
194
|
+
// 有mapField的走它的转换
|
|
195
|
+
this.$origin[dataKey] = mapField ? mapField.convertVal(val) : val;
|
|
205
196
|
},
|
|
206
197
|
});
|
|
198
|
+
|
|
199
|
+
// 一开始初始化的时候先把值转换一下。
|
|
200
|
+
if (mapField) {
|
|
201
|
+
this[uiKey] = mapField.convertVal(this.$origin[dataKey]);
|
|
202
|
+
}
|
|
207
203
|
} else {
|
|
208
204
|
Object.defineProperty(this, uiKey, {
|
|
209
205
|
enumerable: true,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DataTypes } from '@ibiz-template/core';
|
|
1
2
|
import { isNil } from 'ramda';
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -70,4 +71,31 @@ export class UIMapField {
|
|
|
70
71
|
this.dataType = opts.dataType;
|
|
71
72
|
}
|
|
72
73
|
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* 值转换
|
|
77
|
+
* @author lxm
|
|
78
|
+
* @date 2023-09-14 06:45:44
|
|
79
|
+
* @param {unknown} value 原值
|
|
80
|
+
*/
|
|
81
|
+
convertVal(value: unknown): unknown {
|
|
82
|
+
// 没有数据类型的给原值
|
|
83
|
+
if (!this.dataType) {
|
|
84
|
+
return value;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// 数值转换
|
|
88
|
+
if (DataTypes.isNumber(this.dataType)) {
|
|
89
|
+
const numVal = !isNil(value) && value !== '' ? Number(value) : value;
|
|
90
|
+
|
|
91
|
+
if (Number.isNaN(numVal)) {
|
|
92
|
+
// 不能转换的给原值
|
|
93
|
+
ibiz.log.debug(`${value}不能转换成数字`);
|
|
94
|
+
return value;
|
|
95
|
+
}
|
|
96
|
+
return numVal;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return value;
|
|
100
|
+
}
|
|
73
101
|
}
|
|
@@ -249,9 +249,9 @@ export abstract class UIActionProviderBase implements IUIActionProvider {
|
|
|
249
249
|
// 处理自定义导航上下文
|
|
250
250
|
const tempContext = convertNavData(
|
|
251
251
|
navContexts,
|
|
252
|
-
context,
|
|
253
|
-
params,
|
|
254
252
|
isMultiData ? formatMultiData(navContexts, data) : data[0] || {},
|
|
253
|
+
params,
|
|
254
|
+
context,
|
|
255
255
|
);
|
|
256
256
|
Object.assign(resultContext, tempContext);
|
|
257
257
|
|
|
@@ -259,9 +259,9 @@ export abstract class UIActionProviderBase implements IUIActionProvider {
|
|
|
259
259
|
const navParams = action.navigateParams;
|
|
260
260
|
const resultParams = convertNavData(
|
|
261
261
|
navParams,
|
|
262
|
-
resultContext,
|
|
263
|
-
params,
|
|
264
262
|
isMultiData ? formatMultiData(navParams, data) : data[0] || {},
|
|
263
|
+
params,
|
|
264
|
+
resultContext,
|
|
265
265
|
);
|
|
266
266
|
return { resultContext, resultData, resultParams };
|
|
267
267
|
}
|
|
@@ -61,8 +61,8 @@ export function calcNavParams(
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
// 自定义导航视图参数和上下文
|
|
64
|
-
const tempContext = convertNavData(navContexts,
|
|
65
|
-
const tempParams = convertNavData(navParams,
|
|
64
|
+
const tempContext = convertNavData(navContexts, data, params, context);
|
|
65
|
+
const tempParams = convertNavData(navParams, data, params, context);
|
|
66
66
|
Object.assign(resultContext, tempContext);
|
|
67
67
|
Object.assign(resultParams, tempParams);
|
|
68
68
|
|