|
@@ -1,11 +1,11 @@
|
|
|
-import { Button, DatePicker, Input, Pagination, Select, Table } from 'antd';
|
|
|
+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 { getCorpAutoLinkListApi, GetCorpAutoLinkListProps } from '../../API/bookLink';
|
|
|
+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 } from '@ant-design/icons';
|
|
|
+import { SearchOutlined, PlusOutlined, DeleteOutlined } from '@ant-design/icons';
|
|
|
import { getBindMpListApi } from '../../API/corpUserAssign';
|
|
|
import { inject, observer } from 'mobx-react';
|
|
|
import { toJS } from 'mobx';
|
|
@@ -22,6 +22,7 @@ import dayJs from 'dayjs';
|
|
|
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<HTMLDivElement>(null)
|
|
|
const size = useSize(ref)
|
|
@@ -31,8 +32,10 @@ const BookLink: React.FC<{ weComTaskStore: { data: { bookList: TASK_CREATE.BookL
|
|
|
const [mpList, setMplist] = useState<{ label: string, value: number }[]>([])
|
|
|
const [visible, setVisible] = useState<boolean>(false)
|
|
|
const [initialValues, setInitialValues] = useState<any>()
|
|
|
+ const [selectedRows, setselectedRows] = useState<any[]>([])
|
|
|
|
|
|
const getCorpAutoLinkList = useAjax((params) => getCorpAutoLinkListApi(params))
|
|
|
+ const delAutoLink = useAjax((params) => delAutoLinkApi(params))
|
|
|
const getBindMpList = useAjax(() => getBindMpListApi())
|
|
|
/******************************************/
|
|
|
|
|
@@ -83,7 +86,7 @@ const BookLink: React.FC<{ weComTaskStore: { data: { bookList: TASK_CREATE.BookL
|
|
|
case 5:
|
|
|
yueWenCreateLinkDTO.consumeActivityLinkDTO = {
|
|
|
...linkContext,
|
|
|
- activityTheme: linkContext.activityTheme + '',
|
|
|
+ activityTheme: linkContext.activityTheme + '',
|
|
|
activityTime: [dayJs(linkContext.startTime), dayJs(linkContext.endTime)],
|
|
|
display: linkContext?.display ? linkContext?.display?.split(',') : [],
|
|
|
}
|
|
@@ -97,6 +100,20 @@ const BookLink: React.FC<{ weComTaskStore: { data: { bookList: TASK_CREATE.BookL
|
|
|
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 <Card
|
|
|
styles={{ body: { padding: 0, display: 'flex', flexDirection: 'column', height: 'calc(100vh - 74px)', overflow: 'hidden' } }}
|
|
|
>
|
|
@@ -108,6 +125,13 @@ const BookLink: React.FC<{ weComTaskStore: { data: { bookList: TASK_CREATE.BookL
|
|
|
setQueryParamsNew({ ...queryParams, pageNum: 1 })
|
|
|
}} loading={getCorpAutoLinkList.loading} icon={<SearchOutlined />}>搜索</Button>
|
|
|
<Button type="primary" icon={<PlusOutlined />} onClick={() => setVisible(true)}>链接生成</Button>
|
|
|
+ <Popconfirm
|
|
|
+ title="确定删除?"
|
|
|
+ onConfirm={() => { handleDel({ linkIds : selectedRows.map(i => i.id) }) }}
|
|
|
+ disabled={selectedRows.length === 0}
|
|
|
+ >
|
|
|
+ <Button type='primary' danger icon={<DeleteOutlined />} loading={delAutoLink.loading} disabled={selectedRows.length === 0}>删除</Button>
|
|
|
+ </Popconfirm>
|
|
|
</>}
|
|
|
>
|
|
|
<>
|
|
@@ -172,13 +196,47 @@ const BookLink: React.FC<{ weComTaskStore: { data: { bookList: TASK_CREATE.BookL
|
|
|
<div className={style.bookLinkTable} ref={ref}>
|
|
|
<Table
|
|
|
dataSource={getCorpAutoLinkList?.data?.data?.records}
|
|
|
- columns={bookLinkTableConfig(false, handleCopy)}
|
|
|
+ columns={bookLinkTableConfig(false, handleCopy, handleDel)}
|
|
|
bordered
|
|
|
pagination={false}
|
|
|
rowKey={'id'}
|
|
|
size='small'
|
|
|
loading={getCorpAutoLinkList?.loading}
|
|
|
scroll={{ y: size?.height && ref.current ? size?.height - ref.current.querySelector('.ant-table-thead').clientHeight : 300 }}
|
|
|
+ rowSelection={{
|
|
|
+ selectedRowKeys: selectedRows?.map((item: any) => item?.id),
|
|
|
+ onSelect: (record: { id: string }, selected: boolean) => {
|
|
|
+ let newData = JSON.parse(JSON.stringify(selectedRows))
|
|
|
+ if (selected) {
|
|
|
+ newData.push({ ...record })
|
|
|
+ } else {
|
|
|
+ newData = newData.filter((item: { id: string }) => item.id !== record.id)
|
|
|
+ }
|
|
|
+ setselectedRows(newData)
|
|
|
+ },
|
|
|
+ onSelectAll: (selected: boolean, _: { id: string }[], changeRows: { id: string }[]) => {
|
|
|
+ let newData = JSON.parse(JSON.stringify(selectedRows || '[]'))
|
|
|
+ if (selected) {
|
|
|
+ changeRows.forEach((item: { id: string }) => {
|
|
|
+ let index = newData.findIndex((ite: { id: string }) => ite.id === item.id)
|
|
|
+ if (index === -1) {
|
|
|
+ newData.push(item)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ let newSelectAccData = newData.filter((item: { id: string }) => {
|
|
|
+ let index = changeRows.findIndex((ite: { id: string }) => ite.id === item.id)
|
|
|
+ if (index !== -1) {
|
|
|
+ return false
|
|
|
+ } else {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ })
|
|
|
+ newData = newSelectAccData
|
|
|
+ }
|
|
|
+ setselectedRows(newData)
|
|
|
+ }
|
|
|
+ }}
|
|
|
/>
|
|
|
</div>
|
|
|
<div className={style.bookLinkPagination}>
|