@ibiz-template/runtime 0.1.37 → 0.2.0
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 +12431 -360
- package/dist/index.system.min.js +1 -1
- package/dist/index.system.min.js.map +1 -1
- package/out/application.d.ts +9 -1
- package/out/application.d.ts.map +1 -1
- package/out/application.js +9 -2
- package/out/controller/control/exp-bar/chart-exp-bar.controller.d.ts +24 -0
- package/out/controller/control/exp-bar/chart-exp-bar.controller.d.ts.map +1 -0
- package/out/controller/control/exp-bar/chart-exp-bar.controller.js +32 -0
- package/out/controller/control/exp-bar/index.d.ts +1 -0
- package/out/controller/control/exp-bar/index.d.ts.map +1 -1
- package/out/controller/control/exp-bar/index.js +1 -0
- package/out/controller/control/grid/grid-column/grid-field-column/grid-field-column.controller.d.ts +1 -0
- package/out/controller/control/grid/grid-column/grid-field-column/grid-field-column.controller.d.ts.map +1 -1
- package/out/controller/control/grid/grid-column/grid-field-column/grid-field-column.controller.js +8 -0
- package/out/controller/control/medit-view-panel/medit-view-panel.controller.d.ts +1 -13
- package/out/controller/control/medit-view-panel/medit-view-panel.controller.d.ts.map +1 -1
- package/out/controller/control/medit-view-panel/medit-view-panel.controller.js +7 -67
- package/out/controller/control/search-bar/search-bar.controller.d.ts.map +1 -1
- package/out/controller/control/search-bar/search-bar.controller.js +3 -3
- package/out/de-logic/de-logic-context.d.ts +4 -4
- package/out/de-logic/de-logic-context.d.ts.map +1 -1
- package/out/de-logic/de-logic-context.js +2 -1
- package/out/de-logic/de-logic-link/de-logic-link.js +1 -1
- package/out/de-logic/de-logic-param/de-logic-param.d.ts.map +1 -1
- package/out/de-logic/de-logic-param/de-logic-param.js +7 -1
- package/out/de-logic/de-logic.d.ts +1 -1
- package/out/de-logic/de-logic.d.ts.map +1 -1
- package/out/de-logic/index.d.ts +5 -5
- package/out/de-logic/index.d.ts.map +1 -1
- package/out/de-logic/index.js +32 -5
- package/out/engine/md-view.engine.d.ts +3 -3
- package/out/engine/md-view.engine.d.ts.map +1 -1
- package/out/engine/md-view.engine.js +14 -12
- package/out/hub/config/app-view-config-service.d.ts +3 -1
- package/out/hub/config/app-view-config-service.d.ts.map +1 -1
- package/out/hub/config/app-view-config-service.js +9 -0
- package/out/interface/common/i-app-view-config-service/i-app-view-config-service.d.ts +20 -2
- package/out/interface/common/i-app-view-config-service/i-app-view-config-service.d.ts.map +1 -1
- package/out/interface/controller/controller/control/i-chart-exp-bar.controller.d.ts +15 -0
- package/out/interface/controller/controller/control/i-chart-exp-bar.controller.d.ts.map +1 -0
- package/out/interface/controller/controller/control/i-chart-exp-bar.controller.js +1 -0
- package/out/interface/controller/controller/control/index.d.ts +1 -0
- package/out/interface/controller/controller/control/index.d.ts.map +1 -1
- package/out/interface/controller/controller/control/index.js +1 -0
- package/out/interface/controller/event/control/i-chart-exp-bar.event.d.ts +11 -0
- package/out/interface/controller/event/control/i-chart-exp-bar.event.d.ts.map +1 -0
- package/out/interface/controller/event/control/i-chart-exp-bar.event.js +1 -0
- package/out/interface/controller/event/control/index.d.ts +1 -0
- package/out/interface/controller/event/control/index.d.ts.map +1 -1
- package/out/interface/controller/event/control/index.js +1 -0
- package/out/interface/controller/event/view/i-chart-exp-view.event.d.ts +11 -0
- package/out/interface/controller/event/view/i-chart-exp-view.event.d.ts.map +1 -0
- package/out/interface/controller/event/view/i-chart-exp-view.event.js +1 -0
- package/out/interface/controller/event/view/index.d.ts +1 -0
- package/out/interface/controller/event/view/index.d.ts.map +1 -1
- package/out/interface/controller/event/view/index.js +1 -0
- package/out/interface/controller/state/control/i-chart-exp-bar.state.d.ts +11 -0
- package/out/interface/controller/state/control/i-chart-exp-bar.state.d.ts.map +1 -0
- package/out/interface/controller/state/control/i-chart-exp-bar.state.js +1 -0
- package/out/interface/controller/state/control/index.d.ts +1 -0
- package/out/interface/controller/state/control/index.d.ts.map +1 -1
- package/out/interface/controller/state/control/index.js +1 -0
- package/out/interface/controller/state/view/i-chart-exp-view.state.d.ts +11 -0
- package/out/interface/controller/state/view/i-chart-exp-view.state.d.ts.map +1 -0
- package/out/interface/controller/state/view/i-chart-exp-view.state.js +1 -0
- package/out/interface/controller/state/view/index.d.ts +1 -0
- package/out/interface/controller/state/view/index.d.ts.map +1 -1
- package/out/interface/controller/state/view/index.js +1 -0
- package/out/interface/service/code-list-item/code-list-item.d.ts +16 -0
- package/out/interface/service/code-list-item/code-list-item.d.ts.map +1 -1
- package/out/service/index.d.ts +1 -0
- package/out/service/index.d.ts.map +1 -1
- package/out/service/index.js +1 -0
- package/out/service/mqtt/mqtt.service.d.ts +66 -0
- package/out/service/mqtt/mqtt.service.d.ts.map +1 -0
- package/out/service/mqtt/mqtt.service.js +95 -0
- package/out/service/service/code-list/code-list.service.d.ts.map +1 -1
- package/out/service/service/code-list/code-list.service.js +12 -1
- package/out/service/service/entity/de.service.d.ts +2 -2
- package/out/service/service/entity/de.service.d.ts.map +1 -1
- package/out/service/service/entity/method/de-action.d.ts +14 -5
- package/out/service/service/entity/method/de-action.d.ts.map +1 -1
- package/out/service/service/entity/method/de-action.js +56 -15
- package/out/service/service/entity/method/fetch.d.ts +1 -1
- package/out/service/service/entity/method/fetch.d.ts.map +1 -1
- package/out/service/service/entity/method/fetch.js +9 -6
- package/out/service/service/entity/method/method.d.ts +13 -13
- package/out/service/service/entity/method/method.d.ts.map +1 -1
- package/out/service/service/entity/method/method.js +16 -11
- package/out/service/utils/dynamic-code-list/dynamic-code-list.d.ts +7 -1
- package/out/service/utils/dynamic-code-list/dynamic-code-list.d.ts.map +1 -1
- package/out/service/utils/dynamic-code-list/dynamic-code-list.js +89 -13
- package/out/ui-action/uiaction-util.js +3 -3
- package/out/ui-logic/ui-logic-param/ui-logic-param.d.ts.map +1 -1
- package/out/ui-logic/ui-logic-param/ui-logic-param.js +7 -1
- package/out/utils/script/script-factory.d.ts +10 -0
- package/out/utils/script/script-factory.d.ts.map +1 -1
- package/out/utils/script/script-factory.js +15 -0
- package/package.json +5 -3
- package/src/application.ts +22 -1
- package/src/controller/control/exp-bar/chart-exp-bar.controller.ts +51 -0
- package/src/controller/control/exp-bar/index.ts +1 -0
- package/src/controller/control/grid/grid-column/grid-field-column/grid-field-column.controller.ts +14 -0
- package/src/controller/control/medit-view-panel/medit-view-panel.controller.ts +8 -78
- package/src/controller/control/search-bar/search-bar.controller.ts +6 -5
- package/src/de-logic/de-logic-context.ts +6 -5
- package/src/de-logic/de-logic-link/de-logic-link.ts +1 -1
- package/src/de-logic/de-logic-param/de-logic-param.ts +6 -1
- package/src/de-logic/de-logic.ts +5 -1
- package/src/de-logic/index.ts +49 -8
- package/src/engine/md-view.engine.ts +16 -13
- package/src/hub/config/app-view-config-service.ts +12 -1
- package/src/interface/common/i-app-view-config-service/i-app-view-config-service.ts +22 -4
- package/src/interface/controller/controller/control/i-chart-exp-bar.controller.ts +19 -0
- package/src/interface/controller/controller/control/index.ts +1 -0
- package/src/interface/controller/event/control/i-chart-exp-bar.event.ts +10 -0
- package/src/interface/controller/event/control/index.ts +1 -0
- package/src/interface/controller/event/view/i-chart-exp-view.event.ts +11 -0
- package/src/interface/controller/event/view/index.ts +1 -0
- package/src/interface/controller/state/control/i-chart-exp-bar.state.ts +10 -0
- package/src/interface/controller/state/control/index.ts +1 -0
- package/src/interface/controller/state/view/i-chart-exp-view.state.ts +10 -0
- package/src/interface/controller/state/view/index.ts +1 -0
- package/src/interface/service/code-list-item/code-list-item.ts +20 -0
- package/src/service/index.ts +1 -0
- package/src/service/mqtt/mqtt.service.ts +117 -0
- package/src/service/service/code-list/code-list.service.ts +15 -1
- package/src/service/service/entity/de.service.ts +2 -2
- package/src/service/service/entity/method/de-action.ts +74 -33
- package/src/service/service/entity/method/fetch.ts +12 -11
- package/src/service/service/entity/method/method.ts +28 -19
- package/src/service/utils/dynamic-code-list/dynamic-code-list.ts +121 -16
- package/src/ui-action/uiaction-util.ts +3 -3
- package/src/ui-logic/ui-logic-param/ui-logic-param.ts +6 -1
- package/src/utils/script/script-factory.ts +16 -0
|
@@ -30,12 +30,10 @@ export interface IViewConfig {
|
|
|
30
30
|
* 高度
|
|
31
31
|
*/
|
|
32
32
|
height?: number;
|
|
33
|
-
|
|
34
33
|
/**
|
|
35
34
|
* 应用实体id
|
|
36
35
|
*/
|
|
37
36
|
appDataEntityId?: string;
|
|
38
|
-
|
|
39
37
|
/**
|
|
40
38
|
* 是否是重定向视图
|
|
41
39
|
*/
|
|
@@ -44,7 +42,17 @@ export interface IViewConfig {
|
|
|
44
42
|
|
|
45
43
|
export interface IAppViewConfigService {
|
|
46
44
|
/**
|
|
47
|
-
*
|
|
45
|
+
* 是否存在视图 config
|
|
46
|
+
*
|
|
47
|
+
* @author chitanda
|
|
48
|
+
* @date 2023-10-20 11:10:55
|
|
49
|
+
* @param {string} key
|
|
50
|
+
* @return {*} {boolean}
|
|
51
|
+
*/
|
|
52
|
+
has(key: string): boolean;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* 添加视图 config
|
|
48
56
|
* @author lxm
|
|
49
57
|
* @date 2023-07-03 07:04:29
|
|
50
58
|
* @param {string} id
|
|
@@ -53,11 +61,21 @@ export interface IAppViewConfigService {
|
|
|
53
61
|
set(id: string, viewConfig: IViewConfig): void;
|
|
54
62
|
|
|
55
63
|
/**
|
|
56
|
-
* 获取视图config
|
|
64
|
+
* 获取视图 config,不存在会请求视图模型并设置,不存在会抛出异常
|
|
57
65
|
* @author lxm
|
|
58
66
|
* @date 2023-07-03 07:05:13
|
|
59
67
|
* @param {string} key
|
|
60
68
|
* @return {*} {Promise<IViewConfig>}
|
|
61
69
|
*/
|
|
62
70
|
get(key: string): Promise<IViewConfig>;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* 同步获取视图 config,只能获取已经存在的视图 config,不存在返回 null
|
|
74
|
+
*
|
|
75
|
+
* @author chitanda
|
|
76
|
+
* @date 2023-10-19 14:10:52
|
|
77
|
+
* @param {string} key
|
|
78
|
+
* @return {*} {(IViewConfig | null)}
|
|
79
|
+
*/
|
|
80
|
+
getSync(key: string): IViewConfig | null;
|
|
63
81
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { IChartExpBar } from '@ibiz/model-core';
|
|
2
|
+
import { IExpBarControlController } from './i-exp-bar-control.controller';
|
|
3
|
+
import { IChartExpBarState } from '../../state';
|
|
4
|
+
import { IChartExpBarEvent } from '../../event';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 图表导航栏部件控制器
|
|
8
|
+
* @author lxm
|
|
9
|
+
* @date 2023-05-04 01:47:16
|
|
10
|
+
* @export
|
|
11
|
+
* @interface ICalendarController
|
|
12
|
+
* @extends {IMDControlController}
|
|
13
|
+
*/
|
|
14
|
+
export interface IChartExpBarController
|
|
15
|
+
extends IExpBarControlController<
|
|
16
|
+
IChartExpBar,
|
|
17
|
+
IChartExpBarState,
|
|
18
|
+
IChartExpBarEvent
|
|
19
|
+
> {}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ISysImage } from '@ibiz/model-core';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* 返回的代码项格式
|
|
3
5
|
*
|
|
@@ -50,4 +52,22 @@ export interface CodeListItem {
|
|
|
50
52
|
* @type {boolean}
|
|
51
53
|
*/
|
|
52
54
|
disableSelect?: boolean;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* 图标对象
|
|
58
|
+
* @type {ISysImage}
|
|
59
|
+
*/
|
|
60
|
+
sysImage?: ISysImage;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* 代码项数据
|
|
64
|
+
* @type {String}
|
|
65
|
+
*/
|
|
66
|
+
data?: IData;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* 提示信息
|
|
70
|
+
* @type {String}
|
|
71
|
+
*/
|
|
72
|
+
tooltip?: string;
|
|
53
73
|
}
|
package/src/service/index.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from './constant';
|
|
|
4
4
|
export * from './vo';
|
|
5
5
|
export * from './constant';
|
|
6
6
|
export * from './dto/method.dto';
|
|
7
|
+
export { MqttService } from './mqtt/mqtt.service';
|
|
7
8
|
export * from './app-data-entity/app-data-entity';
|
|
8
9
|
|
|
9
10
|
export { DEServiceUtil } from './de-service-util';
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { IPortalMessage } from '@ibiz-template/core';
|
|
2
|
+
import { MqttClient, IClientOptions } from 'mqtt';
|
|
3
|
+
import { QXEvent, createUUID, isNilOrEmpty } from 'qx-util';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* mqtt 连接服务
|
|
7
|
+
*
|
|
8
|
+
* @author chitanda
|
|
9
|
+
* @date 2023-10-20 14:10:40
|
|
10
|
+
* @export
|
|
11
|
+
* @class MqttService
|
|
12
|
+
*/
|
|
13
|
+
export class MqttService {
|
|
14
|
+
/**
|
|
15
|
+
* 接受消息通知
|
|
16
|
+
*
|
|
17
|
+
* @author chitanda
|
|
18
|
+
* @date 2023-10-23 15:10:06
|
|
19
|
+
*/
|
|
20
|
+
readonly evt: QXEvent<{ message: (msg: IPortalMessage) => void }> =
|
|
21
|
+
new QXEvent();
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* mqtt 连接实例
|
|
25
|
+
*
|
|
26
|
+
* @author chitanda
|
|
27
|
+
* @date 2023-10-20 20:10:44
|
|
28
|
+
* @type {MqttClient}
|
|
29
|
+
*/
|
|
30
|
+
client?: MqttClient;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* 连接选项
|
|
34
|
+
*
|
|
35
|
+
* @author chitanda
|
|
36
|
+
* @date 2023-10-20 14:10:25
|
|
37
|
+
* @protected
|
|
38
|
+
* @type {IClientOptions}
|
|
39
|
+
*/
|
|
40
|
+
protected options: IClientOptions = {
|
|
41
|
+
// 超时时间
|
|
42
|
+
connectTimeout: 6000,
|
|
43
|
+
// 认证信息
|
|
44
|
+
clientId: createUUID(),
|
|
45
|
+
username: '',
|
|
46
|
+
password: '',
|
|
47
|
+
// 心跳时间
|
|
48
|
+
keepalive: 60,
|
|
49
|
+
clean: true,
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Creates an instance of MqttService.
|
|
54
|
+
*
|
|
55
|
+
* @author chitanda
|
|
56
|
+
* @date 2023-10-23 15:10:06
|
|
57
|
+
* @param {string} mqttTopic
|
|
58
|
+
* @param {string} token
|
|
59
|
+
* @param {string} appId
|
|
60
|
+
*/
|
|
61
|
+
constructor(
|
|
62
|
+
mqttTopic: string,
|
|
63
|
+
token: string,
|
|
64
|
+
protected appId: string,
|
|
65
|
+
) {
|
|
66
|
+
if (isNilOrEmpty(mqttTopic) || isNilOrEmpty(token)) {
|
|
67
|
+
throw new Error('mqttTopic or token is empty');
|
|
68
|
+
}
|
|
69
|
+
this.options.username = mqttTopic;
|
|
70
|
+
this.options.password = token;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* mqtt 连接
|
|
75
|
+
*
|
|
76
|
+
* @author chitanda
|
|
77
|
+
* @date 2023-10-23 15:10:58
|
|
78
|
+
* @return {*} {Promise<void>}
|
|
79
|
+
*/
|
|
80
|
+
async connect(): Promise<void> {
|
|
81
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
82
|
+
// @ts-ignore
|
|
83
|
+
const module = await import('mqtt/dist/mqtt.min');
|
|
84
|
+
const mqtt = module.default ? module.default : module;
|
|
85
|
+
const { location } = window;
|
|
86
|
+
this.client = mqtt.connect(
|
|
87
|
+
`ws://${location.host}${ibiz.env.baseUrl}/${this.appId}${ibiz.env.mqttUrl}`,
|
|
88
|
+
this.options,
|
|
89
|
+
) as MqttClient;
|
|
90
|
+
this.client.on('connect', () => {
|
|
91
|
+
ibiz.log.debug('mqtt connect');
|
|
92
|
+
});
|
|
93
|
+
this.client.on('error', error => {
|
|
94
|
+
ibiz.log.error('mqtt error', error);
|
|
95
|
+
});
|
|
96
|
+
this.client.on('message', (topic, payload) => {
|
|
97
|
+
this.evt.emit('message', JSON.parse(payload.toString()));
|
|
98
|
+
ibiz.log.debug('mqtt message', topic, payload.toString());
|
|
99
|
+
});
|
|
100
|
+
this.client.on('reconnect', () => {
|
|
101
|
+
ibiz.log.debug('mqtt reconnect');
|
|
102
|
+
});
|
|
103
|
+
this.client.on('close', () => {
|
|
104
|
+
console.debug('mqtt close');
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* 结束 mqtt 连接
|
|
110
|
+
*
|
|
111
|
+
* @author chitanda
|
|
112
|
+
* @date 2023-10-23 15:10:37
|
|
113
|
+
*/
|
|
114
|
+
close(): void {
|
|
115
|
+
this.client?.end();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { RuntimeError } from '@ibiz-template/core';
|
|
2
2
|
import { IAppCodeList, IApplication, ICodeItem } from '@ibiz/model-core';
|
|
3
3
|
import { CodeListItem } from '../../../interface';
|
|
4
|
+
import { ScriptFactory } from '../../../utils';
|
|
4
5
|
import { DynamicCodeListCache } from '../../utils';
|
|
5
6
|
|
|
6
7
|
/**
|
|
@@ -98,11 +99,18 @@ export class CodeListService {
|
|
|
98
99
|
isValueNumber: boolean,
|
|
99
100
|
): Readonly<CodeListItem>[] {
|
|
100
101
|
return codeItems.map(codeItem => {
|
|
101
|
-
// todo代码项其他属性,表单数据
|
|
102
102
|
let text = codeItem.text!;
|
|
103
103
|
if (codeItem.textLanguageRes) {
|
|
104
104
|
text = ibiz.i18n.t(codeItem.textLanguageRes.lanResTag!, codeItem.text);
|
|
105
105
|
}
|
|
106
|
+
// 提示信息
|
|
107
|
+
let { tooltip } = codeItem;
|
|
108
|
+
if (codeItem.tooltipLanguageRes) {
|
|
109
|
+
tooltip = ibiz.i18n.t(
|
|
110
|
+
codeItem.tooltipLanguageRes.lanResTag!,
|
|
111
|
+
codeItem.tooltip,
|
|
112
|
+
);
|
|
113
|
+
}
|
|
106
114
|
const _codeItem: CodeListItem = {
|
|
107
115
|
text,
|
|
108
116
|
value: isValueNumber ? Number(codeItem.value) : codeItem.value!,
|
|
@@ -110,6 +118,12 @@ export class CodeListService {
|
|
|
110
118
|
id: codeItem.codeName!,
|
|
111
119
|
textCls: codeItem.textCls,
|
|
112
120
|
disableSelect: codeItem.disableSelect,
|
|
121
|
+
tooltip,
|
|
122
|
+
// 代码项数据
|
|
123
|
+
data: codeItem.data
|
|
124
|
+
? (ScriptFactory.execSingleLine(codeItem.data) as IData)
|
|
125
|
+
: undefined,
|
|
126
|
+
sysImage: codeItem.sysImage,
|
|
113
127
|
};
|
|
114
128
|
if (codeItem.codeItems?.length) {
|
|
115
129
|
_codeItem.children = this.formatStaticItems(
|
|
@@ -141,7 +141,7 @@ export class DEService implements IAppDEService {
|
|
|
141
141
|
exec(
|
|
142
142
|
id: string,
|
|
143
143
|
context: IParams,
|
|
144
|
-
params?: IData,
|
|
144
|
+
params?: IData | IData[],
|
|
145
145
|
params2?: IParams,
|
|
146
146
|
): Promise<IHttpResponse> {
|
|
147
147
|
const method = this.getMethod(id);
|
|
@@ -165,7 +165,7 @@ export class DEService implements IAppDEService {
|
|
|
165
165
|
execAc(
|
|
166
166
|
id: string,
|
|
167
167
|
context: IParams,
|
|
168
|
-
params?: IData,
|
|
168
|
+
params?: IData | IData[],
|
|
169
169
|
params2: IParams = {},
|
|
170
170
|
): Promise<IHttpResponse> {
|
|
171
171
|
const method = this.getMethod(id, true);
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
HttpResponse,
|
|
3
3
|
IHttpResponse,
|
|
4
|
+
RuntimeError,
|
|
4
5
|
RuntimeModelError,
|
|
5
6
|
} from '@ibiz-template/core';
|
|
6
7
|
import { IAppDEAction } from '@ibiz/model-core';
|
|
7
|
-
import {
|
|
8
|
+
import { isArray, isNil } from 'lodash-es';
|
|
8
9
|
import { Method } from './method';
|
|
9
10
|
import { IDataEntity } from '../../../../interface';
|
|
10
11
|
import { findDELogic } from '../../../../model';
|
|
@@ -36,9 +37,27 @@ export class DEActionMethod extends Method {
|
|
|
36
37
|
return isLocalMode(this.method);
|
|
37
38
|
}
|
|
38
39
|
|
|
40
|
+
/**
|
|
41
|
+
* 处理请求发送参数
|
|
42
|
+
* @author lxm
|
|
43
|
+
* @date 2023-10-19 02:50:36
|
|
44
|
+
* @param {IParams} context 上下文
|
|
45
|
+
* @param {(IData | IData[])} data 数据对象
|
|
46
|
+
* @return {*} {(Promise<IData | IData[]>)}
|
|
47
|
+
*/
|
|
48
|
+
async inputHandle(
|
|
49
|
+
context: IParams,
|
|
50
|
+
data: IData | IData[],
|
|
51
|
+
): Promise<IData | IData[]> {
|
|
52
|
+
if (isArray(data)) {
|
|
53
|
+
return Promise.all(data.map(item => this.input.handle(context, item)));
|
|
54
|
+
}
|
|
55
|
+
return this.input.handle(context, data);
|
|
56
|
+
}
|
|
57
|
+
|
|
39
58
|
async exec(
|
|
40
59
|
context: IParams,
|
|
41
|
-
data?: IData,
|
|
60
|
+
data?: IData | IData[],
|
|
42
61
|
params?: IParams,
|
|
43
62
|
): Promise<HttpResponse<IData>> {
|
|
44
63
|
// 实体逻辑处理
|
|
@@ -48,21 +67,16 @@ export class DEActionMethod extends Method {
|
|
|
48
67
|
if (!deLogic) {
|
|
49
68
|
throw new RuntimeModelError(this.method, '缺少实体处理逻辑');
|
|
50
69
|
}
|
|
51
|
-
return execDELogicAction(
|
|
52
|
-
deLogic,
|
|
53
|
-
clone(context),
|
|
54
|
-
data ? clone(data) : {},
|
|
55
|
-
params ? clone(params) : {},
|
|
56
|
-
);
|
|
70
|
+
return execDELogicAction(deLogic, context, data, params);
|
|
57
71
|
}
|
|
58
72
|
|
|
59
73
|
if (data && !this.isLocalMode) {
|
|
60
|
-
data = await this.
|
|
74
|
+
data = await this.inputHandle(context, data);
|
|
61
75
|
}
|
|
62
76
|
|
|
63
77
|
// 执行变更属性逻辑
|
|
64
78
|
if (data && !['READ', 'GETDRAFT'].includes(this.method.actionMode!)) {
|
|
65
|
-
await execFieldLogics(this.entity, 'change', context, data, params
|
|
79
|
+
await execFieldLogics(this.entity, 'change', context, data, params);
|
|
66
80
|
}
|
|
67
81
|
|
|
68
82
|
let result: IHttpResponse<IData>;
|
|
@@ -100,10 +114,13 @@ export class DEActionMethod extends Method {
|
|
|
100
114
|
default: {
|
|
101
115
|
let path = this.calcPath(context);
|
|
102
116
|
if (this.method.needResourceKey) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
data
|
|
106
|
-
|
|
117
|
+
let srfkey = context[this.entity.codeName!.toLowerCase()];
|
|
118
|
+
if (isNil(srfkey)) {
|
|
119
|
+
srfkey = isArray(data)
|
|
120
|
+
? null
|
|
121
|
+
: data?.[this.entity.keyAppDEFieldId!];
|
|
122
|
+
}
|
|
123
|
+
path = `${path}/${srfkey}`;
|
|
107
124
|
}
|
|
108
125
|
const res = await this.request(path, context, data, params);
|
|
109
126
|
res.data = await this.result.handle(context, res.data);
|
|
@@ -112,13 +129,15 @@ export class DEActionMethod extends Method {
|
|
|
112
129
|
}
|
|
113
130
|
|
|
114
131
|
// 计算属性逻辑
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
132
|
+
if (result.data) {
|
|
133
|
+
await execFieldLogics(
|
|
134
|
+
this.entity,
|
|
135
|
+
'compute',
|
|
136
|
+
context,
|
|
137
|
+
result.data,
|
|
138
|
+
params,
|
|
139
|
+
);
|
|
140
|
+
}
|
|
122
141
|
|
|
123
142
|
return result;
|
|
124
143
|
}
|
|
@@ -134,9 +153,12 @@ export class DEActionMethod extends Method {
|
|
|
134
153
|
*/
|
|
135
154
|
async create(
|
|
136
155
|
context: IParams,
|
|
137
|
-
data
|
|
138
|
-
params
|
|
156
|
+
data?: IData | IData[],
|
|
157
|
+
params?: IParams,
|
|
139
158
|
): Promise<IHttpResponse<IDataEntity>> {
|
|
159
|
+
if (!data) {
|
|
160
|
+
throw new RuntimeError('create行为没有传data');
|
|
161
|
+
}
|
|
140
162
|
if (this.isLocalMode) {
|
|
141
163
|
return this.createTemp(context, this.createEntity(data));
|
|
142
164
|
}
|
|
@@ -182,9 +204,12 @@ export class DEActionMethod extends Method {
|
|
|
182
204
|
*/
|
|
183
205
|
async update(
|
|
184
206
|
context: IParams,
|
|
185
|
-
data
|
|
186
|
-
params
|
|
207
|
+
data?: IData | IData[],
|
|
208
|
+
params?: IParams,
|
|
187
209
|
): Promise<IHttpResponse<IDataEntity>> {
|
|
210
|
+
if (!data) {
|
|
211
|
+
throw new RuntimeError('update行为没有传data');
|
|
212
|
+
}
|
|
188
213
|
if (this.isLocalMode) {
|
|
189
214
|
return this.updateTemp(context, this.createEntity(data));
|
|
190
215
|
}
|
|
@@ -256,12 +281,20 @@ export class DEActionMethod extends Method {
|
|
|
256
281
|
*/
|
|
257
282
|
async createTemp(
|
|
258
283
|
context: IParams,
|
|
259
|
-
entity: IData,
|
|
284
|
+
entity: IData | IData[],
|
|
260
285
|
): Promise<IHttpResponse<IDataEntity>> {
|
|
261
286
|
try {
|
|
262
287
|
const s = await this.getService();
|
|
263
|
-
const
|
|
264
|
-
|
|
288
|
+
const addData = this.createEntity(entity);
|
|
289
|
+
let resultData: IDataEntity | IDataEntity[];
|
|
290
|
+
if (isArray(addData)) {
|
|
291
|
+
resultData = await Promise.all(
|
|
292
|
+
addData.map(item => s.local.add(context, item)!),
|
|
293
|
+
);
|
|
294
|
+
} else {
|
|
295
|
+
resultData = await s.local.add(context, addData)!;
|
|
296
|
+
}
|
|
297
|
+
return new HttpResponse(resultData);
|
|
265
298
|
} catch (err) {
|
|
266
299
|
return new HttpResponse(err, 500);
|
|
267
300
|
}
|
|
@@ -335,15 +368,23 @@ export class DEActionMethod extends Method {
|
|
|
335
368
|
*/
|
|
336
369
|
async updateTemp(
|
|
337
370
|
context: IParams,
|
|
338
|
-
entity: IData,
|
|
371
|
+
entity: IData | IData[],
|
|
339
372
|
): Promise<IHttpResponse<IDataEntity>> {
|
|
340
373
|
try {
|
|
341
374
|
const s = await this.getService();
|
|
342
|
-
const
|
|
343
|
-
|
|
344
|
-
|
|
375
|
+
const updateData = this.createEntity(entity);
|
|
376
|
+
let resultData: IDataEntity | IDataEntity[];
|
|
377
|
+
if (isArray(updateData)) {
|
|
378
|
+
resultData = await Promise.all(
|
|
379
|
+
updateData.map(item => s.local.update(context, item)!),
|
|
380
|
+
);
|
|
381
|
+
} else {
|
|
382
|
+
resultData = await s.local.update(context, updateData)!;
|
|
345
383
|
}
|
|
346
|
-
|
|
384
|
+
if (resultData) {
|
|
385
|
+
return new HttpResponse(resultData);
|
|
386
|
+
}
|
|
387
|
+
return new HttpResponse(resultData, 500);
|
|
347
388
|
} catch (err) {
|
|
348
389
|
return new HttpResponse(err, 500);
|
|
349
390
|
}
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
import { ascSort, descSort } from 'qx-util';
|
|
7
7
|
import { clone, equals, isEmpty, isNil, where } from 'ramda';
|
|
8
8
|
import { IAppDEDataSet } from '@ibiz/model-core';
|
|
9
|
+
import { isArray } from 'lodash-es';
|
|
9
10
|
import { PSDEDQCondEngine, SearchFilter } from '../../../utils';
|
|
10
11
|
import { Method } from './method';
|
|
11
12
|
import { IDataEntity } from '../../../../interface';
|
|
@@ -30,14 +31,17 @@ export class FetchMethod extends Method {
|
|
|
30
31
|
|
|
31
32
|
async exec(
|
|
32
33
|
context: IParams,
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
params?: IData | IData[],
|
|
35
|
+
params2?: IParams,
|
|
35
36
|
): Promise<HttpResponse<IDataEntity[]>> {
|
|
37
|
+
// 过滤参数,必须是对象
|
|
38
|
+
const searchParams = params && isArray(params) ? params : params2 || {};
|
|
39
|
+
|
|
36
40
|
if (this.isLocalMode) {
|
|
37
41
|
// 临时数据
|
|
38
42
|
const items = await this.searchLocal(
|
|
39
43
|
null,
|
|
40
|
-
new SearchFilter(context,
|
|
44
|
+
new SearchFilter(context, searchParams),
|
|
41
45
|
);
|
|
42
46
|
return new HttpResponse<IDataEntity[]>(items, 200);
|
|
43
47
|
}
|
|
@@ -48,12 +52,12 @@ export class FetchMethod extends Method {
|
|
|
48
52
|
case 'INDEXDE':
|
|
49
53
|
case 'CODELIST':
|
|
50
54
|
case 'MULTIFORM':
|
|
51
|
-
res = await this.fetchCodeListSet(context,
|
|
55
|
+
res = await this.fetchCodeListSet(context, searchParams);
|
|
52
56
|
break;
|
|
53
57
|
case 'REMOTE':
|
|
54
58
|
{
|
|
55
59
|
const path = this.calcPath(context);
|
|
56
|
-
res = await this.request(path, context,
|
|
60
|
+
res = await this.request(path, context, params, params2);
|
|
57
61
|
}
|
|
58
62
|
break;
|
|
59
63
|
default:
|
|
@@ -68,13 +72,10 @@ export class FetchMethod extends Method {
|
|
|
68
72
|
res.data = items.map(item => this.createEntity(item));
|
|
69
73
|
|
|
70
74
|
// 计算属性逻辑,每条数据走一遍
|
|
71
|
-
if (res.data
|
|
72
|
-
|
|
73
|
-
res.data.map((item: IData) =>
|
|
74
|
-
execFieldLogics(this.entity, 'compute', context, item, params),
|
|
75
|
-
),
|
|
76
|
-
);
|
|
75
|
+
if (res.data) {
|
|
76
|
+
execFieldLogics(this.entity, 'compute', context, res.data, searchParams);
|
|
77
77
|
}
|
|
78
|
+
|
|
78
79
|
return res as HttpResponse<IDataEntity[]>;
|
|
79
80
|
}
|
|
80
81
|
|