feat(api-select): added numberToString prop #200
This commit is contained in:
parent
b45f8c5021
commit
5d51d48787
|
|
@ -1,3 +1,15 @@
|
||||||
|
## Wip
|
||||||
|
|
||||||
|
### ✨ Features
|
||||||
|
|
||||||
|
- `ApiSelect`新增 `numberToString`属性,用于将 value 为`number`的值全部转化为`string`
|
||||||
|
|
||||||
|
### 🐛 Bug Fixes
|
||||||
|
|
||||||
|
- 修复 modal 高度计算错误
|
||||||
|
- 修复菜单折叠状态下点击标签页弹出菜单
|
||||||
|
- 修复 form 表单初始化值为 0 问题
|
||||||
|
|
||||||
## 2.0.0-rc.17 (2020-01-18)
|
## 2.0.0-rc.17 (2020-01-18)
|
||||||
|
|
||||||
### ✨ Refactor
|
### ✨ Refactor
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
value: propTypes.string,
|
value: propTypes.string,
|
||||||
|
numberToString: propTypes.bool,
|
||||||
api: {
|
api: {
|
||||||
type: Function as PropType<(arg?: Recordable) => Promise<OptionsItem[]>>,
|
type: Function as PropType<(arg?: Recordable) => Promise<OptionsItem[]>>,
|
||||||
default: null,
|
default: null,
|
||||||
|
|
@ -61,13 +62,14 @@
|
||||||
const [state] = useRuleFormItem(props);
|
const [state] = useRuleFormItem(props);
|
||||||
|
|
||||||
const getOptions = computed(() => {
|
const getOptions = computed(() => {
|
||||||
const { labelField, valueField } = props;
|
const { labelField, valueField, numberToString } = props;
|
||||||
|
|
||||||
return unref(options).reduce((prev, next: Recordable) => {
|
return unref(options).reduce((prev, next: Recordable) => {
|
||||||
if (next) {
|
if (next) {
|
||||||
|
const value = next[valueField];
|
||||||
prev.push({
|
prev.push({
|
||||||
label: next[labelField],
|
label: next[labelField],
|
||||||
value: next[valueField],
|
value: numberToString ? `${value}` : value,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return prev;
|
return prev;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue