@lambo-design/shared 1.0.0-beta.239 → 1.0.0-beta.240
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/package.json +1 -1
- package/utils/transform.js +28 -1
package/package.json
CHANGED
package/utils/transform.js
CHANGED
|
@@ -11,7 +11,11 @@
|
|
|
11
11
|
* - 将 sources 中除 gridColumns、workFlow 和 basicFormFields 外的所有属性复制到 formConfig 中。
|
|
12
12
|
* 3. 生成 workFlow:
|
|
13
13
|
* - 直接将 sources 中的 workFlow 复制到 target 的 workFlow 中。
|
|
14
|
-
*
|
|
14
|
+
* 4. 对于每个 basicFormField:
|
|
15
|
+
* - 生成唯一的 ID。
|
|
16
|
+
* - 添加 formItemFlag 属性并设置为 true。
|
|
17
|
+
* - 添加 options 对象,其中 name 字段值来自 basicFormField.formKey。
|
|
18
|
+
* - options 对象还包括其他默认配置项。
|
|
15
19
|
* @param {*} sources
|
|
16
20
|
* @returns
|
|
17
21
|
*/
|
|
@@ -39,10 +43,33 @@
|
|
|
39
43
|
// 计算每列的span值
|
|
40
44
|
const defaultSpan = 24 / sources.gridColumns;
|
|
41
45
|
const specialTypes = ['textarea', 'imgUpload', 'imgListUpload', 'fileUpload', 'videoUpload'];
|
|
46
|
+
let fieldIdCounter = 1; // 用于生成唯一ID
|
|
42
47
|
|
|
43
48
|
// 动态生成cols
|
|
44
49
|
sources.basicFormFields.forEach((field, index) => {
|
|
45
50
|
const span = specialTypes.includes(field.type) ? 24 : defaultSpan;
|
|
51
|
+
|
|
52
|
+
// 为每个field增加id和options
|
|
53
|
+
const uniqueFieldId = `input${fieldIdCounter++}`;
|
|
54
|
+
field.id = uniqueFieldId;
|
|
55
|
+
field.formItemFlag = true;
|
|
56
|
+
field.options = {
|
|
57
|
+
name: field.formKey,
|
|
58
|
+
customClass: "",
|
|
59
|
+
hidden: false,
|
|
60
|
+
defaultValue: null,
|
|
61
|
+
validation: "",
|
|
62
|
+
validationHint: "",
|
|
63
|
+
onCreated: "",
|
|
64
|
+
onMounted: "",
|
|
65
|
+
onInput: "",
|
|
66
|
+
onChange: "",
|
|
67
|
+
onFocus: "",
|
|
68
|
+
onBlur: "",
|
|
69
|
+
onValidate: "",
|
|
70
|
+
onAppendButtonClick: ""
|
|
71
|
+
};
|
|
72
|
+
|
|
46
73
|
target.widgetList[0].cols.push({
|
|
47
74
|
id: `default-col-id-${index + 1}`, // 默认值
|
|
48
75
|
type: "grid-col",
|