Skip to content

Commit 4c441fc

Browse files
committed
feat(lib): 调整 widget onChange prop参数格式,添加 formData参数
re #45
1 parent 55c343a commit 4c441fc

File tree

20 files changed

+79
-22
lines changed

20 files changed

+79
-22
lines changed

packages/demo/demo-v2/src/pages/vue-editor/views/editor/viewComponents/Text/uiSchema.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ export default {
88
getWidget(widgetVm) {
99
console.log(widgetVm);
1010
},
11-
onChange(newVal, oldVal) {
12-
console.log('change:', newVal, oldVal);
11+
onChange(data) {
12+
console.log('change:', data);
1313
}
1414
}
1515
}

packages/docs/docs/zh/guide/basic-config.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,15 @@ uiSchema = {
171171

172172
// onChange
173173
// 支持版本 1.3
174-
onChange(newVal, oldVal) {
175-
console.log('change:', newVal, oldVal);
174+
/**
175+
*
176+
* @param curVal 当前值
177+
* @param preVal 上一次的值
178+
* @param parentFormData 当前父节点的值,响应式的值可在这里设置其它需要联动的值
179+
* @param rootFormData 当前父节点的值,响应式的值可在这里设置其它需要联动的值
180+
*/
181+
onChange({ curVal, preVal, parentFormData, rootFormData }) {
182+
console.log('change:', curVal, preVal, parentFormData, rootFormData);
176183
},
177184

178185
// 显示标题?只对 type为`object`、`array` 类型有效

packages/lib/vue2/vue2-core/src/components/Widget.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,12 @@ export default {
325325
if (formatValue.update && preVal !== formatValue.value) {
326326
self.value = formatValue.value;
327327
if (self.onChange) {
328-
self.onChange(formatValue.value, preVal);
328+
self.onChange({
329+
curVal: formatValue.value,
330+
preVal,
331+
parentFormData: getPathVal(self.rootFormData, self.curNodePath, 1),
332+
rootFormData: self.rootFormData
333+
});
329334
}
330335
}
331336
}

packages/lib/vue2/vue2-form-element/dist/vueJsonSchemaForm.esm.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10316,7 +10316,12 @@ var Widget = {
1031610316
self.value = formatValue.value;
1031710317

1031810318
if (self.onChange) {
10319-
self.onChange(formatValue.value, preVal);
10319+
self.onChange({
10320+
curVal: formatValue.value,
10321+
preVal: preVal,
10322+
parentFormData: getPathVal$1(self.rootFormData, self.curNodePath, 1),
10323+
rootFormData: self.rootFormData
10324+
});
1032010325
}
1032110326
}
1032210327
}

packages/lib/vue2/vue2-form-element/dist/vueJsonSchemaForm.esm.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/lib/vue2/vue2-form-element/dist/vueJsonSchemaForm.umd.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10324,7 +10324,12 @@
1032410324
self.value = formatValue.value;
1032510325

1032610326
if (self.onChange) {
10327-
self.onChange(formatValue.value, preVal);
10327+
self.onChange({
10328+
curVal: formatValue.value,
10329+
preVal: preVal,
10330+
parentFormData: getPathVal$1(self.rootFormData, self.curNodePath, 1),
10331+
rootFormData: self.rootFormData
10332+
});
1032810333
}
1032910334
}
1033010335
}

packages/lib/vue2/vue2-form-element/dist/vueJsonSchemaForm.umd.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/lib/vue2/vue2-form-iview3/dist/vue2-form-iview3.esm.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10316,7 +10316,12 @@ var Widget = {
1031610316
self.value = formatValue.value;
1031710317

1031810318
if (self.onChange) {
10319-
self.onChange(formatValue.value, preVal);
10319+
self.onChange({
10320+
curVal: formatValue.value,
10321+
preVal: preVal,
10322+
parentFormData: getPathVal$1(self.rootFormData, self.curNodePath, 1),
10323+
rootFormData: self.rootFormData
10324+
});
1032010325
}
1032110326
}
1032210327
}

packages/lib/vue2/vue2-form-iview3/dist/vue2-form-iview3.esm.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/lib/vue2/vue2-form-iview3/dist/vue2-form-iview3.umd.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10324,7 +10324,12 @@
1032410324
self.value = formatValue.value;
1032510325

1032610326
if (self.onChange) {
10327-
self.onChange(formatValue.value, preVal);
10327+
self.onChange({
10328+
curVal: formatValue.value,
10329+
preVal: preVal,
10330+
parentFormData: getPathVal$1(self.rootFormData, self.curNodePath, 1),
10331+
rootFormData: self.rootFormData
10332+
});
1032810333
}
1032910334
}
1033010335
}

0 commit comments

Comments
 (0)