@ibiz-template/runtime 0.1.14 → 0.1.16
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 +675 -159
- package/dist/index.system.min.js +1 -1
- package/dist/index.system.min.js.map +1 -1
- package/out/command/app/open-app-view/open-app-view.js +1 -1
- package/out/controller/common/base.controller.d.ts.map +1 -1
- package/out/controller/common/base.controller.js +2 -0
- package/out/controller/control/caption-bar/caption-bar.controller.js +1 -1
- package/out/controller/control/exp-bar/exp-bar.controller.d.ts.map +1 -1
- package/out/controller/control/exp-bar/exp-bar.controller.js +2 -6
- package/out/controller/control/form/form-detail/form-druipart/form-druipart.controller.d.ts.map +1 -1
- package/out/controller/control/form/form-detail/form-druipart/form-druipart.controller.js +4 -2
- package/out/controller/control/grid/grid/grid.controller.d.ts +7 -0
- package/out/controller/control/grid/grid/grid.controller.d.ts.map +1 -1
- package/out/controller/control/grid/grid/grid.controller.js +24 -0
- package/out/controller/control/grid/grid-column/grid-field-column/grid-field-column.controller.d.ts +1 -1
- 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 +30 -23
- package/out/controller/control/search-bar/search-bar.controller.d.ts.map +1 -1
- package/out/controller/control/search-bar/search-bar.controller.js +1 -0
- package/out/controller/control/tree/tree.controller.d.ts.map +1 -1
- package/out/controller/control/tree/tree.controller.js +0 -1
- package/out/controller/utils/event/controller-event.d.ts +7 -0
- package/out/controller/utils/event/controller-event.d.ts.map +1 -1
- package/out/controller/utils/event/controller-event.js +17 -0
- package/out/controller/utils/index.d.ts +1 -0
- package/out/controller/utils/index.d.ts.map +1 -1
- package/out/controller/utils/index.js +1 -0
- package/out/controller/utils/value-ex/value-ex.d.ts +47 -0
- package/out/controller/utils/value-ex/value-ex.d.ts.map +1 -0
- package/out/controller/utils/value-ex/value-ex.js +48 -0
- package/out/engine/md-view.engine.d.ts +10 -1
- package/out/engine/md-view.engine.d.ts.map +1 -1
- package/out/engine/md-view.engine.js +28 -8
- package/out/interface/common/i-modal/i-modal.d.ts +8 -0
- package/out/interface/common/i-modal/i-modal.d.ts.map +1 -1
- package/out/interface/controller/state/common/i-controller.state.d.ts +8 -0
- package/out/interface/controller/state/common/i-controller.state.d.ts.map +1 -1
- package/out/interface/controller/state/control/i-grid.state.d.ts +14 -0
- package/out/interface/controller/state/control/i-grid.state.d.ts.map +1 -1
- package/out/interface/controller/state/control/i-search-bar.state.d.ts +8 -0
- package/out/interface/controller/state/control/i-search-bar.state.d.ts.map +1 -1
- package/out/interface/service/code-list-item/code-list-item.d.ts +5 -0
- package/out/interface/service/code-list-item/code-list-item.d.ts.map +1 -1
- package/out/service/dto/method.dto.d.ts.map +1 -1
- package/out/service/dto/method.dto.js +3 -1
- package/out/service/service/code-list/code-list.service.d.ts.map +1 -1
- package/out/service/service/code-list/code-list.service.js +1 -0
- package/out/service/service/entity/method/method.d.ts.map +1 -1
- package/out/service/service/entity/method/method.js +3 -2
- package/out/ui-action/provider/backend-ui-action-provider.d.ts.map +1 -1
- package/out/ui-action/provider/backend-ui-action-provider.js +4 -2
- package/out/ui-action/uiaction-util.d.ts.map +1 -1
- package/out/ui-action/uiaction-util.js +1 -0
- package/out/utils/handlebars/handlebars.d.ts +11 -2
- package/out/utils/handlebars/handlebars.d.ts.map +1 -1
- package/out/utils/handlebars/handlebars.js +24 -2
- package/out/utils/handlebars/helpers/and/and.d.ts +16 -0
- package/out/utils/handlebars/helpers/and/and.d.ts.map +1 -0
- package/out/utils/handlebars/helpers/and/and.js +24 -0
- package/out/utils/handlebars/helpers/camel-case/camel-case.d.ts +16 -0
- package/out/utils/handlebars/helpers/camel-case/camel-case.d.ts.map +1 -0
- package/out/utils/handlebars/helpers/camel-case/camel-case.js +23 -0
- package/out/utils/handlebars/helpers/concat/concat.d.ts +16 -0
- package/out/utils/handlebars/helpers/concat/concat.d.ts.map +1 -0
- package/out/utils/handlebars/helpers/concat/concat.js +20 -0
- package/out/utils/handlebars/helpers/eq/eq.d.ts +16 -0
- package/out/utils/handlebars/helpers/eq/eq.d.ts.map +1 -0
- package/out/utils/handlebars/helpers/eq/eq.js +22 -0
- package/out/utils/handlebars/helpers/eq-property-value/eq-property-value.d.ts +15 -0
- package/out/utils/handlebars/helpers/eq-property-value/eq-property-value.d.ts.map +1 -0
- package/out/utils/handlebars/helpers/eq-property-value/eq-property-value.js +32 -0
- package/out/utils/handlebars/helpers/gt/gt.d.ts +16 -0
- package/out/utils/handlebars/helpers/gt/gt.d.ts.map +1 -0
- package/out/utils/handlebars/helpers/gt/gt.js +22 -0
- package/out/utils/handlebars/helpers/gte/gte.d.ts +16 -0
- package/out/utils/handlebars/helpers/gte/gte.d.ts.map +1 -0
- package/out/utils/handlebars/helpers/gte/gte.js +22 -0
- package/out/utils/handlebars/helpers/helper-base.d.ts +29 -0
- package/out/utils/handlebars/helpers/helper-base.d.ts.map +1 -0
- package/out/utils/handlebars/helpers/helper-base.js +20 -0
- package/out/utils/handlebars/helpers/index.d.ts +9 -0
- package/out/utils/handlebars/helpers/index.d.ts.map +1 -0
- package/out/utils/handlebars/helpers/index.js +45 -0
- package/out/utils/handlebars/helpers/json/json.d.ts +16 -0
- package/out/utils/handlebars/helpers/json/json.d.ts.map +1 -0
- package/out/utils/handlebars/helpers/json/json.js +19 -0
- package/out/utils/handlebars/helpers/lower-case/lower-case.d.ts +16 -0
- package/out/utils/handlebars/helpers/lower-case/lower-case.d.ts.map +1 -0
- package/out/utils/handlebars/helpers/lower-case/lower-case.js +22 -0
- package/out/utils/handlebars/helpers/lt/lt.d.ts +16 -0
- package/out/utils/handlebars/helpers/lt/lt.d.ts.map +1 -0
- package/out/utils/handlebars/helpers/lt/lt.js +22 -0
- package/out/utils/handlebars/helpers/lte/lte.d.ts +16 -0
- package/out/utils/handlebars/helpers/lte/lte.d.ts.map +1 -0
- package/out/utils/handlebars/helpers/lte/lte.js +22 -0
- package/out/utils/handlebars/helpers/neq/neq.d.ts +16 -0
- package/out/utils/handlebars/helpers/neq/neq.d.ts.map +1 -0
- package/out/utils/handlebars/helpers/neq/neq.js +22 -0
- package/out/utils/handlebars/helpers/not/not.d.ts +16 -0
- package/out/utils/handlebars/helpers/not/not.d.ts.map +1 -0
- package/out/utils/handlebars/helpers/not/not.js +21 -0
- package/out/utils/handlebars/helpers/or/or.d.ts +16 -0
- package/out/utils/handlebars/helpers/or/or.d.ts.map +1 -0
- package/out/utils/handlebars/helpers/or/or.js +27 -0
- package/out/utils/handlebars/helpers/pascal-case/pascal-case.d.ts +16 -0
- package/out/utils/handlebars/helpers/pascal-case/pascal-case.d.ts.map +1 -0
- package/out/utils/handlebars/helpers/pascal-case/pascal-case.js +23 -0
- package/out/utils/handlebars/helpers/snake-case/snake-case.d.ts +16 -0
- package/out/utils/handlebars/helpers/snake-case/snake-case.d.ts.map +1 -0
- package/out/utils/handlebars/helpers/snake-case/snake-case.js +23 -0
- package/out/utils/handlebars/helpers/spinal-case/spinal-case.d.ts +16 -0
- package/out/utils/handlebars/helpers/spinal-case/spinal-case.d.ts.map +1 -0
- package/out/utils/handlebars/helpers/spinal-case/spinal-case.js +23 -0
- package/out/utils/handlebars/helpers/upper-case/upper-case.d.ts +16 -0
- package/out/utils/handlebars/helpers/upper-case/upper-case.d.ts.map +1 -0
- package/out/utils/handlebars/helpers/upper-case/upper-case.js +22 -0
- package/out/utils/handlebars/utils/helper/helper.d.ts +42 -0
- package/out/utils/handlebars/utils/helper/helper.d.ts.map +1 -0
- package/out/utils/handlebars/utils/helper/helper.js +69 -0
- package/out/utils/handlebars/utils/index.d.ts +2 -0
- package/out/utils/handlebars/utils/index.d.ts.map +1 -0
- package/out/utils/handlebars/utils/index.js +1 -0
- package/out/utils/modal/modal.d.ts +1 -0
- package/out/utils/modal/modal.d.ts.map +1 -1
- package/out/utils/modal/modal.js +5 -2
- package/out/utils/text-util/text-util.d.ts +12 -3
- package/out/utils/text-util/text-util.d.ts.map +1 -1
- package/out/utils/text-util/text-util.js +23 -4
- package/package.json +2 -2
- package/src/command/app/open-app-view/open-app-view.ts +1 -1
- package/src/controller/common/base.controller.ts +2 -0
- package/src/controller/control/caption-bar/caption-bar.controller.ts +1 -1
- package/src/controller/control/exp-bar/exp-bar.controller.ts +2 -6
- package/src/controller/control/form/form-detail/form-druipart/form-druipart.controller.ts +4 -2
- package/src/controller/control/grid/grid/grid.controller.ts +25 -0
- package/src/controller/control/grid/grid-column/grid-field-column/grid-field-column.controller.ts +33 -26
- package/src/controller/control/search-bar/search-bar.controller.ts +1 -0
- package/src/controller/control/tree/tree.controller.ts +0 -1
- package/src/controller/utils/event/controller-event.ts +18 -0
- package/src/controller/utils/index.ts +1 -0
- package/src/controller/utils/value-ex/value-ex.ts +83 -0
- package/src/engine/md-view.engine.ts +31 -8
- package/src/interface/common/i-modal/i-modal.ts +9 -0
- package/src/interface/controller/state/common/i-controller.state.ts +9 -0
- package/src/interface/controller/state/control/i-grid.state.ts +16 -0
- package/src/interface/controller/state/control/i-search-bar.state.ts +9 -0
- package/src/interface/service/code-list-item/code-list-item.ts +6 -0
- package/src/service/dto/method.dto.ts +3 -1
- package/src/service/service/code-list/code-list.service.ts +1 -0
- package/src/service/service/entity/method/method.ts +9 -2
- package/src/ui-action/provider/backend-ui-action-provider.ts +4 -2
- package/src/ui-action/uiaction-util.ts +1 -0
- package/src/utils/handlebars/handlebars.ts +25 -3
- package/src/utils/handlebars/helpers/and/and.ts +26 -0
- package/src/utils/handlebars/helpers/camel-case/camel-case.ts +25 -0
- package/src/utils/handlebars/helpers/concat/concat.ts +22 -0
- package/src/utils/handlebars/helpers/eq/eq.ts +28 -0
- package/src/utils/handlebars/helpers/eq-property-value/eq-property-value.ts +41 -0
- package/src/utils/handlebars/helpers/gt/gt.ts +28 -0
- package/src/utils/handlebars/helpers/gte/gte.ts +28 -0
- package/src/utils/handlebars/helpers/helper-base.ts +31 -0
- package/src/utils/handlebars/helpers/index.ts +46 -0
- package/src/utils/handlebars/helpers/json/json.ts +25 -0
- package/src/utils/handlebars/helpers/lower-case/lower-case.ts +24 -0
- package/src/utils/handlebars/helpers/lt/lt.ts +28 -0
- package/src/utils/handlebars/helpers/lte/lte.ts +28 -0
- package/src/utils/handlebars/helpers/neq/neq.ts +28 -0
- package/src/utils/handlebars/helpers/not/not.ts +26 -0
- package/src/utils/handlebars/helpers/or/or.ts +28 -0
- package/src/utils/handlebars/helpers/pascal-case/pascal-case.ts +25 -0
- package/src/utils/handlebars/helpers/snake-case/snake-case.ts +25 -0
- package/src/utils/handlebars/helpers/spinal-case/spinal-case.ts +25 -0
- package/src/utils/handlebars/helpers/upper-case/upper-case.ts +24 -0
- package/src/utils/handlebars/utils/helper/helper.ts +75 -0
- package/src/utils/handlebars/utils/index.ts +1 -0
- package/src/utils/modal/modal.ts +6 -2
- package/src/utils/text-util/text-util.ts +22 -4
|
@@ -148,4 +148,20 @@ export interface IColumnState {
|
|
|
148
148
|
* @type {boolean}
|
|
149
149
|
*/
|
|
150
150
|
hidden: boolean;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* 是否是操作列
|
|
154
|
+
* @author lxm
|
|
155
|
+
* @date 2023-08-31 04:54:58
|
|
156
|
+
* @type {boolean}
|
|
157
|
+
*/
|
|
158
|
+
uaColumn: boolean;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* 是否是固定列,固定在左侧还是右侧
|
|
162
|
+
* @author lxm
|
|
163
|
+
* @date 2023-08-31 04:55:24
|
|
164
|
+
* @type {('left' | 'right')}
|
|
165
|
+
*/
|
|
166
|
+
fixed?: 'left' | 'right';
|
|
151
167
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ISearchBarGroup } from '@ibiz/model-core';
|
|
1
2
|
import { IControlState } from './i-control.state';
|
|
2
3
|
|
|
3
4
|
export interface ISearchBarState extends IControlState {
|
|
@@ -16,4 +17,12 @@ export interface ISearchBarState extends IControlState {
|
|
|
16
17
|
* @type {boolean}
|
|
17
18
|
*/
|
|
18
19
|
visible: boolean;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 选中的分组项
|
|
23
|
+
* @author lxm
|
|
24
|
+
* @date 2023-08-25 05:32:59
|
|
25
|
+
* @type {boolean}
|
|
26
|
+
*/
|
|
27
|
+
selectedGroupItem: ISearchBarGroup | null;
|
|
19
28
|
}
|
|
@@ -108,6 +108,7 @@ export class CodeListService {
|
|
|
108
108
|
value: isValueNumber ? Number(codeItem.value) : codeItem.value!,
|
|
109
109
|
color: codeItem.color,
|
|
110
110
|
id: codeItem.codeName!,
|
|
111
|
+
textCls: codeItem.textCls,
|
|
111
112
|
};
|
|
112
113
|
if (codeItem.codeItems?.length) {
|
|
113
114
|
_codeItem.children = this.formatStaticItems(
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
2
|
import { HttpResponse, RuntimeModelError } from '@ibiz-template/core';
|
|
3
3
|
import { IAppDataEntity, IAppDEMethod } from '@ibiz/model-core';
|
|
4
|
+
import { notNilEmpty } from 'qx-util';
|
|
4
5
|
import { Application } from '../../../../application';
|
|
5
6
|
import { AppDataEntity } from '../../../app-data-entity/app-data-entity';
|
|
6
7
|
import { calcResPath } from '../../../utils';
|
|
@@ -121,13 +122,19 @@ export abstract class Method {
|
|
|
121
122
|
let res: HttpResponse | null = null;
|
|
122
123
|
switch (requestMethod) {
|
|
123
124
|
case 'POST':
|
|
124
|
-
res = await this.app.net.post(
|
|
125
|
+
res = await this.app.net.post(
|
|
126
|
+
`${path}/${methodName}`,
|
|
127
|
+
notNilEmpty(data) ? data : params,
|
|
128
|
+
);
|
|
125
129
|
break;
|
|
126
130
|
case 'GET':
|
|
127
131
|
res = await this.app.net.get(`${path}/${methodName}`, data);
|
|
128
132
|
break;
|
|
129
133
|
case 'PUT':
|
|
130
|
-
res = await this.app.net.put(
|
|
134
|
+
res = await this.app.net.put(
|
|
135
|
+
`${path}/${methodName}`,
|
|
136
|
+
notNilEmpty(data) ? data : params,
|
|
137
|
+
);
|
|
131
138
|
break;
|
|
132
139
|
case 'DELETE':
|
|
133
140
|
res = await this.app.net.delete(`${path}/${methodName}`, data);
|
|
@@ -33,7 +33,7 @@ export class BackendUIActionProvider extends UIActionProviderBase {
|
|
|
33
33
|
data,
|
|
34
34
|
params,
|
|
35
35
|
);
|
|
36
|
-
const tempParams = { ...
|
|
36
|
+
const tempParams = { ...resultParams };
|
|
37
37
|
|
|
38
38
|
// 如果有打开视图,打开视图,并把返回的数据作为子实体数据
|
|
39
39
|
const frontPSAppView = action.frontAppViewId;
|
|
@@ -61,7 +61,9 @@ export class BackendUIActionProvider extends UIActionProviderBase {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
const app = ibiz.hub.getApp(context?.srfappid);
|
|
64
|
-
const _data = resultData
|
|
64
|
+
const _data = resultData
|
|
65
|
+
.map(item => item.getOrigin?.() || item || {})
|
|
66
|
+
.map(item => Object.assign(item, tempParams)); // 界面行为视图参数和data合并一起传给后台
|
|
65
67
|
const isMultiData = ['MULTIKEY', 'MULTIDATA'].includes(
|
|
66
68
|
action.actionTarget!,
|
|
67
69
|
);
|
|
@@ -49,6 +49,7 @@ export class UIActionUtil {
|
|
|
49
49
|
): Promise<void> {
|
|
50
50
|
const result = await this.exec(actionId, params);
|
|
51
51
|
if (result.closeView) {
|
|
52
|
+
params.view.modal.ignoreDismissCheck = true;
|
|
52
53
|
params.view.closeView({ ok: true });
|
|
53
54
|
} else if (result.refresh) {
|
|
54
55
|
switch (result.refreshMode) {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { installHelpers } from './helpers';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* handlebars 渲染工具类
|
|
3
5
|
*
|
|
@@ -10,6 +12,16 @@ export class HandlebarsUtil {
|
|
|
10
12
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11
13
|
protected hsb: any;
|
|
12
14
|
|
|
15
|
+
/**
|
|
16
|
+
* 如果已经在请求中,则不再重复请求
|
|
17
|
+
*
|
|
18
|
+
* @author chitanda
|
|
19
|
+
* @date 2023-08-30 11:08:58
|
|
20
|
+
* @protected
|
|
21
|
+
* @type {(Promise<unknown> | null)}
|
|
22
|
+
*/
|
|
23
|
+
protected p: Promise<unknown> | null = null;
|
|
24
|
+
|
|
13
25
|
/**
|
|
14
26
|
* handlebars 是否已经初始化
|
|
15
27
|
*
|
|
@@ -27,10 +39,20 @@ export class HandlebarsUtil {
|
|
|
27
39
|
*
|
|
28
40
|
* @author chitanda
|
|
29
41
|
* @date 2023-08-28 17:08:24
|
|
30
|
-
* @return {*} {Promise<
|
|
42
|
+
* @return {*} {Promise<unknown>}
|
|
31
43
|
*/
|
|
32
|
-
async init(): Promise<
|
|
33
|
-
this.
|
|
44
|
+
async init(): Promise<unknown> {
|
|
45
|
+
if (this.isInit) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (this.p) {
|
|
49
|
+
return this.p;
|
|
50
|
+
}
|
|
51
|
+
this.p = import('handlebars');
|
|
52
|
+
this.hsb = await this.p;
|
|
53
|
+
this.p = null;
|
|
54
|
+
installHelpers(this.hsb);
|
|
55
|
+
return this.hsb;
|
|
34
56
|
}
|
|
35
57
|
|
|
36
58
|
/**
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { HelperUtil } from '../../utils';
|
|
2
|
+
import { HelperBase } from '../helper-base';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 并且条件模式
|
|
6
|
+
*
|
|
7
|
+
* @description 判断: word wor2 word3 必须在判断中必须全部为 true, 用法: {{#and word word2 word3}}xxx{{else}}yyy{{/and}}、{{and word word2 word3}} 返回值为 boolean 类型
|
|
8
|
+
* @author chitanda
|
|
9
|
+
* @date 2021-12-29 14:12:10
|
|
10
|
+
* @export
|
|
11
|
+
* @class HelperAnd
|
|
12
|
+
* @extends {HelperBase}
|
|
13
|
+
*/
|
|
14
|
+
export class HelperAnd extends HelperBase {
|
|
15
|
+
constructor(hbs: IData) {
|
|
16
|
+
super(hbs, 'and');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
onExecute(...args: unknown[] | Handlebars.HelperOptions[]): string | boolean {
|
|
20
|
+
const options = args[args.length - 1] as Handlebars.HelperOptions;
|
|
21
|
+
args.pop();
|
|
22
|
+
const arr = (args as unknown[]).filter(item => !!item);
|
|
23
|
+
const bol = arr.length === args.length;
|
|
24
|
+
return HelperUtil.handleJudgmentExecute(this, bol, options);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { camelCase } from 'lodash-es';
|
|
2
|
+
import { HelperBase } from '../helper-base';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 转驼峰
|
|
6
|
+
*
|
|
7
|
+
* @description 用法 {{camelCase xxx}},效果: this-is-my-name => thisIsMyName
|
|
8
|
+
* @author chitanda
|
|
9
|
+
* @date 2021-12-24 15:12:59
|
|
10
|
+
* @export
|
|
11
|
+
* @class HelperCamelCase
|
|
12
|
+
* @extends {HelperBase}
|
|
13
|
+
*/
|
|
14
|
+
export class HelperCamelCase extends HelperBase {
|
|
15
|
+
constructor(hbs: IData) {
|
|
16
|
+
super(hbs, 'camelCase');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
onExecute(param: string): string {
|
|
20
|
+
if (!param) {
|
|
21
|
+
return '';
|
|
22
|
+
}
|
|
23
|
+
return camelCase(param);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { HelperBase } from '../helper-base';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 字符串拼接
|
|
5
|
+
*
|
|
6
|
+
* @description 用法:{{concat string1 string2 string3}} 返回值为 string 类型
|
|
7
|
+
* @author mosher
|
|
8
|
+
* @date 2022-10-12 10:59:10
|
|
9
|
+
* @export
|
|
10
|
+
* @class HelperConcat
|
|
11
|
+
* @extends {HelperBase}
|
|
12
|
+
*/
|
|
13
|
+
export class HelperConcat extends HelperBase {
|
|
14
|
+
constructor(hbs: IData) {
|
|
15
|
+
super(hbs, 'concat');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
onExecute(...args: string[]): string {
|
|
19
|
+
args.pop();
|
|
20
|
+
return args.join('');
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { eq } from 'lodash-es';
|
|
2
|
+
import { HelperUtil } from '../../utils';
|
|
3
|
+
import { HelperBase } from '../helper-base';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 等于
|
|
7
|
+
*
|
|
8
|
+
* @description 判断: word === word2, 用法: {{#eq word word2}}xxx{{else}}yyy{{/eq}}、{{eq word 'xxx'}} 返回值为 boolean 类型
|
|
9
|
+
* @author chitanda
|
|
10
|
+
* @date 2021-12-24 14:12:25
|
|
11
|
+
* @export
|
|
12
|
+
* @class HelperEq
|
|
13
|
+
* @extends {HelperBase}
|
|
14
|
+
*/
|
|
15
|
+
export class HelperEq extends HelperBase {
|
|
16
|
+
constructor(hbs: IData) {
|
|
17
|
+
super(hbs, 'eq');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
onExecute(
|
|
21
|
+
param: unknown,
|
|
22
|
+
param2: unknown,
|
|
23
|
+
options: Handlebars.HelperOptions,
|
|
24
|
+
): string | boolean {
|
|
25
|
+
const bol = eq(param, param2);
|
|
26
|
+
return HelperUtil.handleJudgmentExecute(this, bol, options);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import { eq, findIndex, isArray } from 'lodash-es';
|
|
3
|
+
import { HelperUtil } from '../../utils';
|
|
4
|
+
import { HelperBase } from '../helper-base';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 比较数组或对象是否存在某个属性的值
|
|
8
|
+
*
|
|
9
|
+
* @author zk
|
|
10
|
+
* @date 2023-06-15 09:06:37
|
|
11
|
+
* @export
|
|
12
|
+
* @class HelperHaCtrl
|
|
13
|
+
* @extends {HelperBase}
|
|
14
|
+
*/
|
|
15
|
+
export class HelperEqPropertyValue extends HelperBase {
|
|
16
|
+
constructor(hbs: IData) {
|
|
17
|
+
super(hbs, 'eqPropertyValue');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
onExecute(
|
|
21
|
+
obj: unknown[] | unknown,
|
|
22
|
+
key: string,
|
|
23
|
+
val: unknown,
|
|
24
|
+
options: Handlebars.HelperOptions,
|
|
25
|
+
): string | boolean {
|
|
26
|
+
// 数组
|
|
27
|
+
let bol = false;
|
|
28
|
+
if (isArray(obj)) {
|
|
29
|
+
bol = !eq(
|
|
30
|
+
findIndex(obj, o => eq((o as any)[key], val)),
|
|
31
|
+
-1,
|
|
32
|
+
);
|
|
33
|
+
} else {
|
|
34
|
+
bol =
|
|
35
|
+
// eslint-disable-next-line no-prototype-builtins
|
|
36
|
+
(obj as object).hasOwnProperty(key) &&
|
|
37
|
+
(bol = eq((obj as any)[key], val));
|
|
38
|
+
}
|
|
39
|
+
return HelperUtil.handleJudgmentExecute(this, bol, options);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { gt } from 'lodash-es';
|
|
2
|
+
import { HelperUtil } from '../../utils';
|
|
3
|
+
import { HelperBase } from '../helper-base';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 大于
|
|
7
|
+
*
|
|
8
|
+
* @description 判断: word > word2, 用法: {{#gt word word2}}xxx{{else}}yyy{{/gt}}、{{gt word word2}} 返回值为 boolean 类型
|
|
9
|
+
* @author chitanda
|
|
10
|
+
* @date 2021-12-24 15:12:56
|
|
11
|
+
* @export
|
|
12
|
+
* @class HelperGt
|
|
13
|
+
* @extends {HelperBase}
|
|
14
|
+
*/
|
|
15
|
+
export class HelperGt extends HelperBase {
|
|
16
|
+
constructor(hbs: IData) {
|
|
17
|
+
super(hbs, 'gt');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
onExecute(
|
|
21
|
+
param: unknown,
|
|
22
|
+
param2: unknown,
|
|
23
|
+
options: Handlebars.HelperOptions,
|
|
24
|
+
): string | boolean {
|
|
25
|
+
const bol = gt(param, param2);
|
|
26
|
+
return HelperUtil.handleJudgmentExecute(this, bol, options);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { gte } from 'lodash-es';
|
|
2
|
+
import { HelperUtil } from '../../utils';
|
|
3
|
+
import { HelperBase } from '../helper-base';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 大于等于
|
|
7
|
+
*
|
|
8
|
+
* @description 判断: word >= word2, 用法 {{#gte word word2}}xxx{{else}}yyy{{/gte}}、{{gte word word2}} 返回值为 boolean 类型
|
|
9
|
+
* @author chitanda
|
|
10
|
+
* @date 2021-12-24 15:12:35
|
|
11
|
+
* @export
|
|
12
|
+
* @class HelperGte
|
|
13
|
+
* @extends {HelperBase}
|
|
14
|
+
*/
|
|
15
|
+
export class HelperGte extends HelperBase {
|
|
16
|
+
constructor(hbs: IData) {
|
|
17
|
+
super(hbs, 'gte');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
onExecute(
|
|
21
|
+
param: unknown,
|
|
22
|
+
param2: unknown,
|
|
23
|
+
options: Handlebars.HelperOptions,
|
|
24
|
+
): string | boolean {
|
|
25
|
+
const bol = gte(param, param2);
|
|
26
|
+
return HelperUtil.handleJudgmentExecute(this, bol, options);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* helper 基类
|
|
3
|
+
*
|
|
4
|
+
* @author chitanda
|
|
5
|
+
* @date 2021-12-29 14:12:34
|
|
6
|
+
* @export
|
|
7
|
+
* @class HelperBase
|
|
8
|
+
*/
|
|
9
|
+
export abstract class HelperBase {
|
|
10
|
+
/**
|
|
11
|
+
* Creates an instance of HelperBase.
|
|
12
|
+
*
|
|
13
|
+
* @author chitanda
|
|
14
|
+
* @date 2021-12-29 14:12:47
|
|
15
|
+
* @param {string} tag 助手标识
|
|
16
|
+
*/
|
|
17
|
+
constructor(Handlebars: IData, tag: string) {
|
|
18
|
+
Handlebars.registerHelper(tag, this.onExecute);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 助手执行
|
|
23
|
+
*
|
|
24
|
+
* @author chitanda
|
|
25
|
+
* @date 2022-08-05 18:08:03
|
|
26
|
+
* @abstract
|
|
27
|
+
* @param {...unknown[]} args
|
|
28
|
+
* @return {*} {(string | boolean)}
|
|
29
|
+
*/
|
|
30
|
+
abstract onExecute(...args: unknown[]): string | boolean;
|
|
31
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { HelperAnd } from './and/and';
|
|
2
|
+
import { HelperCamelCase } from './camel-case/camel-case';
|
|
3
|
+
import { HelperConcat } from './concat/concat';
|
|
4
|
+
import { HelperEq } from './eq/eq';
|
|
5
|
+
import { HelperGt } from './gt/gt';
|
|
6
|
+
import { HelperGte } from './gte/gte';
|
|
7
|
+
import { HelperEqPropertyValue } from './eq-property-value/eq-property-value';
|
|
8
|
+
import { HelperJson } from './json/json';
|
|
9
|
+
import { HelperLowerCase } from './lower-case/lower-case';
|
|
10
|
+
import { HelperLt } from './lt/lt';
|
|
11
|
+
import { HelperLte } from './lte/lte';
|
|
12
|
+
import { HelperNeq } from './neq/neq';
|
|
13
|
+
import { HelperNot } from './not/not';
|
|
14
|
+
import { HelperOr } from './or/or';
|
|
15
|
+
import { HelperPascalCase } from './pascal-case/pascal-case';
|
|
16
|
+
import { HelperSnakeCase } from './snake-case/snake-case';
|
|
17
|
+
import { HelperSpinalCase } from './spinal-case/spinal-case';
|
|
18
|
+
import { HelperUpperCase } from './upper-case/upper-case';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* 安装自定义助手
|
|
22
|
+
*
|
|
23
|
+
* @author chitanda
|
|
24
|
+
* @date 2021-12-24 14:12:05
|
|
25
|
+
* @export
|
|
26
|
+
*/
|
|
27
|
+
export function installHelpers(hsb: IData): void {
|
|
28
|
+
new HelperAnd(hsb);
|
|
29
|
+
new HelperCamelCase(hsb);
|
|
30
|
+
new HelperConcat(hsb);
|
|
31
|
+
new HelperEq(hsb);
|
|
32
|
+
new HelperGt(hsb);
|
|
33
|
+
new HelperGte(hsb);
|
|
34
|
+
new HelperJson(hsb);
|
|
35
|
+
new HelperLowerCase(hsb);
|
|
36
|
+
new HelperLt(hsb);
|
|
37
|
+
new HelperLte(hsb);
|
|
38
|
+
new HelperNeq(hsb);
|
|
39
|
+
new HelperNot(hsb);
|
|
40
|
+
new HelperOr(hsb);
|
|
41
|
+
new HelperPascalCase(hsb);
|
|
42
|
+
new HelperSnakeCase(hsb);
|
|
43
|
+
new HelperSpinalCase(hsb);
|
|
44
|
+
new HelperUpperCase(hsb);
|
|
45
|
+
new HelperEqPropertyValue(hsb);
|
|
46
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { HelperBase } from '../helper-base';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* json 转 string
|
|
5
|
+
*
|
|
6
|
+
* @description 用法 {{json xxx 2}},支持第二个参数传递格式化。效果: 将 json 对象转为 json 字符串
|
|
7
|
+
* @author chitanda
|
|
8
|
+
* @date 2021-12-24 15:12:59
|
|
9
|
+
* @export
|
|
10
|
+
* @class HelperJson
|
|
11
|
+
* @extends {HelperBase}
|
|
12
|
+
*/
|
|
13
|
+
export class HelperJson extends HelperBase {
|
|
14
|
+
constructor(hbs: IData) {
|
|
15
|
+
super(hbs, 'jsonStringify');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
onExecute(obj: Record<string, unknown> | unknown[], space: number): string {
|
|
19
|
+
return JSON.stringify(
|
|
20
|
+
obj,
|
|
21
|
+
null,
|
|
22
|
+
typeof space === 'number' ? space : undefined,
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { HelperBase } from '../helper-base';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 字符串转换小写
|
|
5
|
+
*
|
|
6
|
+
* @description 用法 {{lowerCase word}}, 效果: MyName => myname
|
|
7
|
+
* @author chitanda
|
|
8
|
+
* @date 2021-12-24 15:12:35
|
|
9
|
+
* @export
|
|
10
|
+
* @class HelperLowerCase
|
|
11
|
+
* @extends {HelperBase}
|
|
12
|
+
*/
|
|
13
|
+
export class HelperLowerCase extends HelperBase {
|
|
14
|
+
constructor(hbs: IData) {
|
|
15
|
+
super(hbs, 'lowerCase');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
onExecute(param: string): string {
|
|
19
|
+
if (!param) {
|
|
20
|
+
return '';
|
|
21
|
+
}
|
|
22
|
+
return param.toLowerCase();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { lt } from 'lodash-es';
|
|
2
|
+
import { HelperUtil } from '../../utils';
|
|
3
|
+
import { HelperBase } from '../helper-base';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 小于
|
|
7
|
+
*
|
|
8
|
+
* @description 判断: word < word2, 用法 {{#lt word word2}}xxx{{else}}yyy{{/lt}}、{{lt word word2}} 返回值为 boolean 类型
|
|
9
|
+
* @author chitanda
|
|
10
|
+
* @date 2021-12-24 15:12:53
|
|
11
|
+
* @export
|
|
12
|
+
* @class HelperLt
|
|
13
|
+
* @extends {HelperBase}
|
|
14
|
+
*/
|
|
15
|
+
export class HelperLt extends HelperBase {
|
|
16
|
+
constructor(hbs: IData) {
|
|
17
|
+
super(hbs, 'lt');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
onExecute(
|
|
21
|
+
param: unknown,
|
|
22
|
+
param2: unknown,
|
|
23
|
+
options: Handlebars.HelperOptions,
|
|
24
|
+
): string | boolean {
|
|
25
|
+
const bol = lt(param, param2);
|
|
26
|
+
return HelperUtil.handleJudgmentExecute(this, bol, options);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { lte } from 'lodash-es';
|
|
2
|
+
import { HelperUtil } from '../../utils';
|
|
3
|
+
import { HelperBase } from '../helper-base';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 小于等于
|
|
7
|
+
*
|
|
8
|
+
* @description 判断: word <= word2, 用法 {{#lte word word2}}xxx{{else}}yyy{{/lte}}、{{lte word word2}} 返回值为 boolean 类型
|
|
9
|
+
* @author chitanda
|
|
10
|
+
* @date 2021-12-24 15:12:18
|
|
11
|
+
* @export
|
|
12
|
+
* @class HelperLte
|
|
13
|
+
* @extends {HelperBase}
|
|
14
|
+
*/
|
|
15
|
+
export class HelperLte extends HelperBase {
|
|
16
|
+
constructor(hbs: IData) {
|
|
17
|
+
super(hbs, 'lte');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
onExecute(
|
|
21
|
+
param: unknown,
|
|
22
|
+
param2: unknown,
|
|
23
|
+
options: Handlebars.HelperOptions,
|
|
24
|
+
): string | boolean {
|
|
25
|
+
const bol = lte(param, param2);
|
|
26
|
+
return HelperUtil.handleJudgmentExecute(this, bol, options);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { eq } from 'lodash-es';
|
|
2
|
+
import { HelperUtil } from '../../utils';
|
|
3
|
+
import { HelperBase } from '../helper-base';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 不等于
|
|
7
|
+
*
|
|
8
|
+
* @description 判断: word !== word2, 用法 {{#neq word 'xxx'}}xxx{{else}}yyy{{/neq}}、{{neq word 'xxx'}} 返回值为 boolean 类型
|
|
9
|
+
* @author chitanda
|
|
10
|
+
* @date 2021-12-24 15:12:21
|
|
11
|
+
* @export
|
|
12
|
+
* @class HelperNeq
|
|
13
|
+
* @extends {HelperBase}
|
|
14
|
+
*/
|
|
15
|
+
export class HelperNeq extends HelperBase {
|
|
16
|
+
constructor(hbs: IData) {
|
|
17
|
+
super(hbs, 'neq');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
onExecute(
|
|
21
|
+
param: unknown,
|
|
22
|
+
param2: unknown,
|
|
23
|
+
options: Handlebars.HelperOptions,
|
|
24
|
+
): string | boolean {
|
|
25
|
+
const bol = !eq(param, param2);
|
|
26
|
+
return HelperUtil.handleJudgmentExecute(this, bol, options);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { HelperUtil } from '../../utils';
|
|
2
|
+
import { HelperBase } from '../helper-base';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 参数不存在或者为空时返回 true
|
|
6
|
+
*
|
|
7
|
+
* @description 判断: 参数为 null、undefined、空字符串、空数组、空对象时返回 true, 用法: {{#not value}}xxx{{else}}yyy{{/not}}、{{not value}} 返回值为 boolean 类型
|
|
8
|
+
* @author chitanda
|
|
9
|
+
* @date 2021-12-29 15:12:38
|
|
10
|
+
* @export
|
|
11
|
+
* @class HelperNot
|
|
12
|
+
* @extends {HelperBase}
|
|
13
|
+
*/
|
|
14
|
+
export class HelperNot extends HelperBase {
|
|
15
|
+
constructor(hbs: IData) {
|
|
16
|
+
super(hbs, 'not');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
onExecute(
|
|
20
|
+
param: unknown,
|
|
21
|
+
options: Handlebars.HelperOptions,
|
|
22
|
+
): string | boolean {
|
|
23
|
+
const bol = Handlebars.Utils.isEmpty(param);
|
|
24
|
+
return HelperUtil.handleJudgmentExecute(this, bol, options);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { HelperBase } from '../helper-base';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 或者条件
|
|
5
|
+
*
|
|
6
|
+
* @description 判断: word word2 word3 其中任意一个值在判断中为 true, 用法 {{#or word word2 word3}}xxx{{else}}yyy{{/or}}、{{or word word2 word3}} 返回值为 boolean 类型
|
|
7
|
+
* @author chitanda
|
|
8
|
+
* @date 2021-12-29 10:12:00
|
|
9
|
+
* @export
|
|
10
|
+
* @class HelperOr
|
|
11
|
+
* @extends {HelperBase}
|
|
12
|
+
*/
|
|
13
|
+
export class HelperOr extends HelperBase {
|
|
14
|
+
constructor(hbs: IData) {
|
|
15
|
+
super(hbs, 'or');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
onExecute(...args: unknown[] | Handlebars.HelperOptions[]): string {
|
|
19
|
+
const options = args[args.length - 1] as Handlebars.HelperOptions;
|
|
20
|
+
args.pop();
|
|
21
|
+
const item = (args as unknown[]).find(itemArg => !!itemArg);
|
|
22
|
+
if (options.fn) {
|
|
23
|
+
const data = options.data?.root || {};
|
|
24
|
+
return item ? options.fn(data) : options.inverse(data);
|
|
25
|
+
}
|
|
26
|
+
return (item as string) || '';
|
|
27
|
+
}
|
|
28
|
+
}
|