diff --git a/src/forge/Source/Index.jsx b/src/forge/Source/Index.jsx
index 777c9103a..d32e447e6 100644
--- a/src/forge/Source/Index.jsx
+++ b/src/forge/Source/Index.jsx
@@ -1,10 +1,11 @@
import React, { useEffect, useState } from 'react';
import './Index.scss';
import { Blueback , FlexAJ } from '../Component/layout';
-import { Dropdown, Input , Menu , Pagination } from 'antd';
+import { Dropdown, Input , Menu , Pagination, Spin , Popconfirm } from 'antd';
import { Link } from 'react-router-dom';
import UploadSource from './UploadSource';
import { getImageUrl } from 'educoder';
+import Nodata from '../Nodata';
import axios from 'axios';
const { Search } = Input;
@@ -21,13 +22,20 @@ function Index(props){
const [ total , setTotal ] = useState(0);
const [ search , setSearch ] = useState(undefined);
const [ data , setData ] = useState(undefined);
+ const [ isSpin , setIsSpin ] = useState(true);
+ const [ error , setError ] = useState(false);
+ const [ attachments , setAttachments ] = useState(undefined);
+
+ const [ id , setId ] = useState(undefined);
const [ visible , setVisible ] = useState(false);
const repo_id = props.projectDetail && props.projectDetail.repo_id;
const owner = props.match.params.owner;
+ const current_user = props.current_user;
useEffect(()=>{
if(owner && repo_id){
+ setIsSpin(true);
getData();
}
},[repo_id,owner,search,sortValue,page])
@@ -46,8 +54,10 @@ function Index(props){
if(result && result.data){
setData(result.data.data.rows);
setTotal(result.data.data.total);
+ setIsSpin(false);
+ setError(false);
}
- }).catch(error=>{})
+ }).catch(error=>{setIsSpin(false);setError(true);})
}
// 搜索
@@ -73,24 +83,50 @@ function Index(props){
)
- const listmenu=(
-
资源库(18)
- setVisible(true)}>上传资源
+ { current_user && current_user.login &&
+ {setId(undefined);setVisible(true);}}>上传资源
+ }
@@ -119,43 +159,59 @@ function Index(props){
{sort[sortValue]}
-
-
- {
- data && data.length> 0 && data.map((item,key)=>{
- return(
- -
-
-
-
- {item.fileName}
-
-
-
-
-
- 上传时间:{item.uploadTime}
- 文件大小:{item.fileSize}
- 下载:{item.download}
-
-
{item.remark}
- { item.tags && item.tags.length>0 &&
-
- {
- item.tags.map((i,k)=>{
- return(
-
{i}
- )
- })
+
+
+ {
+ data && data.length> 0 &&
+
+ {
+ data.map((item,key)=>{
+ return(
+ -
+
+
+
+ {item.fileName}
+ { current_user && current_user.login &&
+ listmenu(item.id,item.attachments)} placement={'bottomRight'}>
+
+
}
-
- }
-
-
- )
- })
- }
-
+
+
+ 上传时间:{item.uploadTime}
+ 文件大小:{item.fileSize}
+ 下载:{item.download}
+
+ {item.remark}
+ { item.tags && item.tags.length>0 &&
+
+ {
+ item.tags.map((i,k)=>{
+ return(
+
{i}
+ {
+ current_user && (current_user.login === item.login) ?
+ removeTagFunc(item.id,i)} okText="是" cancelText="否">
+
+ :""
+ }
+
+ )
+ })
+ }
+
+ }
+
+
+ )
+ })
+ }
+
+ }
+ {
+ ((data && data.length === 0) || error) &&
+ }
{
total > limit &&
@@ -169,6 +225,7 @@ function Index(props){
}
+
)
}
diff --git a/src/forge/Source/Index.scss b/src/forge/Source/Index.scss
index c3ea90cf9..97a964975 100644
--- a/src/forge/Source/Index.scss
+++ b/src/forge/Source/Index.scss
@@ -21,6 +21,7 @@
}
.bodycontent{
padding:0px 20px;
+ min-height: 500px;
& > ul.bodycontentul > li{
display: flex;
border-bottom: 1px solid #eee;
diff --git a/src/forge/Source/UploadSource.jsx b/src/forge/Source/UploadSource.jsx
index 450f1eaef..d521206ef 100644
--- a/src/forge/Source/UploadSource.jsx
+++ b/src/forge/Source/UploadSource.jsx
@@ -11,12 +11,17 @@ const data = [
{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);
+function UploadSource({ form , visible , onCancel , onOk , showNotification , attachments , id ,owner,projectsId}){
+ const [ tableData , setTableData ] = useState(undefined);
const [ fileId , setFilesId ] = useState(undefined);
const [ fileName , setFileName ] = useState(undefined);
const { getFieldDecorator, validateFields , setFieldsValue } = form;
+ useEffect(()=>{
+ if(id && attachments){
+ setTableData(attachments);
+ }
+ },[id,attachments])
// 上传附件后得到的文件id数组
function UploadFunc(id,name){
setFilesId(id);
@@ -25,37 +30,36 @@ function UploadSource({ form , visible , onCancel , onOk , showNotification ,own
const columns = [
{
- dataIndex:"name",
- key:"name",
+ dataIndex:"fileName",
+ key:"fileName",
title:"资源名称",
- width:"45%",
+ width:"42%",
ellipsis:true,
render:(value,item,key)=>{
return
- {value}
+ {value}
{ key === 0 && 当前版本 }
}
},
{
- dataIndex:"loadNum",
- key:"loadNum",
+ dataIndex:"downloads",
+ key:"downloads",
title:"下载数",
- width:"15%",
+ width:"14%",
className:"edu-txt-center"
},
{
- dataIndex:"citeNum",
- key:"citeNum",
- title:"引用数",
- width:"15%",
+ dataIndex:"fileSizeString",
+ key:"fileSizeString",
+ title:"文件大小",
+ width:"16%",
className:"edu-txt-center"
},
{
- dataIndex:"time",
- key:"time",
+ dataIndex:"createdAt",
+ key:"createdAt",
title:"上传时间",
- width:"25%"
}
]
@@ -74,22 +78,35 @@ function UploadSource({ form , visible , onCancel , onOk , showNotification ,own
function postInfo(values){
const url = https+`/api/project/achievement/`;
+ if(id){
+ // 修改
+ axios.put(url,{
+ id,fileName,fileId:`${fileId}`,
+ remark:values.remark
+ }).then(result=>{
+ if(result && result.data){
+ onOk();
+ }
+ }).catch(error=>{})
+ }else{
+ // 上传
+ axios.post(url,{
+ fileId:`${fileId}`,
+ fileName,
+ login:owner,
+ projectId:projectsId,
+ ...values
+ }).then(result=>{
+ if(result && result.data){
+ onOk();
+ }
+ }).catch(error=>{})
+ }
- axios.post(url,{
- fileId:`${fileId}`,
- fileName,
- login:owner,
- projectId:projectsId,
- ...values
- }).then(result=>{
- if(result && result.data){
- onOk();
- }
- }).catch(error=>{})
}
return(