@hzab/list-render 1.10.5 → 1.10.6

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/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # @hzab/list-render@1.10.6
2
+
3
+ fix: table render getVal 增加 getOptItByVal 支持通过 fieldNames 配置 下拉数据格式
4
+
1
5
  # @hzab/list-render@1.10.5
2
6
 
3
7
  feat: 行内编辑默认聚焦
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hzab/list-render",
3
- "version": "1.10.5",
3
+ "version": "1.10.6",
4
4
  "description": "",
5
5
  "main": "src",
6
6
  "scripts": {
@@ -24,6 +24,8 @@ const dateFormatEnum = {
24
24
  * @returns
25
25
  */
26
26
  export function getVal(field = {}, data = {}, opt = {}) {
27
+ console.log("field", field);
28
+
27
29
  const {} = opt;
28
30
  let val = _.get(data, field.name);
29
31
  const {} = field || {};
@@ -70,11 +72,11 @@ export function getVal(field = {}, data = {}, opt = {}) {
70
72
  Array.isArray(dataSource)
71
73
  ) {
72
74
  if (!Array.isArray(val)) {
73
- return dataSource?.find((option) => option.value === val)?.label || val;
75
+ return getFieldOptItByVal(val, field, opt)?.label || val;
74
76
  } else if (Array.isArray(val)) {
75
77
  let _val = [];
76
78
  val.forEach((valIt) => {
77
- _val.push(dataSource?.find((option) => option.value === valIt)?.label || valIt);
79
+ _val.push(getFieldOptItByVal(val, field, opt)?.label || valIt);
78
80
  });
79
81
  val = _val;
80
82
  }
@@ -161,7 +163,10 @@ export const getFieldOptItByVal = function (val, field, opt) {
161
163
  : Array.isArray(field.options)
162
164
  ? field.options
163
165
  : field.dataSource || [];
164
- return getOptItByVal(val, options, { fieldNames: field.fieldNames, ...opt });
166
+ return getOptItByVal(val, options, {
167
+ fieldNames: field.fieldNames || field["x-component-props"]?.fieldNames,
168
+ ...opt,
169
+ });
165
170
  };
166
171
 
167
172
  /**