|
@@ -49,9 +49,13 @@
|
|
</div>
|
|
</div>
|
|
<div class="qe-part-body">
|
|
<div class="qe-part-body">
|
|
<v-editor
|
|
<v-editor
|
|
|
|
+ ref="RichTextEditor"
|
|
v-model="paperRichJson"
|
|
v-model="paperRichJson"
|
|
:enable-formula="false"
|
|
:enable-formula="false"
|
|
:enable-audio="false"
|
|
:enable-audio="false"
|
|
|
|
+ custom-emit-input
|
|
|
|
+ :custom-render-action="renderRichText"
|
|
|
|
+ :custom-tojson-action="richTextToJSON"
|
|
></v-editor>
|
|
></v-editor>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@@ -117,8 +121,8 @@
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
-// import paperRichTextJson from "../datas/paperRichText.json";
|
|
|
|
-// import paperParseData from "../datas/paperParseData.json";
|
|
|
|
|
|
+import paperRichTextJson from "../datas/paperRichText.json";
|
|
|
|
+import paperParseData from "../datas/paperParseData.json";
|
|
|
|
|
|
import { calcSum, deepCopy, objTypeOf, randomCode } from "@/plugins/utils";
|
|
import { calcSum, deepCopy, objTypeOf, randomCode } from "@/plugins/utils";
|
|
import QuestionImportPaperEdit from "./QuestionImportPaperEdit.vue";
|
|
import QuestionImportPaperEdit from "./QuestionImportPaperEdit.vue";
|
|
@@ -133,6 +137,7 @@ import ImportFileDialog from "@/components/ImportFileDialog.vue";
|
|
import { QUESTION_API } from "@/constants/constants";
|
|
import { QUESTION_API } from "@/constants/constants";
|
|
import { propertyNameQueryApi } from "@/modules/question/api";
|
|
import { propertyNameQueryApi } from "@/modules/question/api";
|
|
import { downloadByApi } from "@/plugins/download";
|
|
import { downloadByApi } from "@/plugins/download";
|
|
|
|
+import { richTextToJSON, renderRichText } from "./import-edit/richText";
|
|
|
|
|
|
const questionInfoField = [
|
|
const questionInfoField = [
|
|
"courseId",
|
|
"courseId",
|
|
@@ -174,6 +179,8 @@ export default {
|
|
questionKey: "",
|
|
questionKey: "",
|
|
paperData: [],
|
|
paperData: [],
|
|
paperRichJson: { sections: [] },
|
|
paperRichJson: { sections: [] },
|
|
|
|
+ richTextToJSON,
|
|
|
|
+ renderRichText,
|
|
// upload answer
|
|
// upload answer
|
|
uploadAnswerUrl: `${QUESTION_API}/word/parse/import`,
|
|
uploadAnswerUrl: `${QUESTION_API}/word/parse/import`,
|
|
uploadAnswerData: {},
|
|
uploadAnswerData: {},
|
|
@@ -186,14 +193,38 @@ export default {
|
|
methods: {
|
|
methods: {
|
|
async visibleChange() {
|
|
async visibleChange() {
|
|
await this.getCourseProperty();
|
|
await this.getCourseProperty();
|
|
- // this.paperData = deepCopy(paperParseData);
|
|
|
|
- // this.paperRichJson = deepCopy(paperRichTextJson);
|
|
|
|
|
|
+ this.paperData = deepCopy(paperParseData);
|
|
|
|
+ this.paperRichJson = this.transformRichText(paperRichTextJson);
|
|
this.uploadData = { courseId: this.data.importData.courseId };
|
|
this.uploadData = { courseId: this.data.importData.courseId };
|
|
- this.paperRichJson = deepCopy(this.data.richText);
|
|
|
|
- this.paperData = deepCopy(this.data.detailInfo);
|
|
|
|
|
|
+ // this.paperRichJson = deepCopy(this.data.richText);
|
|
|
|
+ // this.paperData = deepCopy(this.data.detailInfo);
|
|
this.transformDataInfo();
|
|
this.transformDataInfo();
|
|
this.questionKey = randomCode();
|
|
this.questionKey = randomCode();
|
|
},
|
|
},
|
|
|
|
+ transformRichText(richText) {
|
|
|
|
+ let nsections = [];
|
|
|
|
+ richText.sections.forEach((section) => {
|
|
|
|
+ nsections.push({
|
|
|
|
+ blocks: section.blocks,
|
|
|
|
+ attributes: { id: `remark-${section.remark.index}` },
|
|
|
|
+ });
|
|
|
|
+ if (section.remark && !section.remark.status) {
|
|
|
|
+ nsections.push({
|
|
|
|
+ blocks: [
|
|
|
|
+ {
|
|
|
|
+ type: "text",
|
|
|
|
+ value: section.remark.cause,
|
|
|
|
+ },
|
|
|
|
+ ],
|
|
|
|
+ attributes: {
|
|
|
|
+ id: `remark-error-${section.remark.index}`,
|
|
|
|
+ class: "remark-error",
|
|
|
|
+ },
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ return { sections: nsections };
|
|
|
|
+ },
|
|
async getCourseProperty() {
|
|
async getCourseProperty() {
|
|
const res = await propertyNameQueryApi(this.data.importData.courseId, "");
|
|
const res = await propertyNameQueryApi(this.data.importData.courseId, "");
|
|
const optionList = res.data || [];
|
|
const optionList = res.data || [];
|
|
@@ -272,8 +303,14 @@ export default {
|
|
if (this.loading) return;
|
|
if (this.loading) return;
|
|
this.loading = true;
|
|
this.loading = true;
|
|
|
|
|
|
|
|
+ let richText = this.$refs.RichTextEditor.emitJsonAction();
|
|
|
|
+ richText.sections = richText.sections.filter(
|
|
|
|
+ (item) =>
|
|
|
|
+ !item.attributes || item.attributes["class"] !== "remark-error"
|
|
|
|
+ );
|
|
|
|
+
|
|
const res = await questionImportParseRichText({
|
|
const res = await questionImportParseRichText({
|
|
- richText: this.paperRichJson,
|
|
|
|
|
|
+ richText,
|
|
courseId: this.data.importData.courseId,
|
|
courseId: this.data.importData.courseId,
|
|
}).catch(() => {});
|
|
}).catch(() => {});
|
|
this.loading = false;
|
|
this.loading = false;
|