|
@@ -125,6 +125,7 @@ export default {
|
|
modalIsShow: false,
|
|
modalIsShow: false,
|
|
sourceDetailAllList: [],
|
|
sourceDetailAllList: [],
|
|
sourceDetailList: [],
|
|
sourceDetailList: [],
|
|
|
|
+ curSourceDetail: {},
|
|
limitShowCount: 10,
|
|
limitShowCount: 10,
|
|
showMore: false,
|
|
showMore: false,
|
|
questionModel: {
|
|
questionModel: {
|
|
@@ -157,8 +158,15 @@ export default {
|
|
this.loading = false;
|
|
this.loading = false;
|
|
this.hasModifyQuestion = false;
|
|
this.hasModifyQuestion = false;
|
|
|
|
|
|
|
|
+ let questionModel = Object.assign({}, initQuestionModel, this.question);
|
|
|
|
+
|
|
if (this.isEdit) {
|
|
if (this.isEdit) {
|
|
this.sourceDetailList = this.sourceDetailAllList;
|
|
this.sourceDetailList = this.sourceDetailAllList;
|
|
|
|
+
|
|
|
|
+ this.curSourceDetail = {
|
|
|
|
+ id: this.question.sourceDetailId,
|
|
|
|
+ questionType: this.question.questionType,
|
|
|
|
+ };
|
|
} else {
|
|
} else {
|
|
if (this.sourceDetailAllList.length > this.limitShowCount) {
|
|
if (this.sourceDetailAllList.length > this.limitShowCount) {
|
|
this.sourceDetailList = this.sourceDetailAllList.slice(
|
|
this.sourceDetailList = this.sourceDetailAllList.slice(
|
|
@@ -168,15 +176,14 @@ export default {
|
|
} else {
|
|
} else {
|
|
this.sourceDetailList = this.sourceDetailAllList;
|
|
this.sourceDetailList = this.sourceDetailAllList;
|
|
}
|
|
}
|
|
|
|
+ if (!this.question.sourceDetailId && !this.curSourceDetail.id) {
|
|
|
|
+ this.curSourceDetail = this.sourceDetailList[0];
|
|
|
|
+ }
|
|
|
|
+ questionModel.questionType = this.curSourceDetail.questionType;
|
|
|
|
+ questionModel.sourceDetailId = this.curSourceDetail.id;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ this.questionModel = questionModel;
|
|
this.questionKey = randomCode();
|
|
this.questionKey = randomCode();
|
|
- this.questionModel = Object.assign({}, initQuestionModel, this.question);
|
|
|
|
- if (!this.question.questionType) {
|
|
|
|
- const curSourceDetail = this.sourceDetailList[0];
|
|
|
|
- this.questionModel.questionType = curSourceDetail.questionType;
|
|
|
|
- this.questionModel.sourceDetailId = curSourceDetail.id;
|
|
|
|
- }
|
|
|
|
},
|
|
},
|
|
close() {
|
|
close() {
|
|
this.modalIsShow = false;
|
|
this.modalIsShow = false;
|
|
@@ -224,20 +231,18 @@ export default {
|
|
};
|
|
};
|
|
this.$refs.ModifySourceDetail.open();
|
|
this.$refs.ModifySourceDetail.open();
|
|
},
|
|
},
|
|
- async sourceDetailAdded() {
|
|
|
|
|
|
+ async sourceDetailAdded(sourceDetail) {
|
|
await this.getSourceDetailList();
|
|
await this.getSourceDetailList();
|
|
- if (this.isEdit) {
|
|
|
|
- this.sourceDetailList = this.sourceDetailAllList;
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
this.showMore = !this.showMore;
|
|
this.showMore = !this.showMore;
|
|
this.switchMoreSourceDetail();
|
|
this.switchMoreSourceDetail();
|
|
|
|
+ this.curSourceDetail = sourceDetail;
|
|
|
|
+ this.initData();
|
|
},
|
|
},
|
|
async switchType(item) {
|
|
async switchType(item) {
|
|
if (this.isEdit) return;
|
|
if (this.isEdit) return;
|
|
if (this.questionModel.sourceDetailId === item.id) return;
|
|
if (this.questionModel.sourceDetailId === item.id) return;
|
|
if (this.questionModel.questionType === item.questionType) {
|
|
if (this.questionModel.questionType === item.questionType) {
|
|
|
|
+ this.curSourceDetail = item;
|
|
this.questionModel.sourceDetailId = item.id;
|
|
this.questionModel.sourceDetailId = item.id;
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -247,6 +252,7 @@ export default {
|
|
}).catch(() => {});
|
|
}).catch(() => {});
|
|
if (confirm !== "confirm") return;
|
|
if (confirm !== "confirm") return;
|
|
|
|
|
|
|
|
+ this.curSourceDetail = item;
|
|
this.questionKey = randomCode();
|
|
this.questionKey = randomCode();
|
|
this.questionModel = Object.assign({}, this.questionModel, {
|
|
this.questionModel = Object.assign({}, this.questionModel, {
|
|
questionType: item.questionType,
|
|
questionType: item.questionType,
|
|
@@ -262,14 +268,15 @@ export default {
|
|
if (this.loading) return;
|
|
if (this.loading) return;
|
|
this.loading = true;
|
|
this.loading = true;
|
|
|
|
|
|
- this.questionModel = this.$refs.QuestionEditDetail.getData();
|
|
|
|
|
|
+ let questionModel = this.$refs.QuestionEditDetail.getData();
|
|
|
|
+ questionModel.sourceDetailId = this.questionModel.sourceDetailId;
|
|
if (this.question.editMode === "paper") {
|
|
if (this.question.editMode === "paper") {
|
|
- this.$emit("modified", this.questionModel);
|
|
|
|
|
|
+ this.$emit("modified", questionModel);
|
|
this.loading = false;
|
|
this.loading = false;
|
|
this.close();
|
|
this.close();
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- const res = await updateQuestionApi(this.questionModel).catch(() => {});
|
|
|
|
|
|
+ const res = await updateQuestionApi(questionModel).catch(() => {});
|
|
this.loading = false;
|
|
this.loading = false;
|
|
if (!res) return;
|
|
if (!res) return;
|
|
|
|
|