tijiao
This commit is contained in:
@@ -595,6 +595,17 @@
|
||||
</p>
|
||||
</template>
|
||||
</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>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" :width="'200'">
|
||||
<div slot-scope="scope">
|
||||
<div class="operation" style="">
|
||||
@@ -890,6 +901,8 @@ export default {
|
||||
refSelectorSource: 'commonContent',
|
||||
/** 表格抽屉内合并稿防抖:按全文首次出现顺序更新 articleCiteIdOrder,避免角标停留在列表序号 [38] */
|
||||
_tableReorderTimer: null,
|
||||
/** 最近一次 getReferList 返回的 p_refer_id 顺序;与当前 chanFerForm 不一致时回写 batchUpdateRefer */
|
||||
_lastReferListApiOrder: null,
|
||||
/** 打开选择器时若带 currentRefIds(编辑已有引用),排序用「传值计算的顺序」;关闭后清空 */
|
||||
refSelectorContextIds: [],
|
||||
/** 选择参考文献弹窗:按 # 序号快速勾选,如 [5, 6, 10-15] */
|
||||
@@ -1496,6 +1509,7 @@ export default {
|
||||
p_article_id: this.p_article_id
|
||||
})
|
||||
.then((res) => {
|
||||
this._lastReferListApiOrder = this.referIdOrderSnapshot(res.data && res.data.refers).slice();
|
||||
this.chanFerForm = res.data.refers;
|
||||
this.chanFerFormRepeatList = Object.values(res.data.repeat || {});
|
||||
for (let i = 0; i < this.chanFerForm.length; i++) {
|
||||
@@ -1522,6 +1536,8 @@ export default {
|
||||
}
|
||||
/** getReferList 会整表覆盖 chanFerForm,需再按正文首次出现顺序对齐,否则下方列表与 [n] 脱节 */
|
||||
this.applyRefOrderAfterFetchReferList();
|
||||
/** 正文序与接口序不一致时回写(Main_List 未就绪时可能无变化,getDate 后会再比一次) */
|
||||
this.scheduleTryBatchSyncReferOrderIfOutOfSync();
|
||||
});
|
||||
})
|
||||
.catch((err) => {
|
||||
@@ -1774,6 +1790,69 @@ export default {
|
||||
if (sig(next) === sig(refs)) return;
|
||||
this.chanFerForm = next;
|
||||
},
|
||||
/**
|
||||
* 将当前 chanFerForm 全文同步到后端(顺序 + 各字段内容与 getReferList 行结构一致)。
|
||||
* 接口:api/References/batchUpdateRefer:p_article_id + list(JSON 字符串,文献对象数组,顺序即保存序)
|
||||
*/
|
||||
syncBatchReferenceOrderToServer() {
|
||||
const pid = this.p_article_id;
|
||||
if (pid == null || pid === '') return Promise.resolve();
|
||||
const refs = Array.isArray(this.chanFerForm) ? this.chanFerForm : [];
|
||||
if (refs.length === 0) return Promise.resolve();
|
||||
let listJson;
|
||||
try {
|
||||
listJson = JSON.stringify(JSON.parse(JSON.stringify(refs)));
|
||||
} catch (e) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
return this.$api
|
||||
.post('api/References/batchUpdateRefer', {
|
||||
p_article_id: String(pid),
|
||||
list: listJson
|
||||
})
|
||||
.then((res) => {
|
||||
const ok = res && (res.code === 0 || res.code === 1 || res.status === 1);
|
||||
if (ok) {
|
||||
this._lastReferListApiOrder = this.referIdOrderSnapshot(this.chanFerForm).slice();
|
||||
}
|
||||
if (!ok && res && (res.msg || res.message)) {
|
||||
console.warn('[batchUpdateRefer]', res.msg || res.message);
|
||||
}
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
console.warn('[batchUpdateRefer] request failed', err);
|
||||
});
|
||||
},
|
||||
/** 从 getReferList 原始 refers 提取 p_refer_id 顺序(字符串,便于比较) */
|
||||
referIdOrderSnapshot(refs) {
|
||||
return (Array.isArray(refs) ? refs : [])
|
||||
.map((r) => (r && r.p_refer_id != null ? String(r.p_refer_id) : ''))
|
||||
.filter(Boolean);
|
||||
},
|
||||
/** 当前 chanFerForm 顺序与 _lastReferListApiOrder 不一致则调用 batchUpdateRefer */
|
||||
tryBatchSyncReferOrderIfOutOfSync() {
|
||||
if (this._lastReferListApiOrder == null) return;
|
||||
const track = this._lastReferListApiOrder.map(String);
|
||||
const cur = this.referIdOrderSnapshot(this.chanFerForm);
|
||||
if (cur.length === 0) return;
|
||||
const same = track.length === cur.length && track.every((id, i) => id === cur[i]);
|
||||
if (!same) {
|
||||
this.syncBatchReferenceOrderToServer();
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 等 applyRefOrder / syncRefOrder / 表格抽屉内 nextTick 跑完后再比对顺序。
|
||||
*/
|
||||
scheduleTryBatchSyncReferOrderIfOutOfSync() {
|
||||
this.$nextTick(() => {
|
||||
this.$nextTick(() => {
|
||||
this.$nextTick(() => {
|
||||
this.tryBatchSyncReferOrderIfOutOfSync();
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
extractBracketCiteNumbersFromText(raw) {
|
||||
const out = [];
|
||||
if (!raw || typeof raw !== 'string') return out;
|
||||
@@ -2278,6 +2357,9 @@ export default {
|
||||
/** 以接口回写后的 Main_List 再对齐一次;稿面 word 会由 contentList 监听触发 syncRefOrder */
|
||||
this.$nextTick(() => {
|
||||
this.reorderReferencesFromMainListBody(null, null);
|
||||
this.$nextTick(() => {
|
||||
this.syncBatchReferenceOrderToServer();
|
||||
});
|
||||
});
|
||||
} else {
|
||||
loading.close();
|
||||
@@ -3294,6 +3376,8 @@ export default {
|
||||
/** 正文加载后按 Main_List 扫出全文首次出现顺序,写入 articleCiteIdOrder,弹窗角标与稿面一致 */
|
||||
this.$nextTick(() => {
|
||||
this.reorderReferencesFromMainListBody(null, null);
|
||||
/** getReferList 早于 Main_List 时在此才完成正文序重排,与接口序不一致则回写 */
|
||||
this.scheduleTryBatchSyncReferOrderIfOutOfSync();
|
||||
});
|
||||
loading.close();
|
||||
});
|
||||
@@ -3519,6 +3603,9 @@ export default {
|
||||
if (w && typeof w.syncRefOrder === 'function') {
|
||||
w.syncRefOrder();
|
||||
}
|
||||
this.$nextTick(() => {
|
||||
this.syncBatchReferenceOrderToServer();
|
||||
});
|
||||
});
|
||||
} else {
|
||||
this.$message.error(res.msg);
|
||||
@@ -3571,6 +3658,9 @@ export default {
|
||||
if (w && typeof w.syncRefOrder === 'function') {
|
||||
w.syncRefOrder();
|
||||
}
|
||||
this.$nextTick(() => {
|
||||
this.syncBatchReferenceOrderToServer();
|
||||
});
|
||||
});
|
||||
} else {
|
||||
this.$message.error(res.msg);
|
||||
|
||||
Reference in New Issue
Block a user