forked from Gitlink/forgeplus-react
我的资源/文章列表
This commit is contained in:
parent
2a6402e5bb
commit
3821b3102d
|
|
@ -0,0 +1,162 @@
|
|||
import React,{ useState, useEffect } from 'react';
|
||||
import { Breadcrumb , Spin , Pagination , Modal, Button } from 'antd';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { getNewsMyList , getSourceMyList , delNewsMyList , delSourceMyList } from '../api';
|
||||
import moment from 'moment';
|
||||
import nodata from '../img/nodata.png';
|
||||
import '../index.scss';
|
||||
|
||||
|
||||
function SelfList(props){
|
||||
const [ status , setStatus ] = useState(1);
|
||||
const [ isSpin , setIsSpin ] = useState(true);
|
||||
const [ source , setSource ] = useState(undefined);
|
||||
const [ list , setList ] = useState(undefined);
|
||||
const [ page , setPage ] = useState(1);
|
||||
const [ total , setTotal ] = useState(0);
|
||||
|
||||
const [ visible ,setVisible ] = useState(false);
|
||||
const [ deleId , setDeleId] = useState(undefined);
|
||||
const pathname = props.location.pathname;
|
||||
const { id , temp } = props;
|
||||
const limit = 15;
|
||||
|
||||
useEffect(()=>{
|
||||
if(id){
|
||||
setIsSpin(true);
|
||||
if(source && source===true){
|
||||
getSource();
|
||||
}else{
|
||||
getNew();
|
||||
}
|
||||
}
|
||||
},[status, page , id,source])
|
||||
|
||||
|
||||
useEffect(()=>{
|
||||
if(pathname){
|
||||
if(pathname.indexOf("/source/self")>-1){
|
||||
setSource(true);
|
||||
}else{
|
||||
setSource(false);
|
||||
}
|
||||
}
|
||||
},[pathname])
|
||||
|
||||
function getSource(){
|
||||
getSourceMyList({
|
||||
auditStatus:status,
|
||||
zoneId:id,
|
||||
pageSize:limit
|
||||
}).then(result=>{
|
||||
setList(result.data.rows);
|
||||
setTotal(result.data.total);
|
||||
setIsSpin(false);
|
||||
})
|
||||
}
|
||||
|
||||
function getNew(){
|
||||
getNewsMyList(id,{
|
||||
auditStatus:status,
|
||||
pageSize:limit
|
||||
}).then(result=>{
|
||||
setList(result.data.rows);
|
||||
setTotal(result.data.total);
|
||||
setIsSpin(false);
|
||||
})
|
||||
}
|
||||
|
||||
function cancelFunc(){
|
||||
setVisible(false);
|
||||
setDeleId(undefined);
|
||||
}
|
||||
function sureFunc(){
|
||||
if(source){
|
||||
delSourceMyList(deleId).then(response=>{
|
||||
setVisible(false);
|
||||
props.showNotification("删除成功!");
|
||||
getSource();
|
||||
})
|
||||
}else{
|
||||
delNewsMyList(deleId).then(response=>{
|
||||
setVisible(false);
|
||||
props.showNotification("删除成功!");
|
||||
getNew();
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return(
|
||||
<div className="selfBoxContent">
|
||||
<Modal
|
||||
visible={visible}
|
||||
width="456px"
|
||||
title={`申请删除${source?"资源":"文章"}`}
|
||||
onCancel={cancelFunc}
|
||||
footer={null}
|
||||
className="delSModal"
|
||||
>
|
||||
<div className="delBoxCon">
|
||||
<i className="iconfont icon-shanchu_tc_icon font-22 mr15" style={{color:"#ca0002"}}></i>
|
||||
<div>
|
||||
<p className="font-15 mb15 mt5" style={{color:"#202d40"}}>确定删除该{source?"资源":"文章"}?</p>
|
||||
<p style={{color:"#5f6872"}}>{source?"删除后所有资源文件将被清楚,请谨慎操作":"此操作将发出文章删除申请,管理员同意申请后该文章将被删除"}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="delBoxBtn">
|
||||
<Button onClick={cancelFunc}>取消</Button>
|
||||
<Button type="primary" onClick={sureFunc} style={{backgroundColor:"#fff",color:"#466aff"}}>确认</Button>
|
||||
</div>
|
||||
</Modal>
|
||||
<Breadcrumb separator=">" style={{paddingTop:"20px"}}>
|
||||
<Breadcrumb.Item><Link className="primaryColor" to={pathname.replace("/self","")}>{source ? "资源发布":"领域资讯"}</Link></Breadcrumb.Item>
|
||||
<Breadcrumb.Item>我的{source ? "资源":"文章"}</Breadcrumb.Item>
|
||||
</Breadcrumb>
|
||||
<ul className="selfMenu">
|
||||
<li onClick={()=>setStatus(1)} className={status===1?"active":""}>已发布</li>
|
||||
<li onClick={()=>setStatus(0)} className={status===0?"active":""}>待审核</li>
|
||||
<li onClick={()=>setStatus(2)} className={status===2?"active":""}>未通过</li>
|
||||
</ul>
|
||||
<Spin spinning={isSpin}>
|
||||
<ul className="selfListPanel">
|
||||
{
|
||||
list && list.length === 0 &&
|
||||
<div style={{display:"flex",justifyContent:"center",alignItems:"center",flexDirection:"column",height:500}}>
|
||||
<img src={ nodata } alt="" width="300"/>
|
||||
<p className="font-15 color-grey-6 mt20">暂无数据~</p>
|
||||
</div>
|
||||
}
|
||||
{
|
||||
list && list.length > 0 && list.map((i,k)=>{
|
||||
return(
|
||||
<li>
|
||||
<div>
|
||||
<a className="s-name task-hide">{i.name}</a>
|
||||
<div className="s-info">
|
||||
<span>
|
||||
<span>{i.domainName}</span>
|
||||
<span className="ml10 mr15">|</span>
|
||||
<span><i className="iconfont icon-a-31shijian mr5 font-15"></i>{moment(i.createTime).format("YYYY/MM/DD")}</span>
|
||||
</span>
|
||||
<span className="s-info-right">
|
||||
<a href="" style={{color:"#466aff"}}><i className="iconfont icon-a-bianji12 mr5 font-14"></i>编辑</a>
|
||||
<a style={{color:"#d81017",marginLeft:"25px"}}onClick={()=>{setVisible(true);setDeleId(i.id)}}><i className="iconfont icon-fuzhi-shanchu mr5 font-14"></i>删除</a>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
)
|
||||
})
|
||||
}
|
||||
{
|
||||
total > limit &&
|
||||
<div style={{padding:"20px",textAlign:"right"}}>
|
||||
<Pagination showQuickJumper current={page} total={total} pageSize={limit} onChange={(p)=>setPage(p)}/>
|
||||
</div>
|
||||
}
|
||||
</ul>
|
||||
</Spin>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
export default SelfList;
|
||||
|
|
@ -60,6 +60,19 @@ export function getNewsDetail(id){
|
|||
method: 'get',
|
||||
})
|
||||
}
|
||||
export function getNewsMyList(id,params){
|
||||
return fetch({
|
||||
url:`/cms/doc/zone/${id}/myDocList`,
|
||||
method:"get",
|
||||
params
|
||||
})
|
||||
}
|
||||
export function delNewsMyList(id){
|
||||
return fetch({
|
||||
url:`/cms/doc/${id}`,
|
||||
method:"delete"
|
||||
})
|
||||
}
|
||||
|
||||
/**开源项目 */
|
||||
export function getProjectsLists(id,params){
|
||||
|
|
@ -127,6 +140,19 @@ export function getSourceDetail(id){
|
|||
method: 'get'
|
||||
})
|
||||
}
|
||||
export function getSourceMyList(params){
|
||||
return fetch({
|
||||
url:`/zone/zoneFront/myResourceList`,
|
||||
method:"get",
|
||||
params
|
||||
})
|
||||
}
|
||||
export function delSourceMyList(id){
|
||||
return fetch({
|
||||
url:`/zone/zoneFront/removeResource/${id}`,
|
||||
method:"delete"
|
||||
})
|
||||
}
|
||||
|
||||
// 创建专区
|
||||
export function postCreateZone(data) {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ function beforeFetch(actionUrl){
|
|||
}
|
||||
|
||||
const service = axios.create({
|
||||
headers:{Authorization:"a57ec217a1963611f9a0ff591b305dc3d5b3ba1f"},
|
||||
baseURL: actionUrl,
|
||||
timeout: 1800000, // 请求超时时间
|
||||
});
|
||||
|
|
|
|||
|
|
@ -33,6 +33,10 @@ const Source = Loadable({
|
|||
loader: () => import("./Pages/source"),
|
||||
loading: Loading,
|
||||
});
|
||||
const SourceSelfList = Loadable({
|
||||
loader: () => import("./Pages/selfList"),
|
||||
loading: Loading,
|
||||
});
|
||||
const HeaderPage = Loadable({
|
||||
loader: () => import("./Pages/headerPage"),
|
||||
loading: Loading,
|
||||
|
|
@ -129,6 +133,12 @@ function Index(props){
|
|||
<div className="information_main">
|
||||
{ (!sourcedetail && deptId!=="apply") && (id ? <PublicBanner {...props} data={data} temp={ temp } adminUrl={adminUrl}/> : <div style={{ width: '100%', height: '450px' }}></div>)}
|
||||
<Switch>
|
||||
<Route
|
||||
path="/zone/:deptId/news/self"
|
||||
render={(p) => (
|
||||
<SourceSelfList {...props} {...p} id={id} temp={ temp }/>
|
||||
)}
|
||||
></Route>
|
||||
<Route
|
||||
path="/zone/:deptId/news/:cateId"
|
||||
render={(p) => (
|
||||
|
|
@ -141,6 +151,12 @@ function Index(props){
|
|||
<NewsDetail {...props} {...p} id={id} temp={ temp } data={data}/>
|
||||
)}
|
||||
></Route>
|
||||
<Route
|
||||
path="/zone/:deptId/source/self"
|
||||
render={(p) => (
|
||||
<SourceSelfList {...props} {...p} id={id} temp={ temp }/>
|
||||
)}
|
||||
></Route>
|
||||
<Route
|
||||
path="/zone/:deptId/source/:sourceid"
|
||||
render={(p) => (
|
||||
|
|
|
|||
|
|
@ -1562,4 +1562,108 @@
|
|||
position: absolute;
|
||||
}
|
||||
}
|
||||
}
|
||||
.selfBoxContent{
|
||||
width: 1200px;
|
||||
margin:0px auto;
|
||||
padding-bottom: 40px;
|
||||
border-radius: 4px;
|
||||
.selfMenu{
|
||||
width: 540px;
|
||||
margin:20px auto 25px;
|
||||
background-color: #fff;
|
||||
display: flex;
|
||||
border-radius: 4px;
|
||||
box-shadow:0px 0px 10px rgba(61, 85, 183, 0.1);
|
||||
li{
|
||||
flex: 1;
|
||||
border-right: 1px solid rgba(141, 149, 172, 0.17);
|
||||
font-size:17px;
|
||||
text-align:center;
|
||||
color:#3d485d;
|
||||
height: 50px;
|
||||
line-height: 50px;
|
||||
cursor: pointer;
|
||||
&:first-child{
|
||||
border-radius: 4px 0px 0px 4px;
|
||||
}
|
||||
&:last-child{
|
||||
border-right: none;
|
||||
border-radius: 0px 4px 4px 0px;
|
||||
}
|
||||
&.active{
|
||||
background-color: #466aff;
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
}
|
||||
.selfListPanel{
|
||||
padding:17px 0px;
|
||||
background-color: #fff;
|
||||
margin-top: 26px;
|
||||
min-height: 400px;
|
||||
li{
|
||||
padding:0px 25px;
|
||||
&:hover{
|
||||
background-color: #f3f5f8;
|
||||
.s-info-right{
|
||||
display: block!important;
|
||||
}
|
||||
}
|
||||
&>div{
|
||||
border-bottom: 1px dashed rgba(170, 175, 190, 0.15);
|
||||
padding:15px 0px;
|
||||
.s-name{
|
||||
position: relative;
|
||||
color:#1f2329;
|
||||
font-size:18px;
|
||||
padding-left: 16px;
|
||||
height: 26px;
|
||||
line-height: 26px;
|
||||
display: block;
|
||||
&::before{
|
||||
position: absolute;
|
||||
left: 0px;
|
||||
height: 8px;
|
||||
width: 8px;
|
||||
background-color: #466aff;
|
||||
border-radius: 50%;
|
||||
top:10px;
|
||||
content: "";
|
||||
}
|
||||
}
|
||||
.s-info{
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
width: 100%;
|
||||
margin-top: 14px;
|
||||
height: 20px;
|
||||
color:#4c5876;
|
||||
align-items: center;
|
||||
.s-info-right{
|
||||
display: none;
|
||||
transition: 0.3s;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.delSModal{
|
||||
.ant-modal-title{
|
||||
text-align: left;
|
||||
}
|
||||
.delBoxCon{
|
||||
width:334px;
|
||||
display:flex;
|
||||
margin:0px auto 20px;
|
||||
align-items:flex-start;
|
||||
}
|
||||
.delBoxBtn{
|
||||
text-align: center;
|
||||
.ant-btn{
|
||||
width: 95px;
|
||||
margin:0px 20px;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue