@@ -269,7 +275,10 @@ class UseBank extends Component{
-
14 && item.course_list_name} className={nav_my==='myself'?"fl with30 color-grey-6 task-hide pl5":"fl with30 color-grey-6 task-hide pl5"}>{item.course_list_name}
+
14 && item.course_list_name}
+ className={nav_my==='myself'?"fl with30 color-grey-6 task-hide pl5 bankwidth":"fl with30 color-grey-6 task-hide pl5 bankwidth"}
+
+ >{item.course_list_name}
{
nav_my==='public' &&
{item.username}
diff --git a/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js b/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js
index 423632d89..aec7ca390 100644
--- a/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js
+++ b/public/react/src/modules/courses/coursesDetail/CoursesLeftNav.js
@@ -272,9 +272,11 @@ class Coursesleftnav extends Component{
debugger
let {url}=this.state;
if(urls!=url){
+ debugger
this.props.history.replace(urls);
this.props.updataleftNavfun();
}else{
+ debugger
if (key === this.props.indexs) {
this.props.unlocationNavfun(undefined)
} else {
diff --git a/public/react/src/modules/courses/coursesPublic/Addcourses.js b/public/react/src/modules/courses/coursesPublic/Addcourses.js
index f3212d9bd..097d55053 100644
--- a/public/react/src/modules/courses/coursesPublic/Addcourses.js
+++ b/public/react/src/modules/courses/coursesPublic/Addcourses.js
@@ -1,5 +1,5 @@
import React,{ Component } from "react";
-import { Modal,Checkbox,Input} from "antd";
+import { Modal,Checkbox,Input, Spin, Icon } from "antd";
import axios from 'axios';
import Modals from '../../modals/Modals';
const CheckboxGroup = Checkbox.Group;
@@ -23,6 +23,7 @@ class Addcourses extends Component{
modalsType:false,
modalsTopval:undefined,
modalSave:undefined,
+ isSpin:false
}
}
@@ -144,17 +145,22 @@ class Addcourses extends Component{
}
submittojoinclass=()=>{
+ this.setState({
+ isSpin:true
+ })
let {invite_code,professor,assistant_professor,student}=this.state;
if(invite_code===undefined||invite_code===""){
this.setState({
invite_codetype:true,
- invite_codevalue:"邀请码不能为空"
+ invite_codevalue:"邀请码不能为空",
+ spinning:false
})
return
}else{
this.setState({
invite_codetype:false,
- invite_codevalue:" "
+ invite_codevalue:" ",
+ spinning:false
})
}
@@ -178,7 +184,12 @@ class Addcourses extends Component{
// // modalSave:this.submitasyn,
// course_id:response.data.course_id
// })
- this.submitasyn(response.data.course_id)
+ if(response.data.course_id!=undefined){
+ this.submitasyn(response.data.course_id)
+ }
+ this.props.hideAddcoursestype();
+
+ this.props.showNotification(response.data.message);
}else{
this.setState({
Addcoursestype:false
@@ -193,8 +204,15 @@ class Addcourses extends Component{
// course_id:undefined
// })
}
+
+ this.setState({
+ spinning:false
+ })
}).catch((error) => {
console.log(error)
+ this.setState({
+ spinning:false
+ })
})
// if(value===0){
@@ -258,7 +276,7 @@ class Addcourses extends Component{
modalsTopval,
modalSave
}=this.state;
-
+ const antIcon =
;
return(
+
@@ -331,6 +350,7 @@ class Addcourses extends Component{
+
)
diff --git a/public/react/src/modules/courses/exercise/ExerciseListItem.js b/public/react/src/modules/courses/exercise/ExerciseListItem.js
index eb0377022..70df3f577 100644
--- a/public/react/src/modules/courses/exercise/ExerciseListItem.js
+++ b/public/react/src/modules/courses/exercise/ExerciseListItem.js
@@ -167,7 +167,7 @@ class ExerciseListItem extends Component{
{ IsAdmin &&
}
diff --git a/public/react/src/modules/tpm/NewHeader.js b/public/react/src/modules/tpm/NewHeader.js
index 4af1aa6ef..a2ddb242a 100644
--- a/public/react/src/modules/tpm/NewHeader.js
+++ b/public/react/src/modules/tpm/NewHeader.js
@@ -811,7 +811,7 @@ submittojoinclass=(value)=>{
closable={false}
footer={null}
>
-
+
-
diff --git a/public/react/src/modules/tpm/TPMIndexHOC.js b/public/react/src/modules/tpm/TPMIndexHOC.js
index 1ae9e34fb..fff1ce231 100644
--- a/public/react/src/modules/tpm/TPMIndexHOC.js
+++ b/public/react/src/modules/tpm/TPMIndexHOC.js
@@ -123,13 +123,13 @@ export function TPMIndexHOC(WrappedComponent) {
componentDidMount() {
if(this.props.match.path==="/"){
- document.title="创新源于实践";
+ document.title="创新源于实践";
}else if(this.props.match.path==="/403"){
- document.title="你没有权限访问";
+ document.title="你没有权限访问";
}else if(this.props.match.path==="/nopage"){
document.title="没有找到该页面";
}else if(this.props.match.path==="/shixuns"){
- document.title="开发社区";
+ document.title="开发社区";
}else if(this.props.match.path==="/paths"){
document.title="实训课程";
}else if(this.props.match.path==="/courses"){
From 067fa76d20c9f490d3d7ed53b6f5e0926ff92a60 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com>
Date: Fri, 28 Jun 2019 10:13:02 +0800
Subject: [PATCH 8/8] =?UTF-8?q?=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../tasks/GraduationTasksSubmitedit.js | 2 +-
.../tasks/GraduationTasksSubmitnew.js | 240 ++---
.../graduation/tasks/GraduationTasksedit.js | 3 +-
.../graduation/tasks/GraduationTasksnew.js | 2 +
.../topics/GraduateTopicPostWorksNew.js | 849 +++++++++---------
5 files changed, 561 insertions(+), 535 deletions(-)
diff --git a/public/react/src/modules/courses/graduation/tasks/GraduationTasksSubmitedit.js b/public/react/src/modules/courses/graduation/tasks/GraduationTasksSubmitedit.js
index 314aa5447..b5c120879 100644
--- a/public/react/src/modules/courses/graduation/tasks/GraduationTasksSubmitedit.js
+++ b/public/react/src/modules/courses/graduation/tasks/GraduationTasksSubmitedit.js
@@ -504,7 +504,7 @@ class GraduationTasksSubmitedit extends Component{
`}
{getFieldDecorator('description', {
rules: [{
diff --git a/public/react/src/modules/courses/graduation/tasks/GraduationTasksSubmitnew.js b/public/react/src/modules/courses/graduation/tasks/GraduationTasksSubmitnew.js
index b2f28e9b3..3e0972be2 100644
--- a/public/react/src/modules/courses/graduation/tasks/GraduationTasksSubmitnew.js
+++ b/public/react/src/modules/courses/graduation/tasks/GraduationTasksSubmitnew.js
@@ -31,7 +31,8 @@ class GraduationTasksSubmitnew extends Component{
minmaxtype:false,
selectobjct:undefined,
Loadtype:false,
- spinnings:false
+ spinnings:false,
+ shixunsreplace:false
}
}
@@ -88,111 +89,11 @@ class GraduationTasksSubmitnew extends Component{
if(fileList.length === 0){
this.setState({
- Modalstype:true,
- Modalstopval:'请上传附件!',
- Loadtype:true,
- ModalSave:this.cancelAttachment,
+ tshixunsreplace:true,
})
-
-
return
}
-
-
- let userids=[];
-
- for(var list of selectmemberslist){
-
- if(list.user_id!=undefined&&list.user_id!=null){
- userids.push(list.user_id)
- }
-
- }
-
- if(workslist.task_type===1){
- userids=undefined
- }
-
- let listid=[];
-
- for(var list of fileList){
- listid.push(list.response.id)
- }
-
- // e.preventDefault();
- if( GraduationTasksnewtype===true){
- this.props.form.validateFields((err, values) => {
- if (!err) {
- console.log(values.description);
- // console.log(fileList);
- if(values.description===undefined||values.description===""){
-
- return
- }
- if(workslist&&workslist.task_type===2){
- if(userids!=undefined){
- if(userids.length<2){
- this.setState({
- minvalue:2,
- setvalue:"小于",
- minmaxtype:true
- })
-
- return
- }else if(userids.length>5){
- this.setState({
- minvalue:5,
- setvalue:"大于",
- minmaxtype:true
- })
- return
- }
- }
- }
-
- this.setState({
- spinnings:true
- })
-
- let id=this.props.match.params.task_Id;
-
- let url="/graduation_tasks/"+id+"/graduation_works.json";
- axios.post(url, {
- description:values.description,
- attachment_ids:listid,
- user_ids:userids
- }
- ).then((response) => {
- this.setState({
- spinnings:false
- })
- if(response.status===200) {
- GraduationTasksnewtype=false;
- if(response.data.status===0){
- // this.setState({
- // Modalstype:true,
- // Modalstopval:response.data.message,
- // ModalSave:()=>this.setedit(response.data.work_id),
- // Loadtype:true
- // })
- this.setedit(response.data.work_id)
- }else{
- GraduationTasksnewtype=true;
- }
- }
- }).catch((error) => {
- console.log(error)
- })
-
- }
- });
- }
-
-
- // setTimeout(function () {
- // GraduationTasksnewtype=true
- // },10000)
-
+ this.Commoninterface(fileList,selectmemberslist,workslist);
}
handleSelectChange = (value) => {
@@ -433,10 +334,116 @@ class GraduationTasksSubmitnew extends Component{
window.history.go(-1)
}
+ //公用数据
+ Commoninterface = (fileList,selectmemberslist,workslist)=>{
+ let userids=[];
+
+ for(var list of selectmemberslist){
+
+ if(list.user_id!=undefined&&list.user_id!=null){
+ userids.push(list.user_id)
+ }
+
+ }
+
+ if(workslist.task_type===1){
+ userids=undefined
+ }
+
+ let listid=[];
+
+ for(var list of fileList){
+ listid.push(list.response.id)
+ }
+
+ // e.preventDefault();
+ if( GraduationTasksnewtype===true){
+ this.props.form.validateFields((err, values) => {
+ if (!err) {
+ console.log(values.description);
+ // console.log(fileList);
+ if(values.description===undefined||values.description===""){
+
+ return
+ }
+ if(workslist&&workslist.task_type===2){
+ if(userids!=undefined){
+ if(userids.length<2){
+ this.setState({
+ minvalue:2,
+ setvalue:"小于",
+ minmaxtype:true
+ })
+
+ return
+ }else if(userids.length>5){
+ this.setState({
+ minvalue:5,
+ setvalue:"大于",
+ minmaxtype:true
+ })
+ return
+ }
+ }
+ }
+
+ this.setState({
+ spinnings:true
+ })
+
+ let id=this.props.match.params.task_Id;
+
+ let url="/graduation_tasks/"+id+"/graduation_works.json";
+ axios.post(url, {
+ description:values.description,
+ attachment_ids:listid,
+ user_ids:userids
+ }
+ ).then((response) => {
+ this.setState({
+ spinnings:false
+ })
+ if(response.status===200) {
+ GraduationTasksnewtype=false;
+ if(response.data.status===0){
+ // this.setState({
+ // Modalstype:true,
+ // Modalstopval:response.data.message,
+ // ModalSave:()=>this.setedit(response.data.work_id),
+ // Loadtype:true
+ // })
+ this.setedit(response.data.work_id)
+ }else{
+ GraduationTasksnewtype=true;
+ }
+ }
+ }).catch((error) => {
+ console.log(error)
+ })
+
+ }
+ });
+ }
+
+ }
+
+ //确认
+ hidestartshixunsreplace=()=>{
+ let {fileList,selectmemberslist,workslist}=this.state;
+ this.Commoninterface(fileList,selectmemberslist,workslist);
+
+ }
+ //取消
+ hidestartshixunsreplacetwo=()=>{
+ this.setState({
+ shixunsreplace:false,
+ })
+ }
+
render(){
const { getFieldDecorator } = this.props.form;
let {search,fileList, workslist,setvalue,minvalue,minmaxtype,Loadtype,
- Modalstype,Modalstopval,ModalCancel,ModalSave,memberslist,task_status,selectmemberslist} =this.state;
+ Modalstype,Modalstopval,ModalCancel,ModalSave,memberslist,task_status,selectmemberslist,shixunsreplace} =this.state;
let courseId=this.props.match.params.coursesId;
let category_id=this.props.match.params.category_id;
@@ -481,6 +488,24 @@ render(){
modalSave={ModalSave}
loadtype={Loadtype}
/>
+
+
+
+
@@ -520,13 +545,10 @@ render(){
.upload_1 .ant-upload-list {
width: 350px;
}
- .contentbox{
- margin-bottom:0px !important;
- }
`}
{getFieldDecorator('description', {
rules: [{
@@ -583,7 +605,7 @@ render(){
{workslist&&workslist.task_type===1?"":
{getFieldDecorator('description', {
diff --git a/public/react/src/modules/courses/graduation/tasks/GraduationTasksnew.js b/public/react/src/modules/courses/graduation/tasks/GraduationTasksnew.js
index ae7d0aad8..6b9a96108 100644
--- a/public/react/src/modules/courses/graduation/tasks/GraduationTasksnew.js
+++ b/public/react/src/modules/courses/graduation/tasks/GraduationTasksnew.js
@@ -339,9 +339,11 @@ class GraduationTasksnew extends Component {
.ant-form-item{
margin-bottom:0px
}
+
`}
{getFieldDecorator('description', {
diff --git a/public/react/src/modules/courses/graduation/topics/GraduateTopicPostWorksNew.js b/public/react/src/modules/courses/graduation/topics/GraduateTopicPostWorksNew.js
index 9da87835e..bc2f64538 100644
--- a/public/react/src/modules/courses/graduation/topics/GraduateTopicPostWorksNew.js
+++ b/public/react/src/modules/courses/graduation/topics/GraduateTopicPostWorksNew.js
@@ -1,425 +1,426 @@
-import React,{ Component } from "react";
-
-import {
- Form, Input, InputNumber, Switch, Radio,
- Slider, Button, Upload, Icon, Rate, Checkbox, message,
- Row, Col, Select, Modal
-} from 'antd';
-import TPMMDEditor from '../../../tpm/challengesnew/TPMMDEditor';
-import axios from 'axios'
-import {getUrl} from 'educoder';
-import "../../common/formCommon.css"
-
-// import './board.css'
-// import { RouteHOC } from './common.js'
-
-const confirm = Modal.confirm;
-const $ = window.$
-const { Option } = Select;
-// 提交作品
-// https://lanhuapp.com/web/#/item/project/board/detail?pid=a3bcd4b1-99ce-4e43-8ead-5b8b0a410807&project_id=a3bcd4b1-99ce-4e43-8ead-5b8b0a410807&image_id=c6d9b36f-7701-4035-afdb-62404681108c
-class GraduateTopicPostWorksNew extends Component{
- constructor(props){
- super(props);
-
- this.mdRef = React.createRef();
-
- this.state = {
- fileList: [],
- boards: []
- }
- }
- componentDidMount = () => {
-
- const topicId = this.props.match.params.topicId
-
- const cid = this.props.match.params.coursesId
- const boardsUrl = `/courses/${cid}/get_all_boards.json`
- axios.get(boardsUrl, { })
- .then((response) => {
- if (response.data.status == 0) {
- this.setState({
- boards: response.data.data
- })
- }
- })
- .catch(function (error) {
- console.log(error);
- });
-
- const isEdit = !!topicId
- this.isEdit = isEdit
- if (isEdit) {
- const url = `/messages/${topicId}.json`
- axios.get(url, {
- })
- .then((response) => {
- if (response.data.status == 0) {
- const { id, data } = response.data;
- if (data) {
- this.editTopic = data;
- this.props.form.setFieldsValue({
- content: data.content,
- subject: data.subject,
- board_id: data.board_id
- });
- this.mdRef.current.setValue(data.content)
- const _fileList = data.attachments.map(item => {
- return {
- id: item.id,
- uid: item.id,
- name: item.title,
- url: item.url,
- status: 'done'
- }
- })
- this.setState({ fileList: _fileList})
- }
- }
- })
- .catch(function (error) {
- console.log(error);
- });
- } else {
- const boardId = this.props.match.params.boardId
-
- this.props.form.setFieldsValue({
- board_id: parseInt(boardId)
- });
- }
- }
- handleSubmit = (e) => {
- e.preventDefault();
- const cid = this.props.match.params.coursesId
- const boardId = this.props.match.params.boardId
-
- this.props.form.validateFieldsAndScroll((err, values) => {
- if (!err) {
- console.log('Received values of form: ', values);
- if (this.isEdit == true) {
- const editTopic = this.editTopic
- const editUrl = `/messages/${editTopic.id}.json`
-
- let attachment_ids = undefined
- if (this.state.fileList) {
- attachment_ids = this.state.fileList.map(item => {
- return item.response ? item.response.id : item.id
- })
- }
- axios.put(editUrl, {
- subject: values.subject,
- board_id: values.board_id,
- content: values.content,
- sticky: values.sticky,
- attachment_ids,
- // board_id: 3779,
- })
- .then((response) => {
- if (response.data.status == 0) {
- const { id } = response.data;
- console.log('--- success')
-
- this.props.toDetailPage(cid, values.board_id, editTopic.id)
- }
- })
- .catch(function (error) {
- console.log(error);
- });
- } else {
- const url = `/messages.json`
- let attachment_ids = undefined
- if (this.state.fileList) {
- attachment_ids = this.state.fileList.map(item => {
- return item.response.id
- })
- }
-
- axios.post(url, {
- ...values,
- course_id: cid,
- board_id: boardId,
- attachment_ids,
- })
- .then((response) => {
- if (response.data) {
- const { id } = response.data;
- if (id) {
- console.log('--- success')
- }
- }
- })
- .catch(function (error) {
- console.log(error);
- });
- }
- } else {
- $("html").animate({ scrollTop: $('html').scrollTop() - 100 })
- }
- });
- }
- // 附件相关 START
- handleChange = (info) => {
- let fileList = info.fileList;
- this.setState({ fileList });
- }
- onAttachmentRemove = (file) => {
- confirm({
- title: '确定要删除这个附件吗?',
- okText: '确定',
- cancelText: '取消',
- // content: 'Some descriptions',
- onOk: () => {
- this.deleteAttachment(file)
- },
- onCancel() {
- console.log('Cancel');
- },
- });
-
-
- return false;
- }
- deleteAttachment = (file) => {
- const url = `/attachments/${file.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,
- };
- });
- }
- }
- })
- .catch(function (error) {
- console.log(error);
- });
- }
- // 附件相关 ------------ END
- render() {
- let { addGroup, fileList } = this.state;
- const { getFieldDecorator } = this.props.form;
-
- const formItemLayout = {
- labelCol: {
- xs: { span: 24 },
- // sm: { span: 8 },
- sm: { span: 24 },
- },
- wrapperCol: {
- xs: { span: 24 },
- // sm: { span: 16 },
- sm: { span: 24 },
- },
- };
-
- const tailFormItemLayout = {
- wrapperCol: {
- xs: {
- span: 24,
- offset: 0,
- },
- sm: {
- span: 16,
- offset: 8,
- },
- },
- };
-
- 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 < 150;
- if (!isLt150M) {
- message.error('文件大小必须小于150MB!');
- }
- return isLt150M;
- },
- };
- return(
-
- )
- }
-}
-
-const WrappedGraduateTopicPostWorksNew = Form.create({ name: 'topicPostWorksNew' })(GraduateTopicPostWorksNew);
-// RouteHOC()
+import React,{ Component } from "react";
+
+import {
+ Form, Input, InputNumber, Switch, Radio,
+ Slider, Button, Upload, Icon, Rate, Checkbox, message,
+ Row, Col, Select, Modal
+} from 'antd';
+import TPMMDEditor from '../../../tpm/challengesnew/TPMMDEditor';
+import axios from 'axios'
+import {getUrl} from 'educoder';
+import "../../common/formCommon.css"
+
+// import './board.css'
+// import { RouteHOC } from './common.js'
+
+const confirm = Modal.confirm;
+const $ = window.$
+const { Option } = Select;
+// 提交作品
+// https://lanhuapp.com/web/#/item/project/board/detail?pid=a3bcd4b1-99ce-4e43-8ead-5b8b0a410807&project_id=a3bcd4b1-99ce-4e43-8ead-5b8b0a410807&image_id=c6d9b36f-7701-4035-afdb-62404681108c
+class GraduateTopicPostWorksNew extends Component{
+ constructor(props){
+ super(props);
+
+ this.mdRef = React.createRef();
+
+ this.state = {
+ fileList: [],
+ boards: []
+ }
+ }
+ componentDidMount = () => {
+
+ const topicId = this.props.match.params.topicId
+
+ const cid = this.props.match.params.coursesId
+ const boardsUrl = `/courses/${cid}/get_all_boards.json`
+ axios.get(boardsUrl, { })
+ .then((response) => {
+ if (response.data.status == 0) {
+ this.setState({
+ boards: response.data.data
+ })
+ }
+ })
+ .catch(function (error) {
+ console.log(error);
+ });
+
+ const isEdit = !!topicId
+ this.isEdit = isEdit
+ if (isEdit) {
+ const url = `/messages/${topicId}.json`
+ axios.get(url, {
+ })
+ .then((response) => {
+ if (response.data.status == 0) {
+ const { id, data } = response.data;
+ if (data) {
+ this.editTopic = data;
+ this.props.form.setFieldsValue({
+ content: data.content,
+ subject: data.subject,
+ board_id: data.board_id
+ });
+ this.mdRef.current.setValue(data.content)
+ const _fileList = data.attachments.map(item => {
+ return {
+ id: item.id,
+ uid: item.id,
+ name: item.title,
+ url: item.url,
+ status: 'done'
+ }
+ })
+ this.setState({ fileList: _fileList})
+ }
+ }
+ })
+ .catch(function (error) {
+ console.log(error);
+ });
+ } else {
+ const boardId = this.props.match.params.boardId
+
+ this.props.form.setFieldsValue({
+ board_id: parseInt(boardId)
+ });
+ }
+ }
+ handleSubmit = (e) => {
+ e.preventDefault();
+ const cid = this.props.match.params.coursesId
+ const boardId = this.props.match.params.boardId
+
+ this.props.form.validateFieldsAndScroll((err, values) => {
+ if (!err) {
+ console.log('Received values of form: ', values);
+ if (this.isEdit == true) {
+ const editTopic = this.editTopic
+ const editUrl = `/messages/${editTopic.id}.json`
+
+ let attachment_ids = undefined
+ if (this.state.fileList) {
+ attachment_ids = this.state.fileList.map(item => {
+ return item.response ? item.response.id : item.id
+ })
+ }
+ axios.put(editUrl, {
+ subject: values.subject,
+ board_id: values.board_id,
+ content: values.content,
+ sticky: values.sticky,
+ attachment_ids,
+ // board_id: 3779,
+ })
+ .then((response) => {
+ if (response.data.status == 0) {
+ const { id } = response.data;
+ console.log('--- success')
+
+ this.props.toDetailPage(cid, values.board_id, editTopic.id)
+ }
+ })
+ .catch(function (error) {
+ console.log(error);
+ });
+ } else {
+ const url = `/messages.json`
+ let attachment_ids = undefined
+ if (this.state.fileList) {
+ attachment_ids = this.state.fileList.map(item => {
+ return item.response.id
+ })
+ }
+
+ axios.post(url, {
+ ...values,
+ course_id: cid,
+ board_id: boardId,
+ attachment_ids,
+ })
+ .then((response) => {
+ if (response.data) {
+ const { id } = response.data;
+ if (id) {
+ console.log('--- success')
+ }
+ }
+ })
+ .catch(function (error) {
+ console.log(error);
+ });
+ }
+ } else {
+ $("html").animate({ scrollTop: $('html').scrollTop() - 100 })
+ }
+ });
+ }
+ // 附件相关 START
+ handleChange = (info) => {
+ let fileList = info.fileList;
+ this.setState({ fileList });
+ }
+ onAttachmentRemove = (file) => {
+ confirm({
+ title: '确定要删除这个附件吗?',
+ okText: '确定',
+ cancelText: '取消',
+ // content: 'Some descriptions',
+ onOk: () => {
+ this.deleteAttachment(file)
+ },
+ onCancel() {
+ console.log('Cancel');
+ },
+ });
+
+
+ return false;
+ }
+ deleteAttachment = (file) => {
+ const url = `/attachments/${file.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,
+ };
+ });
+ }
+ }
+ })
+ .catch(function (error) {
+ console.log(error);
+ });
+ }
+ // 附件相关 ------------ END
+ render() {
+ let { addGroup, fileList } = this.state;
+ const { getFieldDecorator } = this.props.form;
+
+ const formItemLayout = {
+ labelCol: {
+ xs: { span: 24 },
+ // sm: { span: 8 },
+ sm: { span: 24 },
+ },
+ wrapperCol: {
+ xs: { span: 24 },
+ // sm: { span: 16 },
+ sm: { span: 24 },
+ },
+ };
+
+ const tailFormItemLayout = {
+ wrapperCol: {
+ xs: {
+ span: 24,
+ offset: 0,
+ },
+ sm: {
+ span: 16,
+ offset: 8,
+ },
+ },
+ };
+
+ 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 < 150;
+ if (!isLt150M) {
+ message.error('文件大小必须小于150MB!');
+ }
+ return isLt150M;
+ },
+ };
+ return(
+
+ )
+ }
+}
+
+const WrappedGraduateTopicPostWorksNew = Form.create({ name: 'topicPostWorksNew' })(GraduateTopicPostWorksNew);
+// RouteHOC()
export default (WrappedGraduateTopicPostWorksNew);
\ No newline at end of file