import React, {Component} from 'react'; import {Redirect} from 'react-router'; import {List, Typography, Tag, Modal, Radio, Checkbox, Table, Pagination,Upload,notification} from 'antd'; import { NoneData } from 'educoder' import TPMRightSection from './component/TPMRightSection'; import TPMNav from './component/TPMNav'; import axios from 'axios'; import './tpmmodel/tpmmodel.css' import {getUploadActionUrl,appendFileSizeToUploadFileAll} from 'educoder'; import moment from 'moment'; const confirm = Modal.confirm; class TPMDataset extends Component { constructor(props) { super(props) this.state = { value: undefined, columns: [ { title: '文件', dataIndex: 'title', key: 'title', align: 'left', className: " font-14 wenjiantit", width: '220px', render: (text, record) => (
{record.title}
) }, { title: '最后修改时间', dataIndex: 'timedata', key: 'timedata', align: 'center', className: "edu-txt-center font-14 zuihoushijian", width: '150px', render: (text, record) => (
{record.timedata}
) }, { title: '最后修改人', dataIndex: 'author', key: 'author', align: 'center', className: "edu-txt-center font-14 ", render: (text, record) => (
{record.author}
) }, { title: '文件大小', dataIndex: 'filesize', key: 'filesize', align: 'center', className: "edu-txt-center font-14 ", render: (text, record) => (
{record.filesize}
) }, ], page: 1, limit: 10, selectedRowKeys: [], mylistansum:30, collaboratorList:[], fileList:[], fileListimgs:[], file:null, datalist:[], data_sets_count:0, selectedRowKeysdata:[], loadingstate:false, checked: false, } } componentDidMount() { this.setState({ loadingstate:true, }) this.getdatas() } mysonChange = (e) => { // console.log(`全选checked = ${e.target.checked}`); if (e.target.checked === true) { let mydata=[]; let datas=[]; for(let i=0;i { let id=this.props.match.params.shixunId; let collaborators=`/shixuns/${id}/jupyter_data_sets.json`; axios.get(collaborators,{params:{ page:1, limit:10, }}).then((response)=> { if(response.status===200){ if (response.data.status === 403||response.data.status === 401||response.data.status === 500) { }else{ let datalists=[]; for(let i=0;i { this.setState({ loadingstate:false, }) }, 500) }).catch((error)=>{ setTimeout(() => { this.setState({ loadingstate:false, }) }, 500) console.log(error) }); } getdatastwo = (page,limit) => { let id=this.props.match.params.shixunId; let collaborators=`/shixuns/${id}/jupyter_data_sets.json`; axios.get(collaborators,{params:{ page:page, limit:limit, }}).then((response)=> { if(response.status===200){ if (response.data.status === 403||response.data.status === 401||response.data.status === 500) { }else{ let datalists=[]; for(let i=0;i { this.setState({ loadingstate:false, }) }, 500) }).catch((error)=>{ setTimeout(() => { this.setState({ loadingstate:false, }) }, 500) console.log(error) }); } getdatasthree = (page,limit) => { let id=this.props.match.params.shixunId; let collaborators=`/shixuns/${id}/jupyter_data_sets.json`; axios.get(collaborators,{params:{ page:page, limit:limit, }}).then((response)=> { if(response.status===200){ if (response.data.status === 403||response.data.status === 401||response.data.status === 500) { }else{ } } }).catch((error)=>{ }); } paginationonChanges = (pageNumber) => { // //console.log('Page: '); this.setState({ page: pageNumber, loadingstate:true, }) this.getdatastwo(pageNumber,10); } onSelectChange = (selectedRowKeys, selectedRows) => { console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows); this.setState( { selectedRowKeys } ); let mydata=[]; for(let i=0;i { let className = 'light-row'; if (index % 2 === 1) className = 'dark-row'; return className; } handleChange = (info) => { if(info.file.status == "done" || info.file.status == "uploading" || info.file.status === 'removed'){ let fileList = info.fileList; this.setState({ fileList: appendFileSizeToUploadFileAll(fileList), }); if(info.file.status === 'done'){ //done 成功就会调用这个方法 this.getdatas(); } } } onAttachmentRemove = (file) => { // debugger if(!file.percent || file.percent == 100){ confirm({ title: '确定要删除这个附件吗?', okText: '确定', cancelText: '取消', // content: 'Some descriptions', onOk: () => { console.log("665") this.deleteAttachment(file) }, onCancel() { console.log('Cancel'); }, }); return false; } } deleteRemovedata(){ if(this.state.selectedRowKeysdata===undefined || this.state.selectedRowKeysdata===null ||this.state.selectedRowKeysdata.length===0){ this.props.showNotification(`请选择要删除的文件`); return } confirm({ title: '确定要删除文件吗?', okText: '确定', cancelText: '取消', // content: 'Some descriptions', onOk: () => { const url = `/attachments/destroy_files.json`; axios.delete(url, { params: { id:this.state.selectedRowKeysdata, }} ) .then((response) => { if (response.data) { const { status } = response.data; if (status == 0) { this.props.showNotification(`删除成功`); this.getdatas() } } }) .catch(function (error) { console.log(error); }); }, onCancel() { console.log('Cancel'); }, }); } deleteAttachment = (file) => { // console.log(file); let id=file.response ==undefined ? file.id : file.response.id const url = `/attachements/destroy_files.json` axios.delete(url, { id:[id], }) .then((response) => { if (response.data) { const { status } = response.data; if (status == 0) { // console.log('--- success') this.setState((state) => { const index = state.fileList.indexOf(file); const newFileList = state.fileList.slice(); newFileList.splice(index, 1); return { fileList: newFileList, deleteisnot:true }; }); } } }) .catch(function (error) { console.log(error); }); } render() { const {tpmLoading, shixun, user, match} = this.props; const {columns, page, limit, selectedRowKeys,mylistansum,fileList,datalist,data_sets_count,loadingstate} = this.state; const rowSelection = { selectedRowKeys, onChange: this.onSelectChange, }; // getCheckboxProps: record => ({ // disabled: record.name === 'Disabled User', // Column configuration not to be checked // name: record.name, // }), let id=this.props.match.params.shixunId; const uploadProps = { width: 600, fileList, data:{ attachtype: 2, container_id:this.props.match.params.shixunId, container_type: "Shixun", }, multiple: false, //multiple 是否支持多选 查重的时候不能多选 不然弹许多框出来 // https://github.com/ant-design/ant-design/issues/15505 // showUploadList={false},然后外部拿到 fileList 数组自行渲染列表。 // showUploadList: false, action: `${getUploadActionUrl()}`, showUploadList:false, onChange: this.handleChange, onRemove: this.onAttachmentRemove, beforeUpload: (file) => { //上传前的操作 console.log('beforeUpload', file.name); const isLt150M = file.size / 1024 / 1024 < 150; if (!isLt150M) { this.props.showNotification('文件大小必须小于150MB!'); } return isLt150M; }, }; return (
全选

上传文件

{ data_sets_count>0?
0 ? "deletebutomtextcode intermediatecenter mr21" : "deletebutom intermediatecenter mr21"} onClick={()=>this.deleteRemovedata()}>

删除

:"" }
{data_sets_count===0?
:
} { data_sets_count>=11?
:"" } { data_sets_count===0? :"" }
); } } export default TPMDataset;