@gct-paas/design 0.1.4-dev.8 → 0.1.4-dev.9

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.
Files changed (158) hide show
  1. package/dist/assets/transform-js.worker-BtVTa-PT.js +666 -0
  2. package/dist/index.esm.min.mjs +18271 -17461
  3. package/dist/index.min.cjs +7 -7
  4. package/dist/index.min.css +1 -1
  5. package/dist/index.system.min.js +7 -7
  6. package/es/assets/transform-js.worker-DdeZQ5i-.js +296567 -0
  7. package/es/components/design/design-content/design-content.mjs +12 -10
  8. package/es/components/design/design-drag-item/design-drag-item.mjs +13 -10
  9. package/es/components/design/design-drop-container/design-drop-container.d.ts +4 -0
  10. package/es/components/design/design-drop-container/design-drop-container.mjs +13 -10
  11. package/es/components/design/design-drop-line/design-drop-line.mjs +15 -11
  12. package/es/components/design/design-item-actions/design-item-actions.mjs +10 -9
  13. package/es/components/design/design-item-highlighter/design-item-highlighter.mjs +12 -9
  14. package/es/components/design/design-item-highlighter-container/design-item-highlighter-container.mjs +10 -9
  15. package/es/components/design/design-not-drag-item/design-not-drag-item.mjs +12 -10
  16. package/es/components/design-icon-button/design-icon-button.d.ts +0 -2
  17. package/es/components/design-icon-button/design-icon-button.mjs +1 -2
  18. package/es/components/design-save-tip/design-save-tip.mjs +1 -1
  19. package/es/components/design-view-layout/{design-view-layout.module.css → design-view-layout.css} +20 -17
  20. package/es/components/design-view-layout/design-view-layout.mjs +17 -16
  21. package/es/components/editor/index.mjs +3 -3
  22. package/es/components/editor/style/border-editor/border-box.vue2.mjs +5 -303
  23. package/es/components/editor/style/border-editor/border-box.vue3.mjs +305 -0
  24. package/es/components/editor/style/border-editor/border-editor.vue2.mjs +5 -58
  25. package/es/components/editor/style/border-editor/border-editor.vue3.mjs +60 -0
  26. package/es/components/editor/style/border-editor/border-radius.vue2.mjs +5 -210
  27. package/es/components/editor/style/border-editor/border-radius.vue3.mjs +212 -0
  28. package/es/components/editor/style/font-editor/align-group.vue2.mjs +5 -64
  29. package/es/components/editor/style/font-editor/align-group.vue3.mjs +66 -0
  30. package/es/components/editor/style/font-editor/font-editor.vue.mjs +2 -2
  31. package/es/components/editor/style/font-editor/font-style-group.vue2.mjs +5 -103
  32. package/es/components/editor/style/font-editor/font-style-group.vue3.mjs +105 -0
  33. package/es/components/editor/style/position-editor/position-editor.vue2.mjs +5 -240
  34. package/es/components/editor/style/position-editor/position-editor.vue3.mjs +242 -0
  35. package/es/components/editor/style/spacing-editor/spacing-editor.vue2.mjs +5 -309
  36. package/es/components/editor/style/spacing-editor/spacing-editor.vue3.mjs +311 -0
  37. package/es/components/icon/downleft-icon.vue.mjs +9 -25
  38. package/es/components/icon/downleft-icon.vue2.mjs +25 -9
  39. package/es/components/icon/downright-icon.vue.mjs +9 -25
  40. package/es/components/icon/downright-icon.vue2.mjs +25 -9
  41. package/es/components/icon/upleft-icon.vue.mjs +9 -25
  42. package/es/components/icon/upleft-icon.vue2.mjs +25 -9
  43. package/es/components/icon/upright-icon.vue.mjs +9 -25
  44. package/es/components/icon/upright-icon.vue2.mjs +25 -9
  45. package/es/components/index.mjs +2 -1
  46. package/es/components/material/material-content/material-content.d.ts +8 -0
  47. package/es/components/material/material-content/material-content.mjs +2 -2
  48. package/es/components/material/material-module/material-module.d.ts +4 -0
  49. package/es/components/material/material-module/material-module.mjs +12 -9
  50. package/es/components/material/material-module-drag-container/material-module-drag-container.d.ts +4 -0
  51. package/es/components/material/material-module-drag-item/material-module-drag-item.mjs +11 -9
  52. package/es/components/material/material-outline-tree/material-outline-tree.mjs +15 -12
  53. package/es/components/material/material-tabs/material-tabs.d.ts +4 -0
  54. package/es/components/panel/panel-content/panel-content.mjs +11 -9
  55. package/es/components/panel/panel-form/panel-form.mjs +12 -9
  56. package/es/components/panel/panel-path/panel-path.mjs +12 -9
  57. package/es/controller/view/design-view.controller.mjs +0 -1
  58. package/es/create-app-vue.d.ts +8 -0
  59. package/es/create-app-vue.mjs +11 -0
  60. package/es/editor/child-list-editor/child-list-editor.mjs +13 -11
  61. package/es/editor/model-field-select/model-field-select.mjs +12 -10
  62. package/es/hooks/design-view/constants/style-editor.const.d.ts +24 -0
  63. package/es/hooks/design-view/constants/style-editor.const.mjs +53 -0
  64. package/es/hooks/design-view/design-state.d.ts +2427 -0
  65. package/es/hooks/design-view/design-state.mjs +86 -0
  66. package/es/hooks/design-view/designer/useDesignCache.d.ts +4 -0
  67. package/es/hooks/design-view/designer/useDesignCache.mjs +27 -0
  68. package/es/hooks/design-view/designer/useDesignHistory.d.ts +16 -0
  69. package/es/hooks/design-view/designer/useDesignHistory.mjs +102 -0
  70. package/es/hooks/design-view/designer/useDesignModal.d.ts +1874 -0
  71. package/es/hooks/design-view/designer/useDesignModal.mjs +80 -0
  72. package/es/hooks/design-view/designer/useDesignPreview.d.ts +11 -0
  73. package/es/hooks/design-view/designer/useDesignPreview.mjs +143 -0
  74. package/es/hooks/design-view/designer/useDesignSave.d.ts +12 -0
  75. package/es/hooks/design-view/designer/useDesignSave.mjs +239 -0
  76. package/es/hooks/design-view/{usePropEditor.d.ts → editor/usePropEditor.d.ts} +1 -1
  77. package/es/hooks/design-view/editor/usePropEditor.mjs +99 -0
  78. package/es/hooks/design-view/{useStyle.d.ts → editor/useStyle.d.ts} +2 -2
  79. package/es/hooks/design-view/{useStyle.mjs → editor/useStyle.mjs} +1 -1
  80. package/es/hooks/design-view/editor/useStyleEditor.d.ts +30 -0
  81. package/es/hooks/design-view/editor/useStyleEditor.mjs +77 -0
  82. package/es/hooks/design-view/{useGlobal.d.ts → global/useGlobal.d.ts} +46 -40
  83. package/es/hooks/design-view/{useScope.mjs → layout/useScope.mjs} +17 -3
  84. package/es/hooks/design-view/{useToolkit.d.ts → layout/useToolkit.d.ts} +13 -11
  85. package/es/hooks/design-view/{useToolkit.mjs → layout/useToolkit.mjs} +22 -6
  86. package/es/hooks/design-view/{usePage.d.ts → page/usePage.d.ts} +2 -4
  87. package/es/hooks/design-view/{usePage.mjs → page/usePage.mjs} +9 -26
  88. package/es/hooks/design-view/page/usePageOccupy.d.ts +33 -0
  89. package/es/hooks/design-view/{usePageOccupy.mjs → page/usePageOccupy.mjs} +26 -18
  90. package/es/hooks/design-view/useDesigner.d.ts +153 -183
  91. package/es/hooks/design-view/useDesigner.mjs +76 -790
  92. package/es/hooks/design-view/utils/color.util.d.ts +21 -0
  93. package/es/hooks/design-view/utils/color.util.mjs +36 -0
  94. package/es/hooks/design-view/utils/field-schema.util.d.ts +55 -0
  95. package/es/hooks/design-view/{getFieldSchema.mjs → utils/field-schema.util.mjs} +28 -10
  96. package/es/hooks/design-view/widget/useSelectedWidget.d.ts +53 -0
  97. package/es/hooks/design-view/{useSelectedWidget.mjs → widget/useSelectedWidget.mjs} +12 -42
  98. package/es/hooks/design-view/{useWidget.d.ts → widget/useWidget.d.ts} +12 -8
  99. package/es/hooks/design-view/widget/useWidgetQuery.d.ts +13 -0
  100. package/es/hooks/design-view/widget/useWidgetQuery.mjs +88 -0
  101. package/es/hooks/design-view/widget/useWidgetRegistry.d.ts +11 -0
  102. package/es/hooks/design-view/widget/useWidgetRegistry.mjs +59 -0
  103. package/es/hooks/develop/useKeyParser.mjs +0 -4
  104. package/es/hooks/index.d.ts +20 -10
  105. package/es/hooks/use-model-field/use-model-field.d.ts +32 -0
  106. package/es/hooks/use-model-field/use-model-field.mjs +344 -0
  107. package/es/index.d.ts +2 -5
  108. package/es/index.mjs +100 -35
  109. package/es/interface/designer/i-designer-provider.d.ts +2 -85
  110. package/es/interface/designer/i-designer-state.d.ts +14 -0
  111. package/es/interface/designer/index.d.ts +0 -2
  112. package/es/plugins/design-custom-exp-menu/components/design-custom-exp-menu.component.mjs +12 -9
  113. package/es/plugins/design-editor/upload-file/index.mjs +4 -1
  114. package/es/plugins/design-editor/upload-file/upload-file.mjs +2 -2
  115. package/es/plugins/design-editor/upload-image/index.mjs +4 -1
  116. package/es/plugins/design-editor/user-signature/index.mjs +4 -1
  117. package/es/plugins/design-grid/components/design-grid.component.mjs +12 -9
  118. package/es/plugins/design-grid/design-grid.provider.mjs +33 -0
  119. package/es/plugins/design-grid-item/components/design-grid-item.component.mjs +12 -9
  120. package/es/plugins/design-tab-item/components/design-tab-item.component.mjs +12 -9
  121. package/es/plugins/design-tabs/components/design-tabs.component.mjs +12 -9
  122. package/es/register/designer-register/designer-register.d.ts +29 -0
  123. package/es/register/designer-register/designer-register.mjs +35 -0
  124. package/es/setup-app.d.ts +1 -0
  125. package/es/setup-app.mjs +18 -0
  126. package/es/utils/design-interceptors/design-interceptors.d.ts +8 -0
  127. package/es/utils/design-interceptors/design-interceptors.mjs +20 -0
  128. package/es/utils/field-filter/index.d.ts +4 -0
  129. package/es/utils/field-filter/index.mjs +58 -0
  130. package/es/utils/index.d.ts +5 -1
  131. package/es/utils/init-widget-info/init-widget-info.d.ts +16 -0
  132. package/es/utils/init-widget-info/init-widget-info.mjs +40 -0
  133. package/es/utils/plugin-pkg-util/plugin-pkg-util.mjs +0 -8
  134. package/es/utils/transform-js/index.d.ts +1 -0
  135. package/es/utils/transform-js/transform-js.d.ts +13 -0
  136. package/es/utils/transform-js/transform-js.mjs +48 -0
  137. package/es/utils/transform-js/transform-js.worker.d.ts +1 -0
  138. package/es/views/design-view.d.ts +2 -2
  139. package/es/views/design-view.mjs +14 -12
  140. package/package.json +13 -7
  141. package/es/components/design-view-layout/design-view-layout.module.scss.mjs +0 -27
  142. package/es/components/editor/style/border-editor/border-box.vue.mjs +0 -7
  143. package/es/components/editor/style/border-editor/border-editor.vue.mjs +0 -7
  144. package/es/components/editor/style/border-editor/border-radius.vue.mjs +0 -7
  145. package/es/components/editor/style/font-editor/align-group.vue.mjs +0 -7
  146. package/es/components/editor/style/font-editor/font-style-group.vue.mjs +0 -7
  147. package/es/components/editor/style/position-editor/position-editor.vue.mjs +0 -7
  148. package/es/components/editor/style/spacing-editor/spacing-editor.vue.mjs +0 -7
  149. package/es/hooks/design-view/getFieldSchema.d.ts +0 -26
  150. package/es/hooks/design-view/usePageOccupy.d.ts +0 -13
  151. package/es/hooks/design-view/usePropEditor.mjs +0 -99
  152. package/es/hooks/design-view/useSelectedWidget.d.ts +0 -53
  153. package/es/hooks/design-view/useStyleEditor.d.ts +0 -27
  154. package/es/interface/designer/i-designer-dnd-item-hooks.d.ts +0 -21
  155. package/es/interface/designer/i-designer-schema-exports.d.ts +0 -13
  156. /package/es/hooks/design-view/{useGlobal.mjs → global/useGlobal.mjs} +0 -0
  157. /package/es/hooks/design-view/{useScope.d.ts → layout/useScope.d.ts} +0 -0
  158. /package/es/hooks/design-view/{useWidget.mjs → widget/useWidget.mjs} +0 -0
@@ -0,0 +1,80 @@
1
+ import { BuiltinType, TreeHelper } from '@gct-paas/core';
2
+ import { modalCfg } from '@gct-paas/schema';
3
+ import { cloneDeep } from 'lodash-es';
4
+ import { computed } from 'vue';
5
+ import { modalInfo, subTableModalId, subTableModalState, modalDesignId, modalDesignState, pageJson } from '../design-state.mjs';
6
+ import { useScope } from '../layout/useScope.mjs';
7
+ import { useGlobal } from '../global/useGlobal.mjs';
8
+
9
+ function useDesignModal() {
10
+ const { queryInfo } = useGlobal();
11
+ const { scopeData } = useScope();
12
+ async function setModalDesignState(flag, modalId = "", isGlobal = false) {
13
+ if (flag) {
14
+ await getModalInfo(modalId, isGlobal);
15
+ } else {
16
+ modalInfo.value = cloneDeep(modalCfg.widget);
17
+ }
18
+ modalDesignState.value = flag;
19
+ modalDesignId.value = modalId;
20
+ }
21
+ async function getModalInfo(modelId, isGlobal = false) {
22
+ if (isGlobal) {
23
+ const data = await queryInfo(modelId);
24
+ if (data && data.length > 0) {
25
+ modalInfo.value = JSON.parse(data[0].configJson);
26
+ }
27
+ } else {
28
+ modalInfo.value = pageJson.modals.find(
29
+ (d) => d.id === modelId
30
+ );
31
+ }
32
+ }
33
+ function setSubTableModalDesignState(flag, needId = "") {
34
+ subTableModalState.value = flag;
35
+ subTableModalId.value = needId;
36
+ }
37
+ function setModalInfo(modal) {
38
+ modalInfo.value = modal;
39
+ }
40
+ const modalBody = computed(() => {
41
+ return modalInfo.value.children.find(
42
+ (d) => d?.type === BuiltinType.MODAL_BODY
43
+ );
44
+ });
45
+ const modalFooter = computed(() => {
46
+ return modalInfo.value.children.find(
47
+ (d) => d?.type === BuiltinType.MODAL_FOOTER
48
+ );
49
+ });
50
+ const modalBottomBtn = computed(() => {
51
+ return modalInfo.value.children.find(
52
+ (d) => d?.type === BuiltinType.BottomButtonContainer
53
+ );
54
+ });
55
+ const subTableInfo = computed(() => {
56
+ return TreeHelper.findNode(scopeData.value, (widget) => {
57
+ return widget.id === subTableModalId.value;
58
+ });
59
+ });
60
+ const isGlobalModal = computed(() => {
61
+ return /^i?g_modal_/.test(modalInfo.value.id);
62
+ });
63
+ return {
64
+ modalInfo,
65
+ modalDesignState,
66
+ modalDesignId,
67
+ modalBody,
68
+ modalFooter,
69
+ modalBottomBtn,
70
+ isGlobalModal,
71
+ subTableInfo,
72
+ setModalDesignState,
73
+ setModalInfo,
74
+ setSubTableModalDesignState,
75
+ subTableModalState,
76
+ subTableModalId
77
+ };
78
+ }
79
+
80
+ export { useDesignModal };
@@ -0,0 +1,11 @@
1
+ import { Platform } from '@gct-paas/core';
2
+ export declare function useDesignPreview(): {
3
+ preview: import('@vueuse/core').UseDebounceFnReturn<() => void>;
4
+ previewSandbox: import('@vueuse/core').UseDebounceFnReturn<() => void>;
5
+ sandboxList: import('vue').Ref<any, any>;
6
+ getDataList: () => Promise<void>;
7
+ historyPreview: (hid: string) => {
8
+ url: string;
9
+ platform: Platform;
10
+ };
11
+ };
@@ -0,0 +1,143 @@
1
+ import { Platform, genUrl, getToken, openWindow, getTenant } from '@gct-paas/core';
2
+ import { useDebounceFn } from '@vueuse/core';
3
+ import { ref } from 'vue';
4
+ import { platform } from '../design-state.mjs';
5
+
6
+ function useDesignPreview() {
7
+ function basicPreview({ pid, webUrl, mobileUrl, padUrl }) {
8
+ if (platform.value === Platform.MOBILE) {
9
+ const { origin } = location;
10
+ const appOrigin = origin;
11
+ const curWin = openWindow(
12
+ genUrl(`${appOrigin}${mobileUrl}?_t=${Date.now()}`, {
13
+ aid: _gct.store.context.aid,
14
+ pid,
15
+ bid: _gct.store.context.bid,
16
+ token: getToken(),
17
+ "tenant-id": getTenant()
18
+ }),
19
+ {
20
+ noopener: false,
21
+ noreferrer: false,
22
+ target: "_blank",
23
+ optionStr: `width=414,height=896,top=200,left=${(window.screen.availWidth - 360) / 2}`
24
+ }
25
+ );
26
+ curWin?.resizeTo(414, 896);
27
+ } else if (platform.value === Platform.PAD) {
28
+ const { origin } = location;
29
+ const appOrigin = origin;
30
+ openWindow(
31
+ genUrl(`${appOrigin}${padUrl}?_t=${Date.now()}`, {
32
+ aid: _gct.store.context.aid,
33
+ pid,
34
+ bid: _gct.store.context.bid,
35
+ token: getToken(),
36
+ "tenant-id": getTenant()
37
+ }),
38
+ {
39
+ target: "_blank"
40
+ }
41
+ );
42
+ } else {
43
+ openWindow(
44
+ genUrl(`${location.origin}${webUrl}?_t=${Date.now()}`, {
45
+ aid: _gct.store.context.aid,
46
+ pid,
47
+ bid: _gct.store.context.bid
48
+ }),
49
+ {
50
+ target: "_blank"
51
+ }
52
+ );
53
+ }
54
+ }
55
+ const _doPreview = () => {
56
+ basicPreview({
57
+ pid: _gct.store.context.pid,
58
+ webUrl: undefined ,
59
+ mobileUrl: undefined ,
60
+ padUrl: undefined
61
+ });
62
+ };
63
+ const preview = useDebounceFn(_doPreview, 400);
64
+ const sandboxList = ref();
65
+ const getDataList = async () => {
66
+ const data = await _api.apaas.sandboxConfig.getList();
67
+ if (!data.length) {
68
+ return;
69
+ }
70
+ if (data && data.length && data[0].status !== "INIT") {
71
+ sandboxList.value = data.map((i) => {
72
+ return {
73
+ ...i,
74
+ web: i.webRoutePath,
75
+ mobile: i.pdaRoutePath,
76
+ pad: i.padRoutePath
77
+ };
78
+ });
79
+ }
80
+ };
81
+ const _doPreviewSandbox = () => {
82
+ basicPreview({
83
+ pid: _gct.store.context.pid,
84
+ webUrl: undefined .replace(
85
+ "web-render",
86
+ "web-sandbox"
87
+ ),
88
+ mobileUrl: undefined .replace(
89
+ "mobile-render",
90
+ "mobile-sandbox"
91
+ ),
92
+ padUrl: undefined .replace(
93
+ "pad-render",
94
+ "pad-sandbox"
95
+ )
96
+ });
97
+ };
98
+ const previewSandbox = useDebounceFn(_doPreviewSandbox, 400);
99
+ function historyPreview(hid) {
100
+ if (platform.value === Platform.MOBILE) {
101
+ const url = genUrl(
102
+ `http://${location.hostname}${undefined }?_t=${Date.now()}`,
103
+ {
104
+ aid: _gct.store.context.aid,
105
+ pid: hid,
106
+ bid: _gct.store.context.bid,
107
+ token: getToken()
108
+ }
109
+ );
110
+ return { url, platform: platform.value };
111
+ } else if (platform.value === Platform.PAD) {
112
+ const url = genUrl(
113
+ `http://${location.hostname}${undefined }?_t=${Date.now()}`,
114
+ {
115
+ aid: _gct.store.context.aid,
116
+ pid: hid,
117
+ bid: _gct.store.context.bid,
118
+ token: getToken()
119
+ }
120
+ );
121
+ return { url, platform: platform.value };
122
+ } else {
123
+ const url = genUrl(
124
+ `${location.origin}${undefined }?_t=${Date.now()}`,
125
+ {
126
+ aid: _gct.store.context.aid,
127
+ pid: hid,
128
+ bid: _gct.store.context.bid
129
+ }
130
+ );
131
+ return { url, platform: platform.value };
132
+ }
133
+ }
134
+ return {
135
+ preview,
136
+ previewSandbox,
137
+ sandboxList,
138
+ getDataList,
139
+ historyPreview
140
+ };
141
+ }
142
+
143
+ export { useDesignPreview };
@@ -0,0 +1,12 @@
1
+ import { PageJson, RuntimePageJson } from '@gct-paas/schema';
2
+ export declare function useDesignSave(): {
3
+ save: (_flag?: boolean, showSuccess?: boolean) => Promise<boolean>;
4
+ validateWidgets: (widgets: IData[], parents?: IData[]) => boolean;
5
+ savePageJsonSnapshot: (json?: PageJson) => void;
6
+ };
7
+ /**
8
+ * 递归遍历 tree 并组装运行时 JSON
9
+ *
10
+ * @returns {RuntimePageJson} 运行时页面JSON
11
+ */
12
+ export declare function buildRuntimeJson(): RuntimePageJson;
@@ -0,0 +1,239 @@
1
+ import { TreeHelper, t, SearchComponents, Platform } from '@gct-paas/core';
2
+ import { isArray, isNil, isEmpty } from 'lodash-es';
3
+ import { message } from 'ant-design-vue';
4
+ import { pageJson, widgetInfo, pageJsonSnapshot, regRoot, transformPageJson, platform, pageDesignHistoryList, noMore, pageNo } from '../design-state.mjs';
5
+
6
+ function useDesignSave() {
7
+ const { cancelOccupy } = {};
8
+ function savePageJsonSnapshot(json) {
9
+ pageJsonSnapshot.value = JSON.stringify(json ?? pageJson);
10
+ }
11
+ function validateWidgets(widgets, parents = []) {
12
+ for (let i = 0; i < widgets.length; i++) {
13
+ const widget = widgets[i];
14
+ const { type, props } = widget;
15
+ const configs = widgetInfo.value.propEditors[type];
16
+ const models = configs && isArray(configs) ? configs : configs(widgets, parents);
17
+ for (let j = 0; j < models.length; j++) {
18
+ const model = models[j];
19
+ if (model?.required === true) {
20
+ const { name } = model;
21
+ let keys = [];
22
+ const isObject = typeof name === "object";
23
+ if (typeof name === "object") {
24
+ keys = Object.keys(name).map((item) => {
25
+ return name[item];
26
+ });
27
+ } else if (name?.startsWith("root:")) {
28
+ const key = name.substring(5);
29
+ const val = widget[key];
30
+ if (isNil(val) || isEmpty(val)) {
31
+ message.error(
32
+ `【${widget.alias || widget.props.label || widget.props.fieldName || ""} ${widget.id}】${t("sys.pageDesigner.widget")} -【${t("sys.pageDesigner.prop")} - ${t(
33
+ `sys.pageDesigner.${model.group}Prop`
34
+ )} ${model.label ? "-" + t(model.label) : ""}】${t("sys.model.required")}`
35
+ );
36
+ return false;
37
+ }
38
+ } else {
39
+ keys = name.replace(regRoot, "").split(".");
40
+ }
41
+ let memo = props;
42
+ for (let k = 0; k < keys.length; k++) {
43
+ const key = keys[k];
44
+ const val = isObject ? props[key] : memo[key];
45
+ memo = val;
46
+ if (model.hidden) {
47
+ const hide = model.hidden(widget);
48
+ if (hide === true) {
49
+ continue;
50
+ }
51
+ }
52
+ if (isNil(val) || isEmpty(val)) {
53
+ message.error(
54
+ `【${widget.alias || widget.props.label || widget.props.fieldName || ""} ${widget.id}】${t("sys.pageDesigner.widget")} -【${t("sys.pageDesigner.prop")} - ${t(
55
+ `sys.pageDesigner.${model.group}Prop`
56
+ )} ${model.label ? "-" + t(model.label) : ""}】${t("sys.model.required")}`
57
+ );
58
+ return false;
59
+ }
60
+ }
61
+ }
62
+ if (model?.saveHook) {
63
+ model.saveHook(widget);
64
+ }
65
+ }
66
+ if ([
67
+ SearchComponents.SearchNumberInput,
68
+ SearchComponents.SearchStringNumberInput
69
+ ].includes(type) && props?.isRang && props?.defaultValue && Array.isArray(props?.defaultValue)) {
70
+ const start = props.defaultValue[0];
71
+ const end = props.defaultValue[1];
72
+ if ((start || start === 0) && (end || end === 0) && start > end) {
73
+ message.error(
74
+ `【${widget.alias || widget.props.label || widget.props.fieldName || ""} ${widget.id}】${t("sys.pageDesigner.widget")} -【${t("sys.pageDesigner.prop")} - ${t("sys.pageDesigner.defaultValue")}】- ${t("sys.model.numMaxGTMin")}`
75
+ );
76
+ return false;
77
+ }
78
+ }
79
+ if (widget.children) {
80
+ parents.push(widget);
81
+ const bol = validateWidgets(widget.children, parents);
82
+ if (bol === false) {
83
+ return bol;
84
+ }
85
+ }
86
+ }
87
+ return true;
88
+ }
89
+ async function save(_flag = true, showSuccess = true) {
90
+ const pageId = _gct.store.context.pid;
91
+ const _pageJson = transformPageJson(pageJson);
92
+ const bol = validateWidgets(_pageJson.widgets);
93
+ if (bol === false) {
94
+ return false;
95
+ }
96
+ if (_pageJson.widgets.some((n) => n.type === "data-list")) {
97
+ _pageJson.widgets.forEach((item) => {
98
+ if (item.type === "data-list" && !item.props.showFieldExp) {
99
+ item.props.showFieldExpVal = "";
100
+ }
101
+ });
102
+ }
103
+ const bol2 = validateWidgets(_pageJson.modals);
104
+ if (bol2 === false) {
105
+ return false;
106
+ }
107
+ if (_pageJson.modals.length) {
108
+ _pageJson.modals.forEach((item) => {
109
+ if (!item.props.hasFooter) {
110
+ item.children = item.children.filter((n) => {
111
+ return n?.type !== "bottom-button-container";
112
+ });
113
+ }
114
+ if (item.props.hasFooter && item.children.some((n) => n?.type === "modalFooter")) {
115
+ item.children = item.children.filter((n) => {
116
+ return n?.type !== "modalFooter";
117
+ });
118
+ }
119
+ });
120
+ }
121
+ const plugins = [];
122
+ function deepFindPlugins(widgets) {
123
+ const items = [];
124
+ widgets.forEach((widget) => {
125
+ if (widget._plugin) {
126
+ items.push({
127
+ key: widget._plugin.key,
128
+ version: widget._plugin.version,
129
+ url: widget._plugin.url
130
+ });
131
+ }
132
+ if (widget.children && widget.children.length > 0) {
133
+ items.push(...deepFindPlugins(widget.children));
134
+ }
135
+ });
136
+ return items;
137
+ }
138
+ plugins.push(...deepFindPlugins(_pageJson.widgets));
139
+ if (_pageJson.modals) {
140
+ _pageJson.modals.forEach((modal) => {
141
+ if (modal.children) {
142
+ modal.children.forEach((item) => {
143
+ plugins.push(...deepFindPlugins(item.children));
144
+ });
145
+ }
146
+ });
147
+ }
148
+ _pageJson.plugins = plugins;
149
+ if (platform.value === Platform.MOBILE) {
150
+ await _api.apaas.mobilePage.putUpdateDesignerJsonId(
151
+ { id: pageId },
152
+ {
153
+ designerJson: JSON.stringify(_pageJson),
154
+ runtimeJson: JSON.stringify(buildRuntimeJson()),
155
+ logId: (pageDesignHistoryList.value[0] ?? {}).id
156
+ }
157
+ );
158
+ } else if (platform.value === Platform.PAD) {
159
+ await _api.apaas.padPage.putUpdateDesignerJsonId(
160
+ { id: pageId },
161
+ {
162
+ designerJson: JSON.stringify(_pageJson),
163
+ runtimeJson: JSON.stringify(buildRuntimeJson()),
164
+ logId: (pageDesignHistoryList.value[0] ?? {}).id
165
+ }
166
+ );
167
+ } else {
168
+ await _api.apaas.webpage.putUpdateDesignerJsonId(
169
+ { id: pageId },
170
+ {
171
+ designerJson: JSON.stringify(_pageJson),
172
+ runtimeJson: JSON.stringify(buildRuntimeJson()),
173
+ logId: (pageDesignHistoryList.value[0] ?? {}).id
174
+ }
175
+ );
176
+ }
177
+ savePageJsonSnapshot(_pageJson);
178
+ cancelOccupy();
179
+ noMore.value = false;
180
+ pageNo.value = 1;
181
+ return true;
182
+ }
183
+ return {
184
+ save,
185
+ validateWidgets,
186
+ savePageJsonSnapshot
187
+ };
188
+ }
189
+ function buildRuntimeJson() {
190
+ try {
191
+ const runtimeWidgets = TreeHelper.traverseAndBuildTree(
192
+ // cloneDeep 在 schema 包中
193
+ JSON.parse(JSON.stringify(pageJson.widgets)),
194
+ (node) => findWidgetCallback(node)
195
+ );
196
+ const funcStr = "";
197
+ const modals = pageJson.modals.map((modal) => {
198
+ const modalFuncStr = "";
199
+ const runtimeWidgets2 = TreeHelper.traverseAndBuildTree(
200
+ JSON.parse(JSON.stringify(modal.children)),
201
+ (node) => findWidgetCallback(node, modal)
202
+ );
203
+ return {
204
+ props: modal.props,
205
+ css: modal.css,
206
+ modalName: modal.modalName,
207
+ id: modal.id,
208
+ i18n: modal.i18n || {},
209
+ events: modal.events,
210
+ children: runtimeWidgets2,
211
+ runJs: modalFuncStr,
212
+ style: modal.style
213
+ };
214
+ });
215
+ return {
216
+ widgets: runtimeWidgets,
217
+ runJs: funcStr,
218
+ modals,
219
+ css: pageJson.css,
220
+ keepAlive: pageJson.keepAlive,
221
+ globalEvents: pageJson.globalEvents,
222
+ pageEvents: pageJson.pageEvents,
223
+ permissions: pageJson.permissions,
224
+ pageStyle: pageJson.style,
225
+ pageConfig: pageJson.pageConfig,
226
+ pageVars: pageJson.pageVars,
227
+ plugins: pageJson.plugins,
228
+ pageLayoutMode: pageJson.pageLayoutMode
229
+ };
230
+ } catch (error) {
231
+ message.warn(t("sys.pageDesigner.codeError"));
232
+ throw new Error(error.message);
233
+ }
234
+ }
235
+ function findWidgetCallback(node, modal) {
236
+ return widgetInfo.value.callback[node.type]?.(node, modal);
237
+ }
238
+
239
+ export { buildRuntimeJson, useDesignSave };
@@ -4,7 +4,7 @@ import { LowCodeWidget, LowCodeModal } from '@gct-paas/schema';
4
4
  * propName 类型定义:可以是字符串或对象映射
5
5
  */
6
6
  type PropNameType = string | Record<string, string>;
7
- export declare const props: {
7
+ export declare const propEditorProps: {
8
8
  propName: {
9
9
  type: (ObjectConstructor | StringConstructor)[];
10
10
  default: string;
@@ -0,0 +1,99 @@
1
+ import { computed, nextTick } from 'vue';
2
+ import { useSelectedWidget } from '../widget/useSelectedWidget.mjs';
3
+ import { isString, isObject } from 'lodash-es';
4
+ import { useDesignCache } from '../designer/useDesignCache.mjs';
5
+ import { regRoot } from '../design-state.mjs';
6
+
7
+ const propEditorProps = {
8
+ propName: {
9
+ type: [String, Object],
10
+ default: ""
11
+ },
12
+ propConfig: {
13
+ type: Object,
14
+ default: {}
15
+ },
16
+ changeCallback: {
17
+ type: Function
18
+ },
19
+ required: {
20
+ type: Boolean,
21
+ default: false
22
+ },
23
+ validate: {
24
+ type: Promise
25
+ },
26
+ widget: {
27
+ type: Object
28
+ }
29
+ };
30
+ function usePropEditor(propName, changeCallback, globData = {}) {
31
+ const { selectedProps, selectedRef } = useSelectedWidget();
32
+ const { emitCache } = useDesignCache();
33
+ function setValue(value, name) {
34
+ if (isString(name)) {
35
+ const widget = regRoot.test(name) ? selectedRef : selectedProps;
36
+ const keyslist = name.replace(regRoot, "").split(".");
37
+ const len = keyslist.length - 1;
38
+ keyslist.reduce(
39
+ (memo, cur, index) => {
40
+ if (index === len) {
41
+ memo[cur] = value;
42
+ }
43
+ return memo[cur];
44
+ },
45
+ widget.value
46
+ );
47
+ }
48
+ if (isObject(name)) {
49
+ const valueMap = value;
50
+ for (const key in name) {
51
+ const valKey = name[key];
52
+ setValue(valueMap[key], valKey);
53
+ }
54
+ }
55
+ }
56
+ function getValue(name) {
57
+ if (isString(name)) {
58
+ const widget = regRoot.test(name) ? selectedRef : selectedProps;
59
+ if (!widget?.value) return;
60
+ const keyslist = name.replace(regRoot, "").split(".");
61
+ try {
62
+ return keyslist.reduce(
63
+ (memo, cur) => memo[cur],
64
+ widget.value
65
+ );
66
+ } catch (err) {
67
+ console.warn(err);
68
+ }
69
+ }
70
+ if (isObject(name)) {
71
+ const valueMap = {};
72
+ for (const key in name) {
73
+ const valKey = name[key];
74
+ valueMap[key] = getValue(valKey);
75
+ }
76
+ return valueMap;
77
+ }
78
+ }
79
+ const propValue = computed({
80
+ get() {
81
+ const baseValue = getValue(propName);
82
+ return baseValue ?? (isString(propName) ? globData[propName] : baseValue);
83
+ },
84
+ set(val) {
85
+ setValue(val, propName);
86
+ if (!!changeCallback && typeof changeCallback === "function") {
87
+ nextTick().then(() => {
88
+ changeCallback(selectedRef.value, val);
89
+ });
90
+ }
91
+ emitCache();
92
+ }
93
+ });
94
+ return {
95
+ propValue
96
+ };
97
+ }
98
+
99
+ export { propEditorProps, usePropEditor };
@@ -1,5 +1,5 @@
1
- import { LowCodeWidget } from '@gct-paas/schema';
2
- export declare function useStyle(widget: LowCodeWidget.BasicSchema): {
1
+ import { LowCodeModal, LowCodeWidget } from '@gct-paas/schema';
2
+ export declare function useStyle(widget: LowCodeWidget.BasicSchema | LowCodeModal.Modal): {
3
3
  wrapperStyle: import('vue').ComputedRef<IObject>;
4
4
  wStyle: import('vue').ComputedRef<IObject>;
5
5
  labelFont: import('vue').ComputedRef<IObject>;
@@ -2,7 +2,7 @@ import { computed } from 'vue';
2
2
  import { propsToStyle as propsToStyle$1, extractFontStyle, generateWrapperStyle } from '@gct-paas/schema';
3
3
 
4
4
  function useStyle(widget) {
5
- const { style = {}, ignoringStyle = [] } = widget || {};
5
+ const { style = {}, ignoringStyle } = widget;
6
6
  const wStyle = computed(() => {
7
7
  return propsToStyle$1(style);
8
8
  });
@@ -0,0 +1,30 @@
1
+ import { PropType } from 'vue';
2
+ import { LowCodeWidget, LowCodeModal } from '@gct-paas/schema';
3
+ import { shadeColor, rgba2hex } from '../utils/color.util';
4
+ import { PRESET_COLOR, BTN_TYPE_COLOR } from '../constants/style-editor.const';
5
+ export { shadeColor, rgba2hex };
6
+ export { PRESET_COLOR as presetColor, BTN_TYPE_COLOR as btnTypeColor };
7
+ export declare const styleEditorProps: {
8
+ editor: {
9
+ type: PropType<LowCodeWidget.StyleEditor>;
10
+ default: {};
11
+ };
12
+ widget: {
13
+ type: PropType<LowCodeWidget.BasicSchema | LowCodeModal.Modal>;
14
+ };
15
+ propConfig: {
16
+ type: ObjectConstructor;
17
+ default: {};
18
+ };
19
+ };
20
+ /**
21
+ * 样式编辑器 composable
22
+ * 封装样式属性的读写逻辑,支持链式路径和对象映射
23
+ *
24
+ * @template T 样式值类型
25
+ * @param {IObject} editor 样式编辑器配置
26
+ * @returns {{ styleValue: ComputedRef<T> }}
27
+ */
28
+ export declare function useStyleEditor<T = IObject>(editor: IObject): {
29
+ styleValue: import('vue').WritableComputedRef<T, T>;
30
+ };