2018-03-27 11:43:22 +00:00
|
|
|
/* eslint-disable no-console,func-names,react/no-multi-comp */
|
|
|
|
import Table from '../index'
|
|
|
|
import '../assets/index.less'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
|
|
|
data () {
|
|
|
|
return {
|
|
|
|
data: [{ a: '123' }, { a: 'cdd', b: 'edd' }, { a: '1333', c: 'eee', d: 2 }],
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
remove (index) {
|
|
|
|
const rows = this.data
|
|
|
|
rows.splice(index, 1)
|
|
|
|
this.data = rows
|
|
|
|
},
|
|
|
|
|
|
|
|
handleClick (index) {
|
|
|
|
this.remove(index)
|
|
|
|
},
|
|
|
|
|
2018-04-01 04:52:27 +00:00
|
|
|
checkbox (a) {
|
2018-03-27 11:43:22 +00:00
|
|
|
return <label>
|
|
|
|
<input type='checkbox' />
|
|
|
|
{a}
|
|
|
|
</label>
|
|
|
|
},
|
|
|
|
|
2018-04-01 04:52:27 +00:00
|
|
|
renderAction (o, row, index) {
|
2018-03-27 11:43:22 +00:00
|
|
|
return <a href='javascript:;' onClick={() => this.handleClick(index)}>Delete</a>
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
render () {
|
|
|
|
const columns = [
|
2018-04-01 04:52:27 +00:00
|
|
|
{ title: 'title1', dataIndex: 'a', key: 'a', width: 100, customRender: this.checkbox },
|
2018-03-27 11:43:22 +00:00
|
|
|
{ title: 'title2', dataIndex: 'b', key: 'b', width: 100 },
|
|
|
|
{ title: 'title3', dataIndex: 'c', key: 'c', width: 200 },
|
2018-04-01 04:52:27 +00:00
|
|
|
{ title: 'Operations', dataIndex: '', key: 'x', customRender: this.renderAction },
|
2018-03-27 11:43:22 +00:00
|
|
|
]
|
|
|
|
return (
|
|
|
|
<Table columns={columns} data={this.data} class='table' rowKey={record => record.a} />
|
|
|
|
)
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|