dev_forum
杨树林 5 years ago
parent 2d89702df2
commit 7ee531ac47

@ -94,7 +94,7 @@ class PollNew extends Component {
// 初始化数据 // 初始化数据
componentDidMount = () => { componentDidMount = () => {
console.log("componentDidMount 50") // console.log("componentDidMount 50")
if (this.props.match.params.news !== undefined) { if (this.props.match.params.news !== undefined) {
if (this.props.match.params.news === "new") { if (this.props.match.params.news === "new") {
this.state.Newedit === true; this.state.Newedit === true;
@ -137,12 +137,12 @@ class PollNew extends Component {
// } // }
//初始化请求网络 //初始化请求网络
Initializatio_data = () => { Initializatio_data = () => {
console.log("Initializatio_data 582") // console.log("Initializatio_data 582")
//课堂id //课堂id
let coursesId = this.props.match.params.coursesId; let coursesId = this.props.match.params.coursesId;
//时间id //时间id
let pollid = this.props.match.params.pollid; let pollid = this.props.match.params.pollid;
console.log(pollid); // console.log(pollid);
// let coursesId = 557; // let coursesId = 557;
if (pollid === undefined) { if (pollid === undefined) {
// console.log("没有问卷新建问卷~~~") // console.log("没有问卷新建问卷~~~")
@ -223,8 +223,8 @@ class PollNew extends Component {
polls_descriptiontest: result.data.poll.polls_description, polls_descriptiontest: result.data.poll.polls_description,
questionnair: true, questionnair: true,
}) })
console.log(this.state.polls_nametest) // console.log(this.state.polls_nametest)
console.log(this.state.polls_descriptiontest) // console.log(this.state.polls_descriptiontest)
// } // }
}).catch((error) => { }).catch((error) => {
console.log(error) console.log(error)
@ -321,7 +321,7 @@ class PollNew extends Component {
//添加多选题目 //添加多选题目
addmydoubles = () => { addmydoubles = () => {
console.log("addmymainsint 70") // console.log("addmymainsint 70")
if (this.state.newoption === true) { if (this.state.newoption === true) {
this.setState({ this.setState({
newoption: false newoption: false
@ -361,7 +361,7 @@ class PollNew extends Component {
//编辑方法 //编辑方法
adddomedit = (object) => { adddomedit = (object) => {
console.log("adddomedit 76"); // console.log("adddomedit 76");
if (this.state.q_countst > 0) { if (this.state.q_countst > 0) {
this.props.showNotification(`不能同时编辑两题`); this.props.showNotification(`不能同时编辑两题`);
@ -512,11 +512,12 @@ class PollNew extends Component {
//新增添加题目 有new //新增添加题目 有new
addMytopic = (index, pollid, Insertposition, Whether, id) => { addMytopic = (index, pollid, Insertposition, Whether, id) => {
//Whether 是否插入 //Whether 是否插入
// console.log("id") // console.log("addMytopic 90")
// console.log(id) // console.log(index)
// console.log("Whether") // console.log(pollid)
// console.log(Insertposition)
// console.log(Whether) // console.log(Whether)
console.log("addMytopic 90") // console.log(id)
if (this.state.q_countst > 0) { if (this.state.q_countst > 0) {
this.props.showNotification(`不能同时编辑两题`); this.props.showNotification(`不能同时编辑两题`);
@ -718,7 +719,7 @@ class PollNew extends Component {
//删除指定条目 //删除指定条目
deleteadddom = (indexo) => { deleteadddom = (indexo) => {
console.log("deleteadddom 259") // console.log("deleteadddom 259")
var arr = this.state.adddom; var arr = this.state.adddom;
let newarr = [...arr]; let newarr = [...arr];
@ -758,7 +759,7 @@ class PollNew extends Component {
} }
} }
} catch (e) { } catch (e) {
console.log("PollNew281") // console.log("PollNew281")
console.log(e) console.log(e)
} }
} }
@ -1004,7 +1005,7 @@ class PollNew extends Component {
//////////////////////////////////////////////////////////////////////////////////////////////////// 上面是新增 //////////////////////////////////////////////////////////////////////////////////////////////////// 上面是新增
} else { } else {
///////////////////////////////////////////////////////////////////////////////////////////////////修改点了编辑 ///////////////////////////////////////////////////////////////////////////////////////////////////修改点了编辑
console.log("点了编辑") // console.log("点了编辑")
var uuk = -1 var uuk = -1
//这个地方判断 点了编辑上面题目又把他删除了 保存的时候就只能是插入新增了 //这个地方判断 点了编辑上面题目又把他删除了 保存的时候就只能是插入新增了
for (var uk = 0; uk < newarrpoll.length; uk++) { for (var uk = 0; uk < newarrpoll.length; uk++) {
@ -1130,15 +1131,15 @@ class PollNew extends Component {
// //
// } // }
if (uuk !== -1) { if (uuk !== -1) {
console.log("修改") // 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);
newarrpoll.splice(uuk, 1, question); newarrpoll.splice(uuk, 1, question);
} else { } else {
console.log("删除") // 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);
newarrpoll.push(question); newarrpoll.push(question);
} }
console.log(newarrpoll) // console.log(newarrpoll)
newarr[indexo].question.new = "new" newarr[indexo].question.new = "new"
} else if (object.question.question_type === 3) { } else if (object.question.question_type === 3) {
//插入主观题 //插入主观题
@ -1176,15 +1177,15 @@ class PollNew extends Component {
question = {"question": questiontwo}; question = {"question": questiontwo};
if (uuk !== -1) { if (uuk !== -1) {
console.log("修改") // console.log("修改")
this.edittotheserver(object, 3, null, null, 0, 0); this.edittotheserver(object, 3, null, null, 0, 0);
newarrpoll.splice(uuk, 1, question); newarrpoll.splice(uuk, 1, question);
} else { } else {
console.log("删除") // console.log("删除")
this.createquestionsandanswers(object, 3, null, null, 0, 0, object.question.id); this.createquestionsandanswers(object, 3, null, null, 0, 0, object.question.id);
newarrpoll.push(question); newarrpoll.push(question);
} }
console.log(newarrpoll) // console.log(newarrpoll)
newarr[indexo].question.new = "new" newarr[indexo].question.new = "new"
} }
@ -1453,7 +1454,7 @@ class PollNew extends Component {
for (var uk = 0; uk < newarrpoll.length; uk++) { for (var uk = 0; uk < newarrpoll.length; uk++) {
if (object.question.id === newarrpoll[uk].question.id) { if (object.question.id === newarrpoll[uk].question.id) {
uuk = uk; uuk = uk;
console.log("删除了数据=-09876543234567890-111111111111") // console.log("删除了数据=-09876543234567890-111111111111")
} }
} }
@ -1501,15 +1502,15 @@ class PollNew extends Component {
}; };
question = {"question": questiontwo}; question = {"question": questiontwo};
if (uuk !== -1) { if (uuk !== -1) {
console.log("修改") // console.log("修改")
this.edittotheserver(object, 1, arrc, null, 0, 0); this.edittotheserver(object, 1, arrc, null, 0, 0);
newarrpoll.splice(uuk, 1, question); newarrpoll.splice(uuk, 1, question);
} else { } else {
console.log("删除") // console.log("删除")
this.createquestionsandanswers(object, 1, arrc, null, 0, 0, object.question.id); this.createquestionsandanswers(object, 1, arrc, null, 0, 0, object.question.id);
newarrpoll.push(question); newarrpoll.push(question);
} }
console.log(newarrpoll) // console.log(newarrpoll)
} else if (object.question.question_type === 2) { } else if (object.question.question_type === 2) {
//插入多选题 //插入多选题
if (object.question.max_choices < object.question.min_choices) { if (object.question.max_choices < object.question.min_choices) {
@ -1557,15 +1558,15 @@ class PollNew extends Component {
question = {"question": questiontwo}; question = {"question": questiontwo};
//插入多选题 //插入多选题
if (uuk !== -1) { if (uuk !== -1) {
console.log("修改") // 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);
newarrpoll.splice(uuk, 1, question); newarrpoll.splice(uuk, 1, question);
} else { } else {
console.log("删除") // 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);
newarrpoll.push(question); newarrpoll.push(question);
} }
console.log(newarrpoll) // console.log(newarrpoll)
} else if (object.question.question_type === 3) { } else if (object.question.question_type === 3) {
//插入主观题 //插入主观题
@ -1602,15 +1603,15 @@ class PollNew extends Component {
}; };
question = {"question": questiontwo}; question = {"question": questiontwo};
if (uuk !== -1) { if (uuk !== -1) {
console.log("修改") // console.log("修改")
this.edittotheserver(object, 3, null, null, 0, 0); this.edittotheserver(object, 3, null, null, 0, 0);
newarrpoll.splice(uuk, 1, question); newarrpoll.splice(uuk, 1, question);
} else { } else {
console.log("删除") // console.log("删除")
this.createquestionsandanswers(object, 3, null, null, 0, 0, object.question.id); this.createquestionsandanswers(object, 3, null, null, 0, 0, object.question.id);
newarrpoll.push(question); newarrpoll.push(question);
} }
console.log(newarrpoll) // console.log(newarrpoll)
} }
@ -1693,7 +1694,7 @@ class PollNew extends Component {
} }
///编辑修改到服务器当中 ///编辑修改到服务器当中
edittotheserver = (object, number, option, other, max_choices, min_choices) => { edittotheserver = (object, number, option, other, max_choices, min_choices) => {
console.log("调用了edittotheserver") // console.log("调用了edittotheserver")
var url = `/poll_questions/${object.question.id}.json` var url = `/poll_questions/${object.question.id}.json`
var thiss = this; var thiss = this;
axios.put(url, { axios.put(url, {
@ -1720,7 +1721,7 @@ class PollNew extends Component {
//删除到服务器当中 //删除到服务器当中
eletetoserver = (pollid, newarr, type, index) => { eletetoserver = (pollid, newarr, type, index) => {
console.log("调用了eletetoserver") // console.log("调用了eletetoserver")
var id = pollid; var id = pollid;
var url = `/poll_questions/${id}.json` var url = `/poll_questions/${id}.json`
let {mysingles, mydoubles, mymainsint} = this.state let {mysingles, mydoubles, mymainsint} = this.state
@ -1729,7 +1730,7 @@ class PollNew extends Component {
axios axios
.delete(url, {}) .delete(url, {})
.then(function (response) { .then(function (response) {
console.log(response) // console.log(response)
if (response === undefined) { if (response === undefined) {
return; return;
} }
@ -1774,7 +1775,7 @@ class PollNew extends Component {
} }
// console.log(JSON.stringify(result)) // console.log(JSON.stringify(result))
} catch (e) { } catch (e) {
console.log("上移题目成功 错误") // console.log("上移题目成功 错误")
console.log(e) console.log(e)
} }
@ -1792,7 +1793,7 @@ class PollNew extends Component {
} }
// console.log(JSON.stringify(result)) // console.log(JSON.stringify(result))
} catch (e) { } catch (e) {
console.log("下移题目成功 错误") // console.log("下移题目成功 错误")
console.log(e) console.log(e)
} }
}) })
@ -1804,8 +1805,8 @@ class PollNew extends Component {
//id 条目的唯一id //id 条目的唯一id
//i 为要删除的子条目 //i 为要删除的子条目
deleteentrys = (id, i, stirngname) => { deleteentrys = (id, i, stirngname) => {
console.log(id) // console.log(id)
console.log(stirngname); // console.log(stirngname);
var arrtwoy = this.state.adddom; var arrtwoy = this.state.adddom;
let newarrtwoy = [...arrtwoy]; let newarrtwoy = [...arrtwoy];
for (var k = 0; k < newarrtwoy.length; k++) { for (var k = 0; k < newarrtwoy.length; k++) {
@ -1822,14 +1823,14 @@ class PollNew extends Component {
} }
} }
if (stirngname === true) { if (stirngname === true) {
console.log(stirngname); // console.log(stirngname);
this.setState({ this.setState({
newoption: false, newoption: false,
adddom: newarrtwoy, adddom: newarrtwoy,
}) })
} else { } else {
console.log(stirngname); // console.log(stirngname);
this.setState({ this.setState({
adddom: newarrtwoy, adddom: newarrtwoy,
}); });
@ -1841,8 +1842,8 @@ class PollNew extends Component {
// 新增选项 // 新增选项
ewoption = (id, object) => { ewoption = (id, object) => {
console.log("ewoption 440") // console.log("ewoption 440")
console.log("是否是新建题目还是编辑") // console.log("是否是新建题目还是编辑")
// console.log(object.question.new) // console.log(object.question.new)
@ -1903,10 +1904,10 @@ class PollNew extends Component {
//新增其他选项 //新增其他选项
addanotheroption = (id) => { addanotheroption = (id) => {
console.log("addanotheroption 457") // console.log("addanotheroption 457")
let arrtwo = this.state.adddom; let arrtwo = this.state.adddom;
let newarrtwo = [...arrtwo]; let newarrtwo = [...arrtwo];
console.log(newarrtwo) // console.log(newarrtwo)
for (var k = 0; k < newarrtwo.length; k++) { for (var k = 0; k < newarrtwo.length; k++) {
if (newarrtwo[k] != undefined) { if (newarrtwo[k] != undefined) {
if (newarrtwo[k].question.id === id) { if (newarrtwo[k].question.id === id) {
@ -1928,10 +1929,10 @@ class PollNew extends Component {
//点击向上排序按钮事件 //点击向上排序按钮事件
handleClickBySortUp = (index, object) => { handleClickBySortUp = (index, object) => {
console.log("handleClickBySortUp 521") // console.log("handleClickBySortUp 521")
let arr = this.state.poll_questions; let arr = this.state.poll_questions;
let newarr = [...arr]; let newarr = [...arr];
console.log(newarr) // console.log(newarr)
if (index != 0) { if (index != 0) {
this.Upanddownmovementof(true, object.question.id); this.Upanddownmovementof(true, object.question.id);
let temp = newarr[index - 1]; let temp = newarr[index - 1];
@ -1945,7 +1946,7 @@ class PollNew extends Component {
//点击向下排序按钮事件 //点击向下排序按钮事件
handleClickBySortDown = (index, object) => { handleClickBySortDown = (index, object) => {
console.log("handleClickBySortDown 536") // console.log("handleClickBySortDown 536")
let arr = this.state.poll_questions; let arr = this.state.poll_questions;
let newarr = [...arr]; let newarr = [...arr];
// //
@ -1958,16 +1959,16 @@ class PollNew extends Component {
poll_questions: newarr, poll_questions: newarr,
}); });
} else { } else {
console.log("2222index==arr.length"); // console.log("2222index==arr.length");
console.log(this.state.poll_questions); // console.log(this.state.poll_questions);
} }
} }
//点击删除按钮事件 //点击删除按钮事件
handleClickByDelete = (type, index, object) => { handleClickByDelete = (type, index, object) => {
console.log("handleClickByDelete 556") // console.log("handleClickByDelete 556")
console.log("object.question.id") // console.log("object.question.id")
console.log(object.question.id) // console.log(object.question.id)
let arr = this.state.poll_questions; let arr = this.state.poll_questions;
let newarr = [...arr]; let newarr = [...arr];
this.eletetoserver(object.question.id, newarr, type, index) this.eletetoserver(object.question.id, newarr, type, index)
@ -1979,11 +1980,11 @@ class PollNew extends Component {
//i外层数组 //i外层数组
//k为内层数组 //k为内层数组
handleInputChanges = (e, i, k) => { handleInputChanges = (e, i, k) => {
console.log("handleInputChanges 612") // console.log("handleInputChanges 612")
let value = e.target.value;//取到input的数据 let value = e.target.value;//取到input的数据
console.log("handleInputChanges value is :" + value); // console.log("handleInputChanges value is :" + value);
console.log(k); // console.log(k);
let arr = this.state.adddom; let arr = this.state.adddom;
let newarr = [...arr]; let newarr = [...arr];
@ -1996,11 +1997,11 @@ class PollNew extends Component {
//标题输入监听 //标题输入监听
handleInputTopic = (e, i) => { handleInputTopic = (e, i) => {
console.log("handleInputTopic 633") // console.log("handleInputTopic 633")
let value = e.target.value;//取到input的数据 let value = e.target.value;//取到input的数据
console.log("handleInputTopic value is :" + value); // console.log("handleInputTopic value is :" + value);
console.log(i); // console.log(i);
let arr = this.state.adddom; let arr = this.state.adddom;
let newarr = [...arr]; let newarr = [...arr];
newarr[i].question.question_title = value newarr[i].question.question_title = value
@ -2063,7 +2064,7 @@ class PollNew extends Component {
//提交题目//没有就创建新的题库新建问newz题和保存题目不一样不能同时保存 这里只是新建 和编辑 标题和须知 //提交题目//没有就创建新的题库新建问newz题和保存题目不一样不能同时保存 这里只是新建 和编辑 标题和须知
submitQuestionnaire = (mews) => { submitQuestionnaire = (mews) => {
console.log("调用了submitQuestionnaire") // console.log("调用了submitQuestionnaire")
if (this.state.Newedit === true) { if (this.state.Newedit === true) {
this.newword(); this.newword();
@ -2120,7 +2121,7 @@ class PollNew extends Component {
} }
savedelete = (question_type, index, item) => { savedelete = (question_type, index, item) => {
console.log("savedelete"); // console.log("savedelete");
this.handleClickByDelete(question_type, index, item); this.handleClickByDelete(question_type, index, item);
this.setState({ this.setState({
Modalstype: false, Modalstype: false,
@ -2141,8 +2142,8 @@ class PollNew extends Component {
} }
//必答选项 //必答选项
onCheckAllChange = (e, index) => { onCheckAllChange = (e, index) => {
console.log("onCheckAllChange"); // console.log("onCheckAllChange");
console.log(e.target.checked); // console.log(e.target.checked);
// console.log(e.target.value); // console.log(e.target.value);
let arr = this.state.adddom; let arr = this.state.adddom;
for (var i = 0; i < arr.length; i++) { for (var i = 0; i < arr.length; i++) {
@ -2536,7 +2537,7 @@ class PollNew extends Component {
{this.state.adddom === undefined ? "" : this.state.adddom.map((itemo, indexo) => { {this.state.adddom === undefined ? "" : this.state.adddom.map((itemo, indexo) => {
// console.log('打印this.state.adddom') // console.log('打印this.state.adddom')
// console.log(itemo.question) // console.log(this.state.adddom);
let arrid = itemo.question.id; let arrid = itemo.question.id;
let resultDomtwo; let resultDomtwo;
resultDomtwo = resultDomtwo =
@ -2769,7 +2770,7 @@ class PollNew extends Component {
this.props.match.params.news === "new" ? this.props.match.params.news === "new" ?
this.state.Newedit === false ? this.state.Newedit === false ?
<div> <div>
<div className=" mb10" style={{"border-bottom": "1px solid #eee"}}></div> <div className=" mb10" style={this.state.adddom === undefined?{"border-bottom": "0.5px solid #ffffff"}:this.state.adddom.length <1? {"border-bottom": "0.5px solid #ffffff"}:{"border-bottom": "0.5px solid #eee"}}></div>
<div style={{"padding": "10px 30px 20px 30px"}}> <div style={{"padding": "10px 30px 20px 30px"}}>
<ActionBtn style="green" className="mr20" onClick={() => this.addmysingles()}><i <ActionBtn style="green" className="mr20" onClick={() => this.addmysingles()}><i
@ -2784,7 +2785,7 @@ class PollNew extends Component {
: "" : ""
: :
<div> <div>
<div className=" mb10" style={{"border-bottom": "1px solid #eee"}}></div> <div className=" mb10" style={this.state.adddom === undefined? {"border-bottom": "0.5px solid #ffffff"}:this.state.adddom.length <1? {"border-bottom": "0.5px solid #ffffff"}:{"border-bottom": "0.5px solid #eee"}}></div>
<div style={{"padding": "10px 30px 20px 30px"}}> <div style={{"padding": "10px 30px 20px 30px"}}>
<ActionBtn style="green" className="mr20" onClick={() => this.addmysingles()}><i <ActionBtn style="green" className="mr20" onClick={() => this.addmysingles()}><i
className="iconfont icon-tianjiafangda font-15 mr10"></i></ActionBtn> className="iconfont icon-tianjiafangda font-15 mr10"></i></ActionBtn>

Loading…
Cancel
Save