diff --git a/src/forge/Source/AddTag.jsx b/src/forge/Source/AddTag.jsx
new file mode 100644
index 00000000..8b94b5a6
--- /dev/null
+++ b/src/forge/Source/AddTag.jsx
@@ -0,0 +1,47 @@
+import React , { forwardRef, useEffect } from 'react';
+import { Modal , Form , Input } from 'antd';
+
+function AddTag({form , visible , onCancel ,onOk}){
+ const { getFieldDecorator, validateFields , setFieldsValue } = form;
+
+ useEffect(()=>{
+ setFieldsValue({tagName:undefined})
+ },[visible])
+
+ function submit(){
+ validateFields((error,values)=>{
+ if(!error){
+ onOk(values);
+ }
+ })
+ }
+ const layout = {
+ labelCol: { span: 5 },
+ wrapperCol: { span: 18 },
+ };
+ return(
+
+
+ {getFieldDecorator("tagName",{
+ rules:[{required:true,message:"请输入标签名"}]
+ })(
+
+ )}
+
+
+
+ )
+
+}
+export default Form.create()(forwardRef(AddTag));
\ No newline at end of file
diff --git a/src/forge/Source/Index.jsx b/src/forge/Source/Index.jsx
index d32e447e..f3c68217 100644
--- a/src/forge/Source/Index.jsx
+++ b/src/forge/Source/Index.jsx
@@ -1,9 +1,10 @@
import React, { useEffect, useState } from 'react';
import './Index.scss';
-import { Blueback , FlexAJ } from '../Component/layout';
-import { Dropdown, Input , Menu , Pagination, Spin , Popconfirm } from 'antd';
+import { AlignCenter, Blueback , FlexAJ } from '../Component/layout';
+import { Dropdown, Input , Menu , Pagination, Spin , Popconfirm, Button } from 'antd';
import { Link } from 'react-router-dom';
import UploadSource from './UploadSource';
+import AddTag from './AddTag';
import { getImageUrl } from 'educoder';
import Nodata from '../Nodata';
import axios from 'axios';
@@ -29,6 +30,8 @@ function Index(props){
const [ id , setId ] = useState(undefined);
const [ visible , setVisible ] = useState(false);
+ const [ addVisible , setAddVisible ] = useState(false);
+
const repo_id = props.projectDetail && props.projectDetail.repo_id;
const owner = props.match.params.owner;
const current_user = props.current_user;
@@ -83,32 +86,52 @@ function Index(props){
)
- function listmenu(id,attachments){
+ function listmenu(id,attachments,isPublic){
return(
)
}
-
- // 删除资源方法
- function deleteSourceFunc(id){
- const url = https + `/api/project/achievement/${id}`;
- axios.delete(url).then(result=>{
- if(result && result.data && result.data.code === "1"){
- props.showNotification("资源删除成功");
+ // 更细私有状态
+ function changeStatus(id,isPublic){
+ const url = https+`/api/project/achievement/updateStatus`;
+ axios.put(url,{
+ id,status:isPublic
+ }).then(result=>{
+ if(result && result.data){
+ props.showNotification(`资源${isPublic === 1 ? "设为公开":"设为私有"}成功!`);
setIsSpin(true);
getData();
}
+ }).catch({})
+ }
+
+ // 删除资源方法
+ function deleteSourceFunc(id){
+ props.confirm({
+ content: "是否确认删除所选资源文件?",
+ onOk: () => {
+ const url = https + `/api/project/achievement/${id}`;
+ axios.delete(url).then(result=>{
+ if(result && result.data && result.data.code === "1"){
+ props.showNotification("资源删除成功");
+ setIsSpin(true);
+ getData();
+ }
+ })
+ }
})
+
}
// 上传资源成功
function onOk(){
setVisible(false);
+ setIsSpin(true);
getData();
}
@@ -126,9 +149,36 @@ function Index(props){
}).then(error=>{})
}
+ function addPanel(id){
+ setAddVisible(true);
+ setId(id);
+ }
+
+ function onCancelAdd(){
+ setId(undefined);
+ setAddVisible(false);
+ }
+
+ // 添加标签
+ function sureAddTag(values){
+ const url = https+`/api/project/achievement/addTag?id=`+id+`&tagName=`+values.tagName;
+ axios.put(url).then(result=>{
+ if(result){
+ setId(undefined);
+ setAddVisible(false);
+ setIsSpin(true);
+ getData();
+ }
+ })
+ }
return(
+
setVisible(false)}
@@ -142,8 +192,8 @@ function Index(props){
资源库(18)
- { current_user && current_user.login &&
- {setId(undefined);setVisible(true);}}>上传资源
+ { current_user && current_user.login && (props.projectDetail && props.projectDetail.permission) ?
+ {setId(undefined);setVisible(true);}}>上传资源:""
}
@@ -171,9 +221,13 @@ function Index(props){
- {item.fileName}
+
+ {item.fileName}
+
+ {item.isPublic === 0 && 私有}
+
{ current_user && current_user.login &&
- listmenu(item.id,item.attachments)} placement={'bottomRight'}>
+ listmenu(item.id,item.attachments,item.isPublic)} placement={'bottomRight'}>
}
@@ -184,24 +238,26 @@ function Index(props){
下载:{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="否">
-
- :""
- }
-
- )
- })
- }
-
- }
+
+ {
+ 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="否">
+
+ :""
+ }
+
+ )
+ })
+ }
+ {
+ current_user && (current_user.login === item.login) &&
+
addPanel(item.id)} style={{height:"20px",lineHeight:"20px"}}>+新增标签
+ }
+
)
diff --git a/src/forge/Source/Index.scss b/src/forge/Source/Index.scss
index 751fac53..53e83562 100644
--- a/src/forge/Source/Index.scss
+++ b/src/forge/Source/Index.scss
@@ -41,6 +41,16 @@
.infoname{
font-size: 16px;
}
+ .privateTip{
+ display: block;
+ font-size: 12px;
+ margin-left: 10px;
+ background-color: orange;
+ height: 18px;
+ line-height: 18px;
+ padding:0px 3px;
+ color: #fff;
+ }
.infos{
& > span{
margin-right: 20px;
diff --git a/src/forge/Source/UploadSource.jsx b/src/forge/Source/UploadSource.jsx
index d521206e..64bd5b7c 100644
--- a/src/forge/Source/UploadSource.jsx
+++ b/src/forge/Source/UploadSource.jsx
@@ -5,11 +5,6 @@ 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 , attachments , id ,owner,projectsId}){
const [ tableData , setTableData ] = useState(undefined);