import { Button, Radio, Tooltip, DatePicker, Popconfirm } from "antd"; import React, { useCallback, useEffect, useRef, useState } from "react"; import { ExclamationCircleFilled } from "@ant-design/icons"; import styles from "./index.module.scss"; import dayjs from "dayjs"; import { editWallAutoApi, editWallTypeApi, getWallAutoApi, getWallCategoryoApi, getWallCategoryoListApi, } from "@/store/action/B3Wall"; import { MessageFu } from "@/utils/message"; import WallTable from "./WallTable"; import WallAdd from "./WallAdd"; const { RangePicker } = DatePicker; function Wall() { // 获取自动播放信息 const getWallAutoApiFu = useCallback(async () => { const res = await getWallAutoApi(); if (res.code === 0) { const data = JSON.parse(res.data.content); setValue0(data.isAuto); setTime0(data.startTime + "," + data.endTime); } }, []); // 获取文物类别展示信息 const getWallCategoryApiFu = useCallback(async () => { const res = await getWallCategoryoApi(); if (res.code === 0) { const data = JSON.parse(res.data.content); console.log(data); setValueType(data.isAuto); setTimeType0(data.startTime + "," + data.endTime); setTypeDisplay(data.type) } }, []); // 获取文物类别列表 const getWallCategoryListApiFu = useCallback(async () => { const res = await getWallCategoryoListApi(); if (res.code === 0) { console.log(res); setTypes(res.data); } }, []); useEffect(() => { getWallAutoApiFu(); getWallCategoryApiFu(); getWallCategoryListApiFu(); }, [getWallAutoApiFu, getWallCategoryApiFu, getWallCategoryListApiFu]); // 场景管理的编辑 const [edit, setEdit] = useState(false); // 自动轮播开启关闭的展示 const [value0, setValue0] = useState(-1); // 自动轮播开启关闭的修改 const [value1, setValue1] = useState(0); // 自动轮播时间的展示 const [time0, setTime0] = useState(" , "); // 自动轮播时间的修改 const [time1, setTime1] = useState([]); // 场景管理的编辑 const [editType, setEditType] = useState(false); // 文物类型开启关闭的展示 const [valueType, setValueType] = useState(-1); // 文物类型开启关闭的修改 const [value2, setValue2] = useState(0); // 文物类型时间的展示 const [timeType0, setTimeType0] = useState(" , "); // 文物类型时间的修改 const [timeType1, setTimeType1] = useState([]); // 文物类型列表 const [types, setTypes] = useState([]); // 文物类型展示 const [typeDisplay, setTypeDisplay] = useState([]); // 文物类型修改 const [typeEdit, setTypeEdit] = useState([]); // 点击修改(海报/场景) const editAutoPlay = useCallback(() => { setValue1(value0); setTime1(time0.split(",")); setEdit(true); }, [time0, value0]); // 点击修改(文物类别) const editTypeFu = useCallback(() => { setValue2(valueType); setTimeType1(timeType0.split(",")); setEditType(true); }, [timeType0, valueType]); // 时间选择器改变 const timeChange = (date: any, dateString: any) => { setTime1(dateString); }; // 时间选择器改变 const timeTypeChange = (date: any, dateString: any) => { setTimeType1(dateString); console.log(dateString); }; // 点击确定 (海报/场景) const btnOk = useCallback(async () => { const obj = { endTime: time1[1], startTime: time1[0], isAuto: value1, }; const res: any = await editWallAutoApi({ content: JSON.stringify(obj) }); if (res.code === 0) { MessageFu.success("修改成功!"); getWallAutoApiFu(); } setEdit(false); }, [getWallAutoApiFu, time1, value1]); // 点击确定 (类别) const btnOkType = useCallback(async () => { const obj = { endTime: timeType1[1], startTime: timeType1[0], isAuto: value2, type: typeEdit }; const res: any = await editWallTypeApi({ content: JSON.stringify(obj) }); if (res.code === 0) { MessageFu.success("修改成功!"); getWallCategoryApiFu(); } setEditType(false); }, [getWallCategoryApiFu, timeType1, typeEdit, value2]); // 点击新增或者编辑 const [editId, setEditId] = useState(0); const scrollRef = useRef({ txt: "", num: 0, }); const tablePageIdFu = useCallback((id: number, scrollNum: number) => { scrollRef.current = { ...scrollRef.current, num: scrollNum }; setEditId(id); }, []); // 新增海报 const editTableFu = useCallback(() => { // 获取当前表格的滚动位置 const dom: any = document.querySelector("#wallTable .ant-table-body"); tablePageIdFu(-1, dom.scrollTop); }, [tablePageIdFu]); // 从新增/编辑页面点击取消或者提交 const closeWallAddFu = useCallback((txt: string) => { scrollRef.current = { ...scrollRef.current, txt }; setEditId(0); }, []); return (
{editId === 0 ? "万物墙管理" : editId > 0 ? "编辑海报" : "新增海报"}
{editId === 0 ? ( // 初始页面盒子 <>
海报展示管理 {/*
*/}
{edit ? ( // 修改信息
自动轮播:
setValue1(e.target.value)} value={value1} > 关闭 开启 setEdit(false)} >
) : ( // 展示信息
自动轮播:
{value0 ? "开启" : "关闭"} | 
{time0.split(",")[0]} 至 {time0.split(",")[1]}
  
)} {/* 表格相关 */}
文物按类别展示
{editType ? ( // 修改信息
展示日期:
setValue2(e.target.value)} value={value2} > 关闭 开启 setEditType(false)} >
展示类别:
setTypeEdit(e.target.value)} value={typeEdit} > {types.map((item) => { return ( {item} ); })}
) : ( // 展示信息
展示日期:
{valueType ? "开启" : "关闭"} | 
{timeType0.split(",")[0]} 至 {timeType0.split(",")[1]}
  
展示类别:
{typeDisplay}
)}
) : ( )}
); } const MemoWall = React.memo(Wall); export default MemoWall;