This commit is contained in:
2026-04-13 13:06:31 +08:00
parent d613aa7d0d
commit 1deb5bba86
5 changed files with 177 additions and 73 deletions

View File

@@ -597,13 +597,7 @@
</el-table-column>
<el-table-column :label="$t('wordCite.originalOrder')" width="120" align="center">
<template slot-scope="scope">
<span>{{
scope.row.old_index != null && scope.row.old_index !== ''
? scope.row.old_index+1
: scope.row.old_index != null && scope.row.old_index !== ''
? scope.row.old_index+1
: '—'
}}</span>
<span>{{ refSelectorOrderIndexDisplay(scope.row) }}</span>
</template>
</el-table-column>
<el-table-column align="center" :width="'200'">
@@ -893,6 +887,8 @@ export default {
articleCiteIdOrder: [],
/** Edit Content 弹窗内当前 HTML与保存合并逻辑一致用于实时算出与稿面相同的 [n],避免仅依赖防抖后的 articleCiteIdOrder */
editModalDraftHtml: '',
/** 编辑器 getContent(raw) 快照draft 为空时 editModalBodyCiteOrder 用其与 extract 对齐稿面 */
editModalSyncedHtml: '',
/** 表格抽屉Title+Table+Note 合并稿,驱动 tableModalBodyCiteOrder与 editModalDraftHtml 对 Edit Content 一致) */
tableModalDraftHtml: '',
refSelectorVisible: false,
@@ -1049,16 +1045,22 @@ export default {
}
];
},
/** 弹窗内引用角标:按 Main_List + 当前草稿段合并后的全文首次出现顺序,与保存后一致 */
/** 弹窗内引用角标:与稿面同源 —— 始终用 extractAutociteOrderFromMainList(Main_List, am_id, 当前用于合并的 HTML) */
editModalBodyCiteOrder() {
if (!this.editVisible || !this.currentContent || this.currentContent.am_id == null) {
return this.articleCiteIdOrder;
}
const draft = this.editModalDraftHtml;
if (draft == null || draft === '') {
const d = this.editModalDraftHtml;
const draftTrim = d != null && String(d).trim() !== '' ? d : '';
const s = this.editModalSyncedHtml;
const syncedTrim = s != null && String(s).trim() !== '' ? s : '';
const saved = this.currentContent.content;
const savedTrim = saved != null && String(saved).trim() !== '' ? saved : '';
const htmlForExtract = draftTrim || syncedTrim || savedTrim;
if (!htmlForExtract) {
return this.articleCiteIdOrder;
}
const order = extractAutociteOrderFromMainList(this.Main_List, this.currentContent.am_id, draft);
const order = extractAutociteOrderFromMainList(this.Main_List, this.currentContent.am_id, htmlForExtract);
return order.length > 0 ? order : this.articleCiteIdOrder;
},
/**
@@ -1123,11 +1125,23 @@ export default {
},
watch: {
editVisible(val) {
if (!val) this.editModalDraftHtml = '';
if (!val) {
this.editModalDraftHtml = '';
this.editModalSyncedHtml = '';
}
},
/** 计算属性 editModalBodyCiteOrder 变化后重绘 TinyMCE 角标,与 body-cite-id-order 一致 */
editModalBodyCiteOrder: {
handler() {
if (!this.editVisible) return;
this.$nextTick(() => {
this.refreshEditModalAutociteDisplay();
});
}
},
threeVisible(val) {
if (!val) this.tableModalDraftHtml = '';
}
},
// 监听计算属性
// combinedValue(newVal, oldVal) {
// console.log('value1 或 value2 发生变化');
@@ -1519,8 +1533,8 @@ export default {
if (this.$refs.editPublicRefTableOnly) {
this.$refs.editPublicRefTableOnly.init();
}
if (this.editVisible && this.$refs.commonContent && this.$refs.commonContent.refreshAutociteDisplay) {
this.$refs.commonContent.refreshAutociteDisplay();
if (this.editVisible && this.$refs.commonContent) {
this.refreshEditModalAutociteDisplay();
}
if (this.addContentVisible && this.$refs.addContent && this.$refs.addContent.refreshAutociteDisplay) {
this.$refs.addContent.refreshAutociteDisplay();
@@ -1548,13 +1562,12 @@ export default {
applyRefOrderAfterFetchReferList() {
if (this.editVisible && this.currentContent && this.currentContent.am_id != null) {
let html = this.editModalDraftHtml;
if (html === '' || html == null) {
const t = this.$refs.commonContent && this.$refs.commonContent.$refs && this.$refs.commonContent.$refs.tinymceChild1;
if (t && t.editorInstance) {
html = t.editorInstance.getContent({ format: 'raw' }) || '';
} else {
html = (this.currentContent && this.currentContent.content) || '';
}
if (html === '' || html == null || !String(html).trim()) {
html = this.syncEditModalHtmlFromEditor();
if (html) this.editModalDraftHtml = html;
}
if (html === '' || html == null || !String(html).trim()) {
html = (this.currentContent && this.currentContent.content) || '';
}
this.flushReorderFromEditModal(html);
return;
@@ -1913,8 +1926,28 @@ export default {
this.articleCiteIdOrder = order;
},
onEditModalEditorInput(html) {
this.editModalDraftHtml = html || '';
this.flushReorderFromEditModal(html);
const h = html || '';
this.editModalDraftHtml = h;
this.editModalSyncedHtml = h;
this.flushReorderFromEditModal(h);
},
/** 从 Edit Content 内 TinyMCE 取 raw HTML 写入 editModalSyncedHtml供 extract 与 applyRefOrder 与稿面对齐 */
syncEditModalHtmlFromEditor() {
if (!this.editVisible || !this.currentContent || this.currentContent.am_id == null) return '';
const cc = this.$refs.commonContent;
const inst = cc && cc.$refs && cc.$refs.tinymceChild1;
const ed = inst && inst.editorInstance;
if (!ed || typeof ed.getContent !== 'function') return '';
const raw = ed.getContent({ format: 'raw' }) || '';
this.editModalSyncedHtml = raw;
return raw;
},
refreshEditModalAutociteDisplay() {
if (!this.editVisible) return;
const cc = this.$refs.commonContent;
if (cc && typeof cc.refreshAutociteDisplay === 'function') {
cc.refreshAutociteDisplay();
}
},
/** 打开表格抽屉时用已有 lineStyle 字段拼合并稿,先写入 tableModalDraftHtml角标与 Edit Content 一样按全文算 */
seedTableModalDraftFromLineStyle() {
@@ -1977,6 +2010,28 @@ export default {
handleRefSelectionChange(rows) {
this.refSelectedRows = rows;
},
/**
* 选择文献弹窗「原排序」列:与表格 [n] 一致 —— 有 old_index 时显示 old_index+1否则显示 order_index已为 n
*/
refSelectorOrderIndexDisplay(row) {
if (!row) return '—';
const pick = (v) => {
if (v == null || v === '') return null;
const x = Number(v);
return Number.isNaN(x) ? null : x;
};
const oi =
row.old_index != null && row.old_index !== ''
? pick(row.old_index)
: pick(row.oldIndex);
if (oi != null) return oi + 1;
const ord =
row.order_index != null && row.order_index !== ''
? pick(row.order_index)
: pick(row.orderIndex);
if (ord != null) return ord;
return '—';
},
parseQuickPickNumbers(input) {
const s = String(input || '').trim();
if (!s) return [];
@@ -2074,15 +2129,13 @@ export default {
this.flushReorderFromTableModal();
}
if (this.editVisible && this.$refs.commonContent) {
const t = this.$refs.commonContent.$refs && this.$refs.commonContent.$refs.tinymceChild1;
if (t && t.editorInstance) {
const html = t.editorInstance.getContent({ format: 'raw' });
this.editModalDraftHtml = html || '';
const html = this.syncEditModalHtmlFromEditor();
if (html) {
this.editModalDraftHtml = html;
this.editModalSyncedHtml = html;
this.flushReorderFromEditModal(html);
}
if (typeof this.$refs.commonContent.refreshAutociteDisplay === 'function') {
this.$refs.commonContent.refreshAutociteDisplay();
}
this.refreshEditModalAutociteDisplay();
}
if (
this.addContentVisible &&
@@ -3244,13 +3297,15 @@ export default {
}
this.$nextTick(() => {
this.$nextTick(() => {
if (this.$refs.commonContent && this.$refs.commonContent.refreshAutociteDisplay) {
this.$refs.commonContent.refreshAutociteDisplay();
const raw = this.syncEditModalHtmlFromEditor();
if (raw) {
this.editModalDraftHtml = raw;
}
const draft = this.currentContent && this.currentContent.content;
if (draft != null) {
this.flushReorderFromEditModal(draft);
const html = raw || (this.currentContent && this.currentContent.content) || '';
if (html) {
this.flushReorderFromEditModal(html);
}
this.refreshEditModalAutociteDisplay();
});
});
}