@ibiz-template/runtime 0.5.3-beta.8 → 0.5.3
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 +832 -333
- package/dist/index.system.min.js +1 -1
- package/out/controller/common/view/view.controller.d.ts.map +1 -1
- package/out/controller/common/view/view.controller.js +2 -0
- package/out/controller/control/form/edit-form/edit-form.controller.js +1 -1
- package/out/controller/control/form/form-detail/form-detail/form-detail.controller.d.ts.map +1 -1
- package/out/controller/control/form/form-detail/form-detail/form-detail.controller.js +4 -0
- package/out/controller/control/form/form-detail/form-tab-page/form-tab-page.controller.d.ts +8 -0
- package/out/controller/control/form/form-detail/form-tab-page/form-tab-page.controller.d.ts.map +1 -1
- package/out/controller/control/form/form-detail/form-tab-page/form-tab-page.controller.js +10 -0
- package/out/controller/control/form/form-detail/form-tab-panel/form-tab-panel.controller.d.ts +8 -0
- package/out/controller/control/form/form-detail/form-tab-panel/form-tab-panel.controller.d.ts.map +1 -1
- package/out/controller/control/form/form-detail/form-tab-panel/form-tab-panel.controller.js +15 -0
- package/out/controller/control/form/form-detail/form-tab-panel/form-tab-panel.state.d.ts +7 -0
- package/out/controller/control/form/form-detail/form-tab-panel/form-tab-panel.state.d.ts.map +1 -1
- package/out/controller/control/form/form-detail/form-tab-panel/form-tab-panel.state.js +10 -0
- package/out/controller/control/grid/grid/grid.service.d.ts.map +1 -1
- package/out/controller/control/grid/grid/grid.service.js +1 -10
- package/out/controller/control/grid/grid-column/grid-field-column/grid-field-column.controller.d.ts +7 -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 +11 -2
- package/out/controller/control/grid/grid-column/grid-field-edit-column/grid-field-edit-column.controller.d.ts +0 -7
- package/out/controller/control/grid/grid-column/grid-field-edit-column/grid-field-edit-column.controller.d.ts.map +1 -1
- package/out/controller/control/grid/grid-column/grid-field-edit-column/grid-field-edit-column.controller.js +0 -9
- package/out/controller/control/tree/tree.controller.d.ts +17 -0
- package/out/controller/control/tree/tree.controller.d.ts.map +1 -1
- package/out/controller/control/tree/tree.controller.js +22 -0
- package/out/controller/control/tree-grid-ex/tree-grid-ex.controller.d.ts.map +1 -1
- package/out/controller/control/tree-grid-ex/tree-grid-ex.controller.js +6 -4
- package/out/controller/utils/jsonschema/entity.d.ts.map +1 -1
- package/out/controller/utils/jsonschema/entity.js +4 -1
- package/out/global/global-util/global-util.d.ts +8 -1
- package/out/global/global-util/global-util.d.ts.map +1 -1
- package/out/global/global-util/global-util.js +8 -1
- package/out/interface/controller/common/i-icon/i-icon.d.ts +1 -0
- package/out/interface/controller/common/i-icon/i-icon.d.ts.map +1 -1
- package/out/interface/controller/state/control/i-drbar.state.d.ts +7 -0
- package/out/interface/controller/state/control/i-drbar.state.d.ts.map +1 -1
- package/out/interface/controller/state/control/i-drtab.state.d.ts +7 -0
- package/out/interface/controller/state/control/i-drtab.state.d.ts.map +1 -1
- package/out/interface/service/i-transaction/i-transaction.d.ts +83 -0
- package/out/interface/service/i-transaction/i-transaction.d.ts.map +1 -0
- package/out/interface/service/i-transaction/i-transaction.js +1 -0
- package/out/interface/service/index.d.ts +1 -0
- package/out/interface/service/index.d.ts.map +1 -1
- package/out/interface/service/service/i-app-de.service.d.ts +9 -1
- package/out/interface/service/service/i-app-de.service.d.ts.map +1 -1
- package/out/interface/util/i-view-stack/i-view-stack.d.ts +53 -0
- package/out/interface/util/i-view-stack/i-view-stack.d.ts.map +1 -0
- package/out/interface/util/i-view-stack/i-view-stack.js +1 -0
- package/out/interface/util/index.d.ts +1 -0
- package/out/interface/util/index.d.ts.map +1 -1
- package/out/register/helper/async-action-register.d.ts.map +1 -1
- package/out/register/helper/async-action-register.js +1 -1
- package/out/service/de-service-util.d.ts +11 -0
- package/out/service/de-service-util.d.ts.map +1 -1
- package/out/service/de-service-util.js +34 -0
- package/out/service/dto/method.dto.d.ts +1 -2
- package/out/service/dto/method.dto.d.ts.map +1 -1
- package/out/service/dto/method.dto.js +0 -7
- package/out/service/service/auth/v7-auth.service.d.ts +1 -2
- package/out/service/service/auth/v7-auth.service.d.ts.map +1 -1
- package/out/service/service/auth/v7-auth.service.js +27 -7
- package/out/service/service/entity/de.service.d.ts +1 -1
- package/out/service/service/entity/de.service.d.ts.map +1 -1
- package/out/service/service/entity/de.service.js +4 -1
- package/out/service/service/entity/method/de-action.d.ts +13 -1
- package/out/service/service/entity/method/de-action.d.ts.map +1 -1
- package/out/service/service/entity/method/de-action.js +163 -56
- package/out/service/service/entity/method/fetch.d.ts.map +1 -1
- package/out/service/service/entity/method/fetch.js +2 -1
- package/out/service/service/entity/method/method-renturn.d.ts.map +1 -1
- package/out/service/service/entity/method/method-renturn.js +9 -3
- package/out/service/utils/de-cache/de-cache.d.ts +11 -1
- package/out/service/utils/de-cache/de-cache.d.ts.map +1 -1
- package/out/service/utils/de-cache/de-cache.js +122 -18
- package/out/service/utils/de-dq-cond/ps-model-cond-engine-base.d.ts.map +1 -1
- package/out/service/utils/de-dq-cond/ps-model-cond-engine-base.js +4 -0
- 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 +9 -1
- package/out/service/vo/tree-node-data/tree-node-data.d.ts.map +1 -1
- package/out/service/vo/tree-node-data/tree-node-data.js +3 -0
- package/out/ui-action/provider/front-ui-action-provider.d.ts.map +1 -1
- package/out/ui-action/provider/front-ui-action-provider.js +2 -1
- package/out/utils/index.d.ts +1 -0
- package/out/utils/index.d.ts.map +1 -1
- package/out/utils/index.js +1 -0
- package/out/utils/ui-domain/transaction.d.ts +66 -0
- package/out/utils/ui-domain/transaction.d.ts.map +1 -0
- package/out/utils/ui-domain/transaction.js +94 -0
- package/out/utils/ui-domain/ui-domain.d.ts +18 -0
- package/out/utils/ui-domain/ui-domain.d.ts.map +1 -1
- package/out/utils/ui-domain/ui-domain.js +23 -0
- package/out/utils/view-stack/view-stack.d.ts +29 -0
- package/out/utils/view-stack/view-stack.d.ts.map +1 -0
- package/out/utils/view-stack/view-stack.js +47 -0
- package/package.json +5 -5
- package/src/controller/common/view/view.controller.ts +4 -0
- package/src/controller/control/form/edit-form/edit-form.controller.ts +1 -1
- package/src/controller/control/form/form-detail/form-detail/form-detail.controller.ts +4 -0
- package/src/controller/control/form/form-detail/form-tab-page/form-tab-page.controller.ts +14 -0
- package/src/controller/control/form/form-detail/form-tab-panel/form-tab-panel.controller.ts +16 -0
- package/src/controller/control/form/form-detail/form-tab-panel/form-tab-panel.state.ts +9 -1
- package/src/controller/control/grid/grid/grid.service.ts +1 -11
- package/src/controller/control/grid/grid-column/grid-field-column/grid-field-column.controller.ts +12 -2
- package/src/controller/control/grid/grid-column/grid-field-edit-column/grid-field-edit-column.controller.ts +0 -10
- package/src/controller/control/tree/tree.controller.ts +35 -0
- package/src/controller/control/tree-grid-ex/tree-grid-ex.controller.ts +12 -4
- package/src/controller/utils/jsonschema/entity.ts +4 -1
- package/src/global/global-util/global-util.ts +9 -0
- package/src/interface/controller/common/i-icon/i-icon.ts +1 -0
- package/src/interface/controller/state/control/i-drbar.state.ts +8 -0
- package/src/interface/controller/state/control/i-drtab.state.ts +8 -0
- package/src/interface/service/i-transaction/i-transaction.ts +88 -0
- package/src/interface/service/index.ts +4 -0
- package/src/interface/service/service/i-app-de.service.ts +10 -1
- package/src/interface/util/i-view-stack/i-view-stack.ts +53 -0
- package/src/interface/util/index.ts +1 -0
- package/src/register/helper/async-action-register.ts +3 -1
- package/src/service/de-service-util.ts +43 -0
- package/src/service/dto/method.dto.ts +1 -8
- package/src/service/service/auth/v7-auth.service.ts +37 -19
- package/src/service/service/entity/de.service.ts +6 -1
- package/src/service/service/entity/method/de-action.ts +182 -61
- package/src/service/service/entity/method/fetch.ts +2 -4
- package/src/service/service/entity/method/method-renturn.ts +14 -5
- package/src/service/utils/de-cache/de-cache.ts +128 -19
- package/src/service/utils/de-dq-cond/ps-model-cond-engine-base.ts +4 -0
- package/src/service/utils/dynamic-code-list/dynamic-code-list.ts +11 -0
- package/src/service/vo/tree-node-data/tree-node-data.ts +3 -0
- package/src/ui-action/provider/front-ui-action-provider.ts +2 -1
- package/src/utils/index.ts +1 -0
- package/src/utils/ui-domain/transaction.ts +100 -0
- package/src/utils/ui-domain/ui-domain.ts +25 -0
- package/src/utils/view-stack/view-stack.ts +64 -0
|
@@ -13,7 +13,10 @@ export async function getEntitySchema(
|
|
|
13
13
|
): Promise<IData> {
|
|
14
14
|
const app = ibiz.hub.getApp(context.srfappid);
|
|
15
15
|
const entity = await ibiz.hub.getAppDataEntity(entityId, context.srfappid);
|
|
16
|
-
|
|
16
|
+
let url = `/jsonschema/${entity.name}`;
|
|
17
|
+
if (entity.dynaSysMode === 0 && ibiz.appData) {
|
|
18
|
+
url += `?dynamodeltag=${ibiz.appData.dynamodeltag}`;
|
|
19
|
+
}
|
|
17
20
|
const res = await app.net.get(url);
|
|
18
21
|
return res.data;
|
|
19
22
|
}
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
ThemeUtil,
|
|
9
9
|
DefaultErrorHandler,
|
|
10
10
|
ErrorHandlerCenter,
|
|
11
|
+
ViewStack,
|
|
11
12
|
} from '../../utils';
|
|
12
13
|
|
|
13
14
|
/**
|
|
@@ -74,6 +75,14 @@ export class GlobalUtil {
|
|
|
74
75
|
*/
|
|
75
76
|
readonly error = new ErrorHandlerCenter();
|
|
76
77
|
|
|
78
|
+
/**
|
|
79
|
+
* 视图堆栈
|
|
80
|
+
*
|
|
81
|
+
* @author chitanda
|
|
82
|
+
* @date 2024-01-18 14:01:23
|
|
83
|
+
*/
|
|
84
|
+
readonly viewStack = new ViewStack();
|
|
85
|
+
|
|
77
86
|
constructor() {
|
|
78
87
|
this.error.register(new DefaultErrorHandler());
|
|
79
88
|
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 事务状态
|
|
3
|
+
*
|
|
4
|
+
* @author chitanda
|
|
5
|
+
* @date 2024-01-17 15:01:18
|
|
6
|
+
* @export
|
|
7
|
+
* @interface ITransactionState
|
|
8
|
+
*/
|
|
9
|
+
export interface ITransactionState {
|
|
10
|
+
/**
|
|
11
|
+
* 是否在事务中
|
|
12
|
+
*
|
|
13
|
+
* @author chitanda
|
|
14
|
+
* @date 2024-01-17 15:01:24
|
|
15
|
+
* @type {boolean}
|
|
16
|
+
*/
|
|
17
|
+
isOpen: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* 当前事务是否有变更,如果有变更,提交事务时会触发数据更新并且不可以直接关闭事务
|
|
20
|
+
*
|
|
21
|
+
* @author chitanda
|
|
22
|
+
* @date 2024-01-17 15:01:20
|
|
23
|
+
* @type {boolean}
|
|
24
|
+
*/
|
|
25
|
+
isChange: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* 本地包数据事务,用于界面域下简单数据事务
|
|
30
|
+
*
|
|
31
|
+
* @author chitanda
|
|
32
|
+
* @date 2024-01-17 15:01:46
|
|
33
|
+
* @export
|
|
34
|
+
* @interface ITransaction
|
|
35
|
+
*/
|
|
36
|
+
export interface ITransaction {
|
|
37
|
+
/**
|
|
38
|
+
* 事务状态
|
|
39
|
+
*
|
|
40
|
+
* @author chitanda
|
|
41
|
+
* @date 2024-01-17 15:01:46
|
|
42
|
+
* @type {ITransactionState}
|
|
43
|
+
*/
|
|
44
|
+
readonly state: ITransactionState;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* 开启事务
|
|
48
|
+
*
|
|
49
|
+
* @description 事务开启后,所有的数据操作都会被缓存,直到事务提交或者回滚
|
|
50
|
+
* @author chitanda
|
|
51
|
+
* @date 2024-01-17 15:01:46
|
|
52
|
+
*/
|
|
53
|
+
open(): void;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* 新增变更事务回调,事务提交时会按照添加顺序倒序执行
|
|
57
|
+
*
|
|
58
|
+
* @author chitanda
|
|
59
|
+
* @date 2024-01-17 16:01:25
|
|
60
|
+
* @param {string} id
|
|
61
|
+
* @param {() => void} commit
|
|
62
|
+
*/
|
|
63
|
+
change(id: string, commit: () => void): void;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* 提交事务
|
|
67
|
+
*
|
|
68
|
+
* @author chitanda
|
|
69
|
+
* @date 2024-01-17 15:01:05
|
|
70
|
+
*/
|
|
71
|
+
commit(): void;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* 回滚事务
|
|
75
|
+
*
|
|
76
|
+
* @description 回滚事务会清空所有变更,不会触发数据更新
|
|
77
|
+
* @date 2024-01-17 15:01:05
|
|
78
|
+
*/
|
|
79
|
+
rollback(): void;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* 关闭事务
|
|
83
|
+
*
|
|
84
|
+
* @author chitanda
|
|
85
|
+
* @date 2024-01-17 15:01:02
|
|
86
|
+
*/
|
|
87
|
+
close(): void;
|
|
88
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IHttpResponse, IPortalAsyncAction } from '@ibiz-template/core';
|
|
2
|
-
import { IAppDEMethodDTO } from '@ibiz/model-core';
|
|
2
|
+
import { IAppDEMethodDTO, IAppDataEntity } from '@ibiz/model-core';
|
|
3
3
|
import { DECache } from '../../../service/utils';
|
|
4
4
|
import { IFileService } from './i-file.service';
|
|
5
5
|
import { IWorkFlowService } from './i-wf.service';
|
|
@@ -62,6 +62,15 @@ export interface IAppDEService {
|
|
|
62
62
|
*/
|
|
63
63
|
readonly file: IFileService;
|
|
64
64
|
|
|
65
|
+
/**
|
|
66
|
+
* 当前实体服务对应的实体模型
|
|
67
|
+
*
|
|
68
|
+
* @author chitanda
|
|
69
|
+
* @date 2024-01-17 17:01:16
|
|
70
|
+
* @type {IAppDataEntity}
|
|
71
|
+
*/
|
|
72
|
+
readonly model: IAppDataEntity;
|
|
73
|
+
|
|
65
74
|
/**
|
|
66
75
|
* 执行实体服务方法
|
|
67
76
|
*
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { IViewController } from '../../controller';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 视图堆栈
|
|
5
|
+
*
|
|
6
|
+
* @author chitanda
|
|
7
|
+
* @date 2024-01-18 10:01:16
|
|
8
|
+
* @export
|
|
9
|
+
* @interface IViewStack
|
|
10
|
+
*/
|
|
11
|
+
export interface IViewStack {
|
|
12
|
+
/**
|
|
13
|
+
* 添加视图堆栈信息
|
|
14
|
+
*
|
|
15
|
+
* @author chitanda
|
|
16
|
+
* @date 2024-01-18 10:01:29
|
|
17
|
+
* @param {string} id
|
|
18
|
+
* @param {IViewController} view
|
|
19
|
+
*/
|
|
20
|
+
add(id: string, view: IViewController): void;
|
|
21
|
+
/**
|
|
22
|
+
* 删除视图堆栈信息
|
|
23
|
+
*
|
|
24
|
+
* @author chitanda
|
|
25
|
+
* @date 2024-01-18 10:01:41
|
|
26
|
+
* @param {string} id
|
|
27
|
+
*/
|
|
28
|
+
remove(id: string): void;
|
|
29
|
+
/**
|
|
30
|
+
* 视图激活
|
|
31
|
+
*
|
|
32
|
+
* @author chitanda
|
|
33
|
+
* @date 2024-01-18 10:01:11
|
|
34
|
+
* @param {string} id
|
|
35
|
+
*/
|
|
36
|
+
active(id: string): void;
|
|
37
|
+
/**
|
|
38
|
+
* 视图休眠
|
|
39
|
+
*
|
|
40
|
+
* @author chitanda
|
|
41
|
+
* @date 2024-01-18 10:01:18
|
|
42
|
+
* @param {string} id
|
|
43
|
+
*/
|
|
44
|
+
deactivate(id: string): void;
|
|
45
|
+
/**
|
|
46
|
+
* 当前激活视图清单
|
|
47
|
+
*
|
|
48
|
+
* @author chitanda
|
|
49
|
+
* @date 2024-01-18 14:01:50
|
|
50
|
+
* @return {*} {IViewController[]}
|
|
51
|
+
*/
|
|
52
|
+
getActives(): IViewController[];
|
|
53
|
+
}
|
|
@@ -15,3 +15,4 @@ export type { IOverlayController } from './i-overlay-controller/i-overlay-contro
|
|
|
15
15
|
export type { IOverlayPopoverContainer } from './i-overlay-popover-container/i-overlay-popover-container';
|
|
16
16
|
export type { IScriptFunctionOpts } from './script/i-script-function';
|
|
17
17
|
export type { IExcelUtil } from './i-excel-util/i-excel-util';
|
|
18
|
+
export type { IViewStack } from './i-view-stack/i-view-stack';
|
|
@@ -36,7 +36,9 @@ function getProvider(key: string): IAsyncActionProvider | undefined {
|
|
|
36
36
|
export function getAsyncActionProvider(
|
|
37
37
|
actiontype: string,
|
|
38
38
|
): IAsyncActionProvider {
|
|
39
|
-
const provider: IAsyncActionProvider | undefined = getProvider(
|
|
39
|
+
const provider: IAsyncActionProvider | undefined = getProvider(
|
|
40
|
+
actiontype || 'DEFAULT',
|
|
41
|
+
);
|
|
40
42
|
|
|
41
43
|
// 找异步操作类型
|
|
42
44
|
if (!provider) {
|
|
@@ -135,6 +135,49 @@ export class DEServiceUtil {
|
|
|
135
135
|
});
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
+
/**
|
|
139
|
+
* 清理指定实体的临时数据缓存,并根据关系清理掉子实体的临时数据缓存
|
|
140
|
+
*
|
|
141
|
+
* @author chitanda
|
|
142
|
+
* @date 2024-01-19 14:01:32
|
|
143
|
+
* @param {IContext} context
|
|
144
|
+
* @param {string} entityID
|
|
145
|
+
* @param {string[]} [clearEntities=[]] 已经清理过的实体忽略,避免关系循环引用导致死循环
|
|
146
|
+
* @return {*} {void}
|
|
147
|
+
*/
|
|
148
|
+
clearTempCacheByRs(
|
|
149
|
+
context: IContext,
|
|
150
|
+
entityID: string,
|
|
151
|
+
clearEntities: string[] = [],
|
|
152
|
+
): void {
|
|
153
|
+
if (clearEntities.includes(entityID) === true) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
clearEntities.push(entityID);
|
|
157
|
+
const sandboxId = context.srfsessionid;
|
|
158
|
+
if (!this.cache.has(sandboxId)) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
// 清理当前实体的临时数据缓存
|
|
162
|
+
const map = this.cache.get(sandboxId)!;
|
|
163
|
+
const service = map.get(entityID);
|
|
164
|
+
if (service) {
|
|
165
|
+
service.local.clear();
|
|
166
|
+
}
|
|
167
|
+
// 根据关系清理掉子实体的临时数据缓存
|
|
168
|
+
const uiDomain = ibiz.uiDomainManager.get(context.srfsessionid);
|
|
169
|
+
if (uiDomain) {
|
|
170
|
+
const configs = uiDomain.getDERConfigByMajor(entityID);
|
|
171
|
+
configs.forEach(config => {
|
|
172
|
+
this.clearTempCacheByRs(
|
|
173
|
+
context,
|
|
174
|
+
config.minorAppDataEntityId!,
|
|
175
|
+
clearEntities,
|
|
176
|
+
);
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
138
181
|
/**
|
|
139
182
|
* 执行服务方法
|
|
140
183
|
* @author lxm
|
|
@@ -193,12 +193,6 @@ export class MethodDto {
|
|
|
193
193
|
* @return {*} {Promise<IDataEntity[]>}
|
|
194
194
|
*/
|
|
195
195
|
async sets(context: IContext, data: IData[]): Promise<IDataEntity[]> {
|
|
196
|
-
const uiDomain = ibiz.uiDomainManager.get(context.srfsessionid);
|
|
197
|
-
if (uiDomain && uiDomain.state.rsInit !== true) {
|
|
198
|
-
await this.calcRs(context);
|
|
199
|
-
uiDomain.calcParentRs();
|
|
200
|
-
uiDomain.state.rsInit = true;
|
|
201
|
-
}
|
|
202
196
|
return Promise.all(
|
|
203
197
|
data.map(async datum => {
|
|
204
198
|
const all = this.fields
|
|
@@ -247,12 +241,11 @@ export class MethodDto {
|
|
|
247
241
|
*
|
|
248
242
|
* @author chitanda
|
|
249
243
|
* @date 2023-12-26 16:12:13
|
|
250
|
-
* @protected
|
|
251
244
|
* @param {IContext} context
|
|
252
245
|
* @param {number} [depth=0] 递归层级,避免进入死循环。最大递归层级为 10
|
|
253
246
|
* @return {*} {Promise<void>}
|
|
254
247
|
*/
|
|
255
|
-
|
|
248
|
+
async calcRs(context: IContext, depth: number = 0): Promise<void> {
|
|
256
249
|
if (depth > 10) {
|
|
257
250
|
return;
|
|
258
251
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { CoreConst, HttpError } from '@ibiz-template/core';
|
|
2
2
|
import { clearCookie, getCookie, setCookie } from 'qx-util';
|
|
3
|
-
import { IAuthService } from '../../../interface';
|
|
4
|
-
import { IAuthInfo } from '../../../interface/service/service/i-auth.service';
|
|
3
|
+
import { IAuthService, IAuthInfo } from '../../../interface';
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* 认证服务
|
|
@@ -30,9 +29,13 @@ export class V7AuthService implements IAuthService {
|
|
|
30
29
|
const token = getCookie(CoreConst.TOKEN)!;
|
|
31
30
|
const expirein = getCookie(CoreConst.TOKEN_EXPIRES)!;
|
|
32
31
|
const remember = getCookie(CoreConst.TOKEN_REMEMBER)!;
|
|
32
|
+
const refreshToken = getCookie(CoreConst.REFRESH_TOKEN)!;
|
|
33
33
|
setCookie(CoreConst.TOKEN, token, 0, true);
|
|
34
34
|
setCookie(CoreConst.TOKEN_EXPIRES, expirein, 0, true);
|
|
35
35
|
setCookie(CoreConst.TOKEN_REMEMBER, remember, 0, true);
|
|
36
|
+
if (refreshToken) {
|
|
37
|
+
setCookie(CoreConst.REFRESH_TOKEN, refreshToken, 0, true);
|
|
38
|
+
}
|
|
36
39
|
}
|
|
37
40
|
return result;
|
|
38
41
|
}
|
|
@@ -51,18 +54,22 @@ export class V7AuthService implements IAuthService {
|
|
|
51
54
|
});
|
|
52
55
|
const { data } = res;
|
|
53
56
|
if (data && data.token) {
|
|
57
|
+
const cacheDays = remember ? 7 : 0;
|
|
54
58
|
if (remember) {
|
|
55
|
-
setCookie(CoreConst.TOKEN_REMEMBER, '1',
|
|
59
|
+
setCookie(CoreConst.TOKEN_REMEMBER, '1', cacheDays, true);
|
|
56
60
|
}
|
|
57
|
-
setCookie(CoreConst.TOKEN, data.token,
|
|
61
|
+
setCookie(CoreConst.TOKEN, data.token, cacheDays, true);
|
|
58
62
|
const expiredDate =
|
|
59
63
|
new Date().getTime() + (data.expirein || 7199) * 1000;
|
|
60
|
-
setCookie(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
setCookie(CoreConst.TOKEN_EXPIRES, `${expiredDate}`, cacheDays, true);
|
|
65
|
+
if (data.refresh_token) {
|
|
66
|
+
setCookie(
|
|
67
|
+
CoreConst.REFRESH_TOKEN,
|
|
68
|
+
data.refresh_token,
|
|
69
|
+
cacheDays,
|
|
70
|
+
true,
|
|
71
|
+
);
|
|
72
|
+
}
|
|
66
73
|
clearCookie(CoreConst.IS_ANONYMOUS);
|
|
67
74
|
}
|
|
68
75
|
return true;
|
|
@@ -81,6 +88,7 @@ export class V7AuthService implements IAuthService {
|
|
|
81
88
|
clearCookie(CoreConst.TOKEN);
|
|
82
89
|
clearCookie(CoreConst.TOKEN_EXPIRES);
|
|
83
90
|
clearCookie(CoreConst.TOKEN_REMEMBER);
|
|
91
|
+
clearCookie(CoreConst.REFRESH_TOKEN);
|
|
84
92
|
clearCookie(CoreConst.IS_ANONYMOUS);
|
|
85
93
|
ibiz.appData = undefined;
|
|
86
94
|
ibiz.orgData = undefined;
|
|
@@ -102,24 +110,34 @@ export class V7AuthService implements IAuthService {
|
|
|
102
110
|
|
|
103
111
|
const token = getCookie(CoreConst.TOKEN);
|
|
104
112
|
const expirein = getCookie(CoreConst.TOKEN_EXPIRES);
|
|
105
|
-
const remember = getCookie(CoreConst.TOKEN_REMEMBER);
|
|
106
113
|
if (token && expirein) {
|
|
107
114
|
// 计算到过期时间所需的延时毫秒数,预留提前量
|
|
108
115
|
let wait = Number(expirein) - new Date().getTime();
|
|
109
116
|
const early = 5 * 60 * 1000;
|
|
110
117
|
wait = wait > early ? wait - early : 0;
|
|
111
118
|
setTimeout(async () => {
|
|
112
|
-
const
|
|
119
|
+
const remember = getCookie(CoreConst.TOKEN_REMEMBER);
|
|
120
|
+
const refreshToken = getCookie(CoreConst.REFRESH_TOKEN);
|
|
121
|
+
const cacheDay = remember ? 7 : 0;
|
|
122
|
+
let res;
|
|
123
|
+
if (refreshToken != null && refreshToken !== '') {
|
|
124
|
+
res = await ibiz.net.get(`/uaa/refresh_token/${refreshToken}`);
|
|
125
|
+
} else {
|
|
126
|
+
res = await ibiz.net.get(`/uaa/refreshtoken2`);
|
|
127
|
+
}
|
|
113
128
|
if (res.ok) {
|
|
114
|
-
setCookie(CoreConst.TOKEN, res.data.token,
|
|
129
|
+
setCookie(CoreConst.TOKEN, res.data.token, cacheDay, true);
|
|
115
130
|
const expiredDate =
|
|
116
131
|
new Date().getTime() + (res.data.expirein || 7199) * 1000;
|
|
117
|
-
setCookie(
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
132
|
+
setCookie(CoreConst.TOKEN_EXPIRES, `${expiredDate}`, cacheDay, true);
|
|
133
|
+
if (res.data.refresh_token) {
|
|
134
|
+
setCookie(
|
|
135
|
+
CoreConst.REFRESH_TOKEN,
|
|
136
|
+
res.data.refresh_token,
|
|
137
|
+
cacheDay,
|
|
138
|
+
true,
|
|
139
|
+
);
|
|
140
|
+
}
|
|
123
141
|
}
|
|
124
142
|
// 下一次延时做准备
|
|
125
143
|
this.extendLogin();
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
IPortalAsyncAction,
|
|
9
9
|
ModelError,
|
|
10
10
|
RuntimeError,
|
|
11
|
+
RuntimeModelError,
|
|
11
12
|
} from '@ibiz-template/core';
|
|
12
13
|
import { DECache, calcResPath } from '../../utils';
|
|
13
14
|
import { WorkFlowService } from '../work-flow/work-flow.service';
|
|
@@ -94,7 +95,7 @@ export class DEService implements IAppDEService {
|
|
|
94
95
|
*/
|
|
95
96
|
constructor(
|
|
96
97
|
protected srfSessionId: string,
|
|
97
|
-
|
|
98
|
+
public readonly model: IAppDataEntity,
|
|
98
99
|
) {
|
|
99
100
|
this.local = new DECache(model);
|
|
100
101
|
this.configCache = new ConfigService(
|
|
@@ -126,6 +127,10 @@ export class DEService implements IAppDEService {
|
|
|
126
127
|
}
|
|
127
128
|
const model = findModelChild(this.model.appDEMethods!, id) as IAppDEMethod;
|
|
128
129
|
|
|
130
|
+
if (!model) {
|
|
131
|
+
throw new RuntimeModelError(this.model, `未找到服务方法: ${id}`);
|
|
132
|
+
}
|
|
133
|
+
|
|
129
134
|
// 获取适配器
|
|
130
135
|
const provider = await getDEMethodProvider(model);
|
|
131
136
|
if (!provider) {
|