@gct-paas/render 0.1.4-dev.8 → 0.1.5-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.min.css +2 -0
- package/dist/loader.esm.min.js +1 -0
- package/es/Event/Dependency/controller.d.ts +13 -0
- package/es/Event/Dependency/controller.mjs +84 -0
- package/es/Event/Dependency/displayRule.d.ts +19 -0
- package/es/Event/Dependency/displayRule.mjs +138 -0
- package/es/Event/Dependency/useDependency.d.ts +7 -0
- package/es/Event/Dependency/useDependency.mjs +117 -0
- package/es/Event/Dependency/useDependencyToShow.d.ts +10 -0
- package/es/Event/Dependency/useDependencyToShow.mjs +113 -0
- package/es/Event/baseEvent.d.ts +156 -0
- package/es/Event/baseEvent.mjs +389 -0
- package/es/Event/bizServiceRequest.d.ts +26 -0
- package/es/Event/bizServiceRequest.mjs +35 -0
- package/es/Event/eventType.d.ts +20 -0
- package/es/Event/eventType.mjs +1 -0
- package/es/Event/index.d.ts +7 -0
- package/es/Event/index.mjs +7 -0
- package/es/Event/utils/appRedis.d.ts +29 -0
- package/es/Event/utils/appRedis.mjs +40 -0
- package/es/Event/utils/globalLoading.d.ts +13 -0
- package/es/Event/utils/globalLoading.mjs +104 -0
- package/es/Event/utils/processRovedInfo.d.ts +100 -0
- package/es/Event/utils/processRovedInfo.mjs +231 -0
- package/es/Event/utils/runGlobalByPage.d.ts +335 -0
- package/es/Event/utils/runGlobalByPage.mjs +302 -0
- package/es/Event/utils/verificationVar.d.ts +2 -0
- package/es/Event/utils/verificationVar.mjs +36 -0
- package/es/_virtual/_plugin-vue_export-helper.mjs +8 -0
- package/es/_virtual/_rolldown/runtime.mjs +13 -0
- package/es/components/HandwritingPad.vue.d.ts +27 -0
- package/es/components/HandwritingPad.vue.mjs +7 -0
- package/es/components/HandwritingPad.vue_vue_type_script_setup_true_name_HandwritingPad_lang.mjs +109 -0
- package/es/components/HandwritingPad.vue_vue_type_style_index_0_scoped_d5b980b7_lang.css +9 -0
- package/es/components/index.d.ts +2 -0
- package/es/components/index.mjs +1 -0
- package/es/constant/data-format.d.ts +52 -0
- package/es/constant/data-format.mjs +66 -0
- package/es/constant/date-time.d.ts +99 -0
- package/es/constant/date-time.mjs +187 -0
- package/es/constant/index.d.ts +94 -0
- package/es/constant/index.mjs +100 -0
- package/es/controller/design-render/design-render.controller.d.ts +18 -0
- package/es/controller/design-render/design-render.controller.mjs +78 -0
- package/es/controller/design-render-base/design-render-base.controller.d.ts +9 -0
- package/es/controller/design-render-base/design-render-base.controller.mjs +12 -0
- package/es/controller/design-render-container/design-render-container.controller.d.ts +4 -0
- package/es/controller/design-render-container/design-render-container.controller.mjs +5 -0
- package/es/controller/design-render-item/design-render-item.controller.d.ts +4 -0
- package/es/controller/design-render-item/design-render-item.controller.mjs +5 -0
- package/es/controller/index.d.ts +4 -0
- package/es/controller/index.mjs +4 -0
- package/es/enums/index.d.ts +14 -0
- package/es/enums/index.mjs +18 -0
- package/es/hooks/index.d.ts +2 -0
- package/es/hooks/index.mjs +2 -0
- package/es/hooks/use-design-render-controller/use-design-render-controller.d.ts +11 -0
- package/es/hooks/use-design-render-controller/use-design-render-controller.mjs +32 -0
- package/es/hooks/useStorageRef.d.ts +9 -0
- package/es/hooks/useStorageRef.mjs +37 -0
- package/es/index.d.ts +6 -0
- package/es/index.mjs +36 -1
- package/es/interface/controller/i-design-render-base.controller.d.ts +43 -0
- package/es/interface/controller/i-design-render-container.controller.d.ts +7 -0
- package/es/interface/controller/i-design-render-item.controller.d.ts +7 -0
- package/es/interface/controller/i-design-render.controller.d.ts +93 -0
- package/es/interface/index.d.ts +12 -0
- package/es/interface/provider/i-render-base-node.provider.d.ts +45 -0
- package/es/interface/provider/i-render-container-node.provider.d.ts +30 -0
- package/es/interface/provider/i-render-editor-node.provider.d.ts +29 -0
- package/es/interface/provider/i-render-item-node.provider.d.ts +30 -0
- package/es/interface/state/i-design-render-base.state.d.ts +19 -0
- package/es/interface/state/i-design-render-container.state.d.ts +11 -0
- package/es/interface/state/i-design-render-item.state.d.ts +11 -0
- package/es/interface/state/i-design-render.state.d.ts +18 -0
- package/es/loader.d.ts +1 -0
- package/es/register/index.d.ts +2 -0
- package/es/register/index.mjs +2 -0
- package/es/register/node/node.register.d.ts +92 -0
- package/es/register/node/node.register.mjs +116 -0
- package/es/register/render-register/render-register.d.ts +54 -0
- package/es/register/render-register/render-register.mjs +64 -0
- package/es/state/design-render/design-render.state.d.ts +13 -0
- package/es/state/design-render/design-render.state.mjs +15 -0
- package/es/state/design-render-base/design-render-base.state.d.ts +4 -0
- package/es/state/design-render-base/design-render-base.state.mjs +6 -0
- package/es/state/design-render-container/design-render-container.state.d.ts +4 -0
- package/es/state/design-render-item/design-render-item.state.d.ts +4 -0
- package/es/state/index.d.ts +4 -0
- package/es/types/index.d.ts +6 -0
- package/es/utils/cacheAdapter.d.ts +7 -0
- package/es/utils/cacheAdapter.mjs +65 -0
- package/es/utils/expression/index.d.ts +6 -0
- package/es/utils/expression/index.mjs +116 -0
- package/es/utils/expression/regularExpression/methods.d.ts +77 -0
- package/es/utils/expression/regularExpression/methods.mjs +588 -0
- package/es/utils/field-attrs/basicAttrs.mjs +56 -80
- package/es/utils/field-attrs/index.d.ts +1 -1
- package/es/utils/field-attrs/index.mjs +16 -13
- package/es/utils/get-ref-data.d.ts +1 -0
- package/es/utils/get-ref-data.mjs +44 -0
- package/es/utils/getFieldSchema.d.ts +1 -3
- package/es/utils/getFieldSchema.mjs +69 -0
- package/es/utils/index.d.ts +8 -0
- package/es/utils/index.mjs +11 -0
- package/es/utils/model-transformer.d.ts +46 -0
- package/es/utils/model-transformer.mjs +87 -0
- package/es/utils/render-plugin-pkg-util/render-plugin-pkg-util.d.ts +43 -0
- package/es/utils/render-plugin-pkg-util/render-plugin-pkg-util.mjs +65 -0
- package/es/utils/search/index.d.ts +2 -0
- package/es/utils/search/index.mjs +2 -0
- package/es/utils/search/search-default-value.d.ts +7 -0
- package/es/utils/search/search-default-value.mjs +244 -0
- package/es/utils/search/search-hooks.d.ts +6 -0
- package/es/utils/search/search-hooks.mjs +67 -0
- package/es/utils/useStyle.d.ts +21 -0
- package/es/utils/useStyle.mjs +22 -0
- package/package.json +33 -11
- package/dist/index.esm.min.mjs +0 -89
- package/dist/index.min.cjs +0 -1
- package/dist/index.system.min.js +0 -1
|
@@ -1,82 +1,58 @@
|
|
|
1
|
-
import { FIELD_TYPE } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
to: "minValue"
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
from: "specificConfig.maxValue",
|
|
60
|
-
to: "maxValue"
|
|
61
|
-
}
|
|
62
|
-
]
|
|
63
|
-
},
|
|
64
|
-
[FIELD_TYPE.DECIMAL]: {
|
|
65
|
-
attrsTransform: [
|
|
66
|
-
{
|
|
67
|
-
from: "specificConfig.digits",
|
|
68
|
-
to: "precision"
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
from: "specificConfig.minValue",
|
|
72
|
-
to: "minValue"
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
from: "specificConfig.maxValue",
|
|
76
|
-
to: "maxValue"
|
|
77
|
-
}
|
|
78
|
-
]
|
|
79
|
-
}
|
|
1
|
+
import { FIELD_TYPE } from "@gct-paas/core";
|
|
2
|
+
//#region src/utils/field-attrs/basicAttrs.ts
|
|
3
|
+
/**
|
|
4
|
+
*运行时转化字段属性映射
|
|
5
|
+
*/
|
|
6
|
+
var FieldPropsMap = {
|
|
7
|
+
[FIELD_TYPE.TEXT]: { attrsTransform: [{
|
|
8
|
+
from: "specificConfig.minValue",
|
|
9
|
+
to: "minlength"
|
|
10
|
+
}, {
|
|
11
|
+
from: "specificConfig.maxValue",
|
|
12
|
+
to: "maxlength"
|
|
13
|
+
}] },
|
|
14
|
+
[FIELD_TYPE.LONG_TEXT]: { attrsTransform: [{
|
|
15
|
+
from: "specificConfig.minValue",
|
|
16
|
+
to: "minlength"
|
|
17
|
+
}, {
|
|
18
|
+
from: "specificConfig.maxValue",
|
|
19
|
+
to: "maxlength"
|
|
20
|
+
}] },
|
|
21
|
+
[FIELD_TYPE.INTEGER]: { attrsTransform: [{
|
|
22
|
+
from: "specificConfig.minValue",
|
|
23
|
+
to: "minValue"
|
|
24
|
+
}, {
|
|
25
|
+
from: "specificConfig.maxValue",
|
|
26
|
+
to: "maxValue"
|
|
27
|
+
}] },
|
|
28
|
+
[FIELD_TYPE.LONG]: { attrsTransform: [{
|
|
29
|
+
from: "specificConfig.minValue",
|
|
30
|
+
to: "minValue"
|
|
31
|
+
}, {
|
|
32
|
+
from: "specificConfig.maxValue",
|
|
33
|
+
to: "maxValue"
|
|
34
|
+
}] },
|
|
35
|
+
[FIELD_TYPE.DOUBLE]: { attrsTransform: [{
|
|
36
|
+
from: "specificConfig.minValue",
|
|
37
|
+
to: "minValue"
|
|
38
|
+
}, {
|
|
39
|
+
from: "specificConfig.maxValue",
|
|
40
|
+
to: "maxValue"
|
|
41
|
+
}] },
|
|
42
|
+
[FIELD_TYPE.DECIMAL]: { attrsTransform: [
|
|
43
|
+
{
|
|
44
|
+
from: "specificConfig.digits",
|
|
45
|
+
to: "precision"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
from: "specificConfig.minValue",
|
|
49
|
+
to: "minValue"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
from: "specificConfig.maxValue",
|
|
53
|
+
to: "maxValue"
|
|
54
|
+
}
|
|
55
|
+
] }
|
|
80
56
|
};
|
|
81
|
-
|
|
57
|
+
//#endregion
|
|
82
58
|
export { FieldPropsMap };
|
|
@@ -3,4 +3,4 @@ import { FIELD_TYPE } from '@gct-paas/core';
|
|
|
3
3
|
* @description: 处理字段属性转换
|
|
4
4
|
* 运行时同步字段
|
|
5
5
|
*/
|
|
6
|
-
export declare const transformPropsField: (fieldType: FIELD_TYPE, Props:
|
|
6
|
+
export declare const transformPropsField: (fieldType: FIELD_TYPE, Props: IObject) => IObject;
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { FieldPropsMap } from "./basicAttrs.mjs";
|
|
2
|
+
import "@gct-paas/core";
|
|
3
|
+
import { get } from "lodash-es";
|
|
4
|
+
//#region src/utils/field-attrs/index.ts
|
|
5
|
+
/**
|
|
6
|
+
* @description: 处理字段属性转换
|
|
7
|
+
* 运行时同步字段
|
|
8
|
+
*/
|
|
9
|
+
var transformPropsField = (fieldType, Props) => {
|
|
10
|
+
const { attrsTransform = [] } = FieldPropsMap[fieldType] ?? {};
|
|
11
|
+
return attrsTransform.reduce((curr, row) => {
|
|
12
|
+
const value = get(Props, row.from);
|
|
13
|
+
curr[row.to] = value;
|
|
14
|
+
return curr;
|
|
15
|
+
}, {});
|
|
13
16
|
};
|
|
14
|
-
|
|
17
|
+
//#endregion
|
|
15
18
|
export { transformPropsField };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getRefInfoId: (arg: IObject) => any;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { transSelectData } from "./model-transformer.mjs";
|
|
2
|
+
import { cacheAdapter } from "./cacheAdapter.mjs";
|
|
3
|
+
import { EntityModelCategoryEnum, FIELD_TYPE } from "@gct-paas/core";
|
|
4
|
+
//#region src/utils/get-ref-data.ts
|
|
5
|
+
/**根据id查询 */
|
|
6
|
+
async function getRefDataById({ ids, refOriginField, refOriginFieldType, model, foreignFields }) {
|
|
7
|
+
if (!ids) return Promise.reject();
|
|
8
|
+
const info = await getDataByModelType({
|
|
9
|
+
refOriginFieldType,
|
|
10
|
+
modelKey: model,
|
|
11
|
+
foreignFields,
|
|
12
|
+
ids
|
|
13
|
+
});
|
|
14
|
+
if (info?.data) return transSelectData(refOriginField, info.data, info.dict);
|
|
15
|
+
}
|
|
16
|
+
async function getDataByModelType({ refOriginFieldType, modelKey, foreignFields, ids }) {
|
|
17
|
+
if (refOriginFieldType === FIELD_TYPE.RDO_REF) {
|
|
18
|
+
const { data = {}, dict = {} } = await _gct.api.apaas.modelComprehensive.postBizServiceModelCategoryModelKeyBsKey({
|
|
19
|
+
modelKey,
|
|
20
|
+
bsKey: "rdoGetVersionByRefId",
|
|
21
|
+
modelCategory: EntityModelCategoryEnum.ENTITY
|
|
22
|
+
}, { foreignFields }, { refId: ids });
|
|
23
|
+
return {
|
|
24
|
+
data,
|
|
25
|
+
dict
|
|
26
|
+
};
|
|
27
|
+
} else {
|
|
28
|
+
const { data = {}, dict = {} } = await _gct.api.apaas.modelComprehensive.postBizServiceModelCategoryModelKeyBsKey({
|
|
29
|
+
modelKey,
|
|
30
|
+
bsKey: "getOne",
|
|
31
|
+
modelCategory: EntityModelCategoryEnum.ENTITY
|
|
32
|
+
}, {
|
|
33
|
+
query: { "id_.eq": ids },
|
|
34
|
+
foreignFields
|
|
35
|
+
}, {});
|
|
36
|
+
return {
|
|
37
|
+
data,
|
|
38
|
+
dict
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
var getRefInfoId = (arg) => cacheAdapter(arg, getRefDataById);
|
|
43
|
+
//#endregion
|
|
44
|
+
export { getRefInfoId };
|
|
@@ -23,6 +23,4 @@ export declare class FieldSchema {
|
|
|
23
23
|
static clearCacheMap(useRequest?: boolean): void;
|
|
24
24
|
}
|
|
25
25
|
/**字段运行时需要同步的数据 */
|
|
26
|
-
export declare function initFieldWidgetRuntime(widget: LowCodeWidget.
|
|
27
|
-
props: Record<string, string | number | boolean | undefined>;
|
|
28
|
-
}, isVanField?: boolean): Promise<FieldMetaDTO | undefined>;
|
|
26
|
+
export declare function initFieldWidgetRuntime(widget: LowCodeWidget.BasicSchema, isVanField?: boolean): Promise<FieldMetaDTO>;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
//#region src/utils/getFieldSchema.ts
|
|
2
|
+
var FieldSchema = class {
|
|
3
|
+
static modelData = /* @__PURE__ */ new Map();
|
|
4
|
+
static FiledData = /* @__PURE__ */ new Map();
|
|
5
|
+
static responsePromise = /* @__PURE__ */ new Map();
|
|
6
|
+
static silent = false;
|
|
7
|
+
static async getMap(modelKey, useCache = true) {
|
|
8
|
+
if (!modelKey) return Promise.reject();
|
|
9
|
+
if (!this.responsePromise.has(modelKey) || !useCache) {
|
|
10
|
+
/**防止同一时刻同事调用接口 */
|
|
11
|
+
const P = (async () => {
|
|
12
|
+
const data = await _gct.api.apaas.modelMeta.getDetail({ modelKey });
|
|
13
|
+
this.modelData.set(modelKey, data);
|
|
14
|
+
const fieldMap = !!data?.fieldMetaList && data.fieldMetaList.reduce((total, curr) => {
|
|
15
|
+
if (curr.key) total[curr.key] = curr;
|
|
16
|
+
return total;
|
|
17
|
+
}, {});
|
|
18
|
+
if (fieldMap) this.FiledData.set(modelKey, fieldMap);
|
|
19
|
+
})();
|
|
20
|
+
this.responsePromise.set(modelKey, P);
|
|
21
|
+
}
|
|
22
|
+
return this.responsePromise.get(modelKey);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* 获取模型下字段信息
|
|
26
|
+
* @param modelKey 模型key
|
|
27
|
+
* @param field 字段key
|
|
28
|
+
* @param useCache 是否是用缓存
|
|
29
|
+
* @returns 字段信息
|
|
30
|
+
*/
|
|
31
|
+
static async getConfigByField(modelKey, field, useCache = true) {
|
|
32
|
+
await this.getMap(modelKey, useCache);
|
|
33
|
+
return this.FiledData.get(modelKey)[field];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* 获取模型信息
|
|
37
|
+
* @param modelKey 模型key
|
|
38
|
+
* @returns 模型信息
|
|
39
|
+
*/
|
|
40
|
+
static async getConfigByModel(modelKey) {
|
|
41
|
+
await this.getMap(modelKey);
|
|
42
|
+
return this.modelData.get(modelKey);
|
|
43
|
+
}
|
|
44
|
+
static clearCacheMap(useRequest = false) {
|
|
45
|
+
if (useRequest) this.responsePromise.clear();
|
|
46
|
+
this.modelData.clear();
|
|
47
|
+
this.FiledData.clear();
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
/**字段运行时需要同步的数据 */
|
|
51
|
+
async function initFieldWidgetRuntime(widget, isVanField = false) {
|
|
52
|
+
const { modelKey, field, isCustomField, fieldName, readonly, fieldType } = widget.props;
|
|
53
|
+
if (!widget.isField && !isVanField || field === "table_name_") return {};
|
|
54
|
+
let fieldInfo;
|
|
55
|
+
if (isCustomField) fieldInfo = {
|
|
56
|
+
name: fieldName,
|
|
57
|
+
type: ""
|
|
58
|
+
};
|
|
59
|
+
else if (modelKey) fieldInfo = await FieldSchema.getConfigByField(modelKey, field);
|
|
60
|
+
if (!isCustomField && (!fieldInfo || fieldInfo.type !== fieldType)) throw new Error("该字段可能已经被删除");
|
|
61
|
+
if (!fieldInfo) return {};
|
|
62
|
+
const { required, specificConfig } = fieldInfo;
|
|
63
|
+
widget.props.fieldRequired = !!required;
|
|
64
|
+
if (required && !readonly) widget.props.required = true;
|
|
65
|
+
if (specificConfig?.digits !== void 0) widget.props.precision = specificConfig.digits;
|
|
66
|
+
return fieldInfo;
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
export { FieldSchema, initFieldWidgetRuntime };
|
package/es/utils/index.d.ts
CHANGED
|
@@ -1 +1,9 @@
|
|
|
1
|
+
export { calculate, identify } from './expression';
|
|
1
2
|
export { transformPropsField } from './field-attrs';
|
|
3
|
+
export { RenderPluginPgkUtil } from './render-plugin-pkg-util/render-plugin-pkg-util';
|
|
4
|
+
export { useStyle, schemaToStyle } from './useStyle';
|
|
5
|
+
export { initFieldWidgetRuntime, FieldSchema } from './getFieldSchema';
|
|
6
|
+
export { transformDataToDict, transformSourceData, transformData, addDataByForm, setDataByForm, transSelectData, type RowData, type DictMap, } from './model-transformer';
|
|
7
|
+
export { getRefInfoId } from './get-ref-data';
|
|
8
|
+
export * from './cacheAdapter';
|
|
9
|
+
export * from './search';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import "./expression/index.mjs";
|
|
2
|
+
import "./field-attrs/index.mjs";
|
|
3
|
+
import "./render-plugin-pkg-util/render-plugin-pkg-util.mjs";
|
|
4
|
+
import "./useStyle.mjs";
|
|
5
|
+
import "./getFieldSchema.mjs";
|
|
6
|
+
import "./model-transformer.mjs";
|
|
7
|
+
import "./cacheAdapter.mjs";
|
|
8
|
+
import "./get-ref-data.mjs";
|
|
9
|
+
import "./search/search-hooks.mjs";
|
|
10
|
+
import "./search/search-default-value.mjs";
|
|
11
|
+
import "./search/index.mjs";
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* table 后端返回的分页 数据处理
|
|
3
|
+
* @param data 数据信息
|
|
4
|
+
* @param dict 翻译信息
|
|
5
|
+
* @returns
|
|
6
|
+
*/
|
|
7
|
+
export declare function transformSourceData(data: RowData[], dict: DictMap): RowData[];
|
|
8
|
+
/**
|
|
9
|
+
* 表单 form 数据处理
|
|
10
|
+
* @param data 数据信息
|
|
11
|
+
* @param dict 翻译信息
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
export declare function transformData(row?: RowData, dict?: DictMap): RowData;
|
|
15
|
+
export declare function addDataByForm(formState: RowData, data: RowData, dict: DictMap): void;
|
|
16
|
+
export declare function setDataByForm(formState: RowData, data: RowData, dict: DictMap): void;
|
|
17
|
+
/**
|
|
18
|
+
* 表单 select 数据处理
|
|
19
|
+
* @param data 数据信息
|
|
20
|
+
* @param dict 翻译信息
|
|
21
|
+
* @returns
|
|
22
|
+
*/
|
|
23
|
+
export declare function transSelectData(field: string, row?: RowData, dict?: DictMap): {
|
|
24
|
+
_OPCT: IObject;
|
|
25
|
+
_DICT?: IObject;
|
|
26
|
+
_NOSUBMIT?: boolean;
|
|
27
|
+
_X_ROW_KEY?: string | number;
|
|
28
|
+
__FOREIGN__?: RowData;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* 表单 form 数据f翻译不保留原始信息
|
|
32
|
+
* @param data 翻译信息
|
|
33
|
+
* @returns
|
|
34
|
+
*/
|
|
35
|
+
export declare function transformDataToDict(row?: RowData, dict?: DictMap): IObject | RowData;
|
|
36
|
+
/** 行数据基础结构 */
|
|
37
|
+
export interface RowData {
|
|
38
|
+
_DICT?: IObject;
|
|
39
|
+
_OPCT?: IObject;
|
|
40
|
+
_NOSUBMIT?: boolean;
|
|
41
|
+
_X_ROW_KEY?: string | number;
|
|
42
|
+
__FOREIGN__?: RowData;
|
|
43
|
+
[key: string]: unknown;
|
|
44
|
+
}
|
|
45
|
+
/** 字典映射结构 */
|
|
46
|
+
export type DictMap = Record<string, Record<string, string>>;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { cloneDeep, merge } from "lodash-es";
|
|
2
|
+
//#region src/utils/model-transformer.ts
|
|
3
|
+
/**
|
|
4
|
+
* table 后端返回的分页 数据处理
|
|
5
|
+
* @param data 数据信息
|
|
6
|
+
* @param dict 翻译信息
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
function transformSourceData(data, dict) {
|
|
10
|
+
return data?.map((i) => transformData(i, dict)) || [];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* 表单 form 数据处理
|
|
14
|
+
* @param data 数据信息
|
|
15
|
+
* @param dict 翻译信息
|
|
16
|
+
* @returns
|
|
17
|
+
*/
|
|
18
|
+
function transformData(row = {}, dict = {}) {
|
|
19
|
+
const data = cloneDeep(row);
|
|
20
|
+
data._X_ROW_KEY = void 0;
|
|
21
|
+
const _DICT = Object.keys(dict ?? {})?.length ? Object.keys(data).reduce((total, curr) => {
|
|
22
|
+
const map = dict[curr], value = data[curr];
|
|
23
|
+
if (map && value) try {
|
|
24
|
+
const label = (value + "").split(",").map((k) => map[k]);
|
|
25
|
+
total[curr] = { [value + ""]: label };
|
|
26
|
+
} catch {}
|
|
27
|
+
return total;
|
|
28
|
+
}, {}) : data._DICT || {};
|
|
29
|
+
return {
|
|
30
|
+
...data,
|
|
31
|
+
_DICT,
|
|
32
|
+
_OPCT: data.__FOREIGN__ && typeof data.__FOREIGN__ === "object" ? transformData(data.__FOREIGN__, dict) : {}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function addDataByForm(formState, data, dict) {
|
|
36
|
+
if (typeof data !== "object") return;
|
|
37
|
+
merge(formState, transformData(data, dict));
|
|
38
|
+
}
|
|
39
|
+
function setDataByForm(formState, data, dict) {
|
|
40
|
+
if (typeof data !== "object") return;
|
|
41
|
+
for (const k in formState) if (k !== "_OPCT" && k !== "_NOSUBMIT") delete formState[k];
|
|
42
|
+
const formdata = transformData(data, dict);
|
|
43
|
+
formdata._X_ROW_KEY = data._X_ROW_KEY;
|
|
44
|
+
merge(formState, formdata);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* 表单 select 数据处理
|
|
48
|
+
* @param data 数据信息
|
|
49
|
+
* @param dict 翻译信息
|
|
50
|
+
* @returns
|
|
51
|
+
*/
|
|
52
|
+
function transSelectData(field, row = {}, dict = {}) {
|
|
53
|
+
const data = cloneDeep(row.__FOREIGN__ || row);
|
|
54
|
+
const _OPCT = { _DICT: {} };
|
|
55
|
+
Object.keys(data).forEach((curr) => {
|
|
56
|
+
const fieldkey = `${field}.${curr}`;
|
|
57
|
+
const map = dict[curr], value = data[curr];
|
|
58
|
+
if (map && value) try {
|
|
59
|
+
const label = (value + "").split(",").map((k) => map[k]);
|
|
60
|
+
_OPCT._DICT[fieldkey] = { [value + ""]: label };
|
|
61
|
+
} catch {}
|
|
62
|
+
_OPCT[fieldkey] = value;
|
|
63
|
+
});
|
|
64
|
+
return {
|
|
65
|
+
...data,
|
|
66
|
+
_OPCT
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* 表单 form 数据f翻译不保留原始信息
|
|
71
|
+
* @param data 翻译信息
|
|
72
|
+
* @returns
|
|
73
|
+
*/
|
|
74
|
+
function transformDataToDict(row = {}, dict = {}) {
|
|
75
|
+
const data = cloneDeep(row);
|
|
76
|
+
return Object.keys(dict ?? {})?.length ? Object.keys(data).reduce((total, curr) => {
|
|
77
|
+
const map = dict[curr] || {}, value = data[curr];
|
|
78
|
+
try {
|
|
79
|
+
total[curr] = (value + "").split(",").map((k) => map[k]).join(",");
|
|
80
|
+
} catch {
|
|
81
|
+
total[curr] = value;
|
|
82
|
+
}
|
|
83
|
+
return total;
|
|
84
|
+
}, {}) : data;
|
|
85
|
+
}
|
|
86
|
+
//#endregion
|
|
87
|
+
export { addDataByForm, setDataByForm, transSelectData, transformData, transformDataToDict, transformSourceData };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { PluginTenant } from '@gct-paas/api/platform';
|
|
2
|
+
import { PluginModeEnum, PluginPgkUtil } from '@gct-paas/core';
|
|
3
|
+
/**
|
|
4
|
+
* 插件包处理工具类
|
|
5
|
+
*
|
|
6
|
+
* @export
|
|
7
|
+
* @class RenderPluginPgkUtil
|
|
8
|
+
*/
|
|
9
|
+
export declare class RenderPluginPgkUtil extends PluginPgkUtil {
|
|
10
|
+
/**
|
|
11
|
+
* 加载渲染态指定端插件包
|
|
12
|
+
*
|
|
13
|
+
* @static
|
|
14
|
+
* @param {PluginModeEnum} mode
|
|
15
|
+
* @param {PluginTenant['plugins']} [configs=[]]
|
|
16
|
+
* @return {*} {Promise<void>}
|
|
17
|
+
*/
|
|
18
|
+
static loadRenderPlugin(mode: PluginModeEnum, configs?: PluginTenant['plugins']): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* 加载渲染态移动端插件包
|
|
21
|
+
*
|
|
22
|
+
* @static
|
|
23
|
+
* @param {PluginTenant['plugins']} [configs=[]]
|
|
24
|
+
* @return {*} {Promise<void>}
|
|
25
|
+
*/
|
|
26
|
+
static loadMobilePlugin(configs?: PluginTenant['plugins']): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* 加载渲染态平板端插件包
|
|
29
|
+
*
|
|
30
|
+
* @static
|
|
31
|
+
* @param {PluginTenant['plugins']} [configs=[]]
|
|
32
|
+
* @return {*} {Promise<void>}
|
|
33
|
+
*/
|
|
34
|
+
static loadPadPlugin(configs?: PluginTenant['plugins']): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* 加载渲染态网页端插件包
|
|
37
|
+
*
|
|
38
|
+
* @static
|
|
39
|
+
* @param {PluginTenant['plugins']} [configs=[]]
|
|
40
|
+
* @return {*} {Promise<void>}
|
|
41
|
+
*/
|
|
42
|
+
static loadWebPlugin(configs?: PluginTenant['plugins']): Promise<void>;
|
|
43
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { PluginModeEnum, PluginPgkUtil } from "@gct-paas/core";
|
|
2
|
+
//#region src/utils/render-plugin-pkg-util/render-plugin-pkg-util.ts
|
|
3
|
+
/**
|
|
4
|
+
* 插件包处理工具类
|
|
5
|
+
*
|
|
6
|
+
* @export
|
|
7
|
+
* @class RenderPluginPgkUtil
|
|
8
|
+
*/
|
|
9
|
+
var RenderPluginPgkUtil = class extends PluginPgkUtil {
|
|
10
|
+
/**
|
|
11
|
+
* 加载渲染态指定端插件包
|
|
12
|
+
*
|
|
13
|
+
* @static
|
|
14
|
+
* @param {PluginModeEnum} mode
|
|
15
|
+
* @param {PluginTenant['plugins']} [configs=[]]
|
|
16
|
+
* @return {*} {Promise<void>}
|
|
17
|
+
*/
|
|
18
|
+
static async loadRenderPlugin(mode, configs = []) {
|
|
19
|
+
try {
|
|
20
|
+
const moduleMap = await this.loadPlugins(mode, configs);
|
|
21
|
+
configs.forEach((plugin) => {
|
|
22
|
+
const key = plugin.key;
|
|
23
|
+
if (!moduleMap[key]) {
|
|
24
|
+
console.error(`${key} 插件加载失败,请检查插件配置是否正确`);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
_gct.register.render.register(key, moduleMap[key].default);
|
|
28
|
+
});
|
|
29
|
+
} catch (error) {
|
|
30
|
+
console.error(error);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* 加载渲染态移动端插件包
|
|
35
|
+
*
|
|
36
|
+
* @static
|
|
37
|
+
* @param {PluginTenant['plugins']} [configs=[]]
|
|
38
|
+
* @return {*} {Promise<void>}
|
|
39
|
+
*/
|
|
40
|
+
static loadMobilePlugin(configs = []) {
|
|
41
|
+
return this.loadRenderPlugin(PluginModeEnum.MOBILE, configs);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* 加载渲染态平板端插件包
|
|
45
|
+
*
|
|
46
|
+
* @static
|
|
47
|
+
* @param {PluginTenant['plugins']} [configs=[]]
|
|
48
|
+
* @return {*} {Promise<void>}
|
|
49
|
+
*/
|
|
50
|
+
static loadPadPlugin(configs = []) {
|
|
51
|
+
return this.loadRenderPlugin(PluginModeEnum.PAD, configs);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* 加载渲染态网页端插件包
|
|
55
|
+
*
|
|
56
|
+
* @static
|
|
57
|
+
* @param {PluginTenant['plugins']} [configs=[]]
|
|
58
|
+
* @return {*} {Promise<void>}
|
|
59
|
+
*/
|
|
60
|
+
static loadWebPlugin(configs = []) {
|
|
61
|
+
return this.loadRenderPlugin(PluginModeEnum.WEB, configs);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
//#endregion
|
|
65
|
+
export { RenderPluginPgkUtil };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ISearchSchema } from '@gct-paas/schema';
|
|
2
|
+
import { GetAppResponse } from '@gct-paas/api/apaas';
|
|
3
|
+
interface IParams {
|
|
4
|
+
appInfo?: GetAppResponse;
|
|
5
|
+
}
|
|
6
|
+
export declare const defaultValMap: Map<string, (widget: ISearchSchema, params?: IParams) => Promise<string | string[] | null | undefined | number | number[] | boolean>>;
|
|
7
|
+
export {};
|