|
|
@@ -13,15 +13,14 @@ import { DndProvider, useDrag, useDrop } from "react-dnd";
|
|
|
import { HTML5Backend } from "react-dnd-html5-backend";
|
|
|
|
|
|
type Porps = {
|
|
|
- sroolNum: number;
|
|
|
tableType: string;
|
|
|
- editInfoFu: (id: number, num: number) => void;
|
|
|
+ editInfoFu: (id: number) => void;
|
|
|
};
|
|
|
|
|
|
-function NewsTable({ tableType, editInfoFu, sroolNum }: Porps) {
|
|
|
+function NewsTable({ tableType, editInfoFu }: Porps) {
|
|
|
// 有关表格数据
|
|
|
- const results = useSelector(
|
|
|
- (state: RootState) => state.newsReducer.tableInfo
|
|
|
+ const { tableInfo: results, sroolNum } = useSelector(
|
|
|
+ (state: RootState) => state.newsReducer
|
|
|
);
|
|
|
|
|
|
useEffect(() => {
|
|
|
@@ -31,15 +30,6 @@ function NewsTable({ tableType, editInfoFu, sroolNum }: Porps) {
|
|
|
}
|
|
|
}, [sroolNum]);
|
|
|
|
|
|
- // 点击编辑的时候存入当前表格的滚动位置
|
|
|
- const editInfoFuTemp = useCallback(
|
|
|
- (id: number) => {
|
|
|
- const dom: any = document.querySelector("#NewsTable .ant-table-body");
|
|
|
- editInfoFu(id, dom.scrollTop);
|
|
|
- },
|
|
|
- [editInfoFu]
|
|
|
- );
|
|
|
-
|
|
|
const columns = useMemo(() => {
|
|
|
return [
|
|
|
{
|
|
|
@@ -108,7 +98,7 @@ function NewsTable({ tableType, editInfoFu, sroolNum }: Porps) {
|
|
|
<Button
|
|
|
size="small"
|
|
|
type="text"
|
|
|
- onClick={() => editInfoFuTemp(item.id)}
|
|
|
+ onClick={() => editInfoFu(item.id)}
|
|
|
>
|
|
|
编辑
|
|
|
</Button>
|
|
|
@@ -119,7 +109,7 @@ function NewsTable({ tableType, editInfoFu, sroolNum }: Porps) {
|
|
|
),
|
|
|
},
|
|
|
];
|
|
|
- }, [editInfoFuTemp, results.length, tableType]);
|
|
|
+ }, [editInfoFu, results.length, tableType]);
|
|
|
|
|
|
// 表格拖动排序-----------------
|
|
|
interface DraggableBodyRowProps
|