import { Button, Card, Modal, Pagination, Tabs, Tag } from 'antd' import React, { useCallback, useEffect, useRef, useState } from 'react' import DrawerPage from "@/components/FileBox/components/newsModal" import { useModel } from 'umi' import style from './mpnews.less' import FileBox from '../FileBox' /** * * 图文素材 * * 编辑图文内容 素材库导入 */ type Props = { visible: boolean, onCancel: () => void, onOK: (props: any, type?: number) => void, defaultData: any, wx?: any, isNews?: boolean } /**微信图文弹窗 */ const WxMpnews = React.memo((props: Props) => { const { visible, onCancel, onOK, wx } = props const [action, setAction] = useState('') const { getData, update } = useModel('useOperating.useMaterialContent', model => ({ getData: model.getWeData, update: model.update })) const { actionWX } = useModel('useOperating.useWxGroupList', model => ({ actionWX: model.state.actionWX })) let refD: { current: { showDrawer: (props?: any) => void } } | any = useRef()//DrawerPage获取实例方法 const { state, set, getList } = useModel('useOperating.useBdMedia') const [isWx, setIsWx] = useState(false) const { fileType, belongUser, parentId, selectItem } = state /**加载组件或数据更新执行请求列表 */ useEffect(() => { set({ fileType: 'news' })//设置获取图文列表 if (belongUser === '1' || belongUser === '0') { getList()//获取列表 } }, [fileType, belongUser, parentId]) let pageSizeChange = useCallback((pageNum: number, pageSize: number) => { getData.run({ pageNum: pageNum, pageSize: pageSize, mpId: actionWX?.id, mediaType: 'news' }) }, [actionWX?.id]) //同步更新 let sync = useCallback(() => { update.run({ mpId: actionWX?.id, mediaType: 'news' }) }, [actionWX?.id]) //选中图片 let handleClick = useCallback((data: any) => { setAction(data) }, []) //ok let ok = useCallback(() => { if (isWx) { onOK(action) } else { onOK(selectItem) } }, [action, isWx, selectItem]) useEffect(() => { if (actionWX?.id) { getData.run({ mpId: actionWX?.id, mediaType: 'news', pageSize: 9, pageNum: 1 }) } }, [actionWX?.id]) useEffect(() => { if (props.defaultData) { setAction(props.defaultData) } }, [props.defaultData]) //tabs切换 const change = useCallback((s: string) => { setIsWx(s === '1' ? false : true) }, []) return
{ set({ belongUser: activeKey }) }} activeKey={belongUser} items={[ { label: '个人本地', key: '1' }, { label: '公共本地', key: '0' }, ]} />
{ [0, 1, 2].map((n) => { return
    { getData?.data?.records?.map((item: any, index: number) => { if (index % 3 === n) { return
  • handleClick(item)}> { return
    {list.title}
    }) } />
  • } return null }) }
}) }
总共{total}数据} />
}, (a, b) => { if (JSON.stringify(a) === JSON.stringify(b)) { return true } return false }) export default WxMpnews