From f2e78fb642d4c8312b25ac8bd4bc5037692eb864 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, 3 Jan 2020 21:39:37 +0800
Subject: [PATCH] =?UTF-8?q?=E9=A2=98=E5=BA=93=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../react/src/modules/question/Paperreview.js | 9 +-
.../src/modules/question/Paperreview_item.js | 6 +-
.../question/component/Itembankstop.js | 205 ++++++++----------
3 files changed, 92 insertions(+), 128 deletions(-)
diff --git a/public/react/src/modules/question/Paperreview.js b/public/react/src/modules/question/Paperreview.js
index 30b6cd4bb..1f57c81a4 100644
--- a/public/react/src/modules/question/Paperreview.js
+++ b/public/react/src/modules/question/Paperreview.js
@@ -188,18 +188,12 @@ class Paperreview extends Component {
}
preservation = () => {
- debugger
-
//保存试卷
if(this.state.Cohetepaperbool===true){
-
if (this.contentMdRef.Getdatas().length === 0) {
this.scrollToAnchor("Itembankstopid");
return;
}
- console.log("this.contentMdRef.Getdatas()");
- console.log(this.contentMdRef.Getdatas());
-
var myrbkc=[];
var Getdatasdatas=this.contentMdRef.Getdatas()[2].rbzsd;
for(let myda of Getdatasdatas) {
@@ -213,11 +207,10 @@ class Paperreview extends Component {
discipline_id: this.contentMdRef.Getdatas()[3].rbkc[0],
sub_discipline_id: this.contentMdRef.Getdatas()[3].rbkc[1],
tag_discipline_id: myrbkc,
-
}
axios.post(url, data)
.then((result) => {
- if (result.data.status == 0) {
+ if (result.data.status === 0) {
this.props.showNotification(`组卷成功`);
this.props.history.replace('./paperlibrary');
}
diff --git a/public/react/src/modules/question/Paperreview_item.js b/public/react/src/modules/question/Paperreview_item.js
index dc62930f3..d4657ac95 100644
--- a/public/react/src/modules/question/Paperreview_item.js
+++ b/public/react/src/modules/question/Paperreview_item.js
@@ -438,9 +438,9 @@ class Paperreview_item extends Component {
拖动试题可调整排序
-
共{single_questions && single_questions.questions_count}个试题
-
+ {/*
共{single_questions && single_questions.questions_count}个试题*/}
+ {/*
*/}
diff --git a/public/react/src/modules/question/component/Itembankstop.js b/public/react/src/modules/question/component/Itembankstop.js
index bb847a118..dfb872c6b 100644
--- a/public/react/src/modules/question/component/Itembankstop.js
+++ b/public/react/src/modules/question/component/Itembankstop.js
@@ -52,6 +52,7 @@ class Itembankstop extends Component {
rbtx: undefined,
rbkc: undefined,
knowledgepoints: [],
+ knowledgepoints2:[],
options: [],
NewknTypedel:false
}
@@ -65,30 +66,14 @@ class Itembankstop extends Component {
}
this.setState({
- options: this.props.disciplmy
- })
- // knowledgepoints:this.props.knowledgepoints,
-
- ////console.log("componentDidMount");
- ////console.log(this.state);
- ////console.log(this.props);
- // let homeworkid = this.props.match.params.homeworkid;
- // let url = "/homework_commons/" + homeworkid + "/end_groups.json";
- // axios.get(url).then((response) => {
- // if (response.status === 200) {
- // this.setState({})
- // }
- // }).catch((error) => {
- // ////console.log(error)
- // });()
- // 题型
+ options: this.props.disciplmy,
+ })
}
componentDidUpdate(prevProps) {
//编辑的时候
-
if (prevProps.item_banksedit !== this.props.item_banksedit) {
if (this.props.item_banksedit.item_type) {
this.handleFormtixing(this.props.item_banksedit.item_type);
@@ -99,9 +84,10 @@ class Itembankstop extends Component {
if (this.props.item_banksedit.tag_disciplines) {
this.handletag_disciplinesChange(this.props.item_banksedit.tag_disciplines);
}
-
- if (this.props.item_banksedit.discipline &&this.props.item_banksedit.sub_discipline) {
+ try {
this.handdisciplinesChange(this.props.item_banksedit.discipline,this.props.item_banksedit.sub_discipline);
+ }catch (e) {
+
}
}
if (prevProps.disciplmy !== this.props.disciplmy) {
@@ -109,65 +95,63 @@ class Itembankstop extends Component {
options: this.props.disciplmy
})
}
-
- }
- handdisciplinesChange =(name,title)=>{
- this.setState({
- rbkc:[name.id,title.id]
- })
- this.props.form.setFieldsValue({
- rbkc: [name.id,title.id],
- });
-
- if(this.props.item_banksedit.tag_disciplines.length===0){
- const didata = this.props.disciplinesdata;
- const knowledgepointsdata = [];
-
- for (var i = 0; i < didata.length; i++) {
- //方向
- if (name.id === didata[i].id) {
- const fxdidata = didata[i].sub_disciplines;
- for (var j = 0; j < fxdidata.length; j++) {
- //课程
- if (title.id === fxdidata[j].id) {
- const zsddata = fxdidata[j].tag_disciplines;
- for (var k = 0; k < zsddata.length; k++) {
- //知识点
- knowledgepointsdata.push(zsddata[k]);
-
-
+ // 把知识点放进塞选中 ,如果是编辑 已经选中就不放进去
+ if(prevProps.disciplinesdata!== this.props.disciplinesdata){
+ try {
+ if(this.props.item_banksedit.discipline &&this.props.item_banksedit.sub_discipline){
+ const didata = this.props.disciplinesdata;
+ const knowledgepointsdata = [];
+ for (var i = 0; i < didata.length; i++) {
+ //方向
+ if (this.props.item_banksedit.discipline.id === didata[i].id) {
+ const fxdidata = didata[i].sub_disciplines;
+ for (var j = 0; j < fxdidata.length; j++) {
+ //课程
+ if (this.props.item_banksedit.sub_discipline.id === fxdidata[j].id) {
+ const zsddata = fxdidata[j].tag_disciplines;
+ for (var k = 0; k < zsddata.length; k++) {
+ //知识点
+ knowledgepointsdata.push(zsddata[k]);
+ }
+ }
}
-
}
-
}
+ const _result =[];
+ knowledgepointsdata.filter(item => {
+ if (this.props.item_banksedit.tag_disciplines.findIndex(t => t.id === item.id) === -1) {
+ _result.push(item);
+ }
+ });
+ this.setState({
+ knowledgepoints:knowledgepointsdata,
+ knowledgepoints2: _result,
+ })
}
-
-
+ }catch (e) {
}
-
- this.setState({
- Knowpoints: [],
- knowledgepoints: knowledgepointsdata,
- })
-
}
+ }
+ handdisciplinesChange =(name,title)=>{
+ this.setState({
+ rbkc:[name.id,title.id]
+ })
+ this.props.form.setFieldsValue({
+ rbkc: [name.id,title.id],
+ });
+ }
-
-
-
- }
handletag_disciplinesChange = (data) => {
+ //是否选中的知识点
try {
var sju=data[data.length-1].name;
this.setState({
- rbzsd:sju,
Knowpoints:data,
})
this.props.form.setFieldsValue({
@@ -176,6 +160,8 @@ class Itembankstop extends Component {
}catch (e) {
}
+
+
}
onChange = (e) => {
@@ -238,7 +224,6 @@ class Itembankstop extends Component {
//课程
////console.log("课程");
////console.log(value);
- // console.log("handleFormkechen");
if(this.state.Knowpoints.length>4){
this.props.showNotification(`知识点最多选择5个`);
return
@@ -256,17 +241,20 @@ class Itembankstop extends Component {
}
}
- var tmp = JSON.parse(JSON.stringify(this.state.knowledgepoints));
- for (var i = 0; i < tmp.length; i++) {
- if (tmp[i].id === value) {
- this.state.knowledgepoints.splice(i, 1);
+ const _result =[];
+ this.state.knowledgepoints.filter(item => {
+ if (this.state.Knowpoints.findIndex(t => t.id === item.id) === -1) {
+ console.log("guonue");
+ console.log(item);
+ _result.push(item);
}
- }
+ });
+
this.setState({
rbzsd: valuename,
Knowpoints: this.state.Knowpoints,
- knowledgepoints: this.state.knowledgepoints,
+ knowledgepoints2: _result,
})
}
@@ -314,6 +302,7 @@ class Itembankstop extends Component {
this.setState({
Knowpoints: [],
knowledgepoints: knowledgepointsdata,
+ knowledgepoints2:knowledgepointsdata,
})
this.props.form.setFieldsValue({
@@ -341,19 +330,11 @@ class Itembankstop extends Component {
////console.log('Clicked! But prevent default.');
}
deletesobject = (item, index) => {
- var arr = this.state.Knowpoints;
- for (let data of arr) {
- if (data.id === item.id) {
- this.state.knowledgepoints.push(data);
- }
- }
-
- var tmp = JSON.parse(JSON.stringify(this.state.Knowpoints));
+ var tmp = this.state.Knowpoints;
for (var i = 0; i < tmp.length; i++) {
- if (i >= index) {
- var pos = this.state.Knowpoints.indexOf(tmp[i]);
- this.state.Knowpoints.splice(pos, 1);
+ if (i ===index) {
+ tmp.splice(i,1);
}
}
@@ -361,11 +342,16 @@ class Itembankstop extends Component {
rbzsd: this.state.Knowpoints,
});
-
+ const _result =[];
+ this.state.knowledgepoints.filter(item => {
+ if (this.state.Knowpoints.findIndex(t => t.id === item.id) === -1) {
+ _result.push(item);
+ }
+ });
this.setState({
Knowpoints: this.state.Knowpoints,
+ knowledgepoints2:_result,
})
-
if (this.state.Knowpoints.length === 0) {
this.setState({
rbzsd: undefined,
@@ -389,7 +375,6 @@ class Itembankstop extends Component {
NewknTypedel:bool
})
-
}
NewknTypedeltyoedel=(value)=>{
@@ -422,8 +407,17 @@ class Itembankstop extends Component {
name:value,
}
this.state.knowledgepoints.push(leydata);
+ const _result =[];
+ this.state.knowledgepoints.filter(item => {
+ if (this.state.Knowpoints.findIndex(t => t.id === item.id) === -1) {
+ _result.push(item);
+ }
+ });
+
this.setState({
- knowledgepoints:this.state.knowledgepoints
+ Knowpoints: this.state.Knowpoints,
+ knowledgepoints: this.state.knowledgepoints,
+ knowledgepoints2: _result,
})
}
}).catch((error) => {
@@ -435,13 +429,11 @@ class Itembankstop extends Component {
})
}
+
render() {
- let {page, options,NewknTypedel} = this.state;
+ let {page, options,NewknTypedel,knowledgepoints,knowledgepoints2,Knowpoints} = this.state;
const {getFieldDecorator} = this.props.form;
- //console.log("renderrenderrender");
- //console.log(this.props.item_banksedit);
- //console.log("renderrenderrendersssss");
- //console.log(this.state.rbtx);
+
return (
@@ -500,25 +492,6 @@ class Itembankstop extends Component {
placeholder="请选择..."/>
-
- {/*
*/}
-
- {/* {this.state.Knowpoints === undefined ? "" : this.state.Knowpoints.map((object, index) => {*/}
- {/* return (*/}
- {/*
*/}
- {/*
{object}
*/}
- {/*
this.deletesobject(object,index)}>*/}
- {/*
*/}
- {/* )*/}
- {/* })}*/}
-
- {/*
*/}
)}
@@ -529,17 +502,18 @@ class Itembankstop extends Component {
)(
-
+
this.NewknTypedeldel(true)}/>
@@ -562,6 +536,9 @@ class Itembankstop extends Component {
)
})}
+
+
+
)}
@@ -656,12 +633,6 @@ class Itembankstop extends Component {
)}
- {/**/}
- {/* */}
- {/**/}
-