import { App, Button, DatePicker, Input, Pagination, Popconfirm, Select, Table } from 'antd'; import Card from 'antd/es/card/Card'; import React, { useEffect, useRef, useState } from 'react'; import { delAutoLinkApi, getCorpAutoLinkListApi, GetCorpAutoLinkListProps } from '../../API/bookLink'; import style from './index.less' import { useAjax } from '@/Hook/useAjax'; import SearchBox from '../../components/searchBox'; import { SearchOutlined, PlusOutlined, DeleteOutlined } from '@ant-design/icons'; import { getBindMpListApi } from '../../API/corpUserAssign'; import { inject, observer } from 'mobx-react'; import { toJS } from 'mobx'; import { LINKTYPE } from './const'; import ModalBookLink from './modalBooklink'; import { useSize } from 'ahooks'; import { bookLinkTableConfig } from './tableConfig'; import dayJs from 'dayjs'; /** * 书城自动链接管理 * @returns */ const BookLink: React.FC<{ weComTaskStore: { data: { bookList: TASK_CREATE.BookListProps[], bookPlatForm: TASK_CREATE.BookPlatFormProps[] } } }> = ({ weComTaskStore }) => { /******************************************/ const { message } = App.useApp() const { bookPlatForm } = toJS(weComTaskStore.data) const ref = useRef(null) const size = useSize(ref) const [queryParams, setQueryParams] = useState({ pageNum: 1, pageSize: 20 }) const [queryParamsNew, setQueryParamsNew] = useState({ pageNum: 1, pageSize: 20 }) const [mpList, setMplist] = useState<{ label: string, value: number }[]>([]) const [visible, setVisible] = useState(false) const [initialValues, setInitialValues] = useState() const [selectedRows, setselectedRows] = useState([]) const getCorpAutoLinkList = useAjax((params) => getCorpAutoLinkListApi(params)) const delAutoLink = useAjax((params) => delAutoLinkApi(params)) const getBindMpList = useAjax(() => getBindMpListApi()) /******************************************/ useEffect(() => { getCorpAutoLinkList.run(queryParamsNew) }, [queryParamsNew]) useEffect(() => { getBindMpList.run().then(res => { setMplist(res?.data?.map((item: any) => ({ label: item.name, value: item.id }))) }) }, []) const handleCopy = (value: any) => { const { linkType, linkContext, channelName, channelType, platform, mpAccountId } = value const yueWenCreateLinkDTO: { [x: string]: any } = { linkType: linkType + '', channelName, channelType: channelType + '' } switch (linkType) { case 1: yueWenCreateLinkDTO.pagePromoLinkCreateDTO = { ...linkContext, pageType: linkContext.pageType + '' } break case 2: yueWenCreateLinkDTO.bookPromoLinkCreateDTO = { ...linkContext, forceStyle: Number(linkContext.forceStyle) } break case 3: yueWenCreateLinkDTO.rechargeActivityLinkDTO = { ...linkContext, activityTheme: linkContext.activityTheme + '', activityTime: [dayJs(linkContext.startTime), dayJs(linkContext.endTime)], display: linkContext?.display ? linkContext?.display?.split(',') : [] } break case 4: yueWenCreateLinkDTO.giftActivityLinkDTO = { ...linkContext, // activityTheme: Number(linkContext.activityTheme), activityTime: [dayJs(linkContext.startTime), dayJs(linkContext.endTime)], display: linkContext?.display ? linkContext?.display?.split(',') : [], resourceType: linkContext.resourceType + '' } break case 5: yueWenCreateLinkDTO.consumeActivityLinkDTO = { ...linkContext, activityTheme: linkContext.activityTheme + '', activityTime: [dayJs(linkContext.startTime), dayJs(linkContext.endTime)], display: linkContext?.display ? linkContext?.display?.split(',') : [], } break } setInitialValues({ platform, mpAccountIds: [mpAccountId], yueWenCreateLinkDTOList: [yueWenCreateLinkDTO] }) setVisible(true) } const handleDel = (value: { linkIds: number[] }) => { const hide = message.loading('正在删除...', 0) delAutoLink.run(value).then(res => { hide() setselectedRows([]) if (res?.data) { message.success('删除成功') getCorpAutoLinkList.refresh() } else { message.error('删除失败') } }).catch(() => hide()) } return
{ handleDel({ linkIds : selectedRows.map(i => i.id) }) }} disabled={selectedRows.length === 0} > } > <> setQueryParams({ ...queryParams, mpAccountId: e })} showSearch style={{ width: 110 }} placeholder="公众号" filterOption={(input, option) => ((option?.label ?? '') as string).toLowerCase().includes(input.toLowerCase()) } allowClear options={mpList} /> setQueryParams({ ...queryParams, channelName: e.target.value })} />