|
|
@@ -113,6 +113,14 @@
|
|
|
@confirm="confirmExplanatoryNote"
|
|
|
@cancel="cancelExplanatoryNote"
|
|
|
/>
|
|
|
+ <el-table :data="noteList" style="width: 100%; margin-top: 30px" border>
|
|
|
+ <el-table-column prop="text" label="词" width="200" />
|
|
|
+ <el-table-column label="注释内容">
|
|
|
+ <template #default="{ row }">
|
|
|
+ <div v-html="row.content"></div>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
</template>
|
|
|
</ModuleBase>
|
|
|
</template>
|
|
|
@@ -126,7 +134,7 @@ import ModuleMixin from '../../common/ModuleMixin';
|
|
|
import PinyinText from '@/components/PinyinText.vue';
|
|
|
import DOMPurify from 'dompurify';
|
|
|
import ExplanatoryNoteDialog from '@/components/ExplanatoryNoteDialog.vue';
|
|
|
-import CheckWord from '@/views/book/courseware/create/components/question/article/CheckWord.vue';
|
|
|
+import CheckWord from '@/views/book/courseware/create/components/base/rich_text/CheckWord.vue';
|
|
|
import SoundRecord from '@/views/book/courseware/create/components/question/fill/components/SoundRecord.vue';
|
|
|
import UploadAudio from '@/views/book/courseware/create/components/question/fill/components/UploadAudio.vue';
|
|
|
import { TextToAudioFile } from '@/api/app';
|
|
|
@@ -151,6 +159,14 @@ export default {
|
|
|
paragraphVersion: 0,
|
|
|
};
|
|
|
},
|
|
|
+ computed: {
|
|
|
+ noteList() {
|
|
|
+ return this.data.note_list.map((note) => ({
|
|
|
+ text: note.selectText || note.text || '',
|
|
|
+ content: note.dataStr || '',
|
|
|
+ }));
|
|
|
+ },
|
|
|
+ },
|
|
|
watch: {
|
|
|
'data.property': {
|
|
|
handler(val) {
|
|
|
@@ -198,6 +214,20 @@ export default {
|
|
|
},
|
|
|
deep: true,
|
|
|
},
|
|
|
+ isViewExplanatoryNoteDialog(newVal, oldVal) {
|
|
|
+ if (oldVal && !newVal) {
|
|
|
+ // 弹窗关闭时,如果 oldRichData 还有值(说明没保存成功或被取消),则清理高亮
|
|
|
+ if (this.oldRichData && this.oldRichData.id) {
|
|
|
+ // 判断该 ID 是否还存在于 note_list 中
|
|
|
+ // 如果不存在,说明是新建后取消,需要移除高亮
|
|
|
+ this.data.note_list.some((n) => {
|
|
|
+ if (n.id === this.oldRichData.id && !n?.dataStr) {
|
|
|
+ this.cancelExplanatoryNote();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
},
|
|
|
methods: {
|
|
|
uploads(file_id, file_url) {
|
|
|
@@ -251,9 +281,8 @@ export default {
|
|
|
return;
|
|
|
}
|
|
|
let styles = this.$refs.richText.getFirstCharStyles();
|
|
|
- // let content = this.$refs.richText.getRichContent();
|
|
|
- // let text = content.replace(/<[^>]+>/g, '');
|
|
|
- this.createParsedTextInfoPinyin(null, styles);
|
|
|
+ let content = this.$refs.richText.getRichContent();
|
|
|
+ this.createParsedTextInfoPinyin(content, styles);
|
|
|
},
|
|
|
showSetting() {
|
|
|
this.richId = this.$refs.richText.id;
|
|
|
@@ -265,7 +294,6 @@ export default {
|
|
|
async createParsedTextInfoPinyin(text, styles, fc_list) {
|
|
|
const data = this.data.paragraph_list_parameter;
|
|
|
if (text === null) {
|
|
|
- // text.replace(/<[^>]+>/g, '').replace(/ /g, ' ');
|
|
|
text = this.data.content;
|
|
|
}
|
|
|
if (text === '') {
|
|
|
@@ -280,6 +308,10 @@ export default {
|
|
|
data.is_custom_fc = fcList.length > 0;
|
|
|
data.fc_paragraph_list = fcList;
|
|
|
data.is_rich_text = 'true';
|
|
|
+ // 新增:注释相关参数
|
|
|
+ let hasNotes = this.data.note_list && this.data.note_list.length > 0 ? 'true' : 'false';
|
|
|
+ data.is_match_annota = hasNotes; // 是否匹配注释,默认为 false
|
|
|
+ data.annota_list = hasNotes ? this.data.note_list : [];
|
|
|
|
|
|
await PinyinBuild_OldFormat(data).then(({ parsed_text, rich_text }) => {
|
|
|
if (parsed_text) {
|
|
|
@@ -309,7 +341,7 @@ export default {
|
|
|
);
|
|
|
this.$set(this.data, 'paragraph_list', mergedData);
|
|
|
this.paragraphVersion++;
|
|
|
- this.parseFClist();
|
|
|
+ this.parseFClist(); // 确保在这里调用
|
|
|
}
|
|
|
this.$set(this.data, 'rich_text_list', rich_text.text_list);
|
|
|
});
|
|
|
@@ -397,7 +429,7 @@ export default {
|
|
|
// 打开弹窗,接收子组件的值 { visible: true, noteId: start.id }
|
|
|
viewExplanatoryNote(val) {
|
|
|
this.isViewExplanatoryNoteDialog = val.visible;
|
|
|
- let id = val.noteId;
|
|
|
+ let id = val.annota_id || val.noteId;
|
|
|
if (this.data.note_list.some((p) => p.id === id)) {
|
|
|
this.oldRichData = this.data.note_list.find((p) => p.id === id);
|
|
|
} else {
|
|
|
@@ -408,9 +440,10 @@ export default {
|
|
|
confirmExplanatoryNote(text) {
|
|
|
this.isViewExplanatoryNoteDialog = false;
|
|
|
try {
|
|
|
- let ele = this.findComponentWithRefAndMethod(this.$children, 'richArea', 'setExplanatoryNote');
|
|
|
+ let ele = this.findComponentWithRefAndMethod(this.$children, 'richText', 'setExplanatoryNote');
|
|
|
if (ele) {
|
|
|
- ele.setExplanatoryNote(text);
|
|
|
+ let richTextID = this.$refs.richText.id;
|
|
|
+ ele.setExplanatoryNote(text, richTextID);
|
|
|
}
|
|
|
} catch (error) {
|
|
|
console.error(error);
|
|
|
@@ -418,26 +451,51 @@ export default {
|
|
|
},
|
|
|
// 点击弹窗取消-删除
|
|
|
cancelExplanatoryNote() {
|
|
|
+ const noteId = this.oldRichData?.id;
|
|
|
+ let richTextID = this.$refs.richText.id;
|
|
|
try {
|
|
|
- let ele = this.findComponentWithRefAndMethod(this.$children, 'richArea', 'cancelExplanatoryNote');
|
|
|
- if (ele) {
|
|
|
- ele.cancelExplanatoryNote();
|
|
|
+ // 1. 通知富文本子组件移除高亮标签
|
|
|
+ let ele = this.findComponentWithRefAndMethod(this.$children, 'richText', 'cancelExplanatoryNote');
|
|
|
+ if (ele && noteId && richTextID) {
|
|
|
+ ele.cancelExplanatoryNote(noteId, richTextID);
|
|
|
}
|
|
|
} catch (error) {
|
|
|
- console.error(error);
|
|
|
+ console.error('移除高亮失败:', error);
|
|
|
+ }
|
|
|
+ if (noteId) {
|
|
|
+ this.data.note_list = this.data.note_list.filter((p) => p.id !== noteId);
|
|
|
}
|
|
|
+ this.oldRichData = {};
|
|
|
+ this.isViewExplanatoryNoteDialog = false;
|
|
|
},
|
|
|
// 设置备注
|
|
|
selectContentSetMemo(data, noteId) {
|
|
|
- if (noteId) {
|
|
|
- this.data.note_list = this.data.note_list.filter((p) => p.id !== noteId);
|
|
|
+ if (!data) return;
|
|
|
+ // 统一 ID 字段,方便查找
|
|
|
+ const currentId = data.annota_id || data.id;
|
|
|
+ let oldIndex = this.data.note_list.findIndex((p) => (p.id || p.annota_id) === currentId);
|
|
|
+ if (oldIndex > -1) {
|
|
|
+ // 更新:合并旧数据和新数据,防止索引信息丢失
|
|
|
+ const oldNote = this.data.note_list[oldIndex];
|
|
|
+ const updatedNote = {
|
|
|
+ ...oldNote,
|
|
|
+ ...data,
|
|
|
+ // 确保 ID 字段统一
|
|
|
+ annota_id: currentId,
|
|
|
+ id: currentId,
|
|
|
+ };
|
|
|
+ this.data.note_list.splice(oldIndex, 1, updatedNote);
|
|
|
} else {
|
|
|
- let oldIndex = this.data.note_list.findIndex((p) => p.id === data.id);
|
|
|
- if (oldIndex > -1) {
|
|
|
- this.data.note_list.splice(oldIndex, 1, data);
|
|
|
- } else {
|
|
|
- this.data.note_list.push(data);
|
|
|
- }
|
|
|
+ // 新增:确保包含所有必要字段
|
|
|
+ const newNote = {
|
|
|
+ ...data,
|
|
|
+ annota_id: data.annota_id || data.id,
|
|
|
+ id: data.annota_id || data.id,
|
|
|
+ // 如果新数据里没有索引,给默认值
|
|
|
+ begin_index: data.begin_index === undefined ? 0 : data.begin_index,
|
|
|
+ end_index: data.end_index === undefined ? 0 : data.end_index,
|
|
|
+ };
|
|
|
+ this.data.note_list.push(newNote);
|
|
|
}
|
|
|
},
|
|
|
compareAnnotationAndSave(existingIds) {
|