|
@@ -118,8 +118,7 @@ export default {
|
|
lastCheckList: [],
|
|
lastCheckList: [],
|
|
|
|
|
|
// 选择题选中开放式选项的开放回答值
|
|
// 选择题选中开放式选项的开放回答值
|
|
- selectedOpenIndex: "",
|
|
|
|
- selectedOpenValue: "",
|
|
|
|
|
|
+ selectedOpenList:[]
|
|
};
|
|
};
|
|
},
|
|
},
|
|
mounted: function() {
|
|
mounted: function() {
|
|
@@ -269,8 +268,7 @@ export default {
|
|
questionOptions() {
|
|
questionOptions() {
|
|
console.log("call questionOptions");
|
|
console.log("call questionOptions");
|
|
let opts = [];
|
|
let opts = [];
|
|
- let openValue = this.selectedOpenValue;
|
|
|
|
- let openIndex = this.selectedOpenIndex;
|
|
|
|
|
|
+ let openList = this.selectedOpenList;
|
|
if (this.upperDatasourceQuestion == 0) {
|
|
if (this.upperDatasourceQuestion == 0) {
|
|
opts = this.currentQuestion.options;
|
|
opts = this.currentQuestion.options;
|
|
} else {
|
|
} else {
|
|
@@ -315,9 +313,11 @@ export default {
|
|
for (var index = 0; index < opts.length; index++) {
|
|
for (var index = 0; index < opts.length; index++) {
|
|
// let label = `${i + 1}、${opts[i].optionContent}`;
|
|
// let label = `${i + 1}、${opts[i].optionContent}`;
|
|
let label = `${opts[index].optionContent}`;
|
|
let label = `${opts[index].optionContent}`;
|
|
- if (openIndex == index && opts[index].open && openValue) {
|
|
|
|
- label = label + "(" + openValue + ")";
|
|
|
|
- }
|
|
|
|
|
|
+ for(var openIndex = 0; openIndex < openList.length; openIndex++){
|
|
|
|
+ if (openList[openIndex]&&openList[openIndex].selectedIndex == index && opts[index].open && openList[openIndex].selectedValue) {
|
|
|
|
+ label = label + "(" + openList[openIndex].selectedValue + ")";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
let value = index.toString();
|
|
let value = index.toString();
|
|
Vue.set(opts[index], "label", label);
|
|
Vue.set(opts[index], "label", label);
|
|
Vue.set(opts[index], "value", value);
|
|
Vue.set(opts[index], "value", value);
|
|
@@ -435,8 +435,22 @@ export default {
|
|
let selectedOpt = null;
|
|
let selectedOpt = null;
|
|
if (_type == "object") {
|
|
if (_type == "object") {
|
|
// 多选
|
|
// 多选
|
|
-
|
|
|
|
let isUnselect = this.lastCheckList.length > index.length;
|
|
let isUnselect = this.lastCheckList.length > index.length;
|
|
|
|
+
|
|
|
|
+ if (isUnselect){
|
|
|
|
+ // 取消选中,先判断取消选中的是哪个index,然后在判断开放选项中是否有取消选择的,将其删除掉
|
|
|
|
+ let unselectItem;
|
|
|
|
+ for(var item in this.lastCheckList){
|
|
|
|
+ if (index.indexOf(this.lastCheckList[item])<0) {
|
|
|
|
+ unselectItem = this.lastCheckList[item]
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ for(var oIndex =0; oIndex<this.selectedOpenList.length; oIndex++){
|
|
|
|
+ if(this.selectedOpenList[oIndex].selectedIndex == unselectItem){
|
|
|
|
+ this.selectedOpenList.splice(oIndex,1);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
if (!isUnselect) {
|
|
if (!isUnselect) {
|
|
let lastIndex = index[index.length - 1];
|
|
let lastIndex = index[index.length - 1];
|
|
selectedOpt = this.questionOptions[lastIndex];
|
|
selectedOpt = this.questionOptions[lastIndex];
|
|
@@ -451,10 +465,10 @@ export default {
|
|
}
|
|
}
|
|
} else if (_type == "string") {
|
|
} else if (_type == "string") {
|
|
selectedOpt = this.questionOptions[index];
|
|
selectedOpt = this.questionOptions[index];
|
|
|
|
+ this.selectedOpenList.splice(0,1);
|
|
}
|
|
}
|
|
|
|
+
|
|
// 处理开放选项
|
|
// 处理开放选项
|
|
- this.selectedOpenIndex = "";
|
|
|
|
- this.selectedOpenValue = "";
|
|
|
|
if (selectedOpt.open) {
|
|
if (selectedOpt.open) {
|
|
this.$prompt(selectedOpt.openOptionTips, "请填写", {
|
|
this.$prompt(selectedOpt.openOptionTips, "请填写", {
|
|
confirmButtonText: "确定",
|
|
confirmButtonText: "确定",
|
|
@@ -462,8 +476,10 @@ export default {
|
|
customClass: "select-open-dialog",
|
|
customClass: "select-open-dialog",
|
|
}).then(({ value }) => {
|
|
}).then(({ value }) => {
|
|
console.log(`Dialog value: ${value}, `);
|
|
console.log(`Dialog value: ${value}, `);
|
|
- this.selectedOpenValue = value;
|
|
|
|
- this.selectedOpenIndex = index;
|
|
|
|
|
|
+ this.$set(this.selectedOpenList, this.selectedOpenList.length ,{
|
|
|
|
+ selectedIndex : selectedOpt.value,
|
|
|
|
+ selectedValue : value
|
|
|
|
+ })
|
|
this.answerNote[selectedOpt.id] = value;
|
|
this.answerNote[selectedOpt.id] = value;
|
|
});
|
|
});
|
|
}
|
|
}
|
|
@@ -547,10 +563,13 @@ export default {
|
|
alert(`最少需选中${this.currentQuestion.minOptions}项`);
|
|
alert(`最少需选中${this.currentQuestion.minOptions}项`);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- if(this.selectedOpenIndex && !this.selectedOpenValue){
|
|
|
|
- alert("请填写开放性选项答案")
|
|
|
|
- return;
|
|
|
|
|
|
+ for(let index in this.selectedOpenList){
|
|
|
|
+ if(this.selectedOpenList[index].selectedIndex && !this.selectedOpenList[index].selectedValue ){
|
|
|
|
+ alert("请填写开放性选项答案")
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ this.selectedOpenList.length = 0;
|
|
|
|
|
|
// 确定答案
|
|
// 确定答案
|
|
// this.answers[questionId] = selectionIds.join(',');
|
|
// this.answers[questionId] = selectionIds.join(',');
|