页码标记
This commit is contained in:
parent
576fe3d0cf
commit
c3ec65e327
@ -3,7 +3,6 @@ import './noticeModal.css'
|
|||||||
import { get, put, del } from '../../util/AjaxUtils'
|
import { get, put, del } from '../../util/AjaxUtils'
|
||||||
import {
|
import {
|
||||||
Table,
|
Table,
|
||||||
// Pagination,
|
|
||||||
Select,
|
Select,
|
||||||
Button,
|
Button,
|
||||||
Input,
|
Input,
|
||||||
@ -17,12 +16,6 @@ import {
|
|||||||
} from '@ant-design/icons';
|
} from '@ant-design/icons';
|
||||||
const { Search } = Input;
|
const { Search } = Input;
|
||||||
interface DataType {
|
interface DataType {
|
||||||
// key: React.Key;
|
|
||||||
// title: string;
|
|
||||||
// time: string;
|
|
||||||
// type: string;
|
|
||||||
// orderId: number;
|
|
||||||
// status: boolean
|
|
||||||
content: string;
|
content: string;
|
||||||
gmtCreate: string;
|
gmtCreate: string;
|
||||||
title: string;
|
title: string;
|
||||||
@ -43,12 +36,8 @@ export default function NoticeModal() {
|
|||||||
{
|
{
|
||||||
title: <div title='站内信' style={{ cursor: 'pointer' }}>站内信</div>,
|
title: <div title='站内信' style={{ cursor: 'pointer' }}>站内信</div>,
|
||||||
dataIndex: 'content',
|
dataIndex: 'content',
|
||||||
// align: 'center',
|
|
||||||
render: (text: string, record: DataType) => <div style={{
|
render: (text: string, record: DataType) => <div style={{
|
||||||
cursor: 'pointer', color: record.isRead ? '#b9b9b9' : '', textAlign: 'left',
|
cursor: 'pointer', color: record.isRead ? '#b9b9b9' : '', textAlign: 'left',
|
||||||
// overflow: 'hidden', // 隐藏超出容器的内容
|
|
||||||
// textOverflow: 'ellipsis', // 使用省略号表示被截断的内容
|
|
||||||
// whiteSpace: 'nowrap', // 防止文本换行
|
|
||||||
}} onClick={() => {
|
}} onClick={() => {
|
||||||
// alert('一度')
|
// alert('一度')
|
||||||
|
|
||||||
@ -105,34 +94,12 @@ export default function NoticeModal() {
|
|||||||
// 数据总数
|
// 数据总数
|
||||||
const [total, setTotal] = useState(0)
|
const [total, setTotal] = useState(0)
|
||||||
// 被选中的消息数组
|
// 被选中的消息数组
|
||||||
const [selectArray, setSelectArray] = useState<any[]>([])
|
// const [selectArray, setSelectArray] = useState<any[]>([])
|
||||||
// 被选中的消息id数组
|
// 被选中的消息id数组
|
||||||
const [ids, setIds] = useState<string[]>([])
|
const [ids, setIds] = useState<string[]>([])
|
||||||
const [selectedRowKeys, setSelectedRowKeys] = useState<any[]>([]); // 选中的行键
|
const [selectedRowKeys, setSelectedRowKeys] = useState<any[]>([]); // 选中的行键
|
||||||
const [data, setData] = useState<DataType[]>([
|
// const [totalSelectedKeys, setTotalSelectedKeys] = useState<any[]>([]); // 存储跨页选中项
|
||||||
// {
|
const [data, setData] = useState<DataType[]>([])
|
||||||
// orderId: 111,
|
|
||||||
// title: '消息1',
|
|
||||||
// time: '2024-08-12 12:56:35',
|
|
||||||
// type: '类型1',
|
|
||||||
// status: true
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// orderId: 222,
|
|
||||||
// title: '消息2',
|
|
||||||
// time: '2024-08-12 12:56:35',
|
|
||||||
// type: '类型2',
|
|
||||||
// status: false
|
|
||||||
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// orderId: 333,
|
|
||||||
// title: '消息3嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻',
|
|
||||||
// time: '2024-08-12 12:56:35',
|
|
||||||
// type: '类型3',
|
|
||||||
// status: false
|
|
||||||
// },
|
|
||||||
])
|
|
||||||
// 获取消息列表
|
// 获取消息列表
|
||||||
const getNoticeData = () => {
|
const getNoticeData = () => {
|
||||||
get<any>({
|
get<any>({
|
||||||
@ -140,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 : ''
|
||||||
}
|
}
|
||||||
@ -160,35 +127,12 @@ export default function NoticeModal() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// const data: DataType[] = [
|
|
||||||
// {
|
|
||||||
// orderId: 111,
|
|
||||||
// title: '消息1',
|
|
||||||
// time: '2024-08-12 12:56:35',
|
|
||||||
// type: '类型1',
|
|
||||||
// status: true
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// orderId: 222,
|
|
||||||
// title: '消息2',
|
|
||||||
// time: '2024-08-12 12:56:35',
|
|
||||||
// type: '类型2',
|
|
||||||
// status: false
|
|
||||||
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// orderId: 333,
|
|
||||||
// title: '消息3',
|
|
||||||
// time: '2024-08-12 12:56:35',
|
|
||||||
// type: '类型3',
|
|
||||||
// status: false
|
|
||||||
// },
|
|
||||||
// ];
|
|
||||||
// const isButtonDisabled = !data.some(item => item.status == false);
|
|
||||||
// 输入关键字搜索
|
// 输入关键字搜索
|
||||||
const handleSearch = (value: string) => {
|
const handleSearch = (value: string) => {
|
||||||
// console.log(value);
|
// console.log(value);
|
||||||
setKeywords(value)
|
setKeywords(value)
|
||||||
|
// init()
|
||||||
|
setPage(1)
|
||||||
}
|
}
|
||||||
// 当删除所有关键字时
|
// 当删除所有关键字时
|
||||||
const handleChange = (e: any) => {
|
const handleChange = (e: any) => {
|
||||||
@ -197,6 +141,8 @@ export default function NoticeModal() {
|
|||||||
// 如果删除所有发起请求重新取列表
|
// 如果删除所有发起请求重新取列表
|
||||||
// alert('重新获取')
|
// alert('重新获取')
|
||||||
setKeywords('')
|
setKeywords('')
|
||||||
|
// init()
|
||||||
|
setPage(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 点击删除按钮
|
// 点击删除按钮
|
||||||
@ -218,7 +164,6 @@ export default function NoticeModal() {
|
|||||||
//恢复无内容被选中状态
|
//恢复无内容被选中状态
|
||||||
const init = () => {
|
const init = () => {
|
||||||
setSelectedRowKeys([]);
|
setSelectedRowKeys([]);
|
||||||
setSelectArray([])
|
|
||||||
setIds([])
|
setIds([])
|
||||||
}
|
}
|
||||||
// 标记为已读
|
// 标记为已读
|
||||||
@ -244,9 +189,6 @@ export default function NoticeModal() {
|
|||||||
}
|
}
|
||||||
// 全部已读
|
// 全部已读
|
||||||
const ReadAll = () => {
|
const ReadAll = () => {
|
||||||
// setData(data.map(item => ({ ...item, status: true }))); //将所有false改为true
|
|
||||||
// console.log(data.map(item => item.orderId)); //所有的id数组
|
|
||||||
// console.log(data.filter(item => !item.status).map(item => item.orderId)); //未读的id数组
|
|
||||||
put<any>({
|
put<any>({
|
||||||
messageApi,
|
messageApi,
|
||||||
url: `/api/user-msg/update-read-all/self`,
|
url: `/api/user-msg/update-read-all/self`,
|
||||||
@ -269,18 +211,14 @@ export default function NoticeModal() {
|
|||||||
// 选择(多选)项目
|
// 选择(多选)项目
|
||||||
const rowSelection = {
|
const rowSelection = {
|
||||||
selectedRowKeys,
|
selectedRowKeys,
|
||||||
onChange: (selectedRowKeys: React.Key[], selectedRows: DataType[]) => {
|
onChange: (newselectedRowKeys: React.Key[], selectedRows: DataType[]) => {
|
||||||
console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
|
setSelectedRowKeys(newselectedRowKeys);
|
||||||
const selectedOrderIds = selectedRows.map(row => row.userMsgId);
|
const selectedOrderIds = selectedRows.map(row => row.userMsgId);
|
||||||
// Array.isArray()
|
|
||||||
// console.log(Array.isArray(selectedOrderIds));
|
|
||||||
setSelectedRowKeys(selectedRowKeys);
|
|
||||||
setSelectArray(selectedRowKeys);
|
|
||||||
console.log(`selectedOrderIds: ${selectedOrderIds}`);
|
|
||||||
setIds(selectedOrderIds)
|
setIds(selectedOrderIds)
|
||||||
setSelectArray(selectedRows)
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getNoticeData()
|
getNoticeData()
|
||||||
}, [page, isRead, keywords])
|
}, [page, isRead, keywords])
|
||||||
@ -294,6 +232,8 @@ export default function NoticeModal() {
|
|||||||
style={{ height: '31px', width: '70px' }}
|
style={{ height: '31px', width: '70px' }}
|
||||||
onChange={(value: string) => {
|
onChange={(value: string) => {
|
||||||
// console.log(value);
|
// console.log(value);
|
||||||
|
// init()
|
||||||
|
setPage(1)
|
||||||
setIsRead(value)
|
setIsRead(value)
|
||||||
}}
|
}}
|
||||||
options={[
|
options={[
|
||||||
@ -305,10 +245,10 @@ export default function NoticeModal() {
|
|||||||
// placeholder='选择类型'
|
// placeholder='选择类型'
|
||||||
/>
|
/>
|
||||||
<div>
|
<div>
|
||||||
<Button type="primary" disabled={selectArray.length > 0 ? false : true} onClick={() => {
|
<Button type="primary" disabled={selectedRowKeys.length > 0 ? false : true} onClick={() => {
|
||||||
Delete()
|
Delete()
|
||||||
}}>删除</Button>
|
}}>删除</Button>
|
||||||
<Button type="primary" disabled={selectArray.length > 0 ? false : true} onClick={() => {
|
<Button type="primary" disabled={selectedRowKeys.length > 0 ? false : true} onClick={() => {
|
||||||
Read()
|
Read()
|
||||||
}} style={{ marginLeft: 10 }}>标记为已读</Button>
|
}} style={{ marginLeft: 10 }}>标记为已读</Button>
|
||||||
<Button type="primary"
|
<Button type="primary"
|
||||||
@ -330,9 +270,9 @@ export default function NoticeModal() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Table
|
<Table
|
||||||
rowSelection={{
|
rowSelection={
|
||||||
...rowSelection,
|
rowSelection
|
||||||
}}
|
}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
dataSource={data}
|
dataSource={data}
|
||||||
pagination={
|
pagination={
|
||||||
@ -341,20 +281,15 @@ export default function NoticeModal() {
|
|||||||
total: total,
|
total: total,
|
||||||
onChange: (currentPage) => {
|
onChange: (currentPage) => {
|
||||||
setPage(currentPage);
|
setPage(currentPage);
|
||||||
|
// init()
|
||||||
},
|
},
|
||||||
showSizeChanger: false
|
showSizeChanger: false,
|
||||||
|
current: page
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
scroll={{ y: 500 }} bordered key="dataTable" rowKey="userMsgId"
|
scroll={{ y: 500 }} bordered rowKey="userMsgId"
|
||||||
/>
|
/>
|
||||||
{/* defaultCurrent: 默认当前页数 total:数据总数 defaultPageSize:'页面显示几条' */}
|
|
||||||
{/* <div className='product-release-pagination' >
|
|
||||||
<Pagination
|
|
||||||
showSizeChanger={false}
|
|
||||||
defaultCurrent={1} total={10} defaultPageSize={10} onChange={(page) => {
|
|
||||||
console.log(page)
|
|
||||||
}} />
|
|
||||||
</div> */}
|
|
||||||
</Spin>
|
</Spin>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user