diff --git a/public/react/src/modules/tpm/TPMBanner.js b/public/react/src/modules/tpm/TPMBanner.js index 26e2350a6..b5059cf34 100644 --- a/public/react/src/modules/tpm/TPMBanner.js +++ b/public/react/src/modules/tpm/TPMBanner.js @@ -900,18 +900,25 @@ class TPMBanner extends Component { {this.state.Senttothevcaluetype===true?
请选择你要发送的课堂
:""} -
- 12 ? "block" : "none"}} +
12 ? "block" : "none"}}> + +
- 确定 +
+
+
+
+ 取消 + 确定 +
- 取消 -
+ +
diff --git a/public/react/src/modules/tpm/TPMsettings/TPMsettings.js b/public/react/src/modules/tpm/TPMsettings/TPMsettings.js index 2e34bcffb..ef79f739f 100644 --- a/public/react/src/modules/tpm/TPMsettings/TPMsettings.js +++ b/public/react/src/modules/tpm/TPMsettings/TPMsettings.js @@ -3,7 +3,7 @@ import React, { Component } from 'react'; import MonacoEditor from 'react-monaco-editor'; //MonacoDiffEditor 对比模式 -import {Input, Select, Radio, Checkbox, Popconfirm, message, Modal,Icon,DatePicker,Breadcrumb} from 'antd'; +import {Input, Select, Radio, Checkbox, Popconfirm, message, Modal,Icon,DatePicker,Breadcrumb,Upload,Button,notification} from 'antd'; // import "antd/dist/antd.css"; @@ -207,6 +207,7 @@ export default class TPMsettings extends Component { constructor(props) { super(props) this.state = { + fileList: [], commandLine: 0, Openpublic: 0, settingsData: undefined, @@ -268,7 +269,8 @@ export default class TPMsettings extends Component { pod_exist_time: undefined, pod_exist_timetype: false, shixunmemoMDvalue:"", - language:"" + language:"", + deleteisnot:true } } descriptionMD=(initValue, id)=> { @@ -1011,32 +1013,160 @@ export default class TPMsettings extends Component { }) } - sendsure_apply = () => { - let {sendsure_applyvalue} = this.state; - let url = "/shixuns/apply_shixun_mirror.json"; - axios.post(url, { - note: sendsure_applyvalue - }).then((response) => { - if (response.status === 200) { - if (response.data.status == 1) { - this.setState({ - postapplyvisible: false, - postapplytitle: true - }) - } + setlanguagewrite = (e)=>{ + this.setState({ + languagewrite: e.target.value + }) + } - } - }).catch((error) => { - console.log(error) - }); + setsystemenvironment = (e) => { + this.setState({ + systemenvironment: e.target.value + }) + } - } + settestcoderunmode = (e) => { + this.setState({ + testcoderunmode: e.target.value + }) - sendhideModaly = () => { - this.setState({ - postapplyvisible: false - }) - } + } + + sendsure_apply = () => { + let {languagewrite,systemenvironment,testcoderunmode} = this.state; + // console.log("点击确定") + // console.log("languagewrite"+languagewrite); + // console.log("systemenvironment"+systemenvironment); + // console.log("testcoderunmode"+testcoderunmode); + + // let attachment_ids = undefined + // if (this.state.fileList) { + // attachment_ids = this.state.fileList.map(item => { + // return item.response ? item.response.id : item.id + // }) + // } + if(languagewrite === undefined || languagewrite === "" ){ + // this.props.showNotification(`请填写该镜像是基于什么语言`); + this.setState({ + languagewritetype:true + }) + return + } + if(systemenvironment === undefined || systemenvironment === ""){ + // this.props.showNotification(`请填写该镜像是基于什么语言系统环境`); + this.setState({ + systemenvironmenttype:true + }) + return; + + } + if(testcoderunmode === undefined || testcoderunmode === "") { + // this.props.showNotification(`请填写该镜像中测试代码运行方式`); + this.setState({ + testcoderunmodetype:true + }) + return; + } + var attachment_ids=undefined; + if (this.state.fileList) { + attachment_ids = this.state.fileList.map(item => { + return item.response ? item.response.id : item.id + }) + } + + if( attachment_ids === undefined || attachment_ids.length===0){ + + // notification.open( + // { + // message: '提示', + // description: + // '请上传附件!', + // + // } + // ) + this.setState({ + attachmentidstype:true + }) + return; + } + // console.log("attachment_ids"+attachment_ids); + + // alert(languagewrite +" "+systemenvironment +" "+testcoderunmode + " "+attachment_ids); + + var data={ + language:languagewrite, + runtime:systemenvironment, + run_method:testcoderunmode, + attachment_id:attachment_ids[0], + } + var url =`/shixuns/apply_shixun_mirror.json`; + axios.post(url,data + ).then((response) => { + + try { + if (response.data) { + // const { id } = response.data; + // if (id) { + if(this.state.file !== undefined){ + console.log("549"); + // this.deleteAttachment(this.state.file); + this.setState({ + file:undefined, + languagewrite:"", + systemenvironment:"", + testcoderunmode:"", + }) + }else { + this.setState({ + file:undefined, + languagewrite:"", + systemenvironment:"", + testcoderunmode:"", + }) + } + // this.props.showNotification('提交成功!'); + notification.open( + { + message: '提示', + description: + '提交成功!', + + } + ) + this.sendhideModaly() + // this.props.history.push(`/courses/${cid}/graduation_topics`); + // } + } + }catch (e) { + + } + + }) + + } + + sendhideModaly = () => { + this.setState({ + postapplyvisible: false, + }) + if(this.state.file !== undefined){ + console.log("580"); + // this.deleteAttachment(this.state.file); + this.setState({ + file:undefined, + languagewrite:"", + systemenvironment:"", + testcoderunmode:"", + }) + }else { + this.setState({ + file:undefined, + languagewrite:"", + systemenvironment:"", + testcoderunmode:"", + }) + } + } yeshidemodel = () => { this.setState({ @@ -1198,29 +1328,76 @@ export default class TPMsettings extends Component { }) } + handleChange = (info) => { + console.log("handleChange1"); + let fileList = info.fileList; + this.setState({ fileList:fileList, + deleteisnot:false}); + } + + onAttachmentRemove = (file) => { + confirm({ + title: '确定要删除这个附件吗?', + okText: '确定', + cancelText: '取消', + // content: 'Some descriptions', + onOk: () => { + console.log("665") + this.deleteAttachment(file) + }, + onCancel() { + console.log('Cancel'); + }, + }); + return false; + } + + deleteAttachment = (file) => { + console.log(file); + let id=file.response ==undefined ? file.id : file.response.id + const url = `/attachments/${id}.json` + axios.delete(url, { + }) + .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() { + render() { let { postapplyvisible, - sendsure_applyvalue, postapplytitle, shixunnametype, shixunmaintype, evaluate_scripttype, - exec_timetype, traineetype, standard_scripts, - description, - evaluate_script, name, settingsData, webssh, use_scope, - shixunsstatus, shixunsID, - exec_time, - pod_exist_time, - pod_exist_timetype, can_copy, choice_standard_scripts, Executiveordervalue, @@ -1241,19 +1418,15 @@ export default class TPMsettings extends Component { standard_scriptsModal, standard_scriptsModals, SelectTheCommandtype, - status, - opers, - operss, - opersss, testscripttiptype, operateshixunstype, opening_time, - opensmail, scope_partmenttype, newuse_scope, scope_partments, shixunmemoMDvalue,delType, - shixun_service_configs + shixun_service_configs, + fileList, } = this.state; let options; @@ -1265,7 +1438,46 @@ export default class TPMsettings extends Component { ) }) } + const uploadProps = { + width: 600, + fileList, + multiple: true, + // https://github.com/ant-design/ant-design/issues/15505 + // showUploadList={false},然后外部拿到 fileList 数组自行渲染列表。 + // showUploadList: false, + action: `${getUrl()}/api/attachments.json`, + onChange: this.handleChange, + onRemove: this.onAttachmentRemove, + beforeUpload: (file) => { + // console.log('beforeUpload', file.name); + const isLt150M = file.size / 1024 / 1024 < 50; + if (!isLt150M) { + // this.props.showNotification(`文件大小必须小于50MB`); + notification.open( + { + message: '提示', + description: + '文件大小必须小于50MB', + + } + ) + } + if(thiss.state.file !== undefined){ + console.log("763") + // thiss.deleteAttachment(thiss.state.file); + thiss.setState({ + file:file + }) + }else { + thiss.setState({ + file:file + }) + } + console.log("handleChange2"); + return isLt150M; + }, + } const dateFormat = 'YYYY-MM-DD HH:mm:ss'; let operateauthority=this.props.identity===1?true:this.props.identity<5&&this.state.status==0?true:false; @@ -1391,13 +1603,13 @@ export default class TPMsettings extends Component { }) } - {/**/} - {/*列表中没有?*/} - {/*申请新建*/} - {/*

*/} +

+ 列表中没有? + 申请新建 +

-
  • - +
  • + + style={{width:'89%',height:'100px'}} + onInput={this.setlanguagewrite} + value={this.state.languagewrite} + placeholder="请填写该镜像是基于什么语言:示例:Python" + id="demand_info"> +
  • +
    {this.state.languagewritetype===true?"请填写该镜像语言":""}
    +
  • + + +
  • +
    {this.state.systemenvironmenttype===true?"请填写该镜像语言系统环境":""}
    +
  • + + + +
  • +
    {this.state.testcoderunmodetype===true?"请填写该镜像测试代码运行方式":""}
    +
  • + +
    + { + this.state.deleteisnot=== true? + + + 上传附件 + (单个文件50M以内) + + + : + + + 上传附件 + (单个文件50M以内) + + + } +
    +
  • +
    + {this.state.attachmentidstype===true?"请上传附件":""} +
    +
  • + this.sendhideModaly()} + >取消 +
  • - this.sendsure_apply()} - className="task-btn task-btn-orange fr mr12">确定 - this.sendhideModaly()} - >取消
    +
    + + + {/*
    */}
    -
  • +
  • {this.state.languagewritetype===true?"请填写该镜像语言":""}
    -
  • +