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 (
@@ -99,7 +116,7 @@ function MyNotice(props) {
- e.target.checked?setOnlyUnread(1):setOnlyUnread(2)}>仅看未读{noticeType === "1" ? `私信(12)` : noticeType==="0"?`消息(${noticeUnreadCount})`:`消息(${atUnreadCount})`} + e.target.checked ? setOnlyUnread(1) : setOnlyUnread(2)}>仅看未读{noticeType === "1" ? `私信(12)` : noticeType === "0" ? `消息(${noticeUnreadCount})` : `消息(${atUnreadCount})`}
{noticeType === "2" ? : ""}
@@ -107,7 +124,7 @@ function MyNotice(props) {
{/*   */} - 全选 + 全选    已选择 {selectedNum} 项
@@ -117,45 +134,45 @@ function MyNotice(props) {
- {messageList.map(item => { - // 系统消息 - // 消息类别 - // const iconName = item.source.startsWith("Issue")?"icon-yixiuicon1":item.source.startsWith("Project")?"icon-daimakuicon1":item.source.startsWith("Project")?"icon-daimakuicon1": - if(noticeType ==="0" && item.type === "notification"){ - return( -
-
- {item.status === 1? :} - - window.location.href=(`${item.notification_url}`)}>{item.content} + {messageList.map(item => { + // 系统消息 + // 消息类别 + // const iconName = item.source.startsWith("Issue")?"icon-yixiuicon1":item.source.startsWith("Project")?"icon-daimakuicon1":item.source.startsWith("Project")?"icon-daimakuicon1": + if (noticeType === "0" && item.type === "notification") { + return ( +
+
+ {item.status === 1 ? : } + + window.location.href = (`${item.notification_url}`)}>{item.content} +
+
+ {item.time_ago} + {item.status === 1 && 标记为已读} +
-
- {item.time_ago} - 标记为已读 + ) + } else if (noticeType === "2" && item.type === "atme") { + //@我 + return ( +
+
+ {/* */} + + + + {item.status === 1 ? : } + {item.content} + +
+
+ {item.time_ago} + 标记为已读   删除 +
-
- ) - } else if(noticeType ==="2" && item.type === "atme"){ - //@我 - return( -
-
- {/* */} - - - - {item.status === 1? :} - {item.content} - -
-
- {item.time_ago} - 标记为已读   删除 -
-
- ) - } - })} + ) + } + })}
) } diff --git a/src/forge/SecuritySetting/notice/myNotice/Index.scss b/src/forge/SecuritySetting/notice/myNotice/Index.scss index ef1fef270..d8ce6ad0a 100644 --- a/src/forge/SecuritySetting/notice/myNotice/Index.scss +++ b/src/forge/SecuritySetting/notice/myNotice/Index.scss @@ -87,13 +87,14 @@ button:active { background: #F3F4F6; } - & a{ + & .invisable-read{ display: none; } - &:hover a{ + &:hover .invisable-read{ display: block; color: #466AFF; + cursor: pointer; } &:hover .timeSpan{