import React, {Component} from 'react'; import {Redirect} from 'react-router'; import {List, Typography, Tag, Modal, Radio, Checkbox, Table,message, Pagination,Upload,Button} 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 {getUploadActionUrltwo,appendFileSizeToUploadFileAll} from 'educoder'; import moment from 'moment'; import Tpmdatasetmodel from "./tpmmodel/Tpmdatasetmodel"; const confirm = Modal.confirm; function clearSlct() { if("getSelection" in window){ window.getSelection().removeAllRanges(); }else{ document.selection.empty(); }; } function jsCopy(s) { clearSlct(); const copyEle = document.getElementById(s); copyEle.select(); const copyStatus=document.execCommand("Copy"); // 对成功与否定进行提示 copyStatuss(copyStatus) } function copyStatuss(copyStatus){ if (copyStatus) { message.success('复制成功'); } else { message.error('复制失败'); } } 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}
) }, { title: '操作', dataIndex: 'operation', key: 'operation', align: 'center', className: "edu-txt-center font-14 ", render: (text, record) => (
{ jsCopy("file_path"+record.id) }}> 复制
) }, ], page: 1, limit: 10, selectedRowKeys: [], mylistansum:30, collaboratorList:[], fileList:[], fileListimgs:[], file:null, datalist:[], data_sets_count:0, selectedRowKeysdata:[], loadingstate:false, checked: false, showmodel:false, itemtypebool:false, Buttonloading: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}/get_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}/get_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}/get_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) => { // console.log("handleChange123123"); // console.log(info); //debugger this.setState({ Buttonloading:true }) if(!info.file.status){ this.setState({ Buttonloading:false }) } 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 成功就会调用这个方法 if(info.file.response){ if(info.file.response.status===-1||info.file.response.status==="-1"){ this.setState({ Buttonloading:false }) }else{ this.getdatas(); this.setState({ Buttonloading:false }) // this.props.showNotification(`上传成功`); } } }else{ // this.setState({ // Buttonloading:false // }) } if(info.file.response){ if(info.file.response.status===-1||info.file.response.status==="-1"){ // console.log("准备显示弹框了"); // console.log(info);false let itemtype=-1; try { itemtype=info.file.response.message.indexOf('文件名已经存在'.toLowerCase()); }catch (e) { } this.setState({ showmodel:true, tittest:info.file.response.message, itemtypebool:itemtype>-1?true:itemtype<=-1?false:false, Buttonloading:false }) }else{ this.setState({ Buttonloading:false }) } } } } 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 } let id=this.props.match.params.shixunId; confirm({ title: '确定要删除文件吗?', okText: '确定', cancelText: '取消', // content: 'Some descriptions', onOk: () => { const url = `/shixuns/${id}/destroy_data_sets.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); }); } ModalCancel = () => { this.setState({ showmodel: false, }) } ModalSave=()=>{ this.setState({ showmodel: false, }) } ButtonloadinghandleChange=()=>{ // this.props.showNotification(`zhzzzzz`); // this.setState({ // Buttonloading:false // }) } 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, multiple: true, //multiple 是否支持多选 查重的时候不能多选 不然弹许多框出来 // https://github.com/ant-design/ant-design/issues/15505 // showUploadList={false},然后外部拿到 fileList 数组自行渲染列表。 // showUploadList: false, action: `${getUploadActionUrltwo(id)}`, showUploadList:false, onChange: this.handleChange, onRemove: this.onAttachmentRemove, beforeUpload: (file) => { //上传前的操作 console.log('beforeUpload', file); // this.props.showNotification(`文件上传中`); const isLt400M = file.size / 1024 / 1024 <= 400; if (!isLt400M) { this.props.showNotification('文件大小必须小于等于400MB!'); } return isLt400M; }, }; // console.log("showmodelshowmodel"); // console.log(this.state.showmodel); return (
{ this.state.showmodel===true? this.ModalSave()} tittest={this.state.tittest} modalsType={this.state.showmodel}> :"" }
全选
{ 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;