Skip to content

Commit

Permalink
feat(table): add editable DatePicker & TimePicker (#654)
Browse files Browse the repository at this point in the history
为表格的可编辑单元格添加日期选择框和时间选择框组件
  • Loading branch information
mynetfan authored May 26, 2021
1 parent 4f0d45f commit 93006c7
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 3 deletions.
2 changes: 2 additions & 0 deletions mock/demo/table-demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ const demoList = (() => {
name6: '@cname()',
name7: '@cname()',
name8: '@cname()',
date: `@date('yyyy-MM-dd')`,
time: `@time('HH:mm')`,
'no|100000-10000000': 100000,
'status|1': ['normal', 'enable', 'disable'],
});
Expand Down
12 changes: 11 additions & 1 deletion src/components/Table/src/componentMap.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import type { Component } from 'vue';

import { Input, Select, Checkbox, InputNumber, Switch } from 'ant-design-vue';
import {
Input,
Select,
Checkbox,
InputNumber,
Switch,
DatePicker,
TimePicker,
} from 'ant-design-vue';

import type { ComponentType } from './types/componentType';
import { ApiSelect } from '/@/components/Form';
Expand All @@ -14,6 +22,8 @@ componentMap.set('Select', Select);
componentMap.set('ApiSelect', ApiSelect);
componentMap.set('Switch', Switch);
componentMap.set('Checkbox', Checkbox);
componentMap.set('DatePicker', DatePicker);
componentMap.set('TimePicker', TimePicker);

export function add(compName: ComponentType, component: Component) {
componentMap.set(compName, component);
Expand Down
4 changes: 3 additions & 1 deletion src/components/Table/src/components/editable/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ export function createPlaceholderMessage(component: ComponentType) {
component.includes('Select') ||
component.includes('Checkbox') ||
component.includes('Radio') ||
component.includes('Switch')
component.includes('Switch') ||
component.includes('DatePicker') ||
component.includes('TimePicker')
) {
return t('common.chooseText');
}
Expand Down
4 changes: 3 additions & 1 deletion src/components/Table/src/types/componentType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ export type ComponentType =
| 'Select'
| 'ApiSelect'
| 'Checkbox'
| 'Switch';
| 'Switch'
| 'DatePicker'
| 'TimePicker';
22 changes: 22 additions & 0 deletions src/views/demo/table/EditCellTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,28 @@
},
width: 200,
},
{
title: '日期选择',
dataIndex: 'date',
edit: true,
editComponent: 'DatePicker',
editComponentProps: {
valueFormat: 'YYYY-MM-DD',
format: 'YYYY-MM-DD',
},
width: 200,
},
{
title: '时间选择',
dataIndex: 'time',
edit: true,
editComponent: 'TimePicker',
editComponentProps: {
valueFormat: 'HH:mm',
format: 'HH:mm',
},
width: 200,
},
{
title: '勾选框',
dataIndex: 'name5',
Expand Down
32 changes: 32 additions & 0 deletions src/views/demo/table/EditRowTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,38 @@
},
width: 200,
},
{
title: '日期选择',
dataIndex: 'date',
editRow: true,
editComponent: 'DatePicker',
editComponentProps: {
valueFormat: 'YYYY-MM-DD',
format: 'YYYY-MM-DD',
},
width: 200,
},
{
title: '时间选择',
dataIndex: 'time',
editRow: true,
editComponent: 'TimePicker',
editComponentProps: {
valueFormat: 'HH:mm',
format: 'HH:mm',
},
width: 200,
},
{
title: '远程下拉',
dataIndex: 'name4',
editRow: true,
editComponent: 'ApiSelect',
editComponentProps: {
api: optionsListApi,
},
width: 200,
},
{
title: '勾选框',
dataIndex: 'name5',
Expand Down

0 comments on commit 93006c7

Please sign in to comment.