/* eslint-disable no-console,func-names,react/no-multi-comp */
import Table from '../index'
import '../assets/index.less'
import BaseMixin from '../../_util/BaseMixin'
const ResizeableTitle = (h, props, children) => {
console.log(props)
const { width, ...restProps } = props
if (!width) {
return
{children} |
}
return (
{children} |
)
}
export default {
mixins: [BaseMixin],
data () {
return {
columns: [
{ title: 'title1', dataIndex: 'a', key: 'a', width: 100 },
{ id: '123', title: 'title2', dataIndex: 'b', key: 'b', width: 100 },
{ title: 'title3', dataIndex: 'c', key: 'c', width: 200 },
{
title: 'Operations', dataIndex: '', key: 'd', customRender: () => {
return Operations
},
},
],
data: [
{ a: '123', key: '1' },
{ a: 'cdd', b: 'edd', key: '2' },
{ a: '1333', c: 'eee', d: 2, key: '3' },
],
components: {
header: {
cell: ResizeableTitle,
},
},
}
},
methods: {
handleResize (index) {
return (e, { size }) => {
this.setState(({ columns }) => {
const nextColumns = [...columns]
nextColumns[index] = {
...nextColumns[index],
width: size.width,
}
return { columns: nextColumns }
})
}
},
},
render () {
const columns = this.columns.map((col, index) => ({
...col,
customHeaderCell: (column) => ({
props: {
width: column.width,
},
on: {
resize: this.handleResize(index),
},
}),
}))
return (
Integrate with react-resizable
)
},
}