|
@@ -77,7 +77,12 @@
|
|
|
label="知识点"
|
|
|
>
|
|
|
<div class="box-flex">
|
|
|
- <property-select
|
|
|
+ <KnowledgePoints
|
|
|
+ :courseId="modalForm.courseId"
|
|
|
+ @change="addProperty"
|
|
|
+ :checkedProperties="modalForm.quesProperties"
|
|
|
+ ></KnowledgePoints>
|
|
|
+ <!-- <property-select
|
|
|
v-model="properties.coursePropertyId"
|
|
|
:course-id="modalForm.courseId"
|
|
|
:use-cache="useCoursePropertyCache"
|
|
@@ -104,7 +109,7 @@
|
|
|
:disabled="!propSelected"
|
|
|
@click="addProperty"
|
|
|
>新增属性</el-button
|
|
|
- >
|
|
|
+ > -->
|
|
|
</div>
|
|
|
</el-form-item>
|
|
|
<el-form-item v-if="modalForm.quesProperties.length" label="属性列表">
|
|
@@ -117,14 +122,10 @@
|
|
|
style="margin-right: 5px; margin-bottom: 5px"
|
|
|
@close="removeProperty(content)"
|
|
|
>
|
|
|
- {{ content.courseProperty && content.courseProperty.name }}
|
|
|
- <span style="margin: 0 3px">/</span>
|
|
|
+ <!-- {{ content.courseProperty && content.courseProperty.name }}
|
|
|
+ <span style="margin: 0 3px">/</span> -->
|
|
|
{{ content.firstProperty && content.firstProperty.name }}
|
|
|
- <span
|
|
|
- v-if="content.secondProperty && content.secondProperty.name"
|
|
|
- style="margin: 0 3px"
|
|
|
- >/</span
|
|
|
- >
|
|
|
+ <span style="margin: 0 3px">/</span>
|
|
|
{{ content.secondProperty && content.secondProperty.name }}
|
|
|
</el-tag>
|
|
|
</el-form-item>
|
|
@@ -134,6 +135,8 @@
|
|
|
|
|
|
<script>
|
|
|
import { DIFFICULTY_LIST } from "@/constants/constants";
|
|
|
+import KnowledgePoints from "./KnowledgePoints.vue";
|
|
|
+import { cloneDeep } from "lodash";
|
|
|
|
|
|
const initModalForm = {
|
|
|
editMode: "question",
|
|
@@ -147,6 +150,7 @@ const initModalForm = {
|
|
|
|
|
|
export default {
|
|
|
name: "QuestionInfoEdit",
|
|
|
+ components: { KnowledgePoints },
|
|
|
props: {
|
|
|
question: {
|
|
|
type: Object,
|
|
@@ -167,12 +171,12 @@ export default {
|
|
|
...initModalForm,
|
|
|
},
|
|
|
properties: {
|
|
|
- coursePropertyId: "",
|
|
|
+ // coursePropertyId: "",
|
|
|
firstPropertyId: "",
|
|
|
secondPropertyId: "",
|
|
|
},
|
|
|
selection: {
|
|
|
- courseProperty: {},
|
|
|
+ // courseProperty: {},
|
|
|
firstProperty: {},
|
|
|
secondProperty: {},
|
|
|
},
|
|
@@ -183,11 +187,11 @@ export default {
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
|
- propSelected() {
|
|
|
- return (
|
|
|
- this.properties.coursePropertyId && this.properties.firstPropertyId
|
|
|
- );
|
|
|
- },
|
|
|
+ // propSelected() {
|
|
|
+ // return (
|
|
|
+ // this.properties.coursePropertyId && this.properties.firstPropertyId
|
|
|
+ // );
|
|
|
+ // },
|
|
|
IS_PAPER_MODE() {
|
|
|
return this.modalForm.editMode === "paper";
|
|
|
},
|
|
@@ -204,9 +208,11 @@ export default {
|
|
|
this.question.control
|
|
|
);
|
|
|
}
|
|
|
+ console.log("modalForm.quesProperties", modalForm.quesProperties);
|
|
|
if (modalForm.quesProperties && modalForm.quesProperties.length) {
|
|
|
modalForm.quesProperties.forEach((item) => {
|
|
|
- let ids = [item.courseProperty.id, item.firstProperty.id];
|
|
|
+ // let ids = [item.courseProperty.id, item.firstProperty.id];
|
|
|
+ let ids = [item.firstProperty.id];
|
|
|
if (item.secondProperty && item.secondProperty.id) {
|
|
|
ids.push(item.secondProperty.id);
|
|
|
}
|
|
@@ -217,46 +223,68 @@ export default {
|
|
|
}
|
|
|
this.modalForm = modalForm;
|
|
|
},
|
|
|
- coursePropertyChange(val) {
|
|
|
- this.selection.courseProperty = val || {};
|
|
|
- },
|
|
|
- firstPropertyChange(val) {
|
|
|
- this.selection.firstProperty = val || {};
|
|
|
- },
|
|
|
- secondPropertyChange(val) {
|
|
|
- this.selection.secondProperty = val || {};
|
|
|
- },
|
|
|
+ // coursePropertyChange(val) {
|
|
|
+ // this.selection.courseProperty = val || {};
|
|
|
+ // },
|
|
|
+ // firstPropertyChange(val) {
|
|
|
+ // this.selection.firstProperty = val || {};
|
|
|
+ // },
|
|
|
+ // secondPropertyChange(val) {
|
|
|
+ // this.selection.secondProperty = val || {};
|
|
|
+ // },
|
|
|
removeProperty(property) {
|
|
|
this.modalForm.quesProperties = this.modalForm.quesProperties.filter(
|
|
|
(item) => property.key !== item.key
|
|
|
);
|
|
|
this.emitChange();
|
|
|
},
|
|
|
- addProperty() {
|
|
|
- if (!this.propSelected) return;
|
|
|
- let ids = [
|
|
|
- this.properties.coursePropertyId,
|
|
|
- this.properties.firstPropertyId,
|
|
|
- ];
|
|
|
- if (this.properties.secondPropertyId) {
|
|
|
- ids.push(this.properties.secondPropertyId);
|
|
|
- }
|
|
|
- const newProperty = {
|
|
|
- key: ids.join("_"),
|
|
|
- ...this.selection,
|
|
|
- };
|
|
|
- const propertyExist = this.modalForm.quesProperties.find(
|
|
|
- (item) => item.key === newProperty.key
|
|
|
- );
|
|
|
- if (propertyExist) {
|
|
|
- this.$message.error("属性已存在!");
|
|
|
- return;
|
|
|
- }
|
|
|
- this.modalForm.quesProperties.push(newProperty);
|
|
|
+ // addProperty() {
|
|
|
+ // if (!this.propSelected) return;
|
|
|
+ // let ids = [
|
|
|
+ // // this.properties.coursePropertyId,
|
|
|
+ // this.properties.firstPropertyId,
|
|
|
+ // ];
|
|
|
+ // if (this.properties.secondPropertyId) {
|
|
|
+ // ids.push(this.properties.secondPropertyId);
|
|
|
+ // }
|
|
|
+ // const newProperty = {
|
|
|
+ // key: ids.join("_"),
|
|
|
+ // ...this.selection,
|
|
|
+ // };
|
|
|
+ // const propertyExist = this.modalForm.quesProperties.find(
|
|
|
+ // (item) => item.key === newProperty.key
|
|
|
+ // );
|
|
|
+ // if (propertyExist) {
|
|
|
+ // this.$message.error("属性已存在!");
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ // this.modalForm.quesProperties.push(newProperty);
|
|
|
+ // this.emitChange();
|
|
|
+ // },
|
|
|
+ addProperty(arr) {
|
|
|
+ this.modalForm.quesProperties = arr;
|
|
|
this.emitChange();
|
|
|
},
|
|
|
emitChange() {
|
|
|
- this.$emit("change", this.modalForm);
|
|
|
+ // this.$emit("change", this.modalForm);
|
|
|
+ let modalFormCopy = cloneDeep(this.modalForm);
|
|
|
+ if (modalFormCopy.quesProperties?.length) {
|
|
|
+ modalFormCopy.quesProperties = modalFormCopy.quesProperties.map(
|
|
|
+ (item) => {
|
|
|
+ if (item.firstProperty) {
|
|
|
+ item.firstProperty = {
|
|
|
+ id: item.firstProperty.id,
|
|
|
+ };
|
|
|
+ }
|
|
|
+ if (item.secondProperty) {
|
|
|
+ item.secondProperty = { id: item.secondProperty.id };
|
|
|
+ }
|
|
|
+ return item;
|
|
|
+ }
|
|
|
+ );
|
|
|
+ }
|
|
|
+ console.log("modalFormCopy", modalFormCopy);
|
|
|
+ this.$emit("change", modalFormCopy);
|
|
|
},
|
|
|
},
|
|
|
};
|