add table demo
parent
846c2119e3
commit
f1e62240e0
|
@ -132,4 +132,9 @@ import DatePicker from './date-picker'
|
||||||
const { MonthPicker, RangePicker, WeekPicker } = DatePicker
|
const { MonthPicker, RangePicker, WeekPicker } = DatePicker
|
||||||
export { DatePicker, MonthPicker, RangePicker, WeekPicker }
|
export { DatePicker, MonthPicker, RangePicker, WeekPicker }
|
||||||
|
|
||||||
|
import Table from './table'
|
||||||
|
const { Column: TableColumn, ColumnGroup: TableColumnGroup } = Table
|
||||||
|
|
||||||
|
export { Table, TableColumn, TableColumnGroup }
|
||||||
|
|
||||||
export { default as version } from './version'
|
export { default as version } from './version'
|
||||||
|
|
|
@ -34,3 +34,4 @@ import './steps/style'
|
||||||
import './breadcrumb/style'
|
import './breadcrumb/style'
|
||||||
import './calendar/style'
|
import './calendar/style'
|
||||||
import './date-picker/style'
|
import './date-picker/style'
|
||||||
|
import './table/style'
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
|
|
||||||
|
import cloneDeep from 'lodash/cloneDeep'
|
||||||
import VcTable from '../vc-table'
|
import VcTable from '../vc-table'
|
||||||
import classNames from 'classnames'
|
import classNames from 'classnames'
|
||||||
import Pagination from '../pagination'
|
import Pagination from '../pagination'
|
||||||
|
@ -16,6 +17,7 @@ import ColumnGroup from './ColumnGroup'
|
||||||
import createBodyRow from './createBodyRow'
|
import createBodyRow from './createBodyRow'
|
||||||
import { flatArray, treeMap, flatFilter } from './util'
|
import { flatArray, treeMap, flatFilter } from './util'
|
||||||
import { initDefaultProps, mergeProps, getOptionProps } from '../_util/props-util'
|
import { initDefaultProps, mergeProps, getOptionProps } from '../_util/props-util'
|
||||||
|
import BaseMixin from '../_util/BaseMixin'
|
||||||
import {
|
import {
|
||||||
TableProps,
|
TableProps,
|
||||||
} from './interface'
|
} from './interface'
|
||||||
|
@ -47,12 +49,12 @@ export default {
|
||||||
name: 'Table',
|
name: 'Table',
|
||||||
Column,
|
Column,
|
||||||
ColumnGroup,
|
ColumnGroup,
|
||||||
|
mixins: [BaseMixin],
|
||||||
props: initDefaultProps(TableProps, {
|
props: initDefaultProps(TableProps, {
|
||||||
dataSource: [],
|
dataSource: [],
|
||||||
prefixCls: 'ant-table',
|
prefixCls: 'ant-table',
|
||||||
useFixedHeader: false,
|
useFixedHeader: false,
|
||||||
rowSelection: null,
|
// rowSelection: null,
|
||||||
size: 'large',
|
size: 'large',
|
||||||
loading: false,
|
loading: false,
|
||||||
bordered: false,
|
bordered: false,
|
||||||
|
@ -148,7 +150,7 @@ export default {
|
||||||
this.createComponents(val, preVal)
|
this.createComponents(val, preVal)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
methods: {
|
||||||
getCheckboxPropsByItem (item, index) {
|
getCheckboxPropsByItem (item, index) {
|
||||||
const { rowSelection = {}} = this
|
const { rowSelection = {}} = this
|
||||||
if (!rowSelection.getCheckboxProps) {
|
if (!rowSelection.getCheckboxProps) {
|
||||||
|
@ -653,7 +655,7 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
getMaxCurrent (total) {
|
getMaxCurrent (total) {
|
||||||
const { current, pageSize } = this.sPagination
|
const { current, pageSize } = this.sPagination.props
|
||||||
if ((current - 1) * pageSize >= total) {
|
if ((current - 1) * pageSize >= total) {
|
||||||
return Math.floor((total - 1) / pageSize) + 1
|
return Math.floor((total - 1) / pageSize) + 1
|
||||||
}
|
}
|
||||||
|
@ -789,7 +791,7 @@ export default {
|
||||||
|
|
||||||
// Get pagination, filters, sorter
|
// Get pagination, filters, sorter
|
||||||
prepareParamsArguments (state) {
|
prepareParamsArguments (state) {
|
||||||
const pagination = { ...state.sPagination }
|
const pagination = cloneDeep(state.sPagination)
|
||||||
// remove useless handle function in Table.onChange
|
// remove useless handle function in Table.onChange
|
||||||
if (pagination.on) {
|
if (pagination.on) {
|
||||||
delete pagination.on.change
|
delete pagination.on.change
|
||||||
|
@ -820,13 +822,14 @@ export default {
|
||||||
let data = this.getLocalData()
|
let data = this.getLocalData()
|
||||||
let current
|
let current
|
||||||
let pageSize
|
let pageSize
|
||||||
|
const pagProps = this.sPagination.props || {}
|
||||||
// 如果没有分页的话,默认全部展示
|
// 如果没有分页的话,默认全部展示
|
||||||
if (!this.hasPagination()) {
|
if (!this.hasPagination()) {
|
||||||
pageSize = Number.MAX_VALUE
|
pageSize = Number.MAX_VALUE
|
||||||
current = 1
|
current = 1
|
||||||
} else {
|
} else {
|
||||||
pageSize = this.sPagination.pageSize
|
pageSize = pagProps.pageSize
|
||||||
current = this.getMaxCurrent(this.sPagination.total || data.length)
|
current = this.getMaxCurrent(pagProps.total || data.length)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 分页
|
// 分页
|
||||||
|
@ -886,12 +889,12 @@ export default {
|
||||||
return data
|
return data
|
||||||
},
|
},
|
||||||
|
|
||||||
createComponents (components, prevComponents) {
|
createComponents (components = {}, prevComponents) {
|
||||||
const bodyRow = components && components.body && components.body.row
|
const bodyRow = components && components.body && components.body.row
|
||||||
const preBodyRow = prevComponents && prevComponents.body && prevComponents.body.row
|
const preBodyRow = prevComponents && prevComponents.body && prevComponents.body.row
|
||||||
if (!this.components || bodyRow !== preBodyRow) {
|
if (!this.customComponents || bodyRow !== preBodyRow) {
|
||||||
this.components = { ...components }
|
this.customComponents = { ...components }
|
||||||
this.components.body = {
|
this.customComponents.body = {
|
||||||
...components.body,
|
...components.body,
|
||||||
row: createBodyRow(bodyRow),
|
row: createBodyRow(bodyRow),
|
||||||
}
|
}
|
||||||
|
@ -926,8 +929,8 @@ export default {
|
||||||
key: 'table',
|
key: 'table',
|
||||||
props: {
|
props: {
|
||||||
...restProps,
|
...restProps,
|
||||||
customRow: this.customRow,
|
customRow: this.onRow,
|
||||||
components: this.components,
|
components: this.customComponents,
|
||||||
prefixCls,
|
prefixCls,
|
||||||
data,
|
data,
|
||||||
columns,
|
columns,
|
||||||
|
@ -945,6 +948,7 @@ export default {
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
},
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { prefixCls } = this
|
const { prefixCls } = this
|
||||||
|
|
|
@ -44,7 +44,7 @@ export default function createTableRow (Component = 'tr') {
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const className = {
|
const className = {
|
||||||
[`${this.props.prefixCls}-row-selected`]: this.selected,
|
[`${this.prefixCls}-row-selected`]: this.selected,
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -0,0 +1,59 @@
|
||||||
|
<cn>
|
||||||
|
#### 基本用法
|
||||||
|
简单的表格,最后一列是各种操作。
|
||||||
|
</cn>
|
||||||
|
|
||||||
|
<us>
|
||||||
|
#### basic Usage
|
||||||
|
Simple table with actions.
|
||||||
|
</us>
|
||||||
|
|
||||||
|
```html
|
||||||
|
<template>
|
||||||
|
<a-table :columns="columns" :dataSource="data" />
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
const columns = [{
|
||||||
|
title: 'Name',
|
||||||
|
dataIndex: 'name',
|
||||||
|
key: 'name',
|
||||||
|
}, {
|
||||||
|
title: 'Age',
|
||||||
|
dataIndex: 'age',
|
||||||
|
key: 'age',
|
||||||
|
}, {
|
||||||
|
title: 'Address',
|
||||||
|
dataIndex: 'address',
|
||||||
|
key: 'address',
|
||||||
|
}, {
|
||||||
|
title: 'Action',
|
||||||
|
key: 'action',
|
||||||
|
}];
|
||||||
|
|
||||||
|
const data = [{
|
||||||
|
key: '1',
|
||||||
|
name: 'John Brown',
|
||||||
|
age: 32,
|
||||||
|
address: 'New York No. 1 Lake Park',
|
||||||
|
}, {
|
||||||
|
key: '2',
|
||||||
|
name: 'Jim Green',
|
||||||
|
age: 42,
|
||||||
|
address: 'London No. 1 Lake Park',
|
||||||
|
}, {
|
||||||
|
key: '3',
|
||||||
|
name: 'Joe Black',
|
||||||
|
age: 32,
|
||||||
|
address: 'Sidney No. 1 Lake Park',
|
||||||
|
}];
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
data,
|
||||||
|
columns,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
```
|
|
@ -8,7 +8,8 @@ import Checkbox from '../checkbox'
|
||||||
import Radio from '../radio'
|
import Radio from '../radio'
|
||||||
import FilterDropdownMenuWrapper from './FilterDropdownMenuWrapper'
|
import FilterDropdownMenuWrapper from './FilterDropdownMenuWrapper'
|
||||||
import { FilterMenuProps } from './interface'
|
import { FilterMenuProps } from './interface'
|
||||||
import { initDefaultProps, cloneElement } from '../_util/props-util'
|
import { initDefaultProps } from '../_util/props-util'
|
||||||
|
import { cloneElement } from '../_util/vnode'
|
||||||
import BaseMixin from '../_util/BaseMixin'
|
import BaseMixin from '../_util/BaseMixin'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
|
@ -81,9 +81,9 @@ export const TableRowSelection = {
|
||||||
export const TableProps = {
|
export const TableProps = {
|
||||||
prefixCls: PropTypes.string,
|
prefixCls: PropTypes.string,
|
||||||
dropdownPrefixCls: PropTypes.string,
|
dropdownPrefixCls: PropTypes.string,
|
||||||
rowSelection: PropTypes.shape(TableRowSelection).loose,
|
rowSelection: PropTypes.oneOfType([PropTypes.shape(TableRowSelection).loose, null]),
|
||||||
pagination: PropTypes.oneOfType([PropTypes.shape(PaginationProps).loose, PropTypes.bool]),
|
pagination: PropTypes.oneOfType([PropTypes.shape(PaginationProps).loose, PropTypes.bool]),
|
||||||
size: PropTypes.oneOf(['default', 'middle', 'small']),
|
size: PropTypes.oneOf(['default', 'middle', 'small', 'large']),
|
||||||
dataSource: PropTypes.array,
|
dataSource: PropTypes.array,
|
||||||
components: PropTypes.object,
|
components: PropTypes.object,
|
||||||
columns: PropTypes.array,
|
columns: PropTypes.array,
|
||||||
|
@ -178,6 +178,7 @@ export const FilterMenuProps = {
|
||||||
prefixCls: PropTypes.string,
|
prefixCls: PropTypes.string,
|
||||||
dropdownPrefixCls: PropTypes.string,
|
dropdownPrefixCls: PropTypes.string,
|
||||||
getPopupContainer: PropTypes.func,
|
getPopupContainer: PropTypes.func,
|
||||||
|
handleFilter: PropTypes.func,
|
||||||
}
|
}
|
||||||
|
|
||||||
// export interface FilterMenuState {
|
// export interface FilterMenuState {
|
||||||
|
|
|
@ -3,7 +3,7 @@ const AsyncComp = () => {
|
||||||
const hashs = window.location.hash.split('/')
|
const hashs = window.location.hash.split('/')
|
||||||
const d = hashs[hashs.length - 1]
|
const d = hashs[hashs.length - 1]
|
||||||
return {
|
return {
|
||||||
component: import(`../components/vc-table/demo/${d}`),
|
component: import(`../components/table/demo/${d}`),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export default [
|
export default [
|
||||||
|
|
Loading…
Reference in New Issue