Commit e08a155c40877bb44fce3e90672845058d3b12f9
Committed by
GitHub
1 parent
c37a15fe
feat(EditableCell): table 可编辑单元格和可编辑行 增加 单选框相关组件, 并增加示例 (#2294)
Co-authored-by: 苗大 <caoshengmiao@hypergryph.com>
Showing
6 changed files
with
117 additions
and
5 deletions
mock/demo/table-demo.ts
... | ... | @@ -27,6 +27,9 @@ const demoList = (() => { |
27 | 27 | name6: '@cname()', |
28 | 28 | name7: '@cname()', |
29 | 29 | name8: '@cname()', |
30 | + radio1: `选项${index + 1}`, | |
31 | + radio2: `选项${index + 1}`, | |
32 | + radio3: `选项${index + 1}`, | |
30 | 33 | avatar: Random.image('400x400', Random.color(), Random.color(), Random.first()), |
31 | 34 | imgArr: getRandomPics(Math.ceil(Math.random() * 3) + 1), |
32 | 35 | imgs: getRandomPics(Math.ceil(Math.random() * 3) + 1), | ... | ... |
src/components/Table/src/componentMap.ts
... | ... | @@ -8,9 +8,10 @@ import { |
8 | 8 | DatePicker, |
9 | 9 | TimePicker, |
10 | 10 | AutoComplete, |
11 | + Radio, | |
11 | 12 | } from 'ant-design-vue'; |
12 | 13 | import type { ComponentType } from './types/componentType'; |
13 | -import { ApiSelect, ApiTreeSelect } from '/@/components/Form'; | |
14 | +import { ApiSelect, ApiTreeSelect, RadioButtonGroup, ApiRadioGroup } from '/@/components/Form'; | |
14 | 15 | |
15 | 16 | const componentMap = new Map<ComponentType, Component>(); |
16 | 17 | |
... | ... | @@ -24,6 +25,9 @@ componentMap.set('Switch', Switch); |
24 | 25 | componentMap.set('Checkbox', Checkbox); |
25 | 26 | componentMap.set('DatePicker', DatePicker); |
26 | 27 | componentMap.set('TimePicker', TimePicker); |
28 | +componentMap.set('RadioGroup', Radio.Group); | |
29 | +componentMap.set('RadioButtonGroup', RadioButtonGroup); | |
30 | +componentMap.set('ApiRadioGroup', ApiRadioGroup); | |
27 | 31 | |
28 | 32 | export function add(compName: ComponentType, component: Component) { |
29 | 33 | componentMap.set(compName, component); | ... | ... |
src/components/Table/src/components/editable/EditableCell.vue
... | ... | @@ -14,7 +14,7 @@ |
14 | 14 | import { propTypes } from '/@/utils/propTypes'; |
15 | 15 | import { isArray, isBoolean, isFunction, isNumber, isString } from '/@/utils/is'; |
16 | 16 | import { createPlaceholderMessage } from './helper'; |
17 | - import { omit, pick, set } from 'lodash-es'; | |
17 | + import { pick, set } from 'lodash-es'; | |
18 | 18 | import { treeToList } from '/@/utils/helper/treeHelper'; |
19 | 19 | import { Spin } from 'ant-design-vue'; |
20 | 20 | |
... | ... | @@ -122,7 +122,7 @@ |
122 | 122 | } |
123 | 123 | |
124 | 124 | const component = unref(getComponent); |
125 | - if (!component.includes('Select')) { | |
125 | + if (!component.includes('Select') && !component.includes('Radio')) { | |
126 | 126 | return value; |
127 | 127 | } |
128 | 128 | ... | ... |
src/components/Table/src/types/componentType.ts
src/views/demo/table/EditCellTable.vue
... | ... | @@ -105,7 +105,7 @@ |
105 | 105 | }, |
106 | 106 | { |
107 | 107 | title: '远程下拉树', |
108 | - dataIndex: 'name71', | |
108 | + dataIndex: 'name8', | |
109 | 109 | edit: true, |
110 | 110 | editComponent: 'ApiTreeSelect', |
111 | 111 | editRule: false, |
... | ... | @@ -157,6 +157,57 @@ |
157 | 157 | }, |
158 | 158 | width: 200, |
159 | 159 | }, |
160 | + { | |
161 | + title: '单选框', | |
162 | + dataIndex: 'radio1', | |
163 | + edit: true, | |
164 | + editComponent: 'RadioGroup', | |
165 | + editComponentProps: { | |
166 | + options: [ | |
167 | + { | |
168 | + label: '选项1', | |
169 | + value: '1', | |
170 | + }, | |
171 | + { | |
172 | + label: '选项2', | |
173 | + value: '2', | |
174 | + }, | |
175 | + ], | |
176 | + }, | |
177 | + width: 200, | |
178 | + }, | |
179 | + { | |
180 | + title: '单选按钮框', | |
181 | + dataIndex: 'radio2', | |
182 | + edit: true, | |
183 | + editComponent: 'RadioButtonGroup', | |
184 | + editComponentProps: { | |
185 | + options: [ | |
186 | + { | |
187 | + label: '选项1', | |
188 | + value: '1', | |
189 | + }, | |
190 | + { | |
191 | + label: '选项2', | |
192 | + value: '2', | |
193 | + }, | |
194 | + ], | |
195 | + }, | |
196 | + width: 200, | |
197 | + }, | |
198 | + { | |
199 | + title: '远程单选框', | |
200 | + dataIndex: 'radio3', | |
201 | + edit: true, | |
202 | + editComponent: 'ApiRadioGroup', | |
203 | + editComponentProps: { | |
204 | + api: optionsListApi, | |
205 | + resultField: 'list', | |
206 | + labelField: 'name', | |
207 | + valueField: 'id', | |
208 | + }, | |
209 | + width: 200, | |
210 | + }, | |
160 | 211 | ]; |
161 | 212 | export default defineComponent({ |
162 | 213 | components: { BasicTable }, | ... | ... |
src/views/demo/table/EditRowTable.vue
... | ... | @@ -162,6 +162,57 @@ |
162 | 162 | }, |
163 | 163 | width: 100, |
164 | 164 | }, |
165 | + { | |
166 | + title: '单选框', | |
167 | + dataIndex: 'radio1', | |
168 | + editRow: true, | |
169 | + editComponent: 'RadioGroup', | |
170 | + editComponentProps: { | |
171 | + options: [ | |
172 | + { | |
173 | + label: '选项1', | |
174 | + value: '1', | |
175 | + }, | |
176 | + { | |
177 | + label: '选项2', | |
178 | + value: '2', | |
179 | + }, | |
180 | + ], | |
181 | + }, | |
182 | + width: 200, | |
183 | + }, | |
184 | + { | |
185 | + title: '单选按钮框', | |
186 | + dataIndex: 'radio2', | |
187 | + editRow: true, | |
188 | + editComponent: 'RadioButtonGroup', | |
189 | + editComponentProps: { | |
190 | + options: [ | |
191 | + { | |
192 | + label: '选项1', | |
193 | + value: '1', | |
194 | + }, | |
195 | + { | |
196 | + label: '选项2', | |
197 | + value: '2', | |
198 | + }, | |
199 | + ], | |
200 | + }, | |
201 | + width: 200, | |
202 | + }, | |
203 | + { | |
204 | + title: '远程单选框', | |
205 | + dataIndex: 'radio3', | |
206 | + editRow: true, | |
207 | + editComponent: 'ApiRadioGroup', | |
208 | + editComponentProps: { | |
209 | + api: optionsListApi, | |
210 | + resultField: 'list', | |
211 | + labelField: 'name', | |
212 | + valueField: 'id', | |
213 | + }, | |
214 | + width: 200, | |
215 | + }, | |
165 | 216 | ]; |
166 | 217 | export default defineComponent({ |
167 | 218 | components: { BasicTable, TableAction }, | ... | ... |