import './index.css';
// import { MouseEvent, Reducer, useEffect, useReducer, useState, useContext } from "react";
import { MouseEvent, Reducer, useEffect, useReducer, useState } from "react";
import { useSelector, useDispatch } from 'react-redux'
import { useNavigate, useSearchParams, Outlet } from "react-router-dom";
import { Modal } from 'antd';
import { IMenuListItem, IMenuWithTopButton } from "../../interfaces/menu/IMenuWithTopButton.ts";
import MenuWithTopButton from "../../components/menu/MenuWithTopButton.tsx";
import RefunModal from '../../components/RefunModal/RefunModal.tsx'
import CorrectionModal from '../../components/CorrectionModal/CorrectionModal.tsx'
import ContractModal from '../../components/ContractModal/ContractModal.tsx'
// import MenuWithBottomButtom from '../../components/menu/MenuWithBottomButton.tsx'
// import MenuTreeWithTopButton from "../../components/menu/MenuTreeWithTopButton.tsx";
// import ListProj from "../../components/list/ListProj.tsx";
// import ListProjAgent from "../../components/list/ListProjAgent.tsx";
// import { getMenuActive } from '../../util/cache.ts'
import {
    MenuProps, Select,
    Button,
    Pagination,
    Empty
} from 'antd';
import {
    IndexListContext,
    IndexListDataType,
    IndexListDispatchContext,
    ListAction,
    ListData,
} from "../../context/IndexListContext.ts";
// import { getMenuActive } from '../../util/cache.ts'
import {
    MenuFoldOutlined,
    ClearOutlined,
    CloseOutlined
} from '@ant-design/icons';
import { useLocation } from 'react-router-dom';
import { get, downloadUrl, post, getCouponUrl } from '../../util/AjaxUtils.ts'
import { setMenuActive } from '../../util/cache.ts'
import gpsImg from '../../static/right/gps.png'
import backImg from '../../static/right/back.png'
// import { Link } from "react-router-dom";
import HeadCouponModal from '../../components/CouponModal/HeadCouponModal.tsx'
import {
    Input,
    // Breadcrumb,
    message
} from 'antd';
const { Search } = Input;



export default function Index() {
    // 是否可以点击所属者 (当点击了退款选项,所属者列表跟他不产生联系 不给他点)
    // const [clickBelongpeople, setClickBelongpeople] = useState(true)
    // 补正搜索条件标签数组
    const [tagCorArray, setTagCorArray] = useState([])
    // 获取补正标签
    const getCorTag = () => {
        get({
            messageApi,
            url: `/api/proj/correction/apply/tag/list-tag`,
            onBefore() {

            },
            onSuccess(data: any) {
                // console.log('标签信息', data);
                const newarrty: any = (data.data).map((item: any) => ({
                    value: item.key,
                    label: item.value
                }));
                // console.log('标签信息', newarrty);

                setTagCorArray(newarrty)

            },
            onFinally() {

            }
        })
    }
    // 选择的标签
    const [tagCor, setTagCor] = useState<string | null>(null)


    // 选项数组
    const [tagArray, setTagArray] = useState([])

    // const[tagNot,setTagNot] = useState(false)
    // 获取标签
    const getTag = () => {
        get({
            messageApi,
            url: `/api/proj/tag/list-tag`,
            onBefore() {

            },
            onSuccess(data: any) {
                // console.log('标签信息', data);
                const newarrty: any = (data.data).map((item: any) => ({
                    value: item.key,
                    label: item.value
                }));
                // console.log('标签信息', newarrty);

                setTagArray(newarrty)

            },
            onFinally() {

            }
        })
    }
    // 提示数组
    const [remindTagArray, setRemindTagArray] = useState([])
    // 获取提示
    const getremindTag = () => {
        get({
            messageApi,
            url: `/api/proj/remind/list`,
            onBefore() {

            },
            onSuccess(data: any) {
                // console.log('标签信息', data.data);
                const newarrty: any = (data.data).map((item: any) => ({
                    value: item.projRemindId,
                    label: item.title
                }));
                // console.log('标签信息', newarrty);

                setRemindTagArray(newarrty)

            },
            onFinally() {

            }
        })
    }
    const dispath = useDispatch()
    //redux的belongArray
    const redxuState: any = useSelector(state => state)
    const belongArray = redxuState.belongArray
    // 优惠券弹窗
    const couponModal = redxuState.couponModal

    // 编辑项目得项目名
    // const projName = redxuState.projName
    // 从sessionStorage缓存获取项目名
    const projName = sessionStorage.getItem('projName')
    // 项目状态 查看还是编辑
    // const projStatus = redxuState.projStatus
    const projStatus = sessionStorage.getItem('projStatus')
    // 获取所属者表格储存至redux 更新表格
    const getProjOwnerList = () => {
        get({
            messageApi,
            url: `/api/proj-owner/list/self`,
            onBefore() {

            },
            onSuccess(data: any) {
                // console.log('所属者表格', data.data);
                // setBelongPeopleArray(data.data)
                // 存redux的belongArray
                dispath({
                    type: 'uparray',
                    val: data.data
                })
            },
            onFinally() {

            }
        })
    }

    // 更新数据
    // const upBelongArray = () => {
    //     get({
    //         messageApi,
    //         url: `/api/proj-owner/list/self`,
    //         onBefore() {

    //         },
    //         onSuccess(data: any) {
    //             // console.log('所属者表格', data.data);
    //             setBelongPeopleArray(data.data)

    //         },
    //         onFinally() {

    //         }
    //     })
    // }
    // 监听redux的belongArray
    // useEffect(()=>{
    // },[belongArray])

    const [messageApi, contextHolder] = message.useMessage();
    // 临时关键字 (过度)
    const [nowKeyword, setNowKeyWord] = useState('')
    // 关键字
    const [keywords, setKeywords] = useState('');
    const [type, setType] = useState<string | null>(null)
    const [chargeAdditionals, setchargeAdditionals] = useState<string | null>(null)
    const [tagDataId, settagDataId] = useState<string | null>(null)
    const [payStatus, setpayStatus] = useState<string | null>(null)
    const [authorId, setauthorId] = useState('')
    const [projRemindId, setprojRemindId] = useState<string | null>(null)
    //退款状态
    const [applyStatus, setapplyStatus] = useState<string | null>(null)
    // 退款关键字
    const [refunKeywords, setrefunKeywords] = useState('')
    // 退款临时关键字
    const [newRefunValue, setnewRefunValue] = useState('')
    //补正搜索相关
    // 补正关键字
    const [correctionKeywords, setcorrectionKeywords] = useState('')
    // 补正临时关键字
    const [newCorrectionValue, setnewCorrectionValue] = useState('')
    // 补正类型
    const [correctionNumType, setcorrectionNumType] = useState<string | null>(null)
    // 补正种类
    const [correctionType, setcorrectionType] = useState<string | null>(null)
    // 补正状态
    const [correctionApplyStatus, setcorrectionApplyStatus] = useState<string | null>(null)
    // const indexListContext = useContext(IndexListContext);
    // 所属者信息
    // const [belongPeopleArray, setBelongPeopleArray] = useState<any[]>([])
    const [currentPage, setCurrentPage] = useState(1);
    const itemsPerPage = 5;
    // 计算总页数
    const totalItems = belongArray.length;
    const totalPages = Math.ceil(totalItems / itemsPerPage);

    // 计算当前页数据的起始和结束索引
    const startIndex = (currentPage - 1) * itemsPerPage;
    const endIndex = Math.min(startIndex + itemsPerPage, totalItems);

    // 提取当前页的数据
    const currentPageData = belongArray.slice(startIndex, endIndex);

    // 处理页码切换
    const handlePageChange = (page: number) => {
        if (page >= 1 && page <= totalPages) {
            setCurrentPage(page);
        }
    };
    const nav = useNavigate();
    // // home页初始化搜索条件
    const init = () => {
        setNowKeyWord('')
        setKeywords('')
        setType(null)
        setchargeAdditionals(null)
        settagDataId(null)
        setpayStatus(null)
        setprojRemindId(null)
        nav('/home')
    }
    //  退款页初搜索条件始化
    const refunInit = () => {
        setnewRefunValue('')
        setrefunKeywords('')
        setapplyStatus(null)
        // 刷新当前页面
       
    }
    // 补正页面搜索条件初始化
    const correctionInit = () => {
        setnewCorrectionValue('')
        setcorrectionKeywords('')
        setcorrectionNumType(null)
        setcorrectionType(null)
        setcorrectionApplyStatus(null)
        setTagCor(null)
    }

    const [searchParams] = useSearchParams();

    const listReducer = (state: ListData, action: ListAction) => {
        if (action.type == IndexListDataType.PROJ) {
            state.type = IndexListDataType.PROJ;
            state.status = action.value as string;
        } else if (action.type == IndexListDataType.AGENT) {
            state.type = IndexListDataType.AGENT;
            state.status = action.value as string;
        } else if (action.type == IndexListDataType.CATEGORY) {
            state.categorys = action.value as MenuProps['items'];
            state.categoryChangeCount++;
        } else if (action.type == IndexListDataType.CATEGORY_CHANGE) {
            state.category = action.value as string;
            state.categoryChangeCount++;
        } else if (action.type == IndexListDataType.CATEGORY_DELETE) {
            state.categorys = action.value as MenuProps['items'];
            state.category = '';
            state.categoryChangeCount++;
        }
        return {
            ...state
        };
    }

    const [listData, dispatch] = useReducer<Reducer<ListData, ListAction>>(listReducer, {
        type: IndexListDataType.PROJ,
        categoryChangeCount: 0
    });

    const [projMenu, setProjMenu] = useState<IMenuWithTopButton>({
        button: {
            name: '项目',
            handle() {
                dispatch({
                    type: IndexListDataType.PROJ,
                    value: 'ALL',
                })
                init()
                setauthorId('')
                // nav('/home')
                nav('/proj-create')

            }
        },
        list: [
            { id: 'ALL', name: '全部项目', active: true },
            { id: 'PROCESSING', name: '进行中的' },
            { id: 'COMPLETE', name: '已完成的' },
            { id: 'REFUN', name: '退款项目' },
            // correction
            { id: 'CORRECTION', name: '补正项目' },
            { id: 'CONTRACT', name: '合同下载' },

        ],
        handleListItem(_e, _index, item: IMenuListItem) {
            projMenu.list.forEach(item => item.active = false);
            sellMenu.list.forEach(item => item.active = false);
            buyMenu.list.forEach(item => item.active = false);
            refundMenu.list.forEach(item => item.active = false);
            correctionMenu.list.forEach(item => item.active = false);
            item.active = true;
            setProjMenu({
                ...projMenu
            })
            dispatch({
                type: IndexListDataType.PROJ,
                value: item.id,
                // keywords: ''

            })
        },

    });
    const [refunModal, setRefunModal] = useState(false) //退款弹窗
    const [refundMenu, setRefundMenu] = useState<IMenuWithTopButton>({
        button: {
            name: '',
            handle() {
                // nav('/proj-create')
            }
        },
        list: [
            { id: 'PENDING', name: '待审核', },
            { id: 'APPROVED', name: '已通过' },
            { id: 'REJECTED', name: '未通过' },
            { id: 'CANCELED', name: '已取消' }

        ],
        handleListItem(_e, _index, item: IMenuListItem) {
            projMenu.list.forEach(item => item.active = false);
            sellMenu.list.forEach(item => item.active = false);
            buyMenu.list.forEach(item => item.active = false);
            refundMenu.list.forEach(item => item.active = false);
            correctionMenu.list.forEach(item => item.active = false);

            item.active = true;
            setRefundMenu({
                ...refundMenu
            })
            dispatch({
                type: IndexListDataType.PROJ,
                value: item.id,
                // keywords: ''

            })
        },

    });

    // 补正弹窗
    const [correctionModal, setCorrectionModal] = useState(false)
    const [correctionMenu, setCorrectionMenu] = useState<IMenuWithTopButton>({
        button: {
            name: '补正',
            handle() {
                // nav('/proj-create')
                setCorrectionModal(true)
            }
        },
        list: [
            { id: 'Correction-PENDING', name: '待审核', },
            { id: 'Correction-APPROVED', name: '已通过' },
            { id: 'Correction-REJECTED', name: '未通过' },
            { id: 'Correction-CANCELED', name: '已取消' }
        ],
        handleListItem(_e, _index, item: IMenuListItem) {
            projMenu.list.forEach(item => item.active = false);
            sellMenu.list.forEach(item => item.active = false);
            buyMenu.list.forEach(item => item.active = false);
            refundMenu.list.forEach(item => item.active = false);
            correctionMenu.list.forEach(item => item.active = false);
            item.active = true;
            setCorrectionMenu({
                ...correctionMenu
            })
            dispatch({
                type: IndexListDataType.PROJ,
                value: item.id,
                // keywords: ''

            })
        },
    })

    // 新增合同弹窗
    const [contractModal, setContractModal] = useState(false)
    // const [agentMenu, setAgentMenu] = useState<IMenuWithTopButton>({
    //     button: {
    //         name: '代理服务',
    //         handle() {
    //             dispatch({
    //                 type: IndexListDataType.PROJ,
    //                 value: 'COMPLETE',
    //             })
    //         }
    //     },
    //     list: [
    //         { id: 'ALL', name: '全部项目' },
    //         { id: 'PROCESSING', name: '进行中的' },
    //         { id: 'COMPLETE', name: '已完成的' },
    //     ],
    //     handleListItem(_e: MouseEvent<HTMLLIElement>, _index: number, item: IMenuListItem) {
    //         projMenu.list.forEach(item => item.active = false);
    //         agentMenu.list.forEach(item => item.active = false);
    //         item.active = true;
    //         setAgentMenu({
    //             ...agentMenu
    //         })
    //         dispatch({
    //             type: IndexListDataType.AGENT,
    //             value: item.id,

    //         })
    //     }
    // })
    const [sellMenu, setSellMenu] = useState<IMenuWithTopButton>({
        button: {
            name: '我要卖',
            handle() {
                // dispatch({
                //     type: IndexListDataType.PROJ,
                //     value: 'COMPLETE',
                // })
            }
        },
        list: [
            { id: '1', name: '商品发布', path: '/product-release' },
            { id: '2', name: '交易订单', path: '/transaction-order' },
            // { id: 'COMPLETE', name: '已完成的' },
        ],
        handleListItem(_e: MouseEvent<HTMLLIElement>, _index: number, item: IMenuListItem) {
            projMenu.list.forEach(item => item.active = false);
            sellMenu.list.forEach(item => item.active = false);
            buyMenu.list.forEach(item => item.active = false);
            refundMenu.list.forEach(item => item.active = false);
            correctionMenu.list.forEach(item => item.active = false);
            item.active = true;
            setSellMenu({
                ...sellMenu
            })
            // dispatch({
            //     type: IndexListDataType.AGENT,
            //     value: item.id,

            // })
        }
    })
    const [buyMenu, setBuyMenu] = useState<IMenuWithTopButton>({
        button: {
            name: '我要买',
            handle() {
                // dispatch({
                //     type: IndexListDataType.PROJ,
                //     value: 'COMPLETE',
                // })
            }
        },
        list: [
            { id: '1', name: '著作权商品', path: '/copyright-goods' },
            { id: '2', name: '交易商品', path: '/trading-goods' },
            // { id: 'COMPLETE', name: '已完成的' },
        ],
        handleListItem(_e: MouseEvent<HTMLLIElement>, _index: number, item: IMenuListItem) {
            projMenu.list.forEach(item => item.active = false);
            sellMenu.list.forEach(item => item.active = false);
            buyMenu.list.forEach(item => item.active = false);
            refundMenu.list.forEach(item => item.active = false);
            correctionMenu.list.forEach(item => item.active = false);
            item.active = true;
            setBuyMenu({
                ...buyMenu
            })
            // dispatch({
            //     type: IndexListDataType.AGENT,
            //     value: item.id,

            // })
        }
    })
    // const [refund, setRefund] = useState<IMenuWithTopButton>({
    //     button: {
    //         name: '退款',
    //         handle() {
    //             // dispatch({
    //             //     type: IndexListDataType.PROJ,
    //             //     value: 'COMPLETE',
    //             // })
    //         }
    //     },
    //     list: [
    //         { id: '1', name: '待审核', path: '/copyright-goods?item=1' },
    //         { id: '2', name: '已通过', path: '/copyright-goods?item=2' },
    //         { id: '3', name: '未通过', path: '/copyright-goods?item=3' },
    //         // { id: 'COMPLETE', name: '已完成的' },
    //     ],
    //     handleListItem(_e: MouseEvent<HTMLLIElement>, _index: number, item: IMenuListItem) {
    //         projMenu.list.forEach(item => item.active = false);
    //         // sellMenu.list.forEach(item => item.active = false);
    //         // buyMenu.list.forEach(item => item.active = false);
    //         item.active = true;
    //         setRefund({
    //             ...refund
    //         })
    //         // dispatch({
    //         //     type: IndexListDataType.AGENT,
    //         //     value: item.id,

    //         // })
    //     }
    // })
    const location = useLocation()
    const [now, setNow] = useState<string>('首页 / 项目')
    // 编辑项目路由名
    // const [editname,setEditname] = useState('')
    // 新建项目路由名字
    // const [newname,setNewname] = useState('')

    // const [pathArray, setPathArray] = useState<any>([])
    const [showSearchBox, setShowSearchBox] = useState(true)
    const [refunSearchBox, setRrefunSearchBox] = useState(false)
    const [correctionSearchBox, setCorrectionSearchBox] = useState(false)
    // 新增合同按钮是否显示
    const [contractSearchBox, setContractSearchBox] = useState(false)
    // 优惠券遮罩层是否i西安市
    const [coupon, setCoupon] = useState(false)
    // 获取优惠券弹出层是否显示 
    const [getCouponModal, setGetCouponModal] = useState(false)
    // 优惠券数组
    const [couponArray, setCouponArray] = useState<any>([])
    //优惠券id
    const [couponId, setCouponId] = useState('')
    // 优惠券图片   const imgSrc = `${Axios.defaults?.baseURL}/route/file/v2/download/true/${data.data.couponId}`;
    const [cpuponImg, setCouponImg] = useState('')
    // 获取是否有优惠券信息
    const getCoupon = () => {
        get({
            messageApi,
            url: `/api/coupon/list-can-claim`,
            // url: `/api/proj/refund/apply/listpage?applyStatus=${state.type}`,
            config: {
                params: {

                }
            },
            onBefore() {

            },
            onSuccess(data: any) {
                // console.log(data.data);
                // if (data.data.couponId) {
                //     setCouponId(data.data.couponId)
                //     setCouponImg(data.data.logo)
                //     setCoupon(true)
                // }
                setCouponArray(data.data)
                if (data.data.length == 1) {
                    setCouponId((data.data)[0].couponId)
                    setCouponImg((data.data)[0].logo)
                    setCoupon(true)
                }
                if (data.data.length > 1) {
                    setGetCouponModal(true)
                }

            },
            onFinally() {

            },
        })
    }
    // 领取优惠券单张
    const receiveCoupon = () => {
        post<any>({
            messageApi,
            url: `/api/coupon/user/save`,
            body: {
                couponId: couponId
            },
            onBefore() {

            },
            onSuccess() {
                messageApi.success('领取成功')
                setTimeout(() => {
                    setCoupon(false)
                    // getCoupon()
                }, 500)
            },
            onFinally() {

            }
        })
    }
    // 领取优惠券(多张)
    const receiveCoupons = (id: string) => {
        post<any>({
            messageApi,
            url: `/api/coupon/user/save`,
            body: {
                couponId: id
            },
            onBefore() {

            },
            onSuccess() {
                messageApi.success('领取成功')
                //更新列表
                get({
                    messageApi,
                    url: `/api/coupon/list-can-claim`,
                    // url: `/api/proj/refund/apply/listpage?applyStatus=${state.type}`,
                    config: {
                        params: {

                        }
                    },
                    onBefore() {

                    },
                    onSuccess(data: any) {
                        setCouponArray(data.data)
                        if (data.data.length == 0) {
                            setTimeout(() => {
                                setGetCouponModal(false)
                                // getCoupon()
                            }, 500)
                        }

                    },
                    onFinally() {

                    },
                })
            },
            onFinally() {

            }
        })
    }
    useEffect(() => {
        // const nowname = sessionStorage.getItem('now')
        if (location.pathname == '/') {
            // setCoupon(true)
            getCoupon()
        }

        if (location.pathname.includes('/home')) {
            // setCoupon(true)
            getCoupon()
            setNow('首页 / 项目')
            // setPathArray([{ title: '首页' }])
            setShowSearchBox(true)
            // setClickBelongpeople(true)
            setRrefunSearchBox(false)
            setContractSearchBox(false)
            setCorrectionSearchBox(false)
        } else if (location.pathname.includes('/proj-create')) {
            setShowSearchBox(false)
            setRrefunSearchBox(false)
            setCorrectionSearchBox(false)
            setContractSearchBox(false)
            setNow('创建项目')
            // setPathArray([{ title: <Link to={'/home'}>首页</Link> }, { title: '创建项目' }])
            // /config-mod-list    /config-menu-list /config-mod-show
        } else if (location.pathname.includes('/proj-edit') && !location.pathname.includes('/config-mod-show') && !location.pathname.includes('/config-mod-edit') && !location.pathname.includes('/step') && !location.pathname.includes('/config-loginpage') && !location.pathname.includes('/config-mod-save') && !location.pathname.includes('/config-mod-list') && !location.pathname.includes('/config-menu-list')) {
            setNow(`${projStatus}项目 / ${projName}`)
            setShowSearchBox(false)
            setRrefunSearchBox(false)
            setCorrectionSearchBox(false)
            setContractSearchBox(false)
            // setEditname(location.pathname)
            // setPathArray([{ title: <Link to={'/home'}>首页</Link> }, { title: '编辑项目' }])
        } else if (location.pathname.includes('/proj-new')) {
            setNow(`创建项目`)
            setShowSearchBox(false)
            setRrefunSearchBox(false)
            setCorrectionSearchBox(false)
            setContractSearchBox(false)
            // setNewname(location.pathname)
            // setPathArray([{ title: <Link to={'/home'}>首页</Link> }, { title: <Link to={'/proj-create'}>创建项目</Link> }, { title: '新建项目' }])
        } else if (location.pathname.includes('/proj-efree')) {
            setNow(`${projStatus}项目 / ${projName}`)
            setShowSearchBox(false)
            setRrefunSearchBox(false)
            setCorrectionSearchBox(false)
            setContractSearchBox(false)
            // setNewname(location.pathname)
            // setPathArray([{ title: <Link to={'/home'}>首页</Link> }, { title: '编辑项目' }])
        } else if (location.pathname.includes('/proj-eall')) {
            setNow(`${projStatus}项目 / ${projName}`)
            setShowSearchBox(false)
            setRrefunSearchBox(false)
            setCorrectionSearchBox(false)
            setContractSearchBox(false)
            // setNewname(location.pathname)
            // setPathArray([{ title: <Link to={'/home'}>首页 </Link> }, { title: '编辑项目' }])
        } else if (location.pathname.includes('/proj-edit/step1')) {
            setNow('标题简介')
            setShowSearchBox(false)
            setRrefunSearchBox(false)
            setCorrectionSearchBox(false)
            setContractSearchBox(false)
            // setNewname(location.pathname)
            // setPathArray([{ title: <Link to={'/home'}>首页</Link> }, { title: <Link to={'/proj-create'}>创建项目</Link> }, { title: <a onClick={() => { nav(-1) }}>编辑项目</a> }, { title: '标题简介' }])
        } else if (location.pathname.includes('/proj-edit/step2')) {
            setNow('标题简介')
            setShowSearchBox(false)
            setRrefunSearchBox(false)
            setCorrectionSearchBox(false)
            setContractSearchBox(false)
            // setNewname(location.pathname)
            // setPathArray([{ title: <Link to={'/home'}>首页</Link> }, { title: <Link to={'/proj-create'}>创建项目</Link> }, { title: <a onClick={() => { nav(-1) }}>编辑项目</a> }, { title: '基本信息' }])
        } else if (location.pathname.includes('/proj-edit/config-loginpage')) {
            setNow('登录界面设置')
            setShowSearchBox(false)
            setRrefunSearchBox(false)
            setCorrectionSearchBox(false)
            setContractSearchBox(false)
            // setNewname(location.pathname)
            // setPathArray([{ title: <Link to={'/home'}>首页</Link> }, { title: <Link to={'/proj-create'}>创建项目</Link> }, { title: <a onClick={() => { nav(-1) }}>编辑项目</a> }, { title: '登录界面设置' }])
        } else if (location.pathname.includes('/proj-edit/config-mod-list')) {
            setNow('系统菜单管理')
            setShowSearchBox(false)
            setRrefunSearchBox(false)
            setCorrectionSearchBox(false)
            setContractSearchBox(false)
            // setNewname(location.pathname)
            // setPathArray([{ title: <Link to={'/home'}>首页</Link> }, { title: <Link to={'/proj-create'}>创建项目</Link> }, { title: <a onClick={() => { nav(-1) }}>编辑项目</a> }, { title: '系统菜单管理' }])
        } else if (location.pathname.includes('/proj-edit/config-menu-list')) {
            setNow('系统菜单顺序')
            setShowSearchBox(false)
            setRrefunSearchBox(false)
            setCorrectionSearchBox(false)
            setContractSearchBox(false)
            // setNewname(location.pathname)
            // setPathArray([{ title: <Link to={'/home'}>首页</Link> }, { title: <Link to={'/proj-create'}>创建项目</Link> }, { title: <a onClick={() => { nav(-1) }}>编辑项目</a> }, { title: '系统菜单顺序' }])
        } else if (location.pathname.includes('/step3')) {
            setNow('软件功能特点')
            setShowSearchBox(false)
            setRrefunSearchBox(false)
            setCorrectionSearchBox(false)
            setContractSearchBox(false)
            // setNewname(location.pathname)
            // setPathArray([{ title: <Link to={'/home'}>首页</Link> }, { title: <Link to={'/proj-create'}>创建项目</Link> }, { title: <a onClick={() => { nav(-1) }}>编辑项目</a> }, { title: '软件功能特点' }])
        } else if (location.pathname.includes('/proj-edit/config-mod-save')) {
            setNow('添加菜单')
            setShowSearchBox(false)
            setRrefunSearchBox(false)
            setCorrectionSearchBox(false)
            setContractSearchBox(false)
            // setPathArray([{ title: <Link to={'/home'}>首页</Link> }, { title: <Link to={'/proj-create'}>创建项目</Link> }, { title: <a onClick={() => { nav(-1) }}>编辑项目</a> }, { title: '添加菜单' }])
        } else if (location.pathname.includes('/proj-edit/config-mod-edit')) {
            setNow('编辑菜单')
            setShowSearchBox(false)
            setRrefunSearchBox(false)
            setCorrectionSearchBox(false)
            setContractSearchBox(false)
            // setPathArray([{ title: <Link to={'/home'}>首页</Link> }, { title: <Link to={'/proj-create'}>创建项目</Link> }, { title: <a onClick={() => { nav(-2) }}>编辑项目</a> }, { title: <a onClick={() => { nav(-1) }}>系统菜单管理</a> }, { title: '编辑菜单' }])
            //  /config-mod-edit  /config-mod-show
        } else if (location.pathname.includes('/proj-edit/config-mod-show')) {
            setNow('查看菜单')
            setShowSearchBox(false)
            setRrefunSearchBox(false)
            setCorrectionSearchBox(false)
            setContractSearchBox(false)
            // setPathArray([{ title: <Link to={'/home'}>首页</Link> }, { title: <Link to={'/proj-create'}>创建项目</Link> }, { title: <a onClick={() => { nav(-2) }}>编辑项目</a> }, { title: <a onClick={() => { nav(-1) }}>系统菜单管理</a> }, { title: '查看菜单' }])
            //  /config-mod-edit 
        } else if (location.pathname.includes('/product-release')) {
            setNow('首页')
            setShowSearchBox(false)
            setRrefunSearchBox(false)
            setCorrectionSearchBox(false)
            setContractSearchBox(false)
            // setPathArray([{ title: '首页' }])
            //  /config-mod-edit  /product-release /transaction-order
        } else if (location.pathname.includes(' /transaction-order')) {
            setNow('首页')
            setShowSearchBox(false)
            setRrefunSearchBox(false)
            setCorrectionSearchBox(false)
            setContractSearchBox(false)
            // setPathArray([{ title: '首页' }])
            //  /config-mod-edit  /product-release /transaction-order
        } else if (location.pathname.includes(' /copyright-goods')) {
            setNow('首页')
            setShowSearchBox(false)
            setRrefunSearchBox(false)
            setCorrectionSearchBox(false)
            setContractSearchBox(false)
            // setPathArray([{ title: '首页' }])
            //  /config-mod-edit  /product-release /transaction-order
        } else if (location.pathname.includes(' /trading-goods')) {
            setNow('首页')
            setShowSearchBox(false)
            setRrefunSearchBox(false)
            setCorrectionSearchBox(false)
            setContractSearchBox(false)
            // setPathArray([{ title: '首页' }])
            //  /config-mod-edit  /product-release /transaction-order
        } else if (location.pathname.includes('/refun')) {
            setShowSearchBox(false)
            setNow('首页 / 退款')
            // setClickBelongpeople(false)
            setRrefunSearchBox(true)
            setCorrectionSearchBox(false)
            setContractSearchBox(false)
            // setNewname(location.pathname)
            // setPathArray([{ title: <Link to={'/home'}>首页</Link> }, { title: <Link to={'/proj-create'}>创建项目</Link> }, { title: <a onClick={() => { nav(-1) }}>编辑项目</a> }, { title: '软件功能特点' }])
        } else if (location.pathname.includes('/correction')) {
            setShowSearchBox(false)
            setNow('首页 / 补正')
            // setClickBelongpeople(false)
            setRrefunSearchBox(false)
            setCorrectionSearchBox(true)
            setContractSearchBox(false)
            // setNewname(location.pathname)
            // setPathArray([{ title: <Link to={'/home'}>首页</Link> }, { title: <Link to={'/proj-create'}>创建项目</Link> }, { title: <a onClick={() => { nav(-1) }}>编辑项目</a> }, { title: '软件功能特点' }])
        } else if (location.pathname.includes('/contract')) {
            setShowSearchBox(false)
            setRrefunSearchBox(false)
            setCorrectionSearchBox(false)
            setContractSearchBox(true)
            setNow('首页 / 合同下载')
        }
    }, [location.pathname])
    useEffect(() => {
        // nav('/home')
        // sessionStorage.setItem('pathArray', JSON.stringify([{ title: <Link to={'/home'}>首页</Link> }]));
        // sessionStorage.setItem('now', '首页');
        if (searchParams.get('type') == 'agent') {
            dispatch({
                type: IndexListDataType.AGENT,
                value: 'ALL',

            })

        }
        getProjOwnerList()
        getCorTag()
        getTag()
        getremindTag()
    }, []);
    useEffect(() => {
        if (location.pathname.includes('/home')) {
            nav('/home', {
                state: {
                    keyword: keywords,
                    type: type,
                    chargeAdditionals: chargeAdditionals,
                    tagDataId: tagDataId,
                    authorId: authorId,
                    payStatus: payStatus,
                    projRemindId: projRemindId,
                    // tagNot
                }
            })
        }
        if (location.pathname.includes('/refun')) {
            nav('/refun', {
                state: {
                    keywords: refunKeywords,
                    applyStatus: applyStatus,
                    authorId: authorId,
                  
                }
            })
        }
        if (location.pathname.includes('/correction')) {
            nav('/correction', {
                state: {
                    keywords: correctionKeywords,
                    correctionNumType: correctionNumType,
                    correctionType: correctionType,
                    applyStatus: correctionApplyStatus,
                    authorId: authorId,
                    tagCor: tagCor,
                   
                }
            })
        }

    }, [type, chargeAdditionals, keywords, tagDataId, projRemindId, payStatus, authorId, refunKeywords, applyStatus, correctionKeywords, correctionNumType, correctionType, correctionApplyStatus, tagCor]);

    // const [menuName,setMenuName] = useState<string | null>('')
    // useEffect(()=>{
    //     setMenuName( getMenuActive())
    // },[getMenuActive()])
    const handleSearch = (value: string) => {
        // console.log(value);
        setKeywords(value)
        nav('/home', {
            state: {
                keyword: value,
                type: type,
                chargeAdditionals: chargeAdditionals,
                tagDataId: tagDataId,
                authorId: authorId,
                payStatus: payStatus,
                projRemindId: projRemindId,
                // tagNot

            }
        })
    }
    const handleChange = (e: any) => {
        setNowKeyWord(e.target.value)
        // console.log(e.target.value);
        if (e.target.value == '') {
            setKeywords('')
            nav('/home', {
                state: {
                    keyword: '',
                    type: type,
                    chargeAdditionals: chargeAdditionals,
                    tagDataId: tagDataId,
                    authorId: authorId,
                    payStatus: payStatus,
                    projRemindId: projRemindId,
                    // tagNot

                }
            })
        }
    }
    // 退款状态


    // 退款关键字搜索
    const refunhandleSearch = (value: string) => {
        // console.log(value);
        setrefunKeywords(value)
        nav('/refun', {
            state: {
                keywords: value,
                applyStatus: applyStatus,
                authorId: authorId,
             
            }
        })
    }
    const refunhandleChange = (e: any) => {
        setnewRefunValue(e.target.value)
        // console.log(e.target.value);
        if (e.target.value == '') {
            setrefunKeywords('')
            nav('/refun', {
                state: {
                    keywords: '',
                    applyStatus: applyStatus,
                    authorId: authorId,
                   
                }
            })
        }
    }
    // 补正关键字搜索
    const correctionhandleSearch = (value: string) => {
        // console.log(value);
        setcorrectionKeywords(value)
        nav('/correction', {
            state: {
                keywords: value,
                correctionNumType: correctionNumType,
                correctionType: correctionType,
                applyStatus: correctionApplyStatus,
                authorId: authorId,
                tagCor: tagCor,
               
            }
        })
    }
    const correctionhandleChange = (e: any) => {
        setnewCorrectionValue(e.target.value)
        // console.log(e.target.value);
        if (e.target.value == '') {
            setcorrectionKeywords('')
            nav('/correction', {
                state: {
                    keywords: '',
                    correctionNumType: correctionNumType,
                    correctionType: correctionType,
                    applyStatus: correctionApplyStatus,
                    authorId: authorId,
                    tagCor: tagCor,
                   
                }
            })
        }
    }
    return (
        <>
            {/* <Breadcrumb
                items={[
                    {title: <Link to={'/'}>首页</Link>}
                ]}
            /> */}
            {contextHolder}
            <IndexListContext.Provider value={listData} >
                <IndexListDispatchContext.Provider value={dispatch}>
                    <div className="index">
                        <div className='coupon-mask'></div>
                        <div className='leftbox'>
                            {/* <div style={{display:'flex'}}> */}
                            {/* <div style={{height:1000,width:6,background:'red',marginRight:-6,zIndex:99}}></div> */}
                            <div className="left" >
                                <div className='mediaBox' style={{
                                    // height: '15px', width: '230px', 
                                    background: 'white'
                                }}></div>
                                <MenuWithTopButton
                                    button={projMenu.button}
                                    list={projMenu.list}
                                    handleListItem={projMenu.handleListItem}
                                    keywords={keywords}

                                    chargeAdditionals={chargeAdditionals ? chargeAdditionals : ""}
                                    tagDataId={tagDataId ? tagDataId : ""}
                                    authorId={authorId ? authorId : ""}
                                    payStatus={payStatus ? payStatus : ''}
                                    // 退款
                                    refunKeywords={refunKeywords}
                                    applyStatus={applyStatus ? applyStatus : ''}
                                    type={type ? type : ""}
                                    // 补正
                                    correctionKeywords={correctionKeywords ? correctionKeywords : ''}
                                    correctionNumType={correctionNumType ? correctionNumType : ''}
                                    correctionType={correctionType ? correctionType : ''}
                                    correctionApplyStatus={correctionApplyStatus ? correctionApplyStatus : ''}
                                    tagCor={tagCor ? tagCor : ''}
                                // enableBelongpeople = {()=>{setClickBelongpeople(true)}}
                                />

                                <div className='belongPeopleMenu'>
                                    <div className='belongPeopleMenu-title'>
                                        <MenuFoldOutlined style={{ marginLeft: 10, marginRight: 10 }} />产权所属者
                                    </div>
                                    <div style={{ display: belongArray.length > 0 ? 'block' : 'none' }}>
                                        <div className='belongPeopleMenu-box'>
                                            {
                                                currentPageData.map((item: any) => {
                                                    return (
                                                        <div className='belongpeopleName' key={item.projOwnerId} onClick={() => {
                                                            // const isHome = getMenuActive() == 'ALL' || getMenuActive() == 'PROCESSING' || getMenuActive() == 'COMPLETE'
                                                            if (authorId == item.projOwnerId) {
                                                                setauthorId('')

                                                                // if (isHome) {

                                                                //     nav('/home', {
                                                                //         state: {
                                                                //             keyword: keywords,
                                                                //             type: type,
                                                                //             chargeAdditionals: chargeAdditionals,
                                                                //             tagDataId: tagDataId,
                                                                //             authorId: '',
                                                                //             payStatus: payStatus

                                                                //         }
                                                                //     })
                                                                // }
                                                                // if (getMenuActive() == 'REFUN') {
                                                                //     nav('/refun', {
                                                                //         state: {
                                                                //             state: {
                                                                //                 keywords: refunKeywords,
                                                                //                 applyStatus: applyStatus,
                                                                //                 authorId: '',
                                                                //             }

                                                                //         }
                                                                //     })
                                                                // }

                                                            } else {
                                                                setauthorId(item.projOwnerId)
                                                                // if (isHome) {
                                                                //     nav('/home', {
                                                                //         state: {
                                                                //             keyword: keywords,
                                                                //             type: type,
                                                                //             chargeAdditionals: chargeAdditionals,
                                                                //             tagDataId: tagDataId,
                                                                //             authorId: item.projOwnerId,
                                                                //             payStatus: payStatus

                                                                //         }
                                                                //     })
                                                                // }
                                                                // if (getMenuActive() == 'REFUN') {
                                                                //     nav('/refun', {
                                                                //         state: {
                                                                //             state: {
                                                                //                 keywords: refunKeywords,
                                                                //                 applyStatus: applyStatus,
                                                                //                 authorId: item.projOwnerId,
                                                                //             }

                                                                //         }
                                                                //     })
                                                                // }

                                                            }

                                                            // alert(getMenuActive())


                                                            // const menuName = (getMenuActive())
                                                            // // const menuTrue = menuName == 'ALL' || 'PROCESSING' || 'COMPLETE'
                                                            // if(menuName == 'ALL' || 'PROCESSING' ||'COMPLETE'  ){
                                                            //     alert(1)
                                                            // }else{
                                                            //     alert(2)
                                                            // }

                                                        }}
                                                            style={{ background: authorId == item.projOwnerId ? '#FF9F08' : '', color: authorId == item.projOwnerId ? '#FFF' : '' }}
                                                            title={item.name} // 添加 title 属性以显示完整文本
                                                        >
                                                            {item.name}
                                                        </div>
                                                    )
                                                })
                                            }
                                        </div>
                                        {/* 分页控件 */}
                                        {/* <div className='pagination-controls'>
                                            <Button
                                                type="primary"
                                                onClick={() => handlePageChange(currentPage - 1)}
                                                disabled={currentPage === 1}
                                            >
                                                上一页
                                            </Button>

                                            <Button
                                                type="primary"
                                                onClick={() => handlePageChange(currentPage + 1)}
                                                disabled={currentPage === totalPages}
                                                style={{ marginLeft: 10 }}
                                            >
                                                下一页
                                            </Button>
                                        </div> */}
                                        <div className='belong-pagination'>
                                            <Pagination
                                                showSizeChanger={false}
                                                current={currentPage}
                                                total={totalItems}
                                                pageSize={itemsPerPage}
                                                onChange={handlePageChange} // 页码改变时的回调
                                                className="custom-pagination"
                                            />
                                        </div>
                                    </div>
                                    <div style={{ display: belongArray.length > 0 ? 'none' : 'block', height: 230 }}>
                                        <div style={{ width: 230, height: 230, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
                                            <Empty
                                                description="暂无数据"
                                            />
                                        </div>
                                    </div>
                                </div>
                                {/* <MenuTreeWithTopButton /> */}
                                {/* <MenuWithBottomButtom
                                button={agentMenu.button}
                                list={agentMenu.list}
                                handleListItem={agentMenu.handleListItem}
                            /> */}
                                {/* <MenuWithBottomButtom
                                    button={sellMenu.button}
                                    list={sellMenu.list}
                                    handleListItem={sellMenu.handleListItem}
                                />
                                <MenuWithBottomButtom
                                    button={buyMenu.button}
                                    list={buyMenu.list}
                                    handleListItem={buyMenu.handleListItem}
                                /> */}
                                {/* <MenuWithTopButton
                                    button={refundMenu.button}
                                    list={refundMenu.list}
                                    handleListItem={refundMenu.handleListItem}
                             
                                /> */}
                                {/* <MenuWithTopButton
                                    button={correctionMenu.button}
                                    list={correctionMenu.list}
                                    handleListItem={correctionMenu.handleListItem}
                                /> */}
                            </div>
                            {/* </div> */}
                        </div>

                        <div className="right">
                            <div>
                                <div className="top">
                                    {/* 标签 */}
                                    {/* {renderStatus()} */}
                                    <div className='gps'>
                                        <img src={gpsImg} alt="" />
                                        <div className='gps-now'>{now}</div>
                                    </div>
                                    <div className='mediaLine'>
                                        <div className='line' style={{
                                            display: showSearchBox ? 'block' : 'none',

                                        }} ></div>
                                    </div>
                                    <div style={{ display: showSearchBox ? 'block' : 'none' }}>
                                        <div
                                            className='mediaSearch'
                                            style={{

                                                display: 'flex',
                                                alignItems: 'center',
                                                minHeight: 62,
                                                // flexWrap: 'wrap',
                                                padding: '10px 0',
                                                boxSizing: 'border-box',
                                                // background:'red',
                                                // width:890
                                            }}>


                                            <div
                                                style={{
                                                    width: 1,
                                                    height: 23,
                                                    marginLeft: 33,
                                                    marginRight: 31,
                                                    display: showSearchBox ? 'none' : 'block'
                                                }}
                                            ></div>
                                            <Search placeholder="输入项目名称"
                                                value={nowKeyword}
                                                onSearch={handleSearch}
                                                onChange={handleChange}
                                                className='searchInputmedia'
                                                style={{
                                                    // maxWidth: '200px',
                                                    width: '170px',
                                                    height: '31px',
                                                    display: showSearchBox ? 'block' : 'none'
                                                }}
                                                allowClear
                                            />
                                            <Select
                                                value={type}
                                                allowClear
                                                style={{ height: '31px', width: '110px', marginLeft: 20, display: showSearchBox ? 'block' : 'none' }}
                                                onChange={(value: string) => {
                                                    setType(value)

                                                    nav('/home', {
                                                        state: {
                                                            keyword: keywords,
                                                            type: value,
                                                            chargeAdditionals: chargeAdditionals,
                                                            tagDataId: tagDataId,
                                                            authorId: authorId,
                                                            payStatus: payStatus,
                                                            projRemindId: projRemindId,
                                                            // tagNot
                                                        }
                                                    })

                                                }}
                                                options={[

                                                    { value: 'FREE', label: '免费试用' },
                                                    { value: 'MATERIAL', label: '写材料' },
                                                    { value: 'ALL', label: '全托管' },
                                                ]}

                                                placeholder='选择类型'
                                            />
                                            <Select
                                                allowClear
                                                value={chargeAdditionals}

                                                style={{ height: '31px', width: '130px', marginLeft: 20, display: showSearchBox ? 'block' : 'none' }}
                                                onChange={(value: string) => {
                                                    // console.log(`selected ${value}`);
                                                    setchargeAdditionals(value)
                                                    // alert(`selected ${value}`)
                                                    // lyp

                                                    nav('/home', {
                                                        state: {
                                                            keyword: keywords,
                                                            type: type,
                                                            chargeAdditionals: value,
                                                            tagDataId: tagDataId,
                                                            authorId: authorId,
                                                            payStatus: payStatus,
                                                            projRemindId: projRemindId,
                                                            // tagNot
                                                        }
                                                    })

                                                }}
                                                options={[
                                                    // { value: '', label: '全部项目' },
                                                    { value: 'PKG', label: '安装包' },
                                                    { value: 'VIDEO_DEMO', label: '演示视频' },
                                                    { value: 'URGENT', label: '加急' },
                                                ]}
                                                // defaultValue=""
                                                placeholder={'选择拓展收费'}
                                            />
                                            <Select
                                                allowClear
                                                value={tagDataId}
                                                style={{ height: '31px', width: '130px', marginLeft: 20, display: showSearchBox ? 'block' : 'none' }}
                                                onChange={(value: string) => {
                                                    // console.log(`selected ${value}`);
                                                    // const [part1, part2] = value.split(':');
                                                    // console.log('part1:', part1);
                                                    // console.log('part2:', part2);
                                                    // if (part1 == 'TAG_NOT') {
                                                    //     setTagNot(true)
                                                    // }

                                                    settagDataId(value)
                                                    // alert(`selected ${value}`)
                                                    // lyp
                                                    nav('/home', {
                                                        state: {
                                                            keyword: keywords,
                                                            type: type,
                                                            chargeAdditionals: chargeAdditionals,
                                                            tagDataId: value,
                                                            authorId: authorId,
                                                            payStatus: payStatus,
                                                            projRemindId: projRemindId,
                                                            // tagNot:part2 == 'TAG_NOT'?true:false
                                                        }
                                                    })

                                                }}
                                                options={

                                                    tagArray
                                                }

                                                placeholder={'选择标签'}


                                            />
                                            <div style={{
                                                display: remindTagArray.length > 0 ? 'block' : 'none',
                                            }}>
                                                <Select
                                                    allowClear
                                                    value={projRemindId}
                                                    style={{ height: '31px', width: '130px', marginLeft: 20, display: showSearchBox ? 'block' : 'none' }}
                                                    onChange={(value: string) => {
                                                        // console.log(`selected ${value}`);
                                                        setprojRemindId(value)
                                                        // alert(`selected ${value}`)
                                                        // lyp

                                                        nav('/home', {
                                                            state: {
                                                                keyword: keywords,
                                                                type: type,
                                                                chargeAdditionals: chargeAdditionals,
                                                                tagDataId: tagDataId,
                                                                authorId: authorId,
                                                                payStatus: payStatus,
                                                                projRemindId: value,
                                                                // tagNot
                                                            }
                                                        })

                                                    }}
                                                    options={

                                                        remindTagArray
                                                    }

                                                    placeholder={'选择提醒'}


                                                />
                                            </div>
                                            <Select
                                                allowClear
                                                value={payStatus}

                                                style={{ height: '31px', width: '130px', marginLeft: 20, display: showSearchBox ? 'block' : 'none' }}
                                                onChange={(value: string) => {
                                                    setpayStatus(value)
                                                    nav('/home', {
                                                        state: {
                                                            keyword: keywords,
                                                            type: type,
                                                            chargeAdditionals: chargeAdditionals,
                                                            tagDataId: tagDataId,
                                                            authorId: authorId,
                                                            payStatus: value,
                                                            projRemindId: projRemindId,
                                                            // tagNot
                                                        }
                                                    })

                                                }}
                                                options={[

                                                    { value: 'UNPAID', label: '未付款' },
                                                    { value: 'PAID', label: '已付款' },
                                                    { value: 'ARREARS', label: '欠费' },
                                                    { value: 'FULL_REFUND', label: '全额退费' },
                                                    { value: 'CORRECTION1_REFUND', label: '补正1次退款' },
                                                    { value: 'CORRECTION2_REFUND', label: '补正2次退款' },
                                                ]}

                                                placeholder={'选择付款类型'}
                                            />
                                            <Button onClick={() => {
                                                init()
                                            }} style={{ marginLeft: 10, display: showSearchBox ? 'block' : 'none', height: 31 }}
                                                // type="primary" 
                                                icon={<ClearOutlined />}>
                                                清除
                                            </Button>
                                        </div>
                                    </div>

                                    <div style={{ display: refunSearchBox ? 'block' : 'none' }}>
                                        <div
                                            className='mediaSearch'
                                            style={{
                                                display: 'flex',
                                                alignItems: 'center'
                                            }}>
                                            <div className='mediaLine'>
                                                <div className='line' style={{
                                                }} ></div>
                                            </div>
                                            <Button type="primary" onClick={() => {
                                                setRefunModal(true)
                                                refunInit()
                                                // dispath({
                                                //     type: 'newRefun',
                                                //     val: true
                                                // })
                                            }}
                                                style={{ background: '#FF9F08' }}
                                            >
                                                申请退款
                                            </Button>
                                            <Search placeholder="输入项目名称"
                                                value={newRefunValue}
                                                onSearch={refunhandleSearch}
                                                onChange={refunhandleChange}
                                                style={{
                                                    width: '200px',
                                                    height: '31px',
                                                    marginLeft: 10
                                                }}
                                                allowClear
                                            />
                                            <Select
                                                value={applyStatus}
                                                style={{ height: '31px', width: '150px', marginLeft: 10 }}
                                                onChange={(value: string) => {
                                                    setapplyStatus(value)
                                                    nav('/refun', {
                                                        state: {
                                                            keywords: refunKeywords,
                                                            applyStatus: value,
                                                            authorId: authorId,
                                                          
                                                        }
                                                    })
                                                }}
                                                options={[
                                                    // { value: '', label: '全部项目' },
                                                    { value: 'PENDING', label: '待审核' },
                                                    { value: 'APPROVED', label: '已通过' },
                                                    { value: 'REJECTED', label: '未通过' },
                                                    { value: 'CANCELED', label: '已取消' },
                                                ]}
                                                // defaultValue=""
                                                placeholder={'选择状态'}
                                                allowClear
                                            />
                                            <Button onClick={() => {
                                                refunInit()
                                            }} style={{ marginLeft: 10, height: 31 }}
                                                // type="primary" 
                                                icon={<ClearOutlined />}>
                                                清除
                                            </Button>
                                        </div>
                                    </div>


                                    <div style={{ display: correctionSearchBox ? 'block' : 'none' }}>
                                        <div className='mediaSearch' style={{
                                            display: 'flex',
                                            alignItems: 'center'
                                        }}>
                                            <div className='mediaLine'>
                                                <div className='line' style={{
                                                }} ></div>
                                            </div>
                                            <Button type="primary" onClick={() => {
                                                setCorrectionModal(true)
                                                correctionInit()
                                                // dispath({
                                                //     type: 'newCorrection',
                                                //     val: true
                                                // })
                                            }}
                                                style={{ background: '#FF9F08' }}
                                            >
                                                申请补正
                                            </Button>
                                            <Search placeholder="输入项目名称"
                                                value={newCorrectionValue}
                                                onSearch={correctionhandleSearch}
                                                onChange={correctionhandleChange}
                                                style={{
                                                    width: '160px',
                                                    height: '31px',
                                                    marginLeft: 10
                                                }}
                                                allowClear
                                            />
                                            <Select
                                                value={correctionNumType}
                                                style={{ height: '31px', width: '110px', marginLeft: 10 }}

                                                onChange={(value: string) => {
                                                    setcorrectionNumType(value)
                                                    nav('/correction', {
                                                        state: {
                                                            keywords: correctionKeywords,
                                                            correctionNumType: value,
                                                            correctionType: correctionType,
                                                            applyStatus: correctionApplyStatus,
                                                            authorId: authorId,
                                                            tagCor: tagCor,
                                                           
                                                        }
                                                    })
                                                }}
                                                options={[
                                                    // { value: '', label: '全部项目' },
                                                    { value: 'CORRECTION1', label: '一次补正' },
                                                    { value: 'CORRECTION2', label: '二次补正' },
                                                ]}
                                                // defaultValue=""
                                                placeholder={'选择类型'}
                                                allowClear
                                            />
                                            <Select
                                                style={{ height: '31px', width: '130px', marginLeft: 10 }}
                                                value={correctionType}
                                                onChange={(value: string) => {
                                                    setcorrectionType(value)
                                                    nav('/correction', {
                                                        state: {
                                                            keywords: correctionKeywords,
                                                            correctionNumType: correctionNumType,
                                                            correctionType: value,
                                                            applyStatus: correctionApplyStatus,
                                                            authorId: authorId,
                                                            tagCor: tagCor,
                                                            
                                                        }
                                                    })
                                                }}
                                                allowClear
                                                options={[
                                                    // { value: '', label: '全部项目' },
                                                    { value: 'CODE', label: '代码' },
                                                    { value: 'MANUAL', label: '操作手册' },
                                                    { value: 'ALL', label: '全部补正' },

                                                ]}
                                                // defaultValue=""
                                                placeholder={'选择补正种类'}
                                            />
                                            <Select
                                                value={correctionApplyStatus}
                                                style={{ height: '31px', width: '120px', marginLeft: 10 }}
                                                onChange={(value: string) => {
                                                    setcorrectionApplyStatus(value)
                                                    nav('/correction', {
                                                        state: {
                                                            keywords: correctionKeywords,
                                                            correctionNumType: correctionNumType,
                                                            correctionType: correctionType,
                                                            applyStatus: value,
                                                            authorId: authorId,
                                                            tagCor: tagCor,
                                                            
                                                        }
                                                    })
                                                }}
                                                options={[
                                                    // { value: '', label: '全部项目' },
                                                    { value: 'PENDING', label: '待审核' },
                                                    { value: 'APPROVED', label: '已通过' },
                                                    { value: 'REJECTED', label: '未通过' },
                                                    { value: 'CANCELED', label: '已取消' },
                                                ]}
                                                // defaultValue=""
                                                placeholder={'选择状态'}
                                                allowClear
                                            />
                                            <Select
                                                value={tagCor}
                                                style={{ height: '31px', width: '120px', marginLeft: 10 }}
                                                onChange={(value: string) => {
                                                    setTagCor(value)
                                                    nav('/correction', {
                                                        state: {
                                                            keywords: correctionKeywords,
                                                            correctionNumType: correctionNumType,
                                                            correctionType: correctionType,
                                                            applyStatus: applyStatus,
                                                            authorId: authorId,
                                                            tagCor: value,
                                                          
                                                        }
                                                    })
                                                }}
                                                options={
                                                    tagCorArray
                                                }
                                                // defaultValue=""
                                                placeholder={'选择标签'}
                                                allowClear
                                            />
                                            <Button onClick={() => {
                                                correctionInit()
                                            }} style={{ marginLeft: 10, height: 31 }}
                                                // type="primary" 
                                                icon={<ClearOutlined />}>
                                                清除
                                            </Button>
                                        </div>
                                    </div>
                                    <div style={{ display: contractSearchBox ? 'block' : 'none' }}>
                                        <div className='mediaSearch' style={{
                                            display: 'flex',
                                            alignItems: 'center'
                                        }}>
                                            <div className='mediaLine'>
                                                <div className='line' style={{
                                                }} ></div>
                                            </div>
                                            <Button type="primary" onClick={() => {
                                                setContractModal(true)
                                            }}
                                                style={{ background: '#FF9F08' }}
                                            >
                                                新增合同
                                            </Button>

                                        </div>
                                    </div>
                                    <div style={{
                                        width: '253px',
                                        height: '31px',
                                        display: showSearchBox || refunSearchBox || correctionSearchBox || contractSearchBox ? 'none' : 'block'
                                    }}></div>
                                    <div className='nowPosition'>
                                        <img src={backImg} alt="" />
                                        <div style={{ display: now == '首页-项目' || now == '首页-退款' || now == '首页-补正' ? 'block' : 'none' }}>
                                            {/* <Breadcrumb
                                                separator="|"
                                                // items={[
                                                //     { title: <Link to={'/home'}>首页</Link> },
                                                // ]}
                                                items={pathArray}
                                            /> */}
                                            <span>首页</span>
                                        </div>
                                        <div style={{ display: now == '创建项目' ? 'block' : 'none' }}>
                                            {/* <Breadcrumb
                                                separator="|"
                                                // items={[
                                                //     { title: <Link to={'/home'}>首页</Link> },
                                                // ]}
                                                items={pathArray}
                                            /> */}
                                            <span style={{ cursor: 'pointer' }}
                                                onClick={() => {
                                                    nav('/home', {
                                                        state: {
                                                            keyword: keywords,
                                                            type: type,
                                                            chargeAdditionals: chargeAdditionals,
                                                            tagDataId: tagDataId,
                                                            authorId: authorId,
                                                            payStatus: payStatus,
                                                            // tagNot

                                                        }
                                                    })
                                                }}
                                            >首页</span>
                                            <span style={{ marginLeft: 10, marginRight: 10 }}>|</span>
                                            <span>创建项目</span>
                                        </div>
                                        <div style={{ display: now.includes('项目-') ? 'block' : 'none' }}>
                                            {/* <Breadcrumb
                                                separator="|"
                                                // items={[
                                                //     { title: <Link to={'/home'}>首页</Link> },
                                                // ]}
                                                items={pathArray}
                                            /> */}
                                            <span style={{ cursor: 'pointer' }}
                                                onClick={() => {
                                                    nav('/home', {
                                                        state: {
                                                            keyword: keywords,
                                                            type: type,
                                                            chargeAdditionals: chargeAdditionals,
                                                            tagDataId: tagDataId,
                                                            authorId: authorId,
                                                            payStatus: payStatus,
                                                            // tagNot

                                                        }
                                                    })
                                                }}
                                            >首页</span>
                                            <span style={{ marginLeft: 10, marginRight: 10 }}>|</span>
                                            <span>{projStatus}项目</span>
                                        </div>
                                        <div style={{ display: now == '新建项目' ? 'block' : 'none' }}>
                                            {/* <Breadcrumb
                                                separator="|"
                                                // items={[
                                                //     { title: <Link to={'/home'}>首页</Link> },
                                                // ]}
                                                items={pathArray}
                                            /> */}
                                            <span style={{ cursor: 'pointer' }}
                                                onClick={() => {
                                                    nav('/home', {
                                                        state: {
                                                            keyword: keywords,
                                                            type: type,
                                                            chargeAdditionals: chargeAdditionals,
                                                            tagDataId: tagDataId,
                                                            authorId: authorId,
                                                            payStatus: payStatus,
                                                            // tagNot

                                                        }
                                                    })
                                                }}
                                            >首页</span>
                                            <span style={{ marginLeft: 10, marginRight: 10 }}>|</span>
                                            <span>新建项目</span>
                                        </div>
                                        <div style={{ display: now == '首页-合同下载' ? 'block' : 'none' }}>
                                            <span>首页</span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            {/* {
                                listData.type === IndexListDataType.PROJ ? <ListProj/> : (
                                    listData.type == IndexListDataType.AGENT ? <ListProjAgent/> : <></>
                                )
                            } */}
                            <div>
                                <Outlet></Outlet>
                            </div>
                        </div>
                    </div>
                </IndexListDispatchContext.Provider>
            </IndexListContext.Provider>
            <Modal
                title="申请退款"
                destroyOnClose={true}
                open={refunModal}
                footer={null}
                onCancel={() => {
                    setRefunModal(false)
                }}
                okButtonProps={{ style: { background: 'red', color: 'white' } }}
                width={592}
                maskClosable={false} // 禁止通过点击蒙层关闭
                centered

            >
                <RefunModal closeModal={() => { setRefunModal(false) }}></RefunModal>
            </Modal>
            <Modal
                title="申请补正"
                destroyOnClose={true}
                open={correctionModal}
                footer={null}
                maskClosable={false} // 禁止通过点击蒙层关闭
                onCancel={() => {
                    setCorrectionModal(false)
                }}
                okButtonProps={{ style: { background: 'red', color: 'white' } }}
                width={592}
                centered

            >
                <CorrectionModal closeModal={() => { setCorrectionModal(false) }}
                ></CorrectionModal>
            </Modal>
            <Modal
                title="新增合同"
                destroyOnClose={true}
                open={contractModal}
                footer={null}
                maskClosable={false} // 禁止通过点击蒙层关闭
                onCancel={() => {
                    setContractModal(false)
                }}
                okButtonProps={{ style: { background: 'red', color: 'white' } }}
                width={592}
                centered
            >
                <ContractModal closeModal={() => { setContractModal(false) }}></ContractModal>
            </Modal>
            <Modal title="优惠券"
                footer={null}

                destroyOnClose
                open={couponModal}

                width={809}
                onCancel={() => {
                    // setCouponModal(false)
                    // setUnRead(0)
                    dispath({
                        type: 'changeCouponModal',
                        val: false
                    })
                }}>
                <HeadCouponModal closeModal={() => {
                    // setCouponModal(false)
                    dispath({
                        type: 'changeCouponModal',
                        val: false
                    })
                    nav('/proj-create')
                    setMenuActive('ALL')
                }}></HeadCouponModal>
            </Modal>
            <Modal title="可领取优惠券"
                footer={null}

                destroyOnClose
                open={getCouponModal}
                width={809}
                onCancel={() => {
                    // setCouponModal(false)
                    // setUnRead(0)
                    setGetCouponModal(false)
                }}>
                <div className='headModal-bot'>
                    {couponArray.map((item: any) => {
                        return (
                            <div className='couponList' key={item.couponId} >
                                <div className='content'>
                                    <div className='content-noUse-left'>
                                        <div className='content-left-num'>
                                            <div
                                                style={{ marginTop: -10 }}
                                            >
                                                <span style={{ fontSize: 30 }}>￥</span>
                                                <span style={{ fontSize: 60, fontWeight: 700 }}>{item.amount / 100}</span>
                                            </div>

                                        </div>
                                    </div>
                                    <div className='content-right'>
                                        <div style={{ display: 'flex', marginTop: 20, justifyContent: 'space-between' }}>
                                            <div className='content-text'>
                                                可购买平台内任意软著时使用
                                            </div>
                                            <div className='content-rule' onClick={() => {
                                                //   window.open('https://www.aimzhu.com/CouponRule.html')

                                                getCouponUrl()
                                            }}>
                                                使用规则
                                            </div>
                                        </div>
                                        <div className='content-bot'>
                                            <div className='content-time'>
                                                有效期:{item.useGmtStart} 至 {item.useGmtEnd}
                                            </div>

                                            <div className='content-button' style={{
                                                background: '#1677FF'
                                            }} onClick={() => {
                                                // props.closeModal()
                                                receiveCoupons(item.couponId)

                                            }}>
                                                立即领取
                                            </div>
                                        </div>
                                    </div>

                                </div>

                            </div>
                        )

                    })}
                </div>
            </Modal>
            <div className='couponMask-box'
                style={{ display: coupon && (location.pathname == '/' || location.pathname.includes('/home')) && couponArray.length == 1 ? 'unset' : 'none' }}
            >

                <div className='couponMask' >
                    <div className='couponMask-img'>

                        <img src={downloadUrl(cpuponImg, false)} alt="" width={'100%'} height={'100%'} onClick={() => {

                        }}
                            className='testImg'
                        />
                        <div className='couponMask-btn' onClick={() => {
                            receiveCoupon()
                        }}>
                            立即领取
                        </div>
                    </div>
                    <div className='couponMask-close' onClick={() => {
                        setCoupon(false)
                    }}>
                        <CloseOutlined />
                    </div>
                </div>
            </div>



        </>
    )
}