@gct-paas/render 0.1.4-dev.11 → 0.1.4-dev.13
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.min.js +6189 -0
- package/dist/index.min.css +2 -0
- package/es/Event/Dependency/controller.mjs +81 -94
- package/es/Event/Dependency/displayRule.mjs +65 -67
- package/es/Event/Dependency/useDependency.mjs +117 -0
- package/es/Event/Dependency/useDependencyToShow.mjs +100 -96
- package/es/Event/baseEvent.d.ts +8 -7
- package/es/Event/baseEvent.mjs +382 -423
- package/es/Event/bizServiceRequest.mjs +28 -40
- package/es/Event/eventType.d.ts +1 -1
- package/es/Event/eventType.mjs +1 -0
- package/es/Event/index.d.ts +4 -3
- package/es/Event/index.mjs +5 -0
- package/es/Event/utils/appRedis.mjs +39 -49
- package/es/Event/utils/globalLoading.mjs +95 -94
- package/es/Event/utils/processRovedInfo.mjs +228 -294
- package/es/Event/utils/runGlobalByPage.mjs +297 -301
- package/es/Event/utils/verificationVar.mjs +32 -38
- 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/enums/index.mjs +17 -5
- package/es/hooks/useStorageRef.mjs +35 -31
- package/es/index.d.ts +1 -0
- package/es/index.mjs +20 -21
- package/es/register/render-register/render-register.mjs +63 -58
- package/es/utils/cacheAdapter.mjs +62 -54
- package/es/utils/expression/index.mjs +105 -122
- package/es/utils/expression/regularExpression/methods.mjs +426 -567
- package/es/utils/field-attrs/basicAttrs.mjs +56 -80
- package/es/utils/field-attrs/index.mjs +16 -13
- package/es/utils/get-ref-data.mjs +41 -59
- package/es/utils/getFieldSchema.mjs +66 -80
- package/es/utils/index.d.ts +2 -2
- package/es/utils/index.mjs +6 -0
- package/es/utils/model-transformer.mjs +74 -64
- package/es/utils/useStyle.mjs +20 -16
- package/package.json +10 -10
- package/dist/index.esm.min.mjs +0 -7042
- package/dist/index.min.cjs +0 -17
- package/dist/index.system.min.js +0 -17
|
@@ -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 };
|
|
@@ -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 };
|
|
@@ -1,62 +1,44 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
modelKey: model,
|
|
16
|
-
foreignFields,
|
|
17
|
-
ids
|
|
18
|
-
});
|
|
19
|
-
if (info?.data) {
|
|
20
|
-
return transSelectData(refOriginField, info.data, info.dict);
|
|
21
|
-
}
|
|
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);
|
|
22
15
|
}
|
|
23
|
-
async function getDataByModelType({
|
|
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
|
-
bsKey: "getOne",
|
|
49
|
-
modelCategory: EntityModelCategoryEnum.ENTITY
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
query: { "id_.eq": ids },
|
|
53
|
-
foreignFields
|
|
54
|
-
},
|
|
55
|
-
{}
|
|
56
|
-
);
|
|
57
|
-
return { data, dict };
|
|
58
|
-
}
|
|
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
|
+
}
|
|
59
41
|
}
|
|
60
|
-
|
|
61
|
-
|
|
42
|
+
var getRefInfoId = (arg) => cacheAdapter(arg, getRefDataById);
|
|
43
|
+
//#endregion
|
|
62
44
|
export { getRefInfoId };
|
|
@@ -1,83 +1,69 @@
|
|
|
1
|
-
|
|
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
|
-
}
|
|
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
|
+
/**字段运行时需要同步的数据 */
|
|
52
51
|
async function initFieldWidgetRuntime(widget, isVanField = false) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
if (!fieldInfo) {
|
|
70
|
-
return {};
|
|
71
|
-
}
|
|
72
|
-
const { required, specificConfig } = fieldInfo;
|
|
73
|
-
widget.props.fieldRequired = !!required;
|
|
74
|
-
if (required && !readonly) {
|
|
75
|
-
widget.props.required = true;
|
|
76
|
-
}
|
|
77
|
-
if (specificConfig?.digits !== void 0) {
|
|
78
|
-
widget.props.precision = specificConfig.digits;
|
|
79
|
-
}
|
|
80
|
-
return fieldInfo;
|
|
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;
|
|
81
67
|
}
|
|
82
|
-
|
|
68
|
+
//#endregion
|
|
83
69
|
export { FieldSchema, initFieldWidgetRuntime };
|
package/es/utils/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { transformPropsField } from './field-attrs';
|
|
2
|
-
export { useStyle } from './useStyle';
|
|
2
|
+
export { useStyle, schemaToStyle } from './useStyle';
|
|
3
3
|
export { initFieldWidgetRuntime, FieldSchema } from './getFieldSchema';
|
|
4
|
-
export { transformDataToDict, transformSourceData, transformData, addDataByForm, setDataByForm, transSelectData, type RowData, } from './model-transformer';
|
|
4
|
+
export { transformDataToDict, transformSourceData, transformData, addDataByForm, setDataByForm, transSelectData, type RowData, type DictMap, } from './model-transformer';
|
|
5
5
|
export { calculate, identify } from './expression';
|
|
6
6
|
export { getRefInfoId } from './get-ref-data';
|
|
@@ -1,77 +1,87 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
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
|
+
*/
|
|
3
9
|
function transformSourceData(data, dict) {
|
|
4
|
-
|
|
5
|
-
return list || [];
|
|
10
|
+
return data?.map((i) => transformData(i, dict)) || [];
|
|
6
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* 表单 form 数据处理
|
|
14
|
+
* @param data 数据信息
|
|
15
|
+
* @param dict 翻译信息
|
|
16
|
+
* @returns
|
|
17
|
+
*/
|
|
7
18
|
function transformData(row = {}, dict = {}) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
_DICT,
|
|
24
|
-
_OPCT: data.__FOREIGN__ && typeof data.__FOREIGN__ === "object" ? transformData(data.__FOREIGN__, dict) : {}
|
|
25
|
-
// __FOREIGN__: null,
|
|
26
|
-
};
|
|
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
|
+
};
|
|
27
34
|
}
|
|
28
35
|
function addDataByForm(formState, data, dict) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
merge(formState, formdata);
|
|
36
|
+
if (typeof data !== "object") return;
|
|
37
|
+
merge(formState, transformData(data, dict));
|
|
32
38
|
}
|
|
33
39
|
function setDataByForm(formState, data, dict) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
const formdata = transformData(data, dict);
|
|
41
|
-
formdata._X_ROW_KEY = data._X_ROW_KEY;
|
|
42
|
-
merge(formState, formdata);
|
|
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);
|
|
43
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* 表单 select 数据处理
|
|
48
|
+
* @param data 数据信息
|
|
49
|
+
* @param dict 翻译信息
|
|
50
|
+
* @returns
|
|
51
|
+
*/
|
|
44
52
|
function transSelectData(field, row = {}, dict = {}) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
...data,
|
|
61
|
-
_OPCT
|
|
62
|
-
};
|
|
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
|
+
};
|
|
63
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* 表单 form 数据f翻译不保留原始信息
|
|
71
|
+
* @param data 翻译信息
|
|
72
|
+
* @returns
|
|
73
|
+
*/
|
|
64
74
|
function transformDataToDict(row = {}, dict = {}) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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;
|
|
75
85
|
}
|
|
76
|
-
|
|
86
|
+
//#endregion
|
|
77
87
|
export { addDataByForm, setDataByForm, transSelectData, transformData, transformDataToDict, transformSourceData };
|
package/es/utils/useStyle.mjs
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { extractFontStyle, generateWrapperStyle, propsToStyle } from "@gct-paas/schema";
|
|
2
|
+
//#region src/utils/useStyle.ts
|
|
3
3
|
function useStyle(widget) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
labelFont,
|
|
14
|
-
contentFont
|
|
15
|
-
};
|
|
4
|
+
const { style = {} } = widget || {};
|
|
5
|
+
const ignoringStyle = "ignoringStyle" in widget ? widget.ignoringStyle ?? [] : [];
|
|
6
|
+
const wStyle = propsToStyle(style);
|
|
7
|
+
return {
|
|
8
|
+
wrapperStyle: generateWrapperStyle(style, ignoringStyle),
|
|
9
|
+
wStyle,
|
|
10
|
+
labelFont: extractFontStyle(style.labelFont),
|
|
11
|
+
contentFont: extractFontStyle(style.contentFont)
|
|
12
|
+
};
|
|
16
13
|
}
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
/**
|
|
15
|
+
* 将样式对象转换为字体样式
|
|
16
|
+
*
|
|
17
|
+
* @param schema - 样式配置对象
|
|
18
|
+
* @returns 转换后的字体样式对象
|
|
19
|
+
*/
|
|
20
|
+
var schemaToStyle = (schema) => extractFontStyle(schema);
|
|
21
|
+
//#endregion
|
|
22
|
+
export { schemaToStyle, useStyle };
|