|
|
|
@ -1,9 +1,15 @@
|
|
|
|
|
import React, { Component } from 'react';
|
|
|
|
|
|
|
|
|
|
import MonacoEditor from 'react-monaco-editor';
|
|
|
|
|
import React, {Component} from 'react';
|
|
|
|
|
|
|
|
|
|
//MonacoDiffEditor 对比模式
|
|
|
|
|
import {Input, Select, Radio, Checkbox, Popconfirm, message, Modal,Icon,DatePicker,Breadcrumb,Upload,Button,notification, Tooltip} from 'antd';
|
|
|
|
|
import {
|
|
|
|
|
Badge,
|
|
|
|
|
Select,
|
|
|
|
|
Radio,
|
|
|
|
|
Checkbox,
|
|
|
|
|
Modal,
|
|
|
|
|
DatePicker,
|
|
|
|
|
Button,
|
|
|
|
|
} from 'antd';
|
|
|
|
|
|
|
|
|
|
// import "antd/dist/antd.css";
|
|
|
|
|
|
|
|
|
@ -15,12 +21,9 @@ import axios from 'axios';
|
|
|
|
|
|
|
|
|
|
import './css/TPMsettings.css';
|
|
|
|
|
|
|
|
|
|
import { getImageUrl, toPath, getUrl ,appendFileSizeToUploadFileAll, getUploadActionUrl} from 'educoder';
|
|
|
|
|
import {getImageUrl, toPath, getUrl, appendFileSizeToUploadFileAll, getUploadActionUrl} from 'educoder';
|
|
|
|
|
import {handleDateStrings} from "./oldTPMsettings";
|
|
|
|
|
|
|
|
|
|
let origin = getUrl();
|
|
|
|
|
|
|
|
|
|
let path = getUrl("/editormd/lib/")
|
|
|
|
|
import Bottomsubmit from "../../modals/Bottomsubmit";
|
|
|
|
|
|
|
|
|
|
const $ = window.$;
|
|
|
|
|
|
|
|
|
@ -40,6 +43,7 @@ function range(start, end) {
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function disabledDateTime() {
|
|
|
|
|
return {
|
|
|
|
|
// disabledHours: () => range(0, 24).splice(4, 20),
|
|
|
|
@ -57,119 +61,311 @@ export default class Shixuninformation extends Component {
|
|
|
|
|
constructor(props) {
|
|
|
|
|
super(props)
|
|
|
|
|
this.state = {
|
|
|
|
|
can_copy:false,
|
|
|
|
|
use_scope:0,
|
|
|
|
|
opening_time:null,
|
|
|
|
|
opentime:false,
|
|
|
|
|
oldscope_partment:[],
|
|
|
|
|
scope_partment:[]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
|
if (this.props.data) {
|
|
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
|
can_copy: this.props.data && this.props.data.shixun.can_copy === undefined ? false :this.props.data.shixun.can_copy,
|
|
|
|
|
use_scope:this.props.data && this.props.data.shixun.use_scope,
|
|
|
|
|
opening_time: this.props.data && this.props.data.shixun.opening_time,
|
|
|
|
|
opentime:!this.props.data && this.props.data.shixun.opening_time?false:true,
|
|
|
|
|
oldscope_partment:this.props.data&&this.props.data.shixun.scope_partment,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
let departmentsUrl = `/shixuns/departments.json`;
|
|
|
|
|
axios.get(departmentsUrl).then((response) => {
|
|
|
|
|
if (response.status === 200) {
|
|
|
|
|
if (response.data.message === undefined) {
|
|
|
|
|
this.setState({
|
|
|
|
|
departmentslist: response.data.shools_name
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}).catch((error) => {
|
|
|
|
|
console.log(error)
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
componentDidUpdate(prevProps, prevState) {
|
|
|
|
|
if (prevProps.data != this.props.data) {
|
|
|
|
|
if (this.props.data) {
|
|
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
|
can_copy: this.props.data && this.props.data.shixun.can_copy === undefined ? false :this.props.data.shixun.can_copy,
|
|
|
|
|
use_scope:this.props.data && this.props.data.shixun.use_scope,
|
|
|
|
|
opening_time: this.props.data && this.props.data.shixun.opening_time,
|
|
|
|
|
opentime:!this.props.data && this.props.data.shixun.opening_time?false:true,
|
|
|
|
|
oldscope_partment:this.props.data&&this.props.data.shixun.scope_partment,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onChangeTimePicker =(value, dateString)=> {
|
|
|
|
|
onChangeTimePicker = (value, dateString) => {
|
|
|
|
|
this.setState({
|
|
|
|
|
opening_time: dateString=== ""?"":moment(handleDateStrings(dateString))
|
|
|
|
|
opening_time: dateString === "" ? "" :handleDateStrings(dateString)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onSubmits = () => {
|
|
|
|
|
let {can_copy,use_scope,scope_partment,opening_time }=this.state;
|
|
|
|
|
|
|
|
|
|
let id = this.props.match.params.shixunId;
|
|
|
|
|
let url=`/shixuns/${id}/update_permission_setting.json`;
|
|
|
|
|
axios.post(url,
|
|
|
|
|
{
|
|
|
|
|
scope_partment:scope_partment,
|
|
|
|
|
shixun:{
|
|
|
|
|
can_copy: can_copy,
|
|
|
|
|
use_scope:use_scope,
|
|
|
|
|
opening_time:opening_time
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
).then((response) => {
|
|
|
|
|
if(response.data.status===-1){
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
this.props.getdatas()
|
|
|
|
|
this.props.showNotification("保存成功")
|
|
|
|
|
}
|
|
|
|
|
}).catch((error) => {
|
|
|
|
|
console.log(error)
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
CheckboxonChange=(e)=>{
|
|
|
|
|
this.setState({
|
|
|
|
|
can_copy:e.target.checked
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
SelectOpenpublic=(e)=>{
|
|
|
|
|
this.setState({
|
|
|
|
|
use_scope: e.target.value
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
shixunScopeInput = (e) => {
|
|
|
|
|
let {scope_partment,oldscope_partment} = this.state;
|
|
|
|
|
let datalist = scope_partment;
|
|
|
|
|
if (datalist===undefined) {
|
|
|
|
|
datalist=[]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
datalist.push(e)
|
|
|
|
|
|
|
|
|
|
let scopetype=false;
|
|
|
|
|
|
|
|
|
|
scope_partment.map((item,key)=>{
|
|
|
|
|
if(item===e){
|
|
|
|
|
scopetype=true
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
oldscope_partment.map((item,key)=>{
|
|
|
|
|
if(item===e){
|
|
|
|
|
scopetype=true
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
if(scopetype===false){
|
|
|
|
|
this.setState({
|
|
|
|
|
scope_partment: datalist
|
|
|
|
|
});
|
|
|
|
|
}else{
|
|
|
|
|
this.props.showNotification("请勿指定相同的单位")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
shixunsfetch = (value, callback) => {
|
|
|
|
|
if (timeout) {
|
|
|
|
|
clearTimeout(timeout);
|
|
|
|
|
timeout = null;
|
|
|
|
|
}
|
|
|
|
|
currentValue = value;
|
|
|
|
|
|
|
|
|
|
function fake() {
|
|
|
|
|
let departmentsUrl = `/shixuns/departments.json?q=` + currentValue;
|
|
|
|
|
axios.get(departmentsUrl).then((response) => {
|
|
|
|
|
callback(response.data.shools_name);
|
|
|
|
|
}).catch((error) => {
|
|
|
|
|
console.log(error)
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
timeout = setTimeout(fake, 300);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
shixunHandleSearch = (value) => {
|
|
|
|
|
this.shixunsfetch(value, departmentslist => this.setState({departmentslist}));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
deleteScopeInput = (key) => {
|
|
|
|
|
let {scope_partment} = this.state;
|
|
|
|
|
let datalist = scope_partment;
|
|
|
|
|
datalist.splice(key, 1);
|
|
|
|
|
this.setState({
|
|
|
|
|
scope_partment: datalist
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setopentime=(e)=>{
|
|
|
|
|
this.setState({
|
|
|
|
|
opentime:e.target.checked
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
render() {
|
|
|
|
|
let {can_copy}=this.state;
|
|
|
|
|
let options;
|
|
|
|
|
|
|
|
|
|
if (this.props.departmentslist != undefined) {
|
|
|
|
|
options = this.props.departmentslist.map((d, k) => {
|
|
|
|
|
let options;
|
|
|
|
|
if (this.state.departmentslist != undefined) {
|
|
|
|
|
options = this.state.departmentslist.map((d, k) => {
|
|
|
|
|
return (
|
|
|
|
|
<Option key={d} id={k}>{d}</Option>
|
|
|
|
|
)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const dateFormat = 'YYYY-MM-DD HH:mm';
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="educontent mb50 edu-back-white padding10-20">
|
|
|
|
|
<div className="clearfix ml30">
|
|
|
|
|
<span className="color-grey-6 mt5 fl" style={{minWidth: '95px'}}>复制:</span>
|
|
|
|
|
<span className="fl mt5">
|
|
|
|
|
<Checkbox checked={this.props.data&&this.props.data.shixun.can_copy === undefined ? false : this.props.data&&this.props.data.shixun.can_copy} onChange={this.props.data&&this.props.data.shixun.can_copy}></Checkbox>
|
|
|
|
|
<label style={{top:'6px'}} className="color-grey-9 ml10">(勾选则允许已认证的教师复制该实训)</label>
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<div className="educontent mb200 edu-back-white padding10-20 pdb30">
|
|
|
|
|
<div className="clearfix ml40">
|
|
|
|
|
<span className="color-grey-6 mt5 fl font-16 ml20" style={{minWidth: '45px'}}>复制:</span>
|
|
|
|
|
<span className="fl mt8 ml13">
|
|
|
|
|
<Checkbox
|
|
|
|
|
checked={this.state.can_copy}
|
|
|
|
|
onChange={this.CheckboxonChange}></Checkbox>
|
|
|
|
|
<label style={{top: '6px'}} className="color-grey-9 ml10">(选中则允许已职业认证的教师复制该实训)</label>
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="edu-back-white mb10 padding40-20" style={{display:this.props.identity===1?"block":this.props.data&&this.props.data.shixun.status===2&&this.props.data&&this.props.data.shixun.use_scope===0||this.props.data&&this.props.data.shixun.status===1&&this.props.data&&this.props.data.shixun.use_scope===0?"none":"block"}}>
|
|
|
|
|
<p className="color-grey-6 font-16 mb30">公开程度</p>
|
|
|
|
|
<RadioGroup onChange={this.SelectOpenpublic} value={this.props.data&&this.props.data.use_scope}>
|
|
|
|
|
<Radio className="radioStyle" value={0}><span>对所有公开</span> <span className="color-grey-9">(选中则所有已被试用授权的用户可以学习)</span></Radio>
|
|
|
|
|
<Radio className="radioStyle" value={1}><span>对指定单位公开</span> <span className="color-grey-9">(选中则下方指定单位的已被试用授权的用户可以学习)</span></Radio>
|
|
|
|
|
</RadioGroup>
|
|
|
|
|
|
|
|
|
|
<div className="clearfix none" id="unit-all" style={{display: this.props.scopetype === false ? 'none' : 'block'}}>
|
|
|
|
|
<div className="fl ml25">
|
|
|
|
|
<div className="fl" id="unit-input-part" style={{width:'100%'}}>
|
|
|
|
|
<div id="person-unit" className="fl pr mr10">
|
|
|
|
|
<div className="shixunScopeInput fl" >
|
|
|
|
|
<Select
|
|
|
|
|
style={{width:'200px'}}
|
|
|
|
|
placeholder="请输入并选择单位名称"
|
|
|
|
|
onChange={(value)=>this.shixunScopeInput(value)}
|
|
|
|
|
onSearch={this.shixunHandleSearch}
|
|
|
|
|
showSearch
|
|
|
|
|
defaultActiveFirstOption={false}
|
|
|
|
|
showArrow={false}
|
|
|
|
|
filterOption={false}
|
|
|
|
|
notFoundContent={null}
|
|
|
|
|
className={this.props.scope_partmenttype===true?"bor-red":""}
|
|
|
|
|
>
|
|
|
|
|
{options}
|
|
|
|
|
</Select>
|
|
|
|
|
<div className="edu-back-white mb10 ml30 mt20">
|
|
|
|
|
{this.props.data && this.props.data.shixun.use_scope === 0 &&this.props.data && this.props.data.shixun.status === 2?"": <div>
|
|
|
|
|
<span className="color-grey-6 mt5 fl font-16" style={{minWidth: '45px'}}>公开程度:</span>
|
|
|
|
|
<span className="fl mt8 ml20">
|
|
|
|
|
<RadioGroup onChange={this.SelectOpenpublic} value={this.state.use_scope}>
|
|
|
|
|
<Radio className="radioStyle" value={0}><span>对所有单位公开</span> <span
|
|
|
|
|
className="color-grey-9">(实训发布后,所有用户可见)</span></Radio>
|
|
|
|
|
<Radio className="radioStyle" value={1}><span>对指定单位公开</span> <span
|
|
|
|
|
className="color-grey-9">(实训发布后,仅对下方指定单位的用户可见)</span></Radio>
|
|
|
|
|
</RadioGroup>
|
|
|
|
|
|
|
|
|
|
<div className="clearfix" id="unit-all"
|
|
|
|
|
style={{display:this.state.use_scope === 0 ? 'none' : 'block'}}>
|
|
|
|
|
<div className="fl ml25">
|
|
|
|
|
<div className="fl" id="unit-input-part" style={{width: '100%'}}>
|
|
|
|
|
<div id="person-unit" className="fl pr mr10">
|
|
|
|
|
<div className="shixunScopeInput fl">
|
|
|
|
|
<Select
|
|
|
|
|
style={{width: '200px'}}
|
|
|
|
|
placeholder="请输入并选择单位名称"
|
|
|
|
|
onChange={(value) => this.shixunScopeInput(value)}
|
|
|
|
|
onSearch={this.shixunHandleSearch}
|
|
|
|
|
showSearch
|
|
|
|
|
value={this.state.scope_partment}
|
|
|
|
|
defaultActiveFirstOption={false}
|
|
|
|
|
showArrow={false}
|
|
|
|
|
filterOption={false}
|
|
|
|
|
notFoundContent={null}
|
|
|
|
|
className={this.props.scope_partmenttype === true ? "bor-red" : ""}
|
|
|
|
|
>
|
|
|
|
|
{options}
|
|
|
|
|
</Select>
|
|
|
|
|
</div>
|
|
|
|
|
<span className="color-grey-9 openrenyuan">(请通过搜索并选中单位名称进行添加)</span>
|
|
|
|
|
</div>
|
|
|
|
|
<span className="color-grey-9">(搜索并选中添加单位名称)</span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div style={{width:'100%'}}>
|
|
|
|
|
<div className="mt20 clearfix" id="task_tag_content">
|
|
|
|
|
{
|
|
|
|
|
this.props.scope_partment===undefined?"":this.props.scope_partment.map((item,key)=>{
|
|
|
|
|
|
|
|
|
|
return(
|
|
|
|
|
<li className="task_tag_span" key={key}><span>{item}</span>
|
|
|
|
|
<a style={{ color: 'rgba(0,0,0,.25)' }}
|
|
|
|
|
onClick={(key)=>this.deleteScopeInput(key)}
|
|
|
|
|
>
|
|
|
|
|
{this.props.identity===1?"x":this.state.status===2&&this.props.scope_partment===this.props.scope_partments||this.state.status===1&&this.props.scope_partment===this.props.scope_partments?"":"×"}
|
|
|
|
|
</a>
|
|
|
|
|
</li>
|
|
|
|
|
)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
<div style={{width: '100%'}}>
|
|
|
|
|
<div className="mt20 clearfix" id="task_tag_content">
|
|
|
|
|
{
|
|
|
|
|
this.state.oldscope_partment.map((item,key)=>{
|
|
|
|
|
return (
|
|
|
|
|
<li key={key} className={"fl mr20"}>
|
|
|
|
|
<Button type="primary" ghost className={"Permanentban "}>
|
|
|
|
|
{item}
|
|
|
|
|
</Button>
|
|
|
|
|
</li>
|
|
|
|
|
)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
this.state.scope_partment === undefined ? "" : this.state.scope_partment.map((item, key) => {
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<li key={key} className={"fl mr20"}>
|
|
|
|
|
<Badge count={"x"} onClick={(key) => this.deleteScopeInput(key)}>
|
|
|
|
|
<Button type="primary" ghost className={"Permanentban "}>
|
|
|
|
|
{item}
|
|
|
|
|
</Button>
|
|
|
|
|
</Badge>
|
|
|
|
|
</li>
|
|
|
|
|
)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<span
|
|
|
|
|
className={this.props.scope_partmenttype === true ? "color-orange ml20 fl" : "color-orange ml20 fl none"}
|
|
|
|
|
id="public_unit_notice">
|
|
|
|
|
<i className="fa fa-exclamation-circle mr3"></i>
|
|
|
|
|
请选择需要公开的单位
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<span className={this.props.scope_partmenttype===true?"color-orange ml20 fl":"color-orange ml20 fl none"} id="public_unit_notice">
|
|
|
|
|
<i className="fa fa-exclamation-circle mr3"></i>
|
|
|
|
|
请选择需要公开的单位
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div className="clearfix mt20 ml30">
|
|
|
|
|
<span className="color-grey-6 mt5 fl" style={{minWidth: '95px'}}>开启时间:</span>
|
|
|
|
|
<span className="fl mt5">
|
|
|
|
|
<DatePicker
|
|
|
|
|
showToday={false}
|
|
|
|
|
showTime={{ format: 'HH:mm' }}
|
|
|
|
|
format="YYYY-MM-DD HH:mm"
|
|
|
|
|
width={178}
|
|
|
|
|
locale={locale}
|
|
|
|
|
disabledTime={disabledDateTime}
|
|
|
|
|
disabledDate={disabledDate}
|
|
|
|
|
placeholder="请选择开启时间"
|
|
|
|
|
value={this.props.shixun.opening_time===null||this.props.shixun.opening_time===""?"":moment(this.props.shixun.opening_time, dateFormat)}
|
|
|
|
|
onChange={this.onChangeTimePicker}
|
|
|
|
|
dropdownClassName="hideDisable"
|
|
|
|
|
/>
|
|
|
|
|
<label style={{top:'6px'}} className="color-grey-9 ml10" >(为空,则学员在实训发布后,能随时开启实训挑战;否则,学员在开启时间后,才能开启实训挑战)</label>
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
</div>}
|
|
|
|
|
|
|
|
|
|
<div className="clearfix mt20">
|
|
|
|
|
<span className="color-grey-6 mt5 fl font-16" style={{minWidth: '45px'}}>开启时间:</span>
|
|
|
|
|
<span className="fl mt8 ml20">
|
|
|
|
|
<Checkbox
|
|
|
|
|
checked={this.state.opentime=== undefined ? false : this.state.opentime}
|
|
|
|
|
onChange={this.setopentime}></Checkbox>
|
|
|
|
|
<label style={{top: '6px'}} className="color-grey-9 ml10">(选中则学员在指定的开启时间后,才能开启学习;不选中则学员在实训发布后,能立即开启学习)</label>
|
|
|
|
|
<div className={"both"}></div>
|
|
|
|
|
{this.state.opentime===false?"":<div className="mt20 ml25">
|
|
|
|
|
<DatePicker
|
|
|
|
|
showToday={false}
|
|
|
|
|
showTime={{format: 'HH:mm'}}
|
|
|
|
|
format="YYYY-MM-DD HH:mm"
|
|
|
|
|
width={178}
|
|
|
|
|
locale={locale}
|
|
|
|
|
disabledTime={disabledDateTime}
|
|
|
|
|
disabledDate={disabledDate}
|
|
|
|
|
placeholder="请输入开启时间"
|
|
|
|
|
value={this.state.opening_time === null ||this.state.opening_time === "" ? "" : moment(this.state.opening_time, dateFormat)}
|
|
|
|
|
onChange={this.onChangeTimePicker}
|
|
|
|
|
dropdownClassName="hideDisable"
|
|
|
|
|
/>
|
|
|
|
|
</div>}
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
{this.props.identity < 5 ?
|
|
|
|
|
<Bottomsubmit {...this.props} {...this.state} url={`/shixuns/${this.props.match.params.shixunId}/challenges`}
|
|
|
|
|
onSubmits={this.onSubmits}/> : ""}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|