|
|
@@ -3,7 +3,7 @@ import VideoLook from "@/components/VideoLook";
|
|
|
import { RootState } from "@/store";
|
|
|
import { NewsTableType } from "@/types";
|
|
|
import { Button, Table, Tooltip } from "antd";
|
|
|
-import React, { useCallback, useMemo, useRef } from "react";
|
|
|
+import React, { useCallback, useEffect, useMemo, useRef } from "react";
|
|
|
import { useSelector } from "react-redux";
|
|
|
import { ExclamationOutlined } from "@ant-design/icons";
|
|
|
import styles from "./index.module.scss";
|
|
|
@@ -13,16 +13,33 @@ import { DndProvider, useDrag, useDrop } from "react-dnd";
|
|
|
import { HTML5Backend } from "react-dnd-html5-backend";
|
|
|
|
|
|
type Porps = {
|
|
|
+ sroolNum: number;
|
|
|
tableType: string;
|
|
|
- editInfoFu: (id: number) => void;
|
|
|
+ editInfoFu: (id: number, num: number) => void;
|
|
|
};
|
|
|
|
|
|
-function NewsTable({ tableType, editInfoFu }: Porps) {
|
|
|
+function NewsTable({ tableType, editInfoFu, sroolNum }: Porps) {
|
|
|
// 有关表格数据
|
|
|
const results = useSelector(
|
|
|
(state: RootState) => state.newsReducer.tableInfo
|
|
|
);
|
|
|
|
|
|
+ useEffect(() => {
|
|
|
+ if (sroolNum > 0) {
|
|
|
+ const dom: any = document.querySelector("#NewsTable .ant-table-body");
|
|
|
+ dom.scrollTop = sroolNum;
|
|
|
+ }
|
|
|
+ }, [sroolNum]);
|
|
|
+
|
|
|
+ // 点击编辑的时候存入当前表格的滚动位置
|
|
|
+ const editInfoFuTemp = useCallback(
|
|
|
+ (id: number) => {
|
|
|
+ const dom: any = document.querySelector("#NewsTable .ant-table-body");
|
|
|
+ editInfoFu(id, dom.scrollTop);
|
|
|
+ },
|
|
|
+ [editInfoFu]
|
|
|
+ );
|
|
|
+
|
|
|
const columns = useMemo(() => {
|
|
|
return [
|
|
|
{
|
|
|
@@ -50,7 +67,7 @@ function NewsTable({ tableType, editInfoFu }: Porps) {
|
|
|
tableType === "news"
|
|
|
? "正文"
|
|
|
: tableType === "video"
|
|
|
- ? "视频封面"
|
|
|
+ ? "视频"
|
|
|
: "图片",
|
|
|
render: (item: NewsTableType) => {
|
|
|
if (tableType === "news") {
|
|
|
@@ -91,7 +108,7 @@ function NewsTable({ tableType, editInfoFu }: Porps) {
|
|
|
<Button
|
|
|
size="small"
|
|
|
type="text"
|
|
|
- onClick={() => editInfoFu(item.id)}
|
|
|
+ onClick={() => editInfoFuTemp(item.id)}
|
|
|
>
|
|
|
编辑
|
|
|
</Button>
|
|
|
@@ -102,7 +119,7 @@ function NewsTable({ tableType, editInfoFu }: Porps) {
|
|
|
),
|
|
|
},
|
|
|
];
|
|
|
- }, [editInfoFu, results.length, tableType]);
|
|
|
+ }, [editInfoFuTemp, results.length, tableType]);
|
|
|
|
|
|
// 表格拖动排序-----------------
|
|
|
interface DraggableBodyRowProps
|
|
|
@@ -185,7 +202,7 @@ function NewsTable({ tableType, editInfoFu }: Porps) {
|
|
|
);
|
|
|
|
|
|
return (
|
|
|
- <div className={styles.NewsTable}>
|
|
|
+ <div className={styles.NewsTable} id="NewsTable">
|
|
|
<DndProvider backend={HTML5Backend}>
|
|
|
<Table
|
|
|
scroll={{ y: 615 }}
|