|
@@ -94,7 +94,33 @@ export default {
|
|
|
}, 500);
|
|
|
this.$refs.ElementPropEditComp.submit();
|
|
|
},
|
|
|
- checkTopic(element) {
|
|
|
+ equalTopicType(topic1, topic2) {
|
|
|
+ if (topic1.type === topic2.type) {
|
|
|
+ if (topic1.type !== "FILL_QUESTION") {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ return (
|
|
|
+ topic1.isBoolean === topic2.isBoolean &&
|
|
|
+ topic1.isMultiply === topic2.isMultiply
|
|
|
+ );
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ },
|
|
|
+ checkTopicType(element) {
|
|
|
+ const relateTopics = this.topics.filter(
|
|
|
+ (item) =>
|
|
|
+ item.topicNo === element.topicNo &&
|
|
|
+ ((element.type !== "COMPOSITION" &&
|
|
|
+ item.parent &&
|
|
|
+ item.parent.id !== element.id) ||
|
|
|
+ (element.type === "COMPOSITION" && item.id !== element.id))
|
|
|
+ );
|
|
|
+ if (!relateTopics.length) return true;
|
|
|
+
|
|
|
+ return !relateTopics.some((topic) => this.equalTopicType(element, topic));
|
|
|
+ },
|
|
|
+ checkTopicNo(element) {
|
|
|
if (element.type === "COMPOSITION") return true;
|
|
|
|
|
|
const relateTopics = this.topics.filter(
|
|
@@ -126,10 +152,16 @@ export default {
|
|
|
return !unvalid;
|
|
|
},
|
|
|
modified(element) {
|
|
|
- // 在不校验大题号重复的情况下,需要校验小题号重复
|
|
|
- if (!element["container"] && !this.checkTopic(element)) {
|
|
|
- this.$message.error("小题号重复,请重新设置小题号");
|
|
|
- return;
|
|
|
+ if (!element["container"]) {
|
|
|
+ if (!this.checkTopicType(element)) {
|
|
|
+ this.$message.error("同一大题号的所有试题题型必须相同");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 在不校验大题号重复的情况下,需要校验小题号重复
|
|
|
+ if (!this.checkTopicNo(element)) {
|
|
|
+ this.$message.error("小题号重复,请重新设置小题号");
|
|
|
+ return;
|
|
|
+ }
|
|
|
}
|
|
|
// 编辑试题
|
|
|
// 属性存在的条件:parent:大题的小题,container:题目内的子元素
|