@gct-paas/design 0.1.6-dev.21 → 0.1.6-dev.23
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/loader.esm.min.js +2 -2
- package/es/components/user-occupy/useUserOccupy.mjs +39 -43
- package/es/hooks/design-view/design-state.d.ts +107 -1
- package/es/hooks/design-view/design-state.mjs +7 -7
- package/es/hooks/design-view/designer/useDesignCache.mjs +1 -1
- package/es/hooks/design-view/designer/useDesignSave.d.ts +2 -2
- package/es/hooks/design-view/designer/useDesignSave.mjs +130 -19
- package/es/hooks/design-view/layout/useToolkit.d.ts +1 -1
- package/es/hooks/design-view/layout/useToolkit.mjs +112 -81
- package/es/hooks/design-view/page/usePage.d.ts +12 -6
- package/es/hooks/design-view/page/usePage.mjs +126 -4
- package/es/hooks/design-view/useDesigner.d.ts +3 -2
- package/es/hooks/design-view/useDesigner.mjs +12 -3
- package/es/index.mjs +3 -3
- package/package.json +9 -9
|
@@ -17,42 +17,42 @@ var i18nKeyMap = {
|
|
|
17
17
|
};
|
|
18
18
|
/** 参数 */
|
|
19
19
|
var params = {};
|
|
20
|
+
/** 占用信息 */
|
|
21
|
+
var occupyInfo = ref({});
|
|
22
|
+
/** 锁定信息 */
|
|
23
|
+
var lockInfo = ref({});
|
|
24
|
+
var timeout = computed(() => {
|
|
25
|
+
return occupyInfo.value.querySpanNum * 1e3;
|
|
26
|
+
});
|
|
27
|
+
var wait = computed(() => {
|
|
28
|
+
return (occupyInfo.value.cacheNum - 10) / 2 * 1e3;
|
|
29
|
+
});
|
|
30
|
+
var unlockAvailable = computed(() => {
|
|
31
|
+
const { userId, username } = _gct.store.userInfo;
|
|
32
|
+
return lockInfo.value.id === userId || username === "admin";
|
|
33
|
+
});
|
|
34
|
+
/** 查询占用定时器 */
|
|
35
|
+
var occupyTimer = null;
|
|
36
|
+
async function _loadOccupyInfo() {
|
|
37
|
+
if (!params.id || !params.type || params.id.startsWith("___new___")) return;
|
|
38
|
+
const res = await _api.apaas.designerLock.getGetPageOccupyMsg(params);
|
|
39
|
+
const data = { ...res };
|
|
40
|
+
if (!data.querySpanNum) data.querySpanNum = 120;
|
|
41
|
+
if (!data.cacheNum) data.cacheNum = 500;
|
|
42
|
+
occupyInfo.value = data;
|
|
43
|
+
if (res?.occupyId) destoryOccupyTimer();
|
|
44
|
+
else if (!occupyTimer) occupyTimer = setInterval(() => {
|
|
45
|
+
_loadOccupyInfo();
|
|
46
|
+
}, timeout.value);
|
|
47
|
+
}
|
|
48
|
+
function destoryOccupyTimer() {
|
|
49
|
+
console.log("【销毁占用轮询】");
|
|
50
|
+
if (!occupyTimer) return;
|
|
51
|
+
console.log("【销毁占用轮询 清除定时器】");
|
|
52
|
+
clearInterval(occupyTimer);
|
|
53
|
+
occupyTimer = null;
|
|
54
|
+
}
|
|
20
55
|
function useUserOccupy() {
|
|
21
|
-
/** 占用信息 */
|
|
22
|
-
const occupyInfo = ref({});
|
|
23
|
-
/** 锁定信息 */
|
|
24
|
-
const lockInfo = ref({});
|
|
25
|
-
const timeout = computed(() => {
|
|
26
|
-
return occupyInfo.value.querySpanNum * 1e3;
|
|
27
|
-
});
|
|
28
|
-
const wait = computed(() => {
|
|
29
|
-
return (occupyInfo.value.cacheNum - 10) / 2 * 1e3;
|
|
30
|
-
});
|
|
31
|
-
const unlockAvailable = computed(() => {
|
|
32
|
-
const { userId, username } = _gct.store.userInfo;
|
|
33
|
-
return lockInfo.value.id === userId || username === "admin";
|
|
34
|
-
});
|
|
35
|
-
/** 查询占用定时器 */
|
|
36
|
-
let occupyTimer = null;
|
|
37
|
-
async function _loadOccupyInfo() {
|
|
38
|
-
if (!params.id || !params.type || params.id.startsWith("___new___")) return;
|
|
39
|
-
const res = await _api.apaas.designerLock.getGetPageOccupyMsg(params);
|
|
40
|
-
const data = { ...res };
|
|
41
|
-
if (!data.querySpanNum) data.querySpanNum = 120;
|
|
42
|
-
if (!data.cacheNum) data.cacheNum = 500;
|
|
43
|
-
occupyInfo.value = data;
|
|
44
|
-
if (res?.occupyId) destoryOccupyTimer();
|
|
45
|
-
else if (!occupyTimer) occupyTimer = setInterval(() => {
|
|
46
|
-
_loadOccupyInfo();
|
|
47
|
-
}, timeout.value);
|
|
48
|
-
}
|
|
49
|
-
function destoryOccupyTimer() {
|
|
50
|
-
console.log("【销毁占用轮询】");
|
|
51
|
-
if (!occupyTimer) return;
|
|
52
|
-
console.log("【销毁占用轮询 清除定时器】");
|
|
53
|
-
clearInterval(occupyTimer);
|
|
54
|
-
occupyTimer = null;
|
|
55
|
-
}
|
|
56
56
|
function initMqttOccupy(data) {
|
|
57
57
|
/** 强制刷新主题 */
|
|
58
58
|
const CLEAN_CACHE = `CLEAN_CACHE`;
|
|
@@ -67,13 +67,9 @@ function useUserOccupy() {
|
|
|
67
67
|
})
|
|
68
68
|
}
|
|
69
69
|
}).subscribe(CLEAN_CACHE, () => {
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
arr[1] = Date.now().toString();
|
|
74
|
-
window.location.href = arr.join("reloadTime=");
|
|
75
|
-
} else window.location.href = currentUrl + "&reloadTime=" + Date.now();
|
|
76
|
-
else window.location.href = currentUrl + "?reloadTime=" + Date.now();
|
|
70
|
+
const url = new URL(window.location.href);
|
|
71
|
+
url.searchParams.set("reloadTime", Date.now().toString());
|
|
72
|
+
window.location.href = url.toString();
|
|
77
73
|
location.reload();
|
|
78
74
|
});
|
|
79
75
|
}
|
|
@@ -89,7 +85,7 @@ function useUserOccupy() {
|
|
|
89
85
|
if (lockInfo.value.id) return;
|
|
90
86
|
if (_gct.store.userInfo.userId !== occupyInfo.value.occupyId && occupyInfo.value.occupyId) return;
|
|
91
87
|
try {
|
|
92
|
-
await _api.apaas.designerLock.
|
|
88
|
+
await _api.apaas.designerLock.postOccupyPage(params);
|
|
93
89
|
} catch (err) {
|
|
94
90
|
console.warn("【占用异常】", err);
|
|
95
91
|
} finally {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { pageLayoutModeEnum } from '@gct-paas/core';
|
|
2
2
|
import { ExportMethod, LowCodeWidget, PageJson, IModal } from '@gct-paas/schema';
|
|
3
|
-
import { PageDesignerLogResponse } from '@gct-paas/api/apaas';
|
|
3
|
+
import { PageDesignerLogResponse, WebpageResponse } from '@gct-paas/api/apaas';
|
|
4
4
|
import { platform, designRegister } from '../../utils';
|
|
5
5
|
export { platform, designRegister };
|
|
6
6
|
/**
|
|
@@ -13,6 +13,112 @@ export declare const widgetInfo: import('vue').ComputedRef<import('@gct-paas/sch
|
|
|
13
13
|
/**
|
|
14
14
|
* 当前平台的插件注册实例
|
|
15
15
|
*/
|
|
16
|
+
export type PageInfo = WebpageResponse & {
|
|
17
|
+
categoryId?: string;
|
|
18
|
+
version?: string;
|
|
19
|
+
default?: boolean;
|
|
20
|
+
modelKey?: string;
|
|
21
|
+
_designerJson?: string;
|
|
22
|
+
detailDesignerJson?: string;
|
|
23
|
+
txnPageMode?: 'create' | 'detail';
|
|
24
|
+
baseId?: string;
|
|
25
|
+
};
|
|
26
|
+
/** 当前设计页面基础信息 */
|
|
27
|
+
export declare const pageInfo: import('vue').Ref<{
|
|
28
|
+
categoryResponse?: {
|
|
29
|
+
createTime?: string | undefined;
|
|
30
|
+
createUserId?: string | undefined;
|
|
31
|
+
createUserName?: string | undefined;
|
|
32
|
+
id?: string | undefined;
|
|
33
|
+
modifyTime?: string | undefined;
|
|
34
|
+
modifyUserId?: string | undefined;
|
|
35
|
+
modifyUserName?: string | undefined;
|
|
36
|
+
module?: string | undefined;
|
|
37
|
+
name?: string | undefined;
|
|
38
|
+
sortNum?: number | undefined;
|
|
39
|
+
sysBuiltin?: number | undefined;
|
|
40
|
+
} | undefined;
|
|
41
|
+
createTime?: string | undefined;
|
|
42
|
+
createUserId?: string | undefined;
|
|
43
|
+
createUserName?: string | undefined;
|
|
44
|
+
description?: string | undefined;
|
|
45
|
+
designerJson?: string | undefined;
|
|
46
|
+
id?: string | undefined;
|
|
47
|
+
key?: string | undefined;
|
|
48
|
+
lockUserId?: string | undefined;
|
|
49
|
+
lockUserName?: string | undefined;
|
|
50
|
+
modifyTime?: string | undefined;
|
|
51
|
+
modifyUserId?: string | undefined;
|
|
52
|
+
modifyUserName?: string | undefined;
|
|
53
|
+
name?: string | undefined;
|
|
54
|
+
newLogId?: string | undefined;
|
|
55
|
+
runtimeJson?: string | undefined;
|
|
56
|
+
categoryId?: string | undefined;
|
|
57
|
+
version?: string | undefined;
|
|
58
|
+
default?: boolean | undefined;
|
|
59
|
+
modelKey?: string | undefined;
|
|
60
|
+
_designerJson?: string | undefined;
|
|
61
|
+
detailDesignerJson?: string | undefined;
|
|
62
|
+
txnPageMode?: "create" | "detail" | undefined;
|
|
63
|
+
baseId?: string | undefined;
|
|
64
|
+
}, {
|
|
65
|
+
categoryResponse?: {
|
|
66
|
+
createTime?: string | undefined;
|
|
67
|
+
createUserId?: string | undefined;
|
|
68
|
+
createUserName?: string | undefined;
|
|
69
|
+
id?: string | undefined;
|
|
70
|
+
modifyTime?: string | undefined;
|
|
71
|
+
modifyUserId?: string | undefined;
|
|
72
|
+
modifyUserName?: string | undefined;
|
|
73
|
+
module?: string | undefined;
|
|
74
|
+
name?: string | undefined;
|
|
75
|
+
sortNum?: number | undefined;
|
|
76
|
+
sysBuiltin?: number | undefined;
|
|
77
|
+
} | undefined;
|
|
78
|
+
createTime?: string | undefined;
|
|
79
|
+
createUserId?: string | undefined;
|
|
80
|
+
createUserName?: string | undefined;
|
|
81
|
+
description?: string | undefined;
|
|
82
|
+
designerJson?: string | undefined;
|
|
83
|
+
id?: string | undefined;
|
|
84
|
+
key?: string | undefined;
|
|
85
|
+
lockUserId?: string | undefined;
|
|
86
|
+
lockUserName?: string | undefined;
|
|
87
|
+
modifyTime?: string | undefined;
|
|
88
|
+
modifyUserId?: string | undefined;
|
|
89
|
+
modifyUserName?: string | undefined;
|
|
90
|
+
name?: string | undefined;
|
|
91
|
+
newLogId?: string | undefined;
|
|
92
|
+
runtimeJson?: string | undefined;
|
|
93
|
+
categoryId?: string | undefined;
|
|
94
|
+
version?: string | undefined;
|
|
95
|
+
default?: boolean | undefined;
|
|
96
|
+
modelKey?: string | undefined;
|
|
97
|
+
_designerJson?: string | undefined;
|
|
98
|
+
detailDesignerJson?: string | undefined;
|
|
99
|
+
txnPageMode?: "create" | "detail" | undefined;
|
|
100
|
+
baseId?: string | undefined;
|
|
101
|
+
} | PageInfo>;
|
|
102
|
+
export declare const defaultPageJson: {
|
|
103
|
+
id: string;
|
|
104
|
+
keepAlive: boolean;
|
|
105
|
+
pageEvents: {};
|
|
106
|
+
pageVars: never[];
|
|
107
|
+
widgets: never[];
|
|
108
|
+
js: string;
|
|
109
|
+
css: string;
|
|
110
|
+
modals: never[];
|
|
111
|
+
globalEvents: {};
|
|
112
|
+
permissions: {};
|
|
113
|
+
plugins: never[];
|
|
114
|
+
style: {};
|
|
115
|
+
pageConfig: {
|
|
116
|
+
title: string;
|
|
117
|
+
i18n: {};
|
|
118
|
+
hasFooter: undefined;
|
|
119
|
+
};
|
|
120
|
+
pageLayoutMode: pageLayoutModeEnum;
|
|
121
|
+
};
|
|
16
122
|
/** 设计页面JSON */
|
|
17
123
|
export declare const pageJson: {
|
|
18
124
|
id: string;
|
|
@@ -22,11 +22,9 @@ import { getWidgetInfo } from "@gct-paas/schema";
|
|
|
22
22
|
var widgetInfo = computed(() => {
|
|
23
23
|
return getWidgetInfo(platform.value);
|
|
24
24
|
});
|
|
25
|
-
/**
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
/** 设计页面JSON */
|
|
29
|
-
var pageJson = reactive({
|
|
25
|
+
/** 当前设计页面基础信息 */
|
|
26
|
+
var pageInfo = ref({});
|
|
27
|
+
var defaultPageJson = {
|
|
30
28
|
id: "",
|
|
31
29
|
keepAlive: false,
|
|
32
30
|
pageEvents: {},
|
|
@@ -45,7 +43,9 @@ var pageJson = reactive({
|
|
|
45
43
|
hasFooter: void 0
|
|
46
44
|
},
|
|
47
45
|
pageLayoutMode: pageLayoutModeEnum.SHOW_ALL_DATA
|
|
48
|
-
}
|
|
46
|
+
};
|
|
47
|
+
/** 设计页面JSON */
|
|
48
|
+
var pageJson = reactive(cloneDeep(defaultPageJson));
|
|
49
49
|
/** 页面数据快照,用于脏检查对比 */
|
|
50
50
|
var pageJsonSnapshot = ref("");
|
|
51
51
|
/** 界面数据是否修改过,通过对比快照和当前数据判断 */
|
|
@@ -100,4 +100,4 @@ function transformPageJson(json, isClone = false) {
|
|
|
100
100
|
return _json;
|
|
101
101
|
}
|
|
102
102
|
//#endregion
|
|
103
|
-
export { isModified, loading, methodMap, modalDesignId, modalDesignState, modalInfo, noMore, pageDesignHistoryList, pageJson, pageJsonSnapshot, pageNo, pluginConfigs, regRoot, subTableModalId, subTableModalState, transformPageJson, wfNodesModalId, wfNodesModalState, widgetInfo, workflowModalId, workflowModalState };
|
|
103
|
+
export { defaultPageJson, isModified, loading, methodMap, modalDesignId, modalDesignState, modalInfo, noMore, pageDesignHistoryList, pageInfo, pageJson, pageJsonSnapshot, pageNo, pluginConfigs, regRoot, subTableModalId, subTableModalState, transformPageJson, wfNodesModalId, wfNodesModalState, widgetInfo, workflowModalId, workflowModalState };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PageJson, RuntimePageJson } from '@gct-paas/schema';
|
|
2
2
|
export declare function useDesignSave(): {
|
|
3
|
-
save: (flag?: boolean, showSuccess?: boolean) => Promise<boolean>;
|
|
3
|
+
save: (flag?: boolean, showSuccess?: boolean, isTxn?: boolean) => Promise<boolean>;
|
|
4
4
|
validateWidgets: (widgets: IData[], parents?: IData[]) => boolean;
|
|
5
5
|
savePageJsonSnapshot: (json?: PageJson) => void;
|
|
6
6
|
};
|
|
@@ -9,4 +9,4 @@ export declare function useDesignSave(): {
|
|
|
9
9
|
*
|
|
10
10
|
* @returns {Promise<RuntimePageJson>} 运行时页面JSON
|
|
11
11
|
*/
|
|
12
|
-
export declare function buildRuntimeJson(): Promise<RuntimePageJson>;
|
|
12
|
+
export declare function buildRuntimeJson(source?: PageJson): Promise<RuntimePageJson>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { platform } from "../../../utils/design-view/index.mjs";
|
|
2
2
|
import { buildRunJs } from "../../../utils/transform-js/transform-js.mjs";
|
|
3
3
|
import "../../../utils/index.mjs";
|
|
4
|
-
import { noMore, pageDesignHistoryList, pageJson, pageJsonSnapshot, pageNo, regRoot, transformPageJson, widgetInfo } from "../design-state.mjs";
|
|
4
|
+
import { defaultPageJson, noMore, pageDesignHistoryList, pageInfo, pageJson, pageJsonSnapshot, pageNo, regRoot, transformPageJson, widgetInfo } from "../design-state.mjs";
|
|
5
5
|
import { useUserOccupy } from "../../../components/user-occupy/useUserOccupy.mjs";
|
|
6
6
|
import "../../../components/index.mjs";
|
|
7
|
-
import { isArray, isEmpty, isNil } from "lodash-es";
|
|
7
|
+
import { cloneDeep, isArray, isEmpty, isNil } from "lodash-es";
|
|
8
8
|
import { Platform, SearchComponents, TreeHelper, t } from "@gct-paas/core";
|
|
9
9
|
import { message } from "ant-design-vue";
|
|
10
10
|
//#region src/hooks/design-view/designer/useDesignSave.ts
|
|
@@ -14,6 +14,30 @@ import { message } from "ant-design-vue";
|
|
|
14
14
|
* 管理设计器页面数据的保存、预处理和校验逻辑,
|
|
15
15
|
* 包括组件必填校验、数值范围校验、运行时 JSON 构建等。
|
|
16
16
|
*/
|
|
17
|
+
function deepFindPlugins(widgets) {
|
|
18
|
+
const items = [];
|
|
19
|
+
widgets.forEach((widget) => {
|
|
20
|
+
if (widget._plugin) items.push({
|
|
21
|
+
key: widget._plugin.key,
|
|
22
|
+
version: widget._plugin.version,
|
|
23
|
+
url: widget._plugin.url
|
|
24
|
+
});
|
|
25
|
+
if (widget.children && widget.children.length > 0) items.push(...deepFindPlugins(widget.children));
|
|
26
|
+
});
|
|
27
|
+
return items;
|
|
28
|
+
}
|
|
29
|
+
function getDefaultTxnDetailPageJson() {
|
|
30
|
+
return {
|
|
31
|
+
newDesigner: true,
|
|
32
|
+
style: {
|
|
33
|
+
paddingAll: "",
|
|
34
|
+
paddingTop: "",
|
|
35
|
+
paddingRight: "16",
|
|
36
|
+
paddingBottom: "16",
|
|
37
|
+
paddingLeft: "16"
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
}
|
|
17
41
|
function useDesignSave() {
|
|
18
42
|
const { cancelOccupy } = useUserOccupy();
|
|
19
43
|
/**
|
|
@@ -90,13 +114,66 @@ function useDesignSave() {
|
|
|
90
114
|
return true;
|
|
91
115
|
}
|
|
92
116
|
/**
|
|
117
|
+
* 保存前预处理并校验单个 pageJson
|
|
118
|
+
*/
|
|
119
|
+
function preparePageJsonForSave(json) {
|
|
120
|
+
const _pageJson = transformPageJson(json, true);
|
|
121
|
+
if (validateWidgets(_pageJson.widgets) === false) return false;
|
|
122
|
+
if (_pageJson.widgets.some((n) => n.type === "data-list")) _pageJson.widgets.forEach((item) => {
|
|
123
|
+
if (item.type === "data-list" && !item.props.showFieldExp) item.props.showFieldExpVal = "";
|
|
124
|
+
});
|
|
125
|
+
if (validateWidgets(_pageJson.modals) === false) return false;
|
|
126
|
+
if (_pageJson.modals.length) _pageJson.modals.forEach((item) => {
|
|
127
|
+
if (!item.props.hasFooter) item.children = item.children.filter((n) => {
|
|
128
|
+
return n?.type !== "bottom-button-container";
|
|
129
|
+
});
|
|
130
|
+
if (item.props.hasFooter && item.children.some((n) => n?.type === "modalFooter")) item.children = item.children.filter((n) => {
|
|
131
|
+
return n?.type !== "modalFooter";
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
_pageJson.plugins = collectPlugins(_pageJson);
|
|
135
|
+
return _pageJson;
|
|
136
|
+
}
|
|
137
|
+
function collectPlugins(_pageJson) {
|
|
138
|
+
const plugins = [];
|
|
139
|
+
plugins.push(...deepFindPlugins(_pageJson.widgets));
|
|
140
|
+
if (_pageJson.modals) _pageJson.modals.forEach((modal) => {
|
|
141
|
+
if (modal.children) modal.children.forEach((item) => {
|
|
142
|
+
plugins.push(...deepFindPlugins(item.children));
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
return plugins;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* 根据 txnPageMode 解析创建页 / 详情页两份 pageJson
|
|
149
|
+
*/
|
|
150
|
+
function resolveTxnPageJsonPair() {
|
|
151
|
+
if (pageInfo.value.txnPageMode === "create") return {
|
|
152
|
+
createPageJson: pageJson,
|
|
153
|
+
detailPageJson: pageInfo.value.detailDesignerJson ? JSON.parse(pageInfo.value.detailDesignerJson) : getDefaultTxnDetailPageJson()
|
|
154
|
+
};
|
|
155
|
+
return {
|
|
156
|
+
createPageJson: pageInfo.value._designerJson ? JSON.parse(pageInfo.value._designerJson) : cloneDeep(defaultPageJson),
|
|
157
|
+
detailPageJson: pageJson
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
async function preparePagePayload(json) {
|
|
161
|
+
const prepared = preparePageJsonForSave(json);
|
|
162
|
+
if (!prepared) return false;
|
|
163
|
+
return {
|
|
164
|
+
designerJson: prepared,
|
|
165
|
+
runtimeJson: await buildRuntimeJson(prepared)
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
93
169
|
* 保存完成解除占用
|
|
94
170
|
*
|
|
95
171
|
* @param {boolean} flag 是否为保存操作(true为保存,false为恢复)
|
|
96
172
|
* @param {boolean} showSuccess 是否显示成功提示
|
|
97
173
|
* @returns {Promise<boolean>} 是否保存成功
|
|
98
174
|
*/
|
|
99
|
-
async function save(flag = true, showSuccess = true) {
|
|
175
|
+
async function save(flag = true, showSuccess = true, isTxn = false) {
|
|
176
|
+
if (isTxn) return saveTxn(flag, showSuccess);
|
|
100
177
|
const pageId = _gct.store.context.pid;
|
|
101
178
|
const _pageJson = transformPageJson(pageJson);
|
|
102
179
|
if (validateWidgets(_pageJson.widgets) === false) return false;
|
|
@@ -161,6 +238,42 @@ function useDesignSave() {
|
|
|
161
238
|
pageNo.value = 1;
|
|
162
239
|
return true;
|
|
163
240
|
}
|
|
241
|
+
/**
|
|
242
|
+
* 保存完成解除占用
|
|
243
|
+
*
|
|
244
|
+
* @param {boolean} flag 是否为保存操作(true为保存,false为恢复)
|
|
245
|
+
* @param {boolean} showSuccess 是否显示成功提示
|
|
246
|
+
* @returns {Promise<boolean>} 是否保存成功
|
|
247
|
+
*/
|
|
248
|
+
async function saveTxn(flag = true, showSuccess = true) {
|
|
249
|
+
const pageId = _gct.store.context.pid;
|
|
250
|
+
const { createPageJson, detailPageJson } = resolveTxnPageJsonPair();
|
|
251
|
+
const createPayload = await preparePagePayload(createPageJson);
|
|
252
|
+
if (!createPayload) return false;
|
|
253
|
+
const detailPayload = await preparePagePayload(detailPageJson);
|
|
254
|
+
if (!detailPayload) return false;
|
|
255
|
+
const { designerJson: _designerJson, runtimeJson } = createPayload;
|
|
256
|
+
const { designerJson: _detailDesignerJson, runtimeJson: detailRuntimeJson } = detailPayload;
|
|
257
|
+
pageInfo.value._designerJson = JSON.stringify(_designerJson);
|
|
258
|
+
pageInfo.value.detailDesignerJson = JSON.stringify(_detailDesignerJson);
|
|
259
|
+
await _api.apaas.transaction.putUpdateVersionByIdId({ id: pageId }, {
|
|
260
|
+
designerJson: JSON.stringify(_designerJson),
|
|
261
|
+
runtimeJson: JSON.stringify(runtimeJson),
|
|
262
|
+
detailDesignerJson: JSON.stringify(_detailDesignerJson),
|
|
263
|
+
detailRuntimeJson: JSON.stringify(detailRuntimeJson),
|
|
264
|
+
modelKey: pageInfo.value.modelKey,
|
|
265
|
+
name: pageInfo.value.name,
|
|
266
|
+
version: pageInfo.value.version,
|
|
267
|
+
default: pageInfo.value.default,
|
|
268
|
+
key: pageInfo.value.key
|
|
269
|
+
});
|
|
270
|
+
savePageJsonSnapshot(pageInfo.value.txnPageMode === "create" ? _designerJson : _detailDesignerJson);
|
|
271
|
+
if (showSuccess) _gct.message.success(flag ? "sys.saveSuccess" : "sys.recoverSuccess");
|
|
272
|
+
cancelOccupy();
|
|
273
|
+
noMore.value = false;
|
|
274
|
+
pageNo.value = 1;
|
|
275
|
+
return true;
|
|
276
|
+
}
|
|
164
277
|
return {
|
|
165
278
|
save,
|
|
166
279
|
validateWidgets,
|
|
@@ -172,13 +285,11 @@ function useDesignSave() {
|
|
|
172
285
|
*
|
|
173
286
|
* @returns {Promise<RuntimePageJson>} 运行时页面JSON
|
|
174
287
|
*/
|
|
175
|
-
async function buildRuntimeJson() {
|
|
288
|
+
async function buildRuntimeJson(source = pageJson) {
|
|
176
289
|
try {
|
|
177
|
-
const runtimeWidgets = TreeHelper.traverseAndBuildTree(JSON.parse(JSON.stringify(
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
const funcStr = await buildRunJs(pageJson.js);
|
|
181
|
-
const modals = pageJson.modals.map(async (modal) => {
|
|
290
|
+
const runtimeWidgets = TreeHelper.traverseAndBuildTree(JSON.parse(JSON.stringify(source.widgets)), (node) => findWidgetCallback(node));
|
|
291
|
+
const funcStr = await buildRunJs(source.js);
|
|
292
|
+
const modals = source.modals.map(async (modal) => {
|
|
182
293
|
const modalFuncStr = await buildRunJs(modal.js);
|
|
183
294
|
const runtimeWidgets = TreeHelper.traverseAndBuildTree(JSON.parse(JSON.stringify(modal.children)), (node) => findWidgetCallback(node, modal));
|
|
184
295
|
return {
|
|
@@ -197,16 +308,16 @@ async function buildRuntimeJson() {
|
|
|
197
308
|
widgets: runtimeWidgets,
|
|
198
309
|
runJs: funcStr,
|
|
199
310
|
modals: await Promise.all(modals),
|
|
200
|
-
css:
|
|
201
|
-
keepAlive:
|
|
202
|
-
globalEvents:
|
|
203
|
-
pageEvents:
|
|
204
|
-
permissions:
|
|
205
|
-
pageStyle:
|
|
206
|
-
pageConfig:
|
|
207
|
-
pageVars:
|
|
208
|
-
plugins:
|
|
209
|
-
pageLayoutMode:
|
|
311
|
+
css: source.css,
|
|
312
|
+
keepAlive: source.keepAlive,
|
|
313
|
+
globalEvents: source.globalEvents,
|
|
314
|
+
pageEvents: source.pageEvents,
|
|
315
|
+
permissions: source.permissions,
|
|
316
|
+
pageStyle: source.style,
|
|
317
|
+
pageConfig: source.pageConfig,
|
|
318
|
+
pageVars: source.pageVars,
|
|
319
|
+
plugins: source.plugins,
|
|
320
|
+
pageLayoutMode: source.pageLayoutMode
|
|
210
321
|
};
|
|
211
322
|
} catch (error) {
|
|
212
323
|
message.warn(t("sys.pageDesigner.codeError"));
|
|
@@ -392,7 +392,7 @@ export declare function useToolkit(): {
|
|
|
392
392
|
}[];
|
|
393
393
|
}[]>;
|
|
394
394
|
initToolkitWidgets: () => void;
|
|
395
|
-
changeToolkitWidgets: ({ data, modalState }: IObject) => void;
|
|
395
|
+
changeToolkitWidgets: ({ data, modalState, isTxn }: IObject) => void;
|
|
396
396
|
fixedToolkit: () => void;
|
|
397
397
|
setFieldToolkit: ({ modelKey, formId, childParentModelKey, }: {
|
|
398
398
|
modelKey: string;
|