|
@@ -197,12 +197,14 @@ export default {
|
|
|
if (checked) {
|
|
|
questions.push(item.questionId);
|
|
|
console.log("AAAAAAAAA", questions);
|
|
|
+ this.addQuestion(item, true);
|
|
|
} else {
|
|
|
questions.splice(
|
|
|
questions.findIndex(itemTemp => itemTemp === item.questionId),
|
|
|
1
|
|
|
);
|
|
|
console.log("DDDDDDDDDD", questions);
|
|
|
+ this.deleteQuestion(item);
|
|
|
}
|
|
|
|
|
|
var selecteQuestionList = [];
|
|
@@ -217,6 +219,55 @@ export default {
|
|
|
console.log("RRRRRRRRRR", selecteQuestionList);
|
|
|
this.$store.dispatch("addQuestion", selecteQuestionList);
|
|
|
},
|
|
|
+ addQuestion(item, isFirst) {
|
|
|
+ // 添加题目
|
|
|
+ let param = {};
|
|
|
+ param.top = 170;
|
|
|
+ param.left = 100;
|
|
|
+ param.questionId = item.questionId;
|
|
|
+ param["type"] = "text";
|
|
|
+ param["text"] = item.name;
|
|
|
+ param["width"] = 300;
|
|
|
+ param["lineHeight"] = 1.5;
|
|
|
+ param["backgroundColor"] = "";
|
|
|
+ param["verticalAlign"] = "top";
|
|
|
+ param["display"] = "block";
|
|
|
+ param["textIndent"] = "0.0";
|
|
|
+ param["letterSpacing"] = "0.0";
|
|
|
+ param["allTransparent"] = "";
|
|
|
+ param["nodeId"] = "Id" + Math.random();
|
|
|
+ this.$store.dispatch("addElement", param);
|
|
|
+ // 添加选项
|
|
|
+ var itemTop = 250;
|
|
|
+ for (var i = 0; i < item.optionList.length; i++) {
|
|
|
+ console.log("选项", item.optionList[i].content);
|
|
|
+ let obj = {};
|
|
|
+ obj.questionId = item.questionId;
|
|
|
+ obj.optionId = item.optionList[i].optionId;
|
|
|
+ obj.type = "button";
|
|
|
+ obj.top = itemTop + i * 40 + (i + 1) * 50;
|
|
|
+ obj.left = 100;
|
|
|
+ obj["text"] = item.optionList[i].content;
|
|
|
+ obj["lineHeight"] = 1.5;
|
|
|
+ obj.width = 300;
|
|
|
+ obj.height = 40;
|
|
|
+ obj.backgroundUnselectedImg =
|
|
|
+ "https://dm.static.elab-plus.com/diaoyanbao/option_default.png";
|
|
|
+ obj.backgroundSelectedImg =
|
|
|
+ "https://dm.static.elab-plus.com/diaoyanbao/option_select.png";
|
|
|
+ obj.loop = false;
|
|
|
+ this.$store.dispatch("addElement", obj);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ deleteQuestion(item) {
|
|
|
+ this.$store.dispatch("deleteElementQID", item.questionId);
|
|
|
+ // var elements = this.pages[this.currentPage].elements;
|
|
|
+ // for (var i = 0; i < elements.length; i++) {
|
|
|
+ // if (elements[i].questionId == item.questionId) {
|
|
|
+ // this.$store.dispatch("deleteElement", elements[i]);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ },
|
|
|
isShow: function(index) {
|
|
|
var result = false;
|
|
|
if (index > 0) {
|