- -
-
-
-
- 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/Upload.jsx b/src/forge/Source/Upload.jsx
index 1897b959..de2c8ecb 100644
--- a/src/forge/Source/Upload.jsx
+++ b/src/forge/Source/Upload.jsx
@@ -1,14 +1,15 @@
import React, { useEffect, useState } from "react";
-import { Upload, Icon , Button } from 'antd';
+import { Upload, Button } from 'antd';
import { appendFileSizeToUploadFileAll } from 'educoder';
import axios from 'axios';
-const { Dragger } = Upload;
-function Upload({isComplete, icon , btn , className , size , actionUrl,fileList}) {
+function Uploads({ className , size , actionUrl,fileList,showNotification , load}) {
const [ files , setFiles ] = useState(undefined);
useEffect(()=>{
- init();
+ if(fileList){
+ init();
+ }
},[fileList]);
function init(){
@@ -22,14 +23,12 @@ function Upload({isComplete, icon , btn , className , size , actionUrl,fileList}
}
}
function deleteAttachment(file){
- const url = `/attachments/${file.response ? file.response.id : file.uid}.json`
- axios.delete(url, {
- }).then((response) => {
+ let id = file.response && file.response.data && file.response.data.id;
+ const url = actionUrl + `/busiAttachments/${id}`;
+ axios.delete(url).then((response) => {
if (response.data) {
- if (response.data.status === 0) {
- let index = files.indexOf(file);
- let newFileList = files.slice();
- let nf = newFileList.splice(index, 1);
+ if (response.data.code === "1") {
+ let nf = files.filter(item=>item.response.data.id !== id);
setFiles(nf);
fileIdList(nf);
} else {
@@ -45,18 +44,15 @@ function Upload({isComplete, icon , btn , className , size , actionUrl,fileList}
function handleChange (info) {
if (info.file.status === 'uploading' || info.file.status === 'done' || info.file.status === 'removed') {
let fileList = info.fileList;
-
- setFiles(appendFileSizeToUploadFileAll(fileList));
- fileIdList(fileList);
+ let len = info.fileList && info.fileList.length;
+ setFiles(appendFileSizeToUploadFileAll([fileList[len-1]]));
+ fileIdList(fileList[len-1]);
}
}
function fileIdList (fileList) {
- let array = [];
- fileList && fileList.length > 0 && fileList.map((item) => {
- return array.push(item.response && (item.response.id || (item.response.data && item.response.data.id)));
- })
- array && load && load(array);
+ let data = fileList.response && fileList.response.data;
+ fileList && load && load(data && data.id,data && data.fileName);
}
function beforeUpload(file){
@@ -67,29 +63,20 @@ function Upload({isComplete, icon , btn , className , size , actionUrl,fileList}
return isLt100M;
}
- //判断是否已经提交,如已提交评论则上一条评论数据清除
-
- const upload = {
- name: 'file',
- fileList: files,
- action: actionUrl,
- onChange:handleChange,
- onRemove:onAttachmentRemove,
- beforeUpload:beforeUpload
- };
-
- return (
- btn ?
-
-
- (你可以上传小于{size}MB的文件)
-
- :
-
- {icon || }
- 拖动文件或点击此处上传
-
- )
- }
+ const upload = {
+ name: 'file',
+ fileList: files,
+ action: actionUrl+`/busiAttachments/upload`,
+ onChange:handleChange,
+ onRemove:onAttachmentRemove,
+ beforeUpload:beforeUpload,
+ maxCount:1
+ };
+ return (
+
+
+ (你可以上传小于{size}MB的文件)
+
+ )
}
-export default Upload;
\ No newline at end of file
+export default Uploads;
\ No newline at end of file
diff --git a/src/forge/Source/UploadSource.jsx b/src/forge/Source/UploadSource.jsx
index a8ccfdc3..450f1eae 100644
--- a/src/forge/Source/UploadSource.jsx
+++ b/src/forge/Source/UploadSource.jsx
@@ -1,22 +1,138 @@
-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(
-
+