diff --git a/src/forge/SecuritySetting/notice/myNotice/Index.jsx b/src/forge/SecuritySetting/notice/myNotice/Index.jsx index ffa87ad43..cdf95afd5 100644 --- a/src/forge/SecuritySetting/notice/myNotice/Index.jsx +++ b/src/forge/SecuritySetting/notice/myNotice/Index.jsx @@ -9,28 +9,28 @@ import { CheckboxGroup } from 'rsuite'; function MyNotice(props) { - const [noticeType, setNoticeType] = useState("2");//消息类别tab栏选择 + const [noticeType, setNoticeType] = useState("0");//消息类别tab栏选择 const [selectedNum, setSelectedNum] = useState(0);//@我批量删除选择消息条数 const [isBatchDelete, setIsBatchDelete] = useState(false);//@我是否批量删除 - const [batchDeleteCheckedAll,setBatchDeleteCheckAll] = useState(false);//@我批量删除--全选 - const [batchDeleteList,setBatchDeleteList] = useState(new Set());//@我批量删除--选中 - const [atmeCount,setAtmeCount] = useState(0); + const [batchDeleteCheckedAll, setBatchDeleteCheckAll] = useState(false);//@我批量删除--全选 + const [batchDeleteList, setBatchDeleteList] = useState([]);//@我批量删除--选中 + const [atmeList, setAtmeList] = useState([]); const [noticeUnreadCount, setNoticeUnreadCount] = useState();//未读系统通知数量 const [letterUnreadCount, setLetterUnreadCount] = useState(0);//未读私信数量 const [atUnreadCount, setAtUnreadCount] = useState();//未读@我数量 const [messageList, setMessageList] = useState([]); - const [onlyUnread,setOnlyUnread] = useState(); + const [onlyUnread, setOnlyUnread] = useState(); useEffect(() => { const params = { - type:noticeType==="0"?"notification":noticeType==="2"?"atme":"", - status:onlyUnread?onlyUnread:"", + type: noticeType === "0" ? "notification" : noticeType === "2" ? "atme" : "", + status: onlyUnread ? onlyUnread : "", limit: 20, page: 0, } getMessageList(params); - }, [noticeType,onlyUnread]) + }, [noticeType, onlyUnread]) function getMessageList(params) { Axios.get(`/users/yystopf/messages.json`, { @@ -40,11 +40,13 @@ function MyNotice(props) { setAtUnreadCount(response.data.unread_atme); setMessageList(response.data.messages); }) - var count = 0; - messageList.map(item=>{ - item.type==="atme"?count++:""; + console.log(messageList); + const atmeList = new Array(); + messageList.map(item => { + item.type === "atme" ? atmeList.push(item.id.toString()) : ""; }) - setAtmeCount(count); + setAtmeList(atmeList); + console.log(atmeList); } function handleClick(e) { @@ -54,20 +56,21 @@ function MyNotice(props) { } } - function onChange(e) { - if(e.target.checked){ - batchDeleteList.has(e.target.name)?"":setBatchDeleteList(batchDeleteList.add(e.target.name)); - }else{ - batchDeleteList.delete(e.target.name); - } - batchDeleteList.size === atmeCount?setBatchDeleteCheckAll(true):""; - console.log(batchDeleteCheckedAll); + function onChange(batchDeleteList) { + setBatchDeleteCheckAll(batchDeleteList.length === atmeList.length) + // if(e.target.checked){ + // batchDeleteList.has(e.target.name)?"":setBatchDeleteList(batchDeleteList.add(e.target.name)); + // }else{ + // batchDeleteList.delete(e.target.name); + // } + // batchDeleteList.size === atmeCount?setBatchDeleteCheckAll(true):""; + // console.log(batchDeleteCheckedAll); } function onCheckAllChange(e) { - // setBatchDeleteList(e.target.checked?) setBatchDeleteCheckAll(e.target.checked); + setBatchDeleteList(e.target.checked ? atmeList : []); // const checkbox = document.getElementsByClassName("atme-checkbox"); // for (var i = 0; i < checkbox.length; i++) { // checkbox[i].checked = e.target.checked; @@ -86,6 +89,20 @@ function MyNotice(props) { }); } + function readNotice(id){ + alert("消息已读"); + console.log(id); + const params = { + type: noticeType === "0" ? "notification" : noticeType === "2" ? "atme" : "", + ids:[id], + }; + Axios.post(`/users/yystopf/messages/read.json`,{ + params:params, + }).then((response)=>{ + console.log(response); + }) + } + return (