消息通知更改

This commit is contained in:
xixi 2024-08-19 15:38:49 +08:00
parent 67db0b5844
commit b4099da594

View File

@ -1,4 +1,4 @@
import { useEffect, useState } from 'react' import { useEffect, useRef, useState } from 'react'
import './noticeModal.css' import './noticeModal.css'
import { get, put, del } from '../../util/AjaxUtils' import { get, put, del } from '../../util/AjaxUtils'
import { import {
@ -9,7 +9,7 @@ import {
message, message,
Spin Spin
} from 'antd'; } from 'antd';
import type { TableColumnsType} from 'antd'; import type { TableColumnsType } from 'antd';
import { import {
MailOutlined, MailOutlined,
MailFilled MailFilled
@ -53,8 +53,8 @@ export default function NoticeModal() {
onBefore() { onBefore() {
}, },
onSuccess(data) { onSuccess() {
console.log(data); // console.log(data);
getNoticeData() getNoticeData()
}, },
onFinally() { onFinally() {
@ -107,8 +107,8 @@ export default function NoticeModal() {
url: '/api/user-msg/listpage-simple/self', url: '/api/user-msg/listpage-simple/self',
config: { config: {
params: { params: {
// page: page, page: page,
// rows: 10, rows: 10,
isRead: isRead ? isRead : '', isRead: isRead ? isRead : '',
keywords: keywords ? keywords : '' keywords: keywords ? keywords : ''
} }
@ -148,6 +148,7 @@ export default function NoticeModal() {
// 点击删除按钮 // 点击删除按钮
const Delete = () => { const Delete = () => {
// const deleteIds:any = ids.join('/') // const deleteIds:any = ids.join('/')
console.log(selectedRowKeys);
del<any>({ del<any>({
messageApi, messageApi,
url: `api/user-msg/remove/self/${ids.join('_')}`, url: `api/user-msg/remove/self/${ids.join('_')}`,
@ -177,8 +178,7 @@ export default function NoticeModal() {
onBefore() { onBefore() {
}, },
onSuccess(data) { onSuccess() {
console.log(data);
getNoticeData() getNoticeData()
init() init()
}, },
@ -208,12 +208,35 @@ export default function NoticeModal() {
} }
}) })
} }
const selectedRowKeyRef = useRef<any>({})
const selectedRowRef = useRef<any>({})
// 缓存数组
// const [newArray,setNewArray] = useState<any[]>([])
// 选择(多选)项目 // 选择(多选)项目
const rowSelection = { const rowSelection = {
selectedRowKeys, selectedRowKeys,
onChange: (newselectedRowKeys: React.Key[], selectedRows: DataType[]) => { onChange: (newselectedRowKeys: React.Key[], selectedRows: DataType[]) => {
setSelectedRowKeys(newselectedRowKeys); selectedRowKeyRef.current[page]=newselectedRowKeys
const selectedOrderIds = selectedRows.map(row => row.userMsgId); selectedRowRef.current[page]=selectedRows
// console.log(11111111, newselectedRowKeys, selectedRowKeyRef.current);
const arr=[]
for (const element in selectedRowKeyRef.current) {
// console.log(22222,element);
arr.push(...selectedRowKeyRef.current[element])
}
setSelectedRowKeys(arr);
const arrIds=[]
for (const element in selectedRowRef.current) {
// console.log(22222,element);
arrIds.push(...selectedRowRef.current[element])
}
const selectedOrderIds = arrIds.map(row => row.userMsgId);
setIds(selectedOrderIds) setIds(selectedOrderIds)
}, },
}; };
@ -282,6 +305,10 @@ export default function NoticeModal() {
onChange: (currentPage) => { onChange: (currentPage) => {
setPage(currentPage); setPage(currentPage);
// init() // init()
// setSelectedRowKeys()
// const upArray = [...selectedRowKeys,...newArray]
// setSelectedRowKeys(upArray)
}, },
showSizeChanger: false, showSizeChanger: false,
current: page current: page