Commit 535bdddf91785e20295c18cf80c8a22cc2172681
1 parent
18567e13
fix(demo): fix display problem of editable table with `apiSelect`
修复ApiSelect在可编辑表格中的显示问题
Showing
2 changed files
with
26 additions
and
2 deletions
src/views/demo/table/EditCellTable.vue
@@ -8,11 +8,12 @@ | @@ -8,11 +8,12 @@ | ||
8 | </div> | 8 | </div> |
9 | </template> | 9 | </template> |
10 | <script lang="ts"> | 10 | <script lang="ts"> |
11 | - import { defineComponent } from 'vue'; | 11 | + import { defineComponent, ref } from 'vue'; |
12 | import { BasicTable, useTable, BasicColumn } from '/@/components/Table'; | 12 | import { BasicTable, useTable, BasicColumn } from '/@/components/Table'; |
13 | import { optionsListApi } from '/@/api/demo/select'; | 13 | import { optionsListApi } from '/@/api/demo/select'; |
14 | 14 | ||
15 | import { demoListApi } from '/@/api/demo/table'; | 15 | import { demoListApi } from '/@/api/demo/table'; |
16 | + const optionsData = ref([]); | ||
16 | const columns: BasicColumn[] = [ | 17 | const columns: BasicColumn[] = [ |
17 | { | 18 | { |
18 | title: '输入框', | 19 | title: '输入框', |
@@ -87,6 +88,17 @@ | @@ -87,6 +88,17 @@ | ||
87 | resultField: 'list', | 88 | resultField: 'list', |
88 | labelField: 'name', | 89 | labelField: 'name', |
89 | valueField: 'id', | 90 | valueField: 'id', |
91 | + onOptionsChange(options) { | ||
92 | + optionsData.value = options; | ||
93 | + }, | ||
94 | + }, | ||
95 | + editValueMap(value: any) { | ||
96 | + const found = optionsData.value.find((option) => option.id === value); | ||
97 | + if (found) { | ||
98 | + return found.name; | ||
99 | + } else { | ||
100 | + return value; | ||
101 | + } | ||
90 | }, | 102 | }, |
91 | width: 200, | 103 | width: 200, |
92 | }, | 104 | }, |
src/views/demo/table/EditRowTable.vue
@@ -20,6 +20,8 @@ | @@ -20,6 +20,8 @@ | ||
20 | import { optionsListApi } from '/@/api/demo/select'; | 20 | import { optionsListApi } from '/@/api/demo/select'; |
21 | 21 | ||
22 | import { demoListApi } from '/@/api/demo/table'; | 22 | import { demoListApi } from '/@/api/demo/table'; |
23 | + const optionsData = ref([]); | ||
24 | + | ||
23 | const columns: BasicColumn[] = [ | 25 | const columns: BasicColumn[] = [ |
24 | { | 26 | { |
25 | title: '输入框', | 27 | title: '输入框', |
@@ -98,6 +100,17 @@ | @@ -98,6 +100,17 @@ | ||
98 | resultField: 'list', | 100 | resultField: 'list', |
99 | labelField: 'name', | 101 | labelField: 'name', |
100 | valueField: 'id', | 102 | valueField: 'id', |
103 | + onOptionsChange(options) { | ||
104 | + optionsData.value = options; | ||
105 | + }, | ||
106 | + }, | ||
107 | + editValueMap(value: any) { | ||
108 | + const found = optionsData.value.find((option) => option.id === value); | ||
109 | + if (found) { | ||
110 | + return found.name; | ||
111 | + } else { | ||
112 | + return value; | ||
113 | + } | ||
101 | }, | 114 | }, |
102 | width: 200, | 115 | width: 200, |
103 | }, | 116 | }, |
@@ -149,7 +162,6 @@ | @@ -149,7 +162,6 @@ | ||
149 | components: { BasicTable, TableAction }, | 162 | components: { BasicTable, TableAction }, |
150 | setup() { | 163 | setup() { |
151 | const currentEditKeyRef = ref(''); | 164 | const currentEditKeyRef = ref(''); |
152 | - | ||
153 | const [registerTable] = useTable({ | 165 | const [registerTable] = useTable({ |
154 | title: '可编辑行示例', | 166 | title: '可编辑行示例', |
155 | titleHelpMessage: [ | 167 | titleHelpMessage: [ |