Commit 5d51d48787f7b96637bc6abe5175578e0263092a

Authored by vben
1 parent b45f8c50

feat(api-select): added numberToString prop #200

CHANGELOG.zh_CN.md
  1 +## Wip
  2 +
  3 +### ✨ Features
  4 +
  5 +- `ApiSelect`新增 `numberToString`属性,用于将 value 为`number`的值全部转化为`string`
  6 +
  7 +### 🐛 Bug Fixes
  8 +
  9 +- 修复 modal 高度计算错误
  10 +- 修复菜单折叠状态下点击标签页弹出菜单
  11 +- 修复 form 表单初始化值为 0 问题
  12 +
1 ## 2.0.0-rc.17 (2020-01-18) 13 ## 2.0.0-rc.17 (2020-01-18)
2 14
3 ### ✨ Refactor 15 ### ✨ Refactor
src/components/Form/src/components/ApiSelect.vue
@@ -36,6 +36,7 @@ @@ -36,6 +36,7 @@
36 }, 36 },
37 props: { 37 props: {
38 value: propTypes.string, 38 value: propTypes.string,
  39 + numberToString: propTypes.bool,
39 api: { 40 api: {
40 type: Function as PropType<(arg?: Recordable) => Promise<OptionsItem[]>>, 41 type: Function as PropType<(arg?: Recordable) => Promise<OptionsItem[]>>,
41 default: null, 42 default: null,
@@ -61,13 +62,14 @@ @@ -61,13 +62,14 @@
61 const [state] = useRuleFormItem(props); 62 const [state] = useRuleFormItem(props);
62 63
63 const getOptions = computed(() => { 64 const getOptions = computed(() => {
64 - const { labelField, valueField } = props; 65 + const { labelField, valueField, numberToString } = props;
65 66
66 return unref(options).reduce((prev, next: Recordable) => { 67 return unref(options).reduce((prev, next: Recordable) => {
67 if (next) { 68 if (next) {
  69 + const value = next[valueField];
68 prev.push({ 70 prev.push({
69 label: next[labelField], 71 label: next[labelField],
70 - value: next[valueField], 72 + value: numberToString ? `${value}` : value,
71 }); 73 });
72 } 74 }
73 return prev; 75 return prev;