| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558 |
- import React, { useEffect, useState } from "react"
- import style from './index.less';
- import { Avatar, Badge, Button, DatePicker, Drawer, Input, Modal, Select, Space, Table, Tabs, Tag } from "antd";
- import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
- import { faCommentDots } from "@fortawesome/free-solid-svg-icons";
- import { useAjax } from "@/Hook/useAjax";
- import { getProjectGroupsAllListApi } from "../../API/groupManage";
- import { ExclamationCircleOutlined, SearchOutlined } from "@ant-design/icons";
- import { getMomentCorpUserLogListApi, getMomentJobLogListApi, GetSendMomentLogListProps } from "../../API/logs";
- import useNewToken from "@/Hook/useNewToken";
- import SearchBox from "../../components/searchBox";
- import dayJs from "dayjs";
- import { copy } from "@/utils/utils";
- interface Props {
- taskTotal: number
- todayAddTask: number
- todayFinishTaskRate: number
- todayFailTask: number
- }
- /**
- * 朋友圈
- * @returns
- */
- const MomentItem: React.FC<Props> = ({ taskTotal, todayAddTask, todayFinishTaskRate, todayFailTask }) => {
- /*************************************************/
- const [visible, setVisible] = useState<boolean>(false)
- const [activeKey, setActiveKey] = useState<string>('2')
- const [groupList, setGroupList] = useState<{ label: string, value: number }[]>([]);
- const getProjectGroupsAllList = useAjax(() => getProjectGroupsAllListApi())
- /*************************************************/
- useEffect(() => {
- if (visible) {
- getProjectGroupsAllList.run().then(res => {
- setGroupList([{ label: '空项目组', value: 0 }, ...res?.data?.map(item => ({ label: item.name, value: item.id })) || []])
- })
- }
- }, [visible])
- return <>
- <div className={style.moduleCard} onClick={() => setVisible(true)}>
- <div className={style.moduleCard_header}>
- <Avatar style={{ backgroundColor: '#dcfce7', color: '#16a34a' }} size={30}>
- <FontAwesomeIcon icon={faCommentDots} />
- </Avatar>
- 朋友圈
- </div>
- <div className={style.moduleCard_center}>
- 总任务数:{taskTotal || 0} | 今日新增:{todayAddTask || 0}
- </div>
- <div className={style.moduleCard_footer}>
- <span>今日完成率:{((todayFinishTaskRate || 0) * 100).toFixed(2)} %</span>
- <span className={style.error}>今日异常:{todayFailTask}</span>
- </div>
- </div>
- <Drawer
- title={'朋友圈'}
- onClose={() => setVisible(false)}
- open={visible}
- width={'70%'}
- >
- <Tabs
- destroyOnHidden={false}
- onChange={(key) => {
- setActiveKey(key)
- }}
- activeKey={activeKey}
- type="card"
- items={[
- {
- key: '2',
- label: '下发企微号',
- children: <>
- {activeKey == '2' && <GroupXfCorpTabls groupList={groupList} />}
- </>
- },
- {
- key: '4',
- label: '群发记录',
- children: <>
- {activeKey == '4' && <GroupTaskNotes groupList={groupList} />}
- </>
- }
- ]}
- />
- </Drawer>
- </>
- }
- /**
- * 下发企微号
- * @param param0
- * @returns
- */
- const GroupXfCorpTabls: React.FC<{ groupList: { label: string, value: number }[] }> = ({ groupList }) => {
- /***********************************/
- const [queryParams, setQueryParams] = useState<GetSendMomentLogListProps>({ pageNum: 1, pageSize: 20 })
- const [oldQueryParams, setOldQueryParams] = useState<GetSendMomentLogListProps>({ pageNum: 1, pageSize: 20 })
- const { token } = useNewToken()
- const [modal, contextHolder] = Modal.useModal();
- const getMomentCorpUserLogList = useAjax((params) => getMomentCorpUserLogListApi(params))
- /***********************************/
- useEffect(() => {
- getMomentCorpUserLogList.run(queryParams)
- }, [queryParams])
- return <div>
- {contextHolder}
- <SearchBox
- bodyPadding={`0 0 10px`}
- buttons={<>
- <Button type="primary" onClick={() => {
- setQueryParams({ ...oldQueryParams, pageNum: 1, pageSize: queryParams.pageSize })
- }} loading={getMomentCorpUserLogList.loading} icon={<SearchOutlined />}>搜索</Button>
- </>}
- >
- <>
- <Input
- placeholder="任务名称"
- style={{ width: 120 }}
- allowClear
- onChange={(e) => setOldQueryParams({ ...oldQueryParams, projectName: e.target.value })}
- value={oldQueryParams?.projectName}
- />
- <Input
- placeholder="子任务ID"
- style={{ width: 120 }}
- allowClear
- onChange={(e) => setOldQueryParams({ ...oldQueryParams, taskId: e.target.value })}
- value={oldQueryParams?.taskId}
- />
- <Select
- placeholder='请选择项目组'
- allowClear
- options={groupList}
- showSearch
- maxTagCount={1}
- style={{ minWidth: 150 }}
- filterOption={(input, option) =>
- (option?.label ?? '').toLowerCase().includes(input.toLowerCase())
- }
- mode="multiple"
- value={oldQueryParams?.projectGroupIds}
- onChange={(value) => setOldQueryParams({ ...oldQueryParams, projectGroupIds: value })}
- />
- <DatePicker
- placeholder="发送开始时间"
- onChange={(e, date) => { setOldQueryParams({ ...oldQueryParams, startDay: date as string }) }}
- allowClear
- value={oldQueryParams?.startDay ? dayJs(oldQueryParams?.startDay) : undefined}
- />
- <DatePicker
- placeholder="发送结束时间"
- onChange={(e, date) => { setOldQueryParams({ ...oldQueryParams, endDay: date as string }) }}
- allowClear
- value={oldQueryParams?.endDay ? dayJs(oldQueryParams?.endDay) : undefined}
- />
- </>
- </SearchBox>
- {/* 表 */}
- <Table
- style={{ marginTop: 10 }}
- dataSource={getMomentCorpUserLogList?.data?.data?.records}
- loading={getMomentCorpUserLogList?.loading}
- bordered
- columns={[
- {
- title: '操作',
- dataIndex: 'cz',
- key: 'cz',
- width: 100,
- align: 'center',
- render: (_, record: any) => {
- return <Space>
- <a onClick={() => {
- modal.confirm({
- title: '确认',
- icon: <ExclamationCircleOutlined />,
- content: '是否跳转到日志详情?',
- okText: '确认',
- cancelText: '复制',
- onCancel: () => {
- copy(record.projectName + '任务Id:' + record.taskId)
- },
- onOk: () => {
- localStorage.setItem('OPENTASK', JSON.stringify({
- id: record.projectId,
- projectName: record.projectName,
- taskType: 'TASK_STAT_MOMENT',
- taskId: record.taskId,
- msg: '跳转日志详情'
- }))
- window.open(`/weComTask#/weComTask/moments/taskList`)
- },
- });
- }}>任务跳转</a>
- </Space>
- }
- },
- {
- title: '任务名称',
- dataIndex: 'projectName',
- key: 'projectName',
- width: 180,
- ellipsis: true,
- render: (text) => <a onClick={() => copy(text)}>{text}</a>
- },
- {
- title: '子任务ID',
- dataIndex: 'taskId',
- key: 'taskId',
- width: 70,
- align: 'center'
- },
- {
- title: '项目组名称',
- dataIndex: 'projectGroupName',
- key: 'projectGroupName',
- width: 100,
- ellipsis: true,
- align: 'center',
- render: (text) => text ? <a onClick={() => copy(text)}>{text}</a> : '--'
- },
- {
- title: '项目组ID',
- dataIndex: 'projectGroupId',
- key: 'projectGroupId',
- width: 70,
- align: 'center'
- },
- {
- title: '所属企业',
- dataIndex: 'corpName',
- key: 'corpName',
- align: 'center',
- width: 120,
- ellipsis: true
- },
- {
- title: '企微号',
- dataIndex: 'corpUserName',
- key: 'corpUserName',
- align: 'center',
- width: 120,
- ellipsis: true,
- render: (a: string, b: any) => {
- return a + `(${b?.corpUserId})`
- }
- },
- {
- title: '发送状态',
- dataIndex: 'sendStatus',
- key: 'sendStatus',
- align: 'center',
- width: 80,
- render: (a) => {
- return <Badge text={a === 1 ? '已确认发送' : '未确认发送'} status={a === 1 ? 'success' : 'error'} />
- }
- },
- {
- title: '预计送达数',
- dataIndex: 'sendCount',
- key: 'sendCount',
- align: 'center',
- width: 75,
- ellipsis: true,
- render: (a) => {
- return a > 0 ? a : 0
- }
- },
- {
- title: '消息ID',
- dataIndex: 'jobId',
- key: 'jobId',
- align: 'center',
- width: 65,
- ellipsis: true,
- },
- {
- title: '发送成功',
- dataIndex: 'sendSuccessCount',
- key: 'sendSuccessCount',
- align: 'center',
- width: 75,
- render: (a) => {
- return a > 0 ? a : 0
- }
- },
- {
- title: '发送失败',
- dataIndex: 'sendFailedCount',
- key: 'sendFailedCount',
- align: 'center',
- width: 75,
- render: (a) => {
- return a > 0 ? a : 0
- }
- },
- {
- title: '评论数',
- dataIndex: 'commentCount',
- key: 'commentCount',
- align: 'center',
- width: 65,
- ellipsis: true,
- },
- {
- title: '点赞数',
- dataIndex: 'likeCount',
- key: 'likeCount',
- align: 'center',
- width: 65,
- ellipsis: true,
- },
- {
- title: '发送时间',
- dataIndex: 'sendTime',
- key: 'sendTime',
- align: 'center',
- width: 135,
- ellipsis: true
- }
- ]}
- scroll={{ x: 1000 }}
- rowKey={'id'}
- size='small'
- onRow={(row: any) => {
- return !row?.status ? {
- style: { background: token.colorPrimaryBgHover }
- } : {}
- }}
- pagination={{
- total: getMomentCorpUserLogList?.data?.data?.total,
- showTotal: (total) => <Tag color="cyan">总共{total}数据</Tag>,
- showSizeChanger: true,
- showLessItems: true,
- defaultCurrent: 1,
- defaultPageSize: 200,//默认初始的每页条数
- current: getMomentCorpUserLogList?.data?.data?.current || 1,
- pageSize: getMomentCorpUserLogList?.data?.data?.size || 20,
- onChange: (page, pageSize) => {
- setQueryParams({ ...queryParams, pageNum: page, pageSize })
- setOldQueryParams({ ...oldQueryParams, pageNum: page, pageSize })
- }
- }}
- />
- </div>
- }
- /**
- * 群发记录
- * @param param0
- * @returns
- */
- const GroupTaskNotes: React.FC<{ groupList: { label: string, value: number }[] }> = ({ groupList }) => {
- /***********************************/
- const [queryParams, setQueryParams] = useState<GetSendMomentLogListProps>({ pageNum: 1, pageSize: 20 })
- const [oldQueryParams, setOldQueryParams] = useState<GetSendMomentLogListProps>({ pageNum: 1, pageSize: 20 })
- const { token } = useNewToken()
- const [modal, contextHolder] = Modal.useModal();
- const getMomentJobLogList = useAjax((params) => getMomentJobLogListApi(params))
- /***********************************/
- useEffect(() => {
- getMomentJobLogList.run(queryParams)
- }, [queryParams])
- return <div>
- {contextHolder}
- <SearchBox
- bodyPadding={`0 0 10px`}
- buttons={<>
- <Button type="primary" onClick={() => {
- setQueryParams({ ...oldQueryParams, pageNum: 1, pageSize: queryParams.pageSize })
- }} loading={getMomentJobLogList.loading} icon={<SearchOutlined />}>搜索</Button>
- </>}
- >
- <>
- <Input
- placeholder="任务名称"
- style={{ width: 120 }}
- allowClear
- onChange={(e) => setOldQueryParams({ ...oldQueryParams, projectName: e.target.value })}
- value={oldQueryParams?.projectName}
- />
- <Input
- placeholder="子任务ID"
- style={{ width: 120 }}
- allowClear
- onChange={(e) => setOldQueryParams({ ...oldQueryParams, taskId: e.target.value })}
- value={oldQueryParams?.taskId}
- />
- <Select
- placeholder='请选择项目组'
- allowClear
- options={groupList}
- showSearch
- maxTagCount={1}
- style={{ minWidth: 150 }}
- filterOption={(input, option) =>
- (option?.label ?? '').toLowerCase().includes(input.toLowerCase())
- }
- mode="multiple"
- value={oldQueryParams?.projectGroupIds}
- onChange={(value) => setOldQueryParams({ ...oldQueryParams, projectGroupIds: value })}
- />
- <DatePicker
- placeholder="发送开始时间"
- onChange={(e, date) => { setOldQueryParams({ ...oldQueryParams, startDay: date as string }) }}
- allowClear
- value={oldQueryParams?.startDay ? dayJs(oldQueryParams?.startDay) : undefined}
- />
- <DatePicker
- placeholder="发送结束时间"
- onChange={(e, date) => { setOldQueryParams({ ...oldQueryParams, endDay: date as string }) }}
- allowClear
- value={oldQueryParams?.endDay ? dayJs(oldQueryParams?.endDay) : undefined}
- />
- </>
- </SearchBox>
- <Table
- style={{ marginTop: 10 }}
- dataSource={getMomentJobLogList?.data?.data?.records}
- loading={getMomentJobLogList?.loading}
- bordered
- columns={[
- {
- title: '操作',
- dataIndex: 'cz',
- key: 'cz',
- width: 100,
- align: 'center',
- render: (_, record: any) => {
- return <Space>
- <a onClick={() => {
- modal.confirm({
- title: '确认',
- icon: <ExclamationCircleOutlined />,
- content: '是否跳转到日志详情?',
- okText: '确认',
- cancelText: '复制',
- onCancel: () => {
- copy(record.projectName + '任务Id:' + record.taskId)
- },
- onOk: () => {
- localStorage.setItem('OPENTASK', JSON.stringify({
- id: record.projectId,
- projectName: record.projectName,
- taskType: 'TASK_STAT_MOMENT',
- taskId: record.taskId,
- msg: '跳转日志详情'
- }))
- window.open(`/weComTask#/weComTask/moments/taskList`)
- },
- });
- }}>任务跳转</a>
- </Space>
- }
- },
- {
- title: '任务名称',
- dataIndex: 'projectName',
- key: 'projectName',
- width: 180,
- ellipsis: true,
- render: (text) => <a onClick={() => copy(text)}>{text}</a>
- },
- {
- title: '子任务ID',
- dataIndex: 'taskId',
- key: 'taskId',
- width: 70,
- align: 'center'
- },
- {
- title: '项目组名称',
- dataIndex: 'projectGroupName',
- key: 'projectGroupName',
- width: 100,
- ellipsis: true,
- align: 'center',
- render: (text) => text ? <a onClick={() => copy(text)}>{text}</a> : '--'
- },
- {
- title: '项目组ID',
- dataIndex: 'projectGroupId',
- key: 'projectGroupId',
- width: 70,
- align: 'center'
- },
- {
- title: '消息ID',
- dataIndex: 'jobId',
- key: 'jobId',
- width: 70,
- ellipsis: true
- },
- {
- title: '发送时间',
- dataIndex: 'createTime',
- key: 'createTime',
- width: 110
- },
- {
- title: '任务日志',
- dataIndex: 'jobLog',
- key: 'jobLog',
- width: 250,
- ellipsis: true
- },
- {
- title: '任务状态',
- dataIndex: 'jobStatus',
- key: 'jobStatus',
- width: 110,
- ellipsis: true
- }
- ]}
- scroll={{ x: 1000 }}
- rowKey={(s) => {
- return s.id
- }}
- size='small'
- pagination={{
- total: getMomentJobLogList?.data?.data?.total,
- showTotal: (total) => <Tag color="cyan">总共{total}数据</Tag>,
- showSizeChanger: true,
- showLessItems: true,
- defaultCurrent: 1,
- defaultPageSize: 200,//默认初始的每页条数
- current: getMomentJobLogList?.data?.data?.current || 1,
- pageSize: getMomentJobLogList?.data?.data?.size || 20,
- onChange: (page, pageSize) => {
- setQueryParams({ ...queryParams, pageNum: page, pageSize })
- setOldQueryParams({ ...oldQueryParams, pageNum: page, pageSize })
- }
- }}
- />
- </div>
- }
- export default React.memo(MomentItem)
|