Skip to content

Commit

Permalink
feat(api-select): added numberToString prop #200
Browse files Browse the repository at this point in the history
  • Loading branch information
anncwb committed Jan 19, 2021
1 parent b45f8c5 commit 5d51d48
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.zh_CN.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
## Wip

### ✨ Features

- `ApiSelect`新增 `numberToString`属性,用于将 value 为`number`的值全部转化为`string`

### 🐛 Bug Fixes

- 修复 modal 高度计算错误
- 修复菜单折叠状态下点击标签页弹出菜单
- 修复 form 表单初始化值为 0 问题

## 2.0.0-rc.17 (2020-01-18)

### ✨ Refactor
Expand Down
6 changes: 4 additions & 2 deletions src/components/Form/src/components/ApiSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
},
props: {
value: propTypes.string,
numberToString: propTypes.bool,
api: {
type: Function as PropType<(arg?: Recordable) => Promise<OptionsItem[]>>,
default: null,
Expand All @@ -61,13 +62,14 @@
const [state] = useRuleFormItem(props);
const getOptions = computed(() => {
const { labelField, valueField } = props;
const { labelField, valueField, numberToString } = props;
return unref(options).reduce((prev, next: Recordable) => {
if (next) {
const value = next[valueField];
prev.push({
label: next[labelField],
value: next[valueField],
value: numberToString ? `${value}` : value,
});
}
return prev;
Expand Down

0 comments on commit 5d51d48

Please sign in to comment.