协作者管理删除按钮没显示

This commit is contained in:
caishi 2021-04-02 14:08:59 +08:00
parent dccbd6735d
commit 101478d924
6 changed files with 105 additions and 9 deletions

View File

@ -36,7 +36,7 @@ export function initAxiosInterceptors(props) {
//响应前的设置
axios.interceptors.request.use(
config => {
if (config.url.indexOf(proxy) !== -1 || config.url.indexOf("http") !== -1) {
if(config.url.indexOf("http") !== -1) {
return config
}
requestProxy(config);

View File

@ -42,7 +42,7 @@ function Collaborator(props){
<div>
{
nav === "1" ?
<Member newId={newId} projectsId={projectsId} owner={owner} project_id={props.project_id} author={props.author} showNotification={props.showNotification}/>
<Member newId={newId} projectsId={projectsId} owner={owner} project_id={props.project_id} author={props.projectDetail && props.projectDetail.author} showNotification={props.showNotification}/>
:
<Group owner={owner} projectsId={projectsId} newGroupId={newGroupId}/>
}

View File

@ -20,8 +20,6 @@ function CollaboratorMember({projectsId,owner,project_id,author,showNotification
const [ role , setRole ] = useState(undefined);
const [ listData , setListData ] = useState(undefined);
const [ total , setTotal ] = useState(0);
useEffect(()=>{
if(newId){
addCollaborator(newId);

View File

@ -0,0 +1,95 @@
import React, { useEffect, useState } from "react";
import { Upload, Icon , Button } from 'antd';
import { appendFileSizeToUploadFileAll } from 'educoder';
import axios from 'axios';
const { Dragger } = Upload;
function Upload({isComplete, icon , btn , className , size , actionUrl,fileList}) {
const [ files , setFiles ] = useState(undefined);
useEffect(()=>{
init();
},[fileList]);
function init(){
let f = appendFileSizeToUploadFileAll(fileList);
setFiles(f);
}
function onAttachmentRemove(file){
if (!file.percent || file.percent === 100) {
deleteAttachment(file);
return false;
}
}
function deleteAttachment(file){
const url = `/attachments/${file.response ? file.response.id : file.uid}.json`
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);
setFiles(nf);
fileIdList(nf);
} else {
showNotification(response.data.message)
}
}
}).catch(function (error) {
console.log(error);
});
}
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);
}
}
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);
}
function beforeUpload(file){
const isLt100M = file.size / 1024 / 1024 < size;
if (!isLt100M) {
showNotification(`文件大小必须小于${size}MB!`);
}
return isLt100M;
}
//
const upload = {
name: 'file',
fileList: files,
action: actionUrl,
onChange:handleChange,
onRemove:onAttachmentRemove,
beforeUpload:beforeUpload
};
return (
btn ?
<Upload {...upload} className={className}>
<Button type={"default"}>上传文件</Button>
<span className="ml10 color-grey-9">(你可以上传小于<span className="color-red">{size}MB</span>的文件)</span>
</Upload>
:
<Dragger {...upload} className={className}>
{icon || <Icon type="inbox" />}
<p className="ant-upload-text font-14">拖动文件或<span className="color-blue">点击此处上传</span></p>
</Dragger>
)
}
}
export default Upload;

View File

@ -10,12 +10,14 @@ 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"}
]
const https = 'https://testfiles.trustie.net';
function UploadSource({ form , visible , onCancel , onOk , showNotification}){
const [ tableData , setTableData ] = useState(data);
const { getFieldDecorator, validateFields , setFieldsValue } = form;
function UploadFunc(){
// id
function UploadFunc(files){
}
const columns = [
@ -88,6 +90,7 @@ function UploadSource({ form , visible , onCancel , onOk , showNotification}){
load={UploadFunc}
size={100}
showNotification={showNotification}
actionUrl= {https+`/busiAttachments/upload`}
btn
/>
<Form.Item className="mt20">

View File

@ -73,7 +73,7 @@ class Index extends Component {
fileIdList = (fileList) => {
let array = [];
fileList && fileList.length > 0 && fileList.map((item) => {
return array.push(item.response && item.response.id);
return array.push(item.response && (item.response.id || (item.response.data && item.response.data.id)));
})
array && this.props.load && this.props.load(array);
}
@ -89,14 +89,14 @@ class Index extends Component {
render() {
//判断是否已经提交,如已提交评论则上一条评论数据清除
const { isComplete, icon , btn , className , size} = this.props;
const { isComplete, icon , btn , className , size , actionUrl } = this.props;
const { fileList } = this.state;
let list = isComplete === true ? fileList : undefined;
const upload = {
name: 'file',
fileList: list,
action: `${getUploadActionUrl()}`,
action: actionUrl || `${getUploadActionUrl()}`,
onChange: this.handleChange,
onRemove: this.onAttachmentRemove,
beforeUpload: this.beforeUpload