import DraggableResizable from '@/libs/draggable-resizable/index.vue'; import {reactive} from 'vue'; export const columns = [ { title: 'Date', dataIndex: 'date', width: 200 }, { title: 'Amount', dataIndex: 'amount', width: 100 }, { title: 'Type', dataIndex: 'type', width: 100 }, { title: 'Note', dataIndex: 'note', width: 100 }, { title: 'Action', key: 'action', slots: {customRender: 'action'} } ]; const draggingMap = {}; columns.forEach(col => { draggingMap[col.key] = col.width; }); const draggingState = reactive(draggingMap); const DraggableResizable2 = DraggableResizable as any; export default (props, children) => { let thDom = null; const {key, ...restProps} = props; const col = columns.find(col => { const k = col.dataIndex || col.key; return k === key; }); if (!col.width) { return {children}; } const onDrag = x => { draggingState[key] = 0; col.width = Math.max(x, 1); }; const onDragstop = () => { draggingState[key] = thDom.getBoundingClientRect().width; }; return ( thDom = el} width={col.width} class="resize-table-th"> {children} ); };