From 2e66904f81949077a5f3ec18e799adb290a8d913 Mon Sep 17 00:00:00 2001 From: caishi <1149225589@qq.com> Date: Fri, 2 Apr 2021 17:31:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=88=E5=B9=B6=E8=B5=84=E6=BA=90=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/forge/Source/Index.jsx | 74 ++++++++++++------ src/forge/Source/UploadSource.jsx | 126 ++++++++++++++++++++++++++++-- 2 files changed, 169 insertions(+), 31 deletions(-) diff --git a/src/forge/Source/Index.jsx b/src/forge/Source/Index.jsx index bcc27acd..777c9103 100644 --- a/src/forge/Source/Index.jsx +++ b/src/forge/Source/Index.jsx @@ -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){ ) - // 上传资源确定 + // 上传资源成功 function onOk(){ - + getData(); } // 删除标签 @@ -91,7 +93,14 @@ function Index(props){ return(
- setVisible(false)} onOk={onOk} showNotification={props.showNotification}/> + setVisible(false)} + onOk={onOk} + showNotification={props.showNotification} + owner={owner} + projectsId={repo_id} + />
资源库(18) @@ -112,27 +121,40 @@ function Index(props){
    -
  • - -
    - - DaVinci.fdb - - - - -

    - 上传时间:2021-03-30 - 上传类型:软件版本 - 文件大小:10KB - 下载:111 -

    -

    资源描述资源描述资源描述资源描述资源描述资源描述资源描述

    -
    - 软件版本 -
    -
    -
  • + { + 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} + ) + }) + } +
    + } +
    +
  • + ) + }) + }
{ total > limit && diff --git a/src/forge/Source/UploadSource.jsx b/src/forge/Source/UploadSource.jsx index e57131da..22a45392 100644 --- a/src/forge/Source/UploadSource.jsx +++ b/src/forge/Source/UploadSource.jsx @@ -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 +
{value}
+ { key === 0 && 当前版本 } +
+ } + }, + { + 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( -
+
+
+ + + {getFieldDecorator("tagNames",{ + rules:[] + })( + + 软件版本 + 文档 + 代码 + 媒体 + 论文 + 其它 + + )} + + + + {getFieldDecorator("remark",{ + rules:[] + })( +