dev_aliyun_beta
杨树林 6 years ago
commit 3501f2caa5

@ -975,18 +975,23 @@ class PollNew extends Component {
if (this.state.problemtopicbool === true) {
insindex = this.state.problemtopic;
}
this.createquestionsandanswers(object, 1, arrc, null, 0, 0, insindex);
this.createquestionsandanswers(object, 1, arrc, null, 0, 0, insindex,0);
// newarrpoll.push(question);
newarrpoll.splice(thiss.state.Insertposition, 0, question);
} else if (object.question.question_type === 2) {
//插入多选题
if (object.question.max_choices < object.question.min_choices) {
this.props.showNotification(`可选的最大限制不能小于最小限制`);
if(object.question.max_choices){
if(object.question.max_choices>0){
if (object.question.max_choices < object.question.min_choices) {
this.props.showNotification(`可选的最大限制不能小于最小限制`);
return;
return;
}
}
}
var questiontwo = {};
var other = [];
var option = [];
@ -1035,7 +1040,7 @@ class PollNew extends Component {
if (this.state.problemtopicbool === true) {
insindex = this.state.problemtopic;
}
this.createquestionsandanswers(object, 2, arrc, null, object.question.max_choices, object.question.min_choices, insindex);
this.createquestionsandanswers(object, 2, arrc, null, object.question.max_choices, object.question.min_choices, insindex,object.question.answers.length);
//插入多选题
// if (object.question.max_choices > arrc.length) {
// // console.log("选择题的最大可选项不能大于选项数")
@ -1105,7 +1110,7 @@ class PollNew extends Component {
if (this.state.problemtopicbool === true) {
insindex = this.state.problemtopic;
}
this.createquestionsandanswers(object, 3, null, null, 0, 0, insindex);
this.createquestionsandanswers(object, 3, null, null, 0, 0, insindex,0);
// newarrpoll.push(question);
newarrpoll.splice(thiss.state.Insertposition, 0, question);
}
@ -1168,23 +1173,31 @@ class PollNew extends Component {
question = {"question": questiontwo};
if (uuk !== -1) {
// console.log("修改")
this.edittotheserver(object, 1, arrc, null, 0, 0);
this.edittotheserver(object, 1, arrc, null, 0, 0,0);
newarrpoll.splice(uuk, 1, question);
} else {
// console.log("他原来的删除掉了")
this.createquestionsandanswers(object, 1, arrc, null, 0, 0, object.question.id);
this.createquestionsandanswers(object, 1, arrc, null, 0, 0, object.question.id,0);
newarrpoll.push(question);
}
newarr[indexo].question.new = "new"
// console.log(newarrpoll)
} else if (object.question.question_type === 2) {
//插入多选题
if(object.question.max_choices){
if(object.question.max_choices>0){
if (object.question.max_choices < object.question.min_choices) {
this.props.showNotification(`可选的最大限制不能小于最小限制`);
if (object.question.max_choices < object.question.min_choices) {
this.props.showNotification('可选的最大限制不能小于最小限制!');
return;
return;
}
}
}
// if (object.question.max_choices < object.question.min_choices) {
// this.props.showNotification('可选的最大限制不能小于最小限制!');
//
// return;
// }
var questiontwo = {};
var other = [];
var option = [];
@ -1239,11 +1252,11 @@ class PollNew extends Component {
// }
if (uuk !== -1) {
// console.log("修改")
this.edittotheserver(object, 2, arrc, null, object.question.max_choices, object.question.min_choices);
this.edittotheserver(object, 2, arrc, null, object.question.max_choices, object.question.min_choices,object.question.answers.length);
newarrpoll.splice(uuk, 1, question);
} else {
// console.log("删除")
this.createquestionsandanswers(object, 2, arrc, null, object.question.max_choices, object.question.min_choices, object.question.id);
this.createquestionsandanswers(object, 2, arrc, null, object.question.max_choices, object.question.min_choices, object.question.id,object.question.answers.length);
newarrpoll.push(question);
}
// console.log(newarrpoll)
@ -1285,11 +1298,11 @@ class PollNew extends Component {
if (uuk !== -1) {
// console.log("修改")
this.edittotheserver(object, 3, null, null, 0, 0);
this.edittotheserver(object, 3, null, null, 0, 0,0);
newarrpoll.splice(uuk, 1, question);
} else {
// console.log("删除")
this.createquestionsandanswers(object, 3, null, null, 0, 0, object.question.id);
this.createquestionsandanswers(object, 3, null, null, 0, 0, object.question.id,0);
newarrpoll.push(question);
}
// console.log(newarrpoll)
@ -1457,15 +1470,24 @@ class PollNew extends Component {
if (this.state.problemtopicbool === true) {
insindex = this.state.problemtopic;
}
this.createquestionsandanswers(object, 1, arrc, null, 0, 0, insindex);
this.createquestionsandanswers(object, 1, arrc, null, 0, 0, insindex,0);
newarrpoll.splice(thiss.state.Insertposition, 0, question);
} else if (object.question.question_type === 2) {
//插入多选题
if (object.question.max_choices < object.question.min_choices) {
this.props.showNotification(`可选的最大限制不能小于最小限制`);
if(object.question.max_choices){
if(object.question.max_choices>0){
if (object.question.max_choices < object.question.min_choices) {
this.props.showNotification(`可选的最大限制不能小于最小限制`);
return;
return;
}
}
}
// if (object.question.max_choices < object.question.min_choices) {
// this.props.showNotification(`可选的最大限制不能小于最小限制`);
//
// return;
// }
var questiontwo = {};
var other = [];
@ -1511,7 +1533,7 @@ class PollNew extends Component {
if (this.state.problemtopicbool === true) {
insindex = this.state.problemtopic;
}
this.createquestionsandanswers(object, 2, arrc, null, object.question.max_choices, object.question.min_choices, insindex);
this.createquestionsandanswers(object, 2, arrc, null, object.question.max_choices, object.question.min_choices, insindex,object.question.answers.length);
//插入多选题
// if (object.question.max_choices > arrc.length) {
@ -1559,7 +1581,7 @@ class PollNew extends Component {
if (this.state.problemtopicbool === true) {
insindex = this.state.problemtopic;
}
this.createquestionsandanswers(object, 3, null, null, 0, 0, insindex);
this.createquestionsandanswers(object, 3, null, null, 0, 0, insindex,0);
// newarrpoll.push(question);
newarrpoll.splice(thiss.state.Insertposition, 0, question);
}
@ -1620,21 +1642,30 @@ class PollNew extends Component {
question = {"question": questiontwo};
if (uuk !== -1) {
// console.log("修改")
this.edittotheserver(object, 1, arrc, null, 0, 0);
this.edittotheserver(object, 1, arrc, null, 0, 0,0);
newarrpoll.splice(uuk, 1, question);
} else {
// console.log("删除")
this.createquestionsandanswers(object, 1, arrc, null, 0, 0, object.question.id);
this.createquestionsandanswers(object, 1, arrc, null, 0, 0, object.question.id,0);
newarrpoll.push(question);
}
// console.log(newarrpoll)
} else if (object.question.question_type === 2) {
//插入多选题
if (object.question.max_choices < object.question.min_choices) {
this.props.showNotification(`可选的最大限制不能小于最小限制`);
if(object.question.max_choices){
if(object.question.max_choices>0){
if (object.question.max_choices < object.question.min_choices) {
this.props.showNotification(`可选的最大限制不能小于最小限制`);
return;
return;
}
}
}
// if (object.question.max_choices < object.question.min_choices) {
// this.props.showNotification(`可选的最大限制不能小于最小限制`);
//
// return;
// }
var questiontwo = {};
var other = [];
var option = [];
@ -1676,11 +1707,11 @@ class PollNew extends Component {
//插入多选题
if (uuk !== -1) {
// console.log("修改")
this.edittotheserver(object, 2, arrc, null, object.question.max_choices, object.question.min_choices);
this.edittotheserver(object, 2, arrc, null, object.question.max_choices, object.question.min_choices,object.question.answers.length);
newarrpoll.splice(uuk, 1, question);
} else {
// console.log("删除")
this.createquestionsandanswers(object, 2, arrc, null, object.question.max_choices, object.question.min_choices, object.question.id);
this.createquestionsandanswers(object, 2, arrc, null, object.question.max_choices, object.question.min_choices, object.question.id,object.question.answers.length);
newarrpoll.push(question);
}
// console.log(newarrpoll)
@ -1721,11 +1752,11 @@ class PollNew extends Component {
question = {"question": questiontwo};
if (uuk !== -1) {
// console.log("修改")
this.edittotheserver(object, 3, null, null, 0, 0);
this.edittotheserver(object, 3, null, null, 0, 0,0);
newarrpoll.splice(uuk, 1, question);
} else {
// console.log("删除")
this.createquestionsandanswers(object, 3, null, null, 0, 0, object.question.id);
this.createquestionsandanswers(object, 3, null, null, 0, 0, object.question.id,0);
newarrpoll.push(question);
}
// console.log(newarrpoll)
@ -1761,7 +1792,8 @@ class PollNew extends Component {
////新增到服务器中
createquestionsandanswers = (object, number, option, other, max_choices, min_choices, insert_id) => {
createquestionsandanswers = (object, number, option, other, max_choices, min_choices, insert_id,length) => {
var thiss = this;
var poll_id = this.state.pollid;
var urlly = `/polls/${poll_id}/poll_questions.json`
@ -1774,12 +1806,16 @@ class PollNew extends Component {
max_choicess = max_choices;
min_choicess = min_choices;
}
console.log("createquestionsandanswers");
console.log(max_choicess);
console.log(min_choicess);
console.log(length);
axios.post(urlly, {
question_title: object.question.question_title,
question_type: number,
is_necessary: object.question.is_necessary,
max_choices: max_choicess===undefined?null:max_choicess===null?null:max_choicess===0?null:max_choicess,
min_choices: min_choicess===undefined?null:min_choicess===null?null:min_choicess===0?null:min_choicess,
max_choices: max_choicess===undefined?length:max_choicess===null?length:max_choicess===0?length:max_choicess,
min_choices: min_choicess===undefined?2:min_choicess===null?2:min_choicess===0?2:min_choicess,
question_answers: option,
question_other_answer: null,
insert_id: insert_id
@ -1810,17 +1846,30 @@ class PollNew extends Component {
}
///编辑修改到服务器当中
edittotheserver = (object, number, option, other, max_choices, min_choices) => {
edittotheserver = (object, number, option, other, max_choices, min_choices,length) => {
// console.log("调用了edittotheserver")
var url = `/poll_questions/${object.question.id}.json`
var thiss = this;
var max_choicess = null;
var min_choicess = null;
if (max_choices === 0 && min_choices === 0) {
max_choicess = null;
min_choicess = null;
} else {
max_choicess = max_choices;
min_choicess = min_choices;
}
console.log("createquestionsandanswers");
console.log(max_choicess);
console.log(min_choicess);
console.log(length);
axios.put(url, {
// debug: true,
question_title: object.question.question_title,
question_type: number,
is_necessary: object.question.is_necessary,
max_choices: max_choices,
min_choices: min_choices,
max_choices: max_choicess===undefined?length:max_choicess===null?length:max_choicess===0?length:max_choicess,
min_choices: min_choicess===undefined?2:min_choicess===null?2:min_choicess===0?2:min_choicess,
question_answers: option,
question_other_answer: null,
}).then((result) => {
@ -2132,11 +2181,11 @@ class PollNew extends Component {
//最小值
HandleGradationGroupChangee = (value, index, max, length) => {
console.log("最小值");
console.log(value);
console.log(index);
console.log(max);
console.log(length);
// console.log("最小值");
// console.log(value);
// console.log(index);
// console.log(max);
// console.log(length);
// debugger
var minbool = false;
@ -2178,11 +2227,11 @@ class PollNew extends Component {
// console.log("2112");
// console.log(value);
// console.log(minchoices);
console.log("最大值");
console.log(value);
console.log(index);
console.log(minchoices);
console.log(length);
// console.log("最大值");
// console.log(value);
// console.log(index);
// console.log(minchoices);
// console.log(length);
let arr = this.state.adddom;
for (var i = 0; i < arr.length; i++) {
if (index === i) {

Loading…
Cancel
Save