forked from Gitlink/forgeplus-react
合并资源库
This commit is contained in:
parent
21f7a2530a
commit
2e66904f81
|
|
@ -4,6 +4,7 @@ import { Blueback , FlexAJ } from '../Component/layout';
|
|||
import { Dropdown, Input , Menu , Pagination } from 'antd';
|
||||
import { Link } from 'react-router-dom';
|
||||
import UploadSource from './UploadSource';
|
||||
import { getImageUrl } from 'educoder';
|
||||
import axios from 'axios';
|
||||
|
||||
const { Search } = Input;
|
||||
|
|
@ -19,6 +20,7 @@ function Index(props){
|
|||
const [ page , setPage ] = useState(1);
|
||||
const [ total , setTotal ] = useState(0);
|
||||
const [ search , setSearch ] = useState(undefined);
|
||||
const [ data , setData ] = useState(undefined);
|
||||
|
||||
const [ visible , setVisible ] = useState(false);
|
||||
const repo_id = props.projectDetail && props.projectDetail.repo_id;
|
||||
|
|
@ -42,7 +44,8 @@ function Index(props){
|
|||
}
|
||||
}).then(result=>{
|
||||
if(result && result.data){
|
||||
|
||||
setData(result.data.data.rows);
|
||||
setTotal(result.data.data.total);
|
||||
}
|
||||
}).catch(error=>{})
|
||||
}
|
||||
|
|
@ -54,7 +57,6 @@ function Index(props){
|
|||
|
||||
// 切换排序方式
|
||||
function changeSort(e,index){
|
||||
console.log(index);
|
||||
setSortValue(index);
|
||||
}
|
||||
|
||||
|
|
@ -79,9 +81,9 @@ function Index(props){
|
|||
</Menu>
|
||||
)
|
||||
|
||||
// 上传资源确定
|
||||
// 上传资源成功
|
||||
function onOk(){
|
||||
|
||||
getData();
|
||||
}
|
||||
|
||||
// 删除标签
|
||||
|
|
@ -91,7 +93,14 @@ function Index(props){
|
|||
|
||||
return(
|
||||
<div className="sourcePanel">
|
||||
<UploadSource visible={visible} onCancel={()=>setVisible(false)} onOk={onOk} showNotification={props.showNotification}/>
|
||||
<UploadSource
|
||||
visible={visible}
|
||||
onCancel={()=>setVisible(false)}
|
||||
onOk={onOk}
|
||||
showNotification={props.showNotification}
|
||||
owner={owner}
|
||||
projectsId={repo_id}
|
||||
/>
|
||||
<div className="headtitle">
|
||||
<FlexAJ>
|
||||
<span className="font-18">资源库(18)</span>
|
||||
|
|
@ -112,27 +121,40 @@ function Index(props){
|
|||
</FlexAJ>
|
||||
<div className="bodycontent">
|
||||
<ul className="bodycontentul">
|
||||
<li>
|
||||
<Link to= {`/users/`} className="infoImg"><img src={`https://testforgeplus.trustie.net/images/avatars/User/b`} alt="" /></Link>
|
||||
<div style={{flex:'1',width:"0"}}>
|
||||
<FlexAJ>
|
||||
<a href={``} className="infoname">DaVinci.fdb</a>
|
||||
<Dropdown overlay={listmenu} placement={'bottomRight'}>
|
||||
<i className="iconfont icon-gengduo1 color-grey-6"></i>
|
||||
</Dropdown>
|
||||
</FlexAJ>
|
||||
<p className="infos">
|
||||
<span>上传时间:<span>2021-03-30</span></span>
|
||||
<span>上传类型:<span>软件版本</span></span>
|
||||
<span>文件大小:<span>10KB</span></span>
|
||||
<span>下载:<span>111</span></span>
|
||||
</p>
|
||||
<p className="infodesc task-hide-2">资源描述资源描述资源描述资源描述资源描述资源描述资源描述</p>
|
||||
<div className="infotag">
|
||||
<span>软件版本<i className="iconfont icon-guanbi font-12 ml2" onClick={removeTagFunc}></i></span>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
{
|
||||
data && data.length> 0 && data.map((item,key)=>{
|
||||
return(
|
||||
<li>
|
||||
<Link to= {`/users/${item.login}`} className="infoImg"><img src={getImageUrl(`${item.imageUrl}`)} alt="" /></Link>
|
||||
<div style={{flex:'1',width:"0"}}>
|
||||
<FlexAJ>
|
||||
<a href={``} className="infoname">{item.fileName}</a>
|
||||
<Dropdown overlay={listmenu} placement={'bottomRight'}>
|
||||
<i className="iconfont icon-gengduo1 color-grey-6"></i>
|
||||
</Dropdown>
|
||||
</FlexAJ>
|
||||
<p className="infos">
|
||||
<span>上传时间:<span>{item.uploadTime}</span></span>
|
||||
<span>文件大小:<span>{item.fileSize}</span></span>
|
||||
<span>下载:<span>{item.download}</span></span>
|
||||
</p>
|
||||
<p className="infodesc task-hide-2">{item.remark}</p>
|
||||
{ item.tags && item.tags.length>0 &&
|
||||
<div className="infotag">
|
||||
{
|
||||
item.tags.map((i,k)=>{
|
||||
return(
|
||||
<span>{i}<i className="iconfont icon-guanbi font-12 ml2" onClick={removeTagFunc}></i></span>
|
||||
)
|
||||
})
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</li>
|
||||
)
|
||||
})
|
||||
}
|
||||
</ul>
|
||||
{
|
||||
total > limit &&
|
||||
|
|
|
|||
|
|
@ -1,21 +1,137 @@
|
|||
import React from 'react';
|
||||
import { Modal } from 'antd';
|
||||
import React , { forwardRef, useEffect, useState } from 'react';
|
||||
import { Modal , Form , Checkbox , Input , Table } from 'antd';
|
||||
import Upload from './Upload';
|
||||
import { AlignCenter } from '../Component/layout';
|
||||
import axios from 'axios';
|
||||
const { TextArea } = Input;
|
||||
|
||||
const data = [
|
||||
{name:"sdfkjsfj.pdf",loadNum:"10",citeNum:"15",time:"2021-04-01 10:45"},
|
||||
{name:"sdfkjsfj.pdf",loadNum:"10",citeNum:"15",time:"2021-04-01 10:45"},
|
||||
{name:"sdfkjsfj.pdf",loadNum:"10",citeNum:"15",time:"2021-04-01 10:45"}
|
||||
]
|
||||
const https = 'https://testfiles.trustie.net';
|
||||
function UploadSource({ form , visible , onCancel , onOk , showNotification ,owner,projectsId}){
|
||||
const [ tableData , setTableData ] = useState(data);
|
||||
const [ fileId , setFilesId ] = useState(undefined);
|
||||
const [ fileName , setFileName ] = useState(undefined);
|
||||
const { getFieldDecorator, validateFields , setFieldsValue } = form;
|
||||
|
||||
function UploadSource({ visible , onCancel , onOk }){
|
||||
// 上传附件后得到的文件id数组
|
||||
function UploadFunc(id,name){
|
||||
setFilesId(id);
|
||||
setFileName(name);
|
||||
}
|
||||
|
||||
const columns = [
|
||||
{
|
||||
dataIndex:"name",
|
||||
key:"name",
|
||||
title:"资源名称",
|
||||
width:"45%",
|
||||
ellipsis:true,
|
||||
render:(value,item,key)=>{
|
||||
return <AlignCenter>
|
||||
<div className="task-hide" style={{maxWidth:key===0 ? "250px":"100%"}}>{value}</div>
|
||||
{ key === 0 && <span className="currentTip">当前版本</span> }
|
||||
</AlignCenter>
|
||||
}
|
||||
},
|
||||
{
|
||||
dataIndex:"loadNum",
|
||||
key:"loadNum",
|
||||
title:"下载数",
|
||||
width:"15%",
|
||||
className:"edu-txt-center"
|
||||
},
|
||||
{
|
||||
dataIndex:"citeNum",
|
||||
key:"citeNum",
|
||||
title:"引用数",
|
||||
width:"15%",
|
||||
className:"edu-txt-center"
|
||||
},
|
||||
{
|
||||
dataIndex:"time",
|
||||
key:"time",
|
||||
title:"上传时间",
|
||||
width:"25%"
|
||||
}
|
||||
]
|
||||
|
||||
// 确定
|
||||
function submit(){
|
||||
if(fileId){
|
||||
validateFields((error,values)=>{
|
||||
if(!error){
|
||||
postInfo(values);
|
||||
}
|
||||
})
|
||||
}else{
|
||||
showNotification("请先上传文件!");
|
||||
}
|
||||
}
|
||||
|
||||
function postInfo(values){
|
||||
const url = https+`/api/project/achievement/`;
|
||||
|
||||
axios.post(url,{
|
||||
fileId:`${fileId}`,
|
||||
fileName,
|
||||
login:owner,
|
||||
projectId:projectsId,
|
||||
...values
|
||||
}).then(result=>{
|
||||
if(result && result.data){
|
||||
onOk();
|
||||
}
|
||||
}).catch(error=>{})
|
||||
}
|
||||
return(
|
||||
<Modal
|
||||
title={"上传资源"}
|
||||
closable={false}
|
||||
visible={visible}
|
||||
onCancel={onCancel}
|
||||
onOk={onOk}
|
||||
onOk={submit}
|
||||
cancelText="取消"
|
||||
okText="确定"
|
||||
width="600px"
|
||||
centered
|
||||
>
|
||||
<div></div>
|
||||
<div>
|
||||
<Form>
|
||||
<Table className="versionTable" columns={columns} dataSource={tableData} pagination={false} size={"small"}/>
|
||||
<Form.Item>
|
||||
{getFieldDecorator("tagNames",{
|
||||
rules:[]
|
||||
})(
|
||||
<Checkbox.Group>
|
||||
<Checkbox value="软件版本">软件版本</Checkbox>
|
||||
<Checkbox value="文档">文档</Checkbox>
|
||||
<Checkbox value="代码">代码</Checkbox>
|
||||
<Checkbox value="媒体">媒体</Checkbox>
|
||||
<Checkbox value="论文">论文</Checkbox>
|
||||
<Checkbox value="其它">其它</Checkbox>
|
||||
</Checkbox.Group>
|
||||
)}
|
||||
</Form.Item>
|
||||
<Upload
|
||||
className="commentStyle"
|
||||
load={UploadFunc}
|
||||
size={100}
|
||||
showNotification={showNotification}
|
||||
actionUrl= {https}
|
||||
/>
|
||||
<Form.Item className="mt20">
|
||||
{getFieldDecorator("remark",{
|
||||
rules:[]
|
||||
})(
|
||||
<TextArea rows={4} placeholder="请输入资源描述" />
|
||||
)}
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</div>
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue