@pisell/materials 1.0.974 → 1.0.975

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.
@@ -91,18 +91,40 @@ var BaseForm = /*#__PURE__*/forwardRef(function (props, ref) {
91
91
  channelCode: channelCode,
92
92
  isBoard: isBoard
93
93
  }).then(function (res) {
94
- var _formRef$current2;
94
+ var _dataSource$fields2, _formRef$current2;
95
95
  var formattedValues = formatInitialValues ? formatInitialValues(res.data) : res.data || {};
96
- (_formRef$current2 = formRef.current) === null || _formRef$current2 === void 0 || _formRef$current2.setFields(transformFormObjToArrayWithUntouched(_objectSpread({}, formattedValues)));
96
+
97
+ // 根据 dataSource.fields 筛选 formattedValues
98
+ var fieldNames = new Set((dataSource === null || dataSource === void 0 || (_dataSource$fields2 = dataSource.fields) === null || _dataSource$fields2 === void 0 ? void 0 : _dataSource$fields2.map(function (field) {
99
+ return field.name;
100
+ })) || []);
101
+ var filteredValues = Object.keys(formattedValues).reduce(function (acc, key) {
102
+ if (fieldNames.has(key)) {
103
+ acc[key] = formattedValues[key];
104
+ }
105
+ return acc;
106
+ }, {});
107
+ (_formRef$current2 = formRef.current) === null || _formRef$current2 === void 0 || _formRef$current2.setFields(transformFormObjToArrayWithUntouched(_objectSpread({}, filteredValues)));
97
108
  }).catch(function (error) {
98
109
  console.error('获取formSettingMeta数据失败:', error);
99
110
  });
100
111
  return;
101
112
  }
102
113
  get === null || get === void 0 || get.runAsync().then(function (res) {
103
- var _formRef$current3;
114
+ var _dataSource$fields3, _formRef$current3;
104
115
  var formattedValues = formatInitialValues ? formatInitialValues(res) : res;
105
- (_formRef$current3 = formRef.current) === null || _formRef$current3 === void 0 || _formRef$current3.setFields(transformFormObjToArrayWithUntouched(formattedValues));
116
+
117
+ // 根据 dataSource.fields 筛选 formattedValues
118
+ var fieldNames = new Set((dataSource === null || dataSource === void 0 || (_dataSource$fields3 = dataSource.fields) === null || _dataSource$fields3 === void 0 ? void 0 : _dataSource$fields3.map(function (field) {
119
+ return field.name;
120
+ })) || []);
121
+ var filteredValues = Object.keys(formattedValues).reduce(function (acc, key) {
122
+ if (fieldNames.has(key)) {
123
+ acc[key] = formattedValues[key];
124
+ }
125
+ return acc;
126
+ }, {});
127
+ (_formRef$current3 = formRef.current) === null || _formRef$current3 === void 0 || _formRef$current3.setFields(transformFormObjToArrayWithUntouched(filteredValues));
106
128
  });
107
129
  }
108
130
  }, [renderMode, dataSource]);
@@ -93,10 +93,17 @@ var BaseForm = (0, import_react.forwardRef)(
93
93
  const { businessCode, channelCode, isBoard } = (0, import_urlUtils.getFormSettingParams)();
94
94
  const sectionCodes = Array.from(new Set((_a2 = dataSource == null ? void 0 : dataSource.fields) == null ? void 0 : _a2.map((field) => field.name.split(".").shift())));
95
95
  (0, import_serve.getFormSettingMetaData)({ sectionCodes, businessCode, channelCode, isBoard }).then((res) => {
96
- var _a3;
96
+ var _a3, _b;
97
97
  const formattedValues = formatInitialValues ? formatInitialValues(res.data) : res.data || {};
98
- (_a3 = formRef.current) == null ? void 0 : _a3.setFields((0, import_utils.transformFormObjToArrayWithUntouched)({
99
- ...formattedValues
98
+ const fieldNames = new Set(((_a3 = dataSource == null ? void 0 : dataSource.fields) == null ? void 0 : _a3.map((field) => field.name)) || []);
99
+ const filteredValues = Object.keys(formattedValues).reduce((acc, key) => {
100
+ if (fieldNames.has(key)) {
101
+ acc[key] = formattedValues[key];
102
+ }
103
+ return acc;
104
+ }, {});
105
+ (_b = formRef.current) == null ? void 0 : _b.setFields((0, import_utils.transformFormObjToArrayWithUntouched)({
106
+ ...filteredValues
100
107
  }));
101
108
  }).catch((error) => {
102
109
  console.error("获取formSettingMeta数据失败:", error);
@@ -104,9 +111,16 @@ var BaseForm = (0, import_react.forwardRef)(
104
111
  return;
105
112
  }
106
113
  get == null ? void 0 : get.runAsync().then((res) => {
107
- var _a3;
114
+ var _a3, _b;
108
115
  const formattedValues = formatInitialValues ? formatInitialValues(res) : res;
109
- (_a3 = formRef.current) == null ? void 0 : _a3.setFields((0, import_utils.transformFormObjToArrayWithUntouched)(formattedValues));
116
+ const fieldNames = new Set(((_a3 = dataSource == null ? void 0 : dataSource.fields) == null ? void 0 : _a3.map((field) => field.name)) || []);
117
+ const filteredValues = Object.keys(formattedValues).reduce((acc, key) => {
118
+ if (fieldNames.has(key)) {
119
+ acc[key] = formattedValues[key];
120
+ }
121
+ return acc;
122
+ }, {});
123
+ (_b = formRef.current) == null ? void 0 : _b.setFields((0, import_utils.transformFormObjToArrayWithUntouched)(filteredValues));
110
124
  });
111
125
  }
112
126
  }, [renderMode, dataSource]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/materials",
3
- "version": "1.0.974",
3
+ "version": "1.0.975",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -75,9 +75,9 @@
75
75
  "antd-mobile": "^5.38.1",
76
76
  "vod-js-sdk-v6": "^1.4.11",
77
77
  "react-camera-pro": "1.4.0",
78
+ "@pisell/icon": "0.0.10",
78
79
  "@pisell/date-picker": "1.0.127",
79
- "@pisell/utils": "1.0.55",
80
- "@pisell/icon": "0.0.10"
80
+ "@pisell/utils": "1.0.55"
81
81
  },
82
82
  "peerDependencies": {
83
83
  "react": "^18.0.0",