|
|
@ -9,7 +9,7 @@ import Tags from './CaseTags'
|
|
|
|
|
|
|
|
|
|
|
|
import axios from 'axios';
|
|
|
|
import axios from 'axios';
|
|
|
|
import TPMMDEditor from '../tpm/challengesnew/TPMMDEditor';
|
|
|
|
import TPMMDEditor from '../tpm/challengesnew/TPMMDEditor';
|
|
|
|
|
|
|
|
import _ from 'lodash'
|
|
|
|
const { Dragger } = Upload;
|
|
|
|
const { Dragger } = Upload;
|
|
|
|
function beforeUpload(file) {
|
|
|
|
function beforeUpload(file) {
|
|
|
|
const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png';
|
|
|
|
const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png';
|
|
|
@ -34,9 +34,9 @@ class CaseNew extends Component{
|
|
|
|
this.DescMdRef = React.createRef();
|
|
|
|
this.DescMdRef = React.createRef();
|
|
|
|
|
|
|
|
|
|
|
|
this.state={
|
|
|
|
this.state={
|
|
|
|
goldCases:false,
|
|
|
|
casesTags:[],
|
|
|
|
bankCases:false,
|
|
|
|
|
|
|
|
contentFileList:[],
|
|
|
|
contentFileList:[],
|
|
|
|
|
|
|
|
filesID:[],
|
|
|
|
imageUrl:undefined,
|
|
|
|
imageUrl:undefined,
|
|
|
|
loading: false,
|
|
|
|
loading: false,
|
|
|
|
checkTag:false,
|
|
|
|
checkTag:false,
|
|
|
@ -88,6 +88,16 @@ class CaseNew extends Component{
|
|
|
|
handleContentUploadChange = (info) => {
|
|
|
|
handleContentUploadChange = (info) => {
|
|
|
|
let contentFileList = info.fileList;
|
|
|
|
let contentFileList = info.fileList;
|
|
|
|
this.setState({ contentFileList: appendFileSizeToUploadFileAll(contentFileList)});
|
|
|
|
this.setState({ contentFileList: appendFileSizeToUploadFileAll(contentFileList)});
|
|
|
|
|
|
|
|
let list = appendFileSizeToUploadFileAll(contentFileList);
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
|
|
|
|
filesID:list.map(item=>{
|
|
|
|
|
|
|
|
return ( item.response && item.response.id )
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
console.log("fujian");
|
|
|
|
|
|
|
|
console.log(list.map(item=>{
|
|
|
|
|
|
|
|
return ( item.response && item.response.id )
|
|
|
|
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 上传封面图-change
|
|
|
|
// 上传封面图-change
|
|
|
@ -137,14 +147,10 @@ class CaseNew extends Component{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
coverID:this.props.cover && this.props.cover.id,
|
|
|
|
coverID:this.props.cover && this.props.cover.id,
|
|
|
|
imageUrl:this.props.CaseDetail.cover && getImageUrl(this.props.CaseDetail.cover.url)
|
|
|
|
imageUrl:this.props.CaseDetail.cover && getImageUrl(this.props.CaseDetail.cover.url),
|
|
|
|
})
|
|
|
|
casesTags:this.props.tags.map(item=>{
|
|
|
|
this.props.tags.map((item)=>{
|
|
|
|
return (item.id);
|
|
|
|
if(item.name=="入库案例"){
|
|
|
|
})
|
|
|
|
this.setState({bankCases:true})
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
this.setState({goldCases:true})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -156,44 +162,80 @@ class CaseNew extends Component{
|
|
|
|
|
|
|
|
|
|
|
|
// 申请提交和保存
|
|
|
|
// 申请提交和保存
|
|
|
|
handleSubmit = (type) => {
|
|
|
|
handleSubmit = (type) => {
|
|
|
|
|
|
|
|
let caseID = this.props.match.params.caseID;
|
|
|
|
console.log(type);
|
|
|
|
console.log(type);
|
|
|
|
this.props.form.validateFieldsAndScroll((err, values) => {
|
|
|
|
this.props.form.validateFieldsAndScroll((err, values) => {
|
|
|
|
let { goldCases , bankCases } = this.state;
|
|
|
|
let { casesTags } = this.state;
|
|
|
|
if(!goldCases && !bankCases){
|
|
|
|
if(casesTags.length == 0){
|
|
|
|
$("html").animate({ scrollTop: $("#tagFormItem").offset().top - 100 });
|
|
|
|
$("html").animate({ scrollTop: $("#tagFormItem").offset().top - 100 });
|
|
|
|
this.setState({
|
|
|
|
this.setState({
|
|
|
|
checkTag:true
|
|
|
|
checkTag:true
|
|
|
|
})
|
|
|
|
})
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const mdContnet = this.DescMdRef.current.getValue().trim();
|
|
|
|
//const mdContnet = this.DescMdRef.current.getValue().trim();
|
|
|
|
console.log(values);
|
|
|
|
console.log(values);
|
|
|
|
let url=`/libraries/:id.json`;
|
|
|
|
let url = caseID ? `/libraries/${caseID}.json`: `/libraries.json`;
|
|
|
|
// axios.put(())
|
|
|
|
if(caseID){
|
|
|
|
|
|
|
|
axios.put((url),{
|
|
|
|
|
|
|
|
title:values.caseTitle,
|
|
|
|
|
|
|
|
author_name:values.userName,
|
|
|
|
|
|
|
|
author_school_name:values.userUnit,
|
|
|
|
|
|
|
|
content:values.description,
|
|
|
|
|
|
|
|
attachment_ids:this.state.filesID,
|
|
|
|
|
|
|
|
tag_ids:this.state.casesTags,
|
|
|
|
|
|
|
|
cover_id:this.state.coverID,
|
|
|
|
|
|
|
|
publish:type == 'save' ? false : true
|
|
|
|
|
|
|
|
}).then((result)=>{
|
|
|
|
|
|
|
|
if(result){
|
|
|
|
|
|
|
|
this.props.showNotification(type == 'save' ? `案例保存成功!`: `提交成功!`);
|
|
|
|
|
|
|
|
this.props.history.push(type == 'save' ? `/moop_cases/${result.data.id}` : `/moop_cases/${result.data.id}/publish_success`);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}).catch((error)=>{
|
|
|
|
|
|
|
|
console.log(error);
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
axios.post((url),{
|
|
|
|
|
|
|
|
title:values.caseTitle,
|
|
|
|
|
|
|
|
author_name:values.userName,
|
|
|
|
|
|
|
|
author_school_name:values.userUnit,
|
|
|
|
|
|
|
|
content:values.description,
|
|
|
|
|
|
|
|
attachment_ids:this.state.filesID,
|
|
|
|
|
|
|
|
tag_ids:this.state.casesTags,
|
|
|
|
|
|
|
|
cover_id:this.state.coverID,
|
|
|
|
|
|
|
|
publish:type == 'save' ? false : true
|
|
|
|
|
|
|
|
}).then((result)=>{
|
|
|
|
|
|
|
|
if(result){
|
|
|
|
|
|
|
|
this.props.showNotification(type == 'save' ? `案例保存成功!`: `提交成功!`);
|
|
|
|
|
|
|
|
this.props.history.push(type == 'save' ? `/moop_cases/${result.data.id}` : `/moop_cases/${result.data.id}/publish_success`);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}).catch((error)=>{
|
|
|
|
|
|
|
|
console.log(error);
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 选择标签
|
|
|
|
// 选择标签
|
|
|
|
changeType=(type)=>{
|
|
|
|
changeType=(type)=>{
|
|
|
|
let { goldCases , bankCases } = this.state;
|
|
|
|
let tags = [];
|
|
|
|
if(type=="gold"){
|
|
|
|
if(this.state.casesTags.indexOf(type) > -1){
|
|
|
|
this.setState({
|
|
|
|
tags = this.state.casesTags.filter(item => item != type);
|
|
|
|
goldCases:!goldCases
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}else{
|
|
|
|
}else{
|
|
|
|
this.setState({
|
|
|
|
tags = this.state.casesTags.concat(type);
|
|
|
|
bankCases:!bankCases
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!goldCases == true || !bankCases == true){
|
|
|
|
|
|
|
|
this.setState({checkTag:false})
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const tagUniqed = _.uniq(tags);
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
|
|
|
|
casesTags: tagUniqed,
|
|
|
|
|
|
|
|
checkTag:tags.length > 0 ? false : true
|
|
|
|
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
render(){
|
|
|
|
render(){
|
|
|
|
let { caseID } = this.props.match.params;
|
|
|
|
let { caseID } = this.props.match.params;
|
|
|
|
let { CaseDetail } = this.props;
|
|
|
|
let { CaseDetail } = this.props;
|
|
|
|
let { goldCases , bankCases , contentFileList , imageUrl , checkTag } = this.state;
|
|
|
|
let { casesTags , contentFileList , imageUrl , checkTag } = this.state;
|
|
|
|
const {getFieldDecorator} = this.props.form;
|
|
|
|
const {getFieldDecorator} = this.props.form;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -267,9 +309,6 @@ class CaseNew extends Component{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.newCases .resetBottom .ant-form-explain{
|
|
|
|
.newCases .resetBottom .ant-form-explain{
|
|
|
|
bottom:2px;
|
|
|
|
bottom:2px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.markdown-body table{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`
|
|
|
|
`
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -307,8 +346,8 @@ class CaseNew extends Component{
|
|
|
|
<div className={checkTag==true ? "clearfix mb20 pr has-error" : "clearfix mb20"} id="tagFormItem">
|
|
|
|
<div className={checkTag==true ? "clearfix mb20 pr has-error" : "clearfix mb20"} id="tagFormItem">
|
|
|
|
<span className="upload_Title must">标签</span>
|
|
|
|
<span className="upload_Title must">标签</span>
|
|
|
|
<ul className="fl libraries_tab">
|
|
|
|
<ul className="fl libraries_tab">
|
|
|
|
<li className={ goldCases ? "active" :"" } onClick={()=>this.changeType("gold")}>获奖案例</li>
|
|
|
|
<li className={ casesTags.indexOf(1) > -1 ? "active" :"" } onClick={()=>this.changeType(1)}>获奖案例</li>
|
|
|
|
<li className={ bankCases ? "active" :"" } onClick={()=>this.changeType("bank")}>入库案例</li>
|
|
|
|
<li className={ casesTags.indexOf(2) > -1 ? "active" :"" } onClick={()=>this.changeType(2)}>入库案例</li>
|
|
|
|
</ul>
|
|
|
|
</ul>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
checkTag && <div class="ant-form-explain">请选择标签</div>
|
|
|
|
checkTag && <div class="ant-form-explain">请选择标签</div>
|
|
|
|