outaozhen 3 éve
szülő
commit
90e481505d
1 módosított fájl, 5 hozzáadás és 10 törlés
  1. 5 10
      src/pages/Business/Invoice/index.tsx

+ 5 - 10
src/pages/Business/Invoice/index.tsx

@@ -84,18 +84,15 @@ const Invoice: React.FC = () => {
     {
       dataIndex: 'sort',
       title: '排序',
-      index: 0,
       render: () => <DragHandle />
     },
     {
       dataIndex: 'name',
-      title: '开票内容',
-      index: 1
+      title: '开票内容'
     },
     {
       dataIndex: 'enable',
       title: '状态',
-      index: 2,
       render: enable => (
         <span className={classNames({ 'text-red-500': enable === 'close' })}>
           {isEnableEnum[enable]}
@@ -105,7 +102,6 @@ const Invoice: React.FC = () => {
     {
       dataIndex: 'opreate',
       title: '操作',
-      index: 3,
       render: (_, record) => (
         <div className="divide-x divide-bg-gray-400 flex flex-row">
           <div
@@ -155,13 +151,13 @@ const Invoice: React.FC = () => {
   ]
 
   const onSortEnd = ({ oldIndex, newIndex }) => {
-    const { dataSource } = state.dataSource
+    const { dataSource } = state
     if (oldIndex !== newIndex) {
       const newData = arrayMoveImmutable([].concat(dataSource), oldIndex, newIndex).filter(
         el => !!el
       )
       console.log('Sorted items: ', newData)
-      setState({ dataSource: newData })
+      setState({ ...state, dataSource: newData })
     }
   }
 
@@ -176,10 +172,9 @@ const Invoice: React.FC = () => {
   )
 
   const DraggableBodyRow = ({ ...restProps }) => {
-    const { dataSource } = state.dataSource
+    const { dataSource } = state
     // function findIndex base on Table rowKey props and should always be a right array index
     const index = dataSource?.findIndex(x => x.index === restProps['data-row-key'])
-    console.log({ ...restProps })
     return <SortableItem index={index} {...restProps} />
   }
 
@@ -205,7 +200,7 @@ const Invoice: React.FC = () => {
               <Table
                 pagination={false}
                 columns={mainColumns}
-                dataSource={state.dataSource}
+                dataSource={state.dataSource.map((item, index) => index)}
                 components={{
                   body: {
                     wrapper: DraggableContainer,