This commit is contained in:
2026-04-03 09:05:56 +08:00
parent 95b52b4d06
commit 620a35f958
9 changed files with 609 additions and 106 deletions

View File

@@ -122,6 +122,7 @@
@onEditTitle="onEditTitle"
@onAddRow="onAddRow"
@changeComment="changeComment"
@openRefSelector="handleOpenRefSelectorFromManuscript"
style="width: calc(100%); height: calc(100%)"
:style="`100%`"
>
@@ -447,34 +448,46 @@
<el-dialog
:title="$t('wordCite.selectRef')"
:visible.sync="refSelectorVisible"
width="860px"
width="900px"
append-to-body
:close-on-click-modal="false"
>
<div v-if="refSelectedRows.length > 0" style="margin-bottom: 10px; font-size: 13px; color: #606266;">
{{ $t('wordCite.selected') }}: <b style="color: #0082AA;">[{{ refPreviewLabel }}]</b>
</div>
<el-table
ref="refSelectorTable"
:data="chanFerForm"
highlight-current-row
@current-change="handleRefCurrentChange"
@selection-change="handleRefSelectionChange"
style="width: 100%"
max-height="400"
max-height="420"
size="small"
row-key="p_refer_id"
>
<el-table-column type="index" :label="'#'" width="60" :index="idx => idx + 1"></el-table-column>
<el-table-column :label="$t('wordCite.reference')">
<el-table-column type="selection" width="45" :reserve-selection="true"></el-table-column>
<el-table-column :label="'#'" width="50">
<template slot-scope="scope">
{{ scope.row.refer_frag || [scope.row.author, scope.row.title, scope.row.joura, scope.row.dateno].filter(Boolean).join(' ') || '-' }}
<b>{{ scope.$index + 1 }}.</b>
</template>
</el-table-column>
<el-table-column label="DOI" width="200">
<el-table-column :label="$t('wordCite.reference')">
<template slot-scope="scope">
{{ scope.row.doilink || scope.row.doi || scope.row.isbn || '-' }}
<div style="line-height: 1.6;">
<span>{{ scope.row.refer_frag || [scope.row.author, scope.row.title, scope.row.joura, scope.row.dateno].filter(Boolean).join('. ') || '-' }}</span>
<br v-if="scope.row.doilink || scope.row.doi || scope.row.isbn">
<a v-if="scope.row.doilink || scope.row.doi || scope.row.isbn"
:href="(scope.row.doilink || scope.row.doi || '').startsWith('http') ? (scope.row.doilink || scope.row.doi) : 'https://doi.org/' + (scope.row.doilink || scope.row.doi || scope.row.isbn)"
target="_blank"
style="color: #0082AA; font-size: 12px;"
>{{ scope.row.doilink || scope.row.doi || scope.row.isbn }}</a>
</div>
</template>
</el-table-column>
</el-table>
<span slot="footer" class="dialog-footer">
<el-button @click="refSelectorVisible = false">{{ $t('wordCite.cancel') }}</el-button>
<el-button type="danger" v-if="refSelectorCurrentRefId" @click="handleRemoveRefCite">{{ $t('wordCite.remove') }}</el-button>
<el-button type="primary" :disabled="!refSelectedRow" @click="handleConfirmRefCite">{{ $t('wordCite.confirm') }}</el-button>
<el-button type="danger" v-if="refSelectorIsEdit" @click="handleRemoveRefCite">{{ $t('wordCite.remove') }}</el-button>
<el-button type="primary" :disabled="refSelectedRows.length === 0" @click="handleConfirmRefCite">{{ $t('wordCite.confirm') }}</el-button>
</span>
</el-dialog>
</div>
@@ -616,8 +629,8 @@ export default {
chanFerForm: [],
chanFerFormRepeatList: [],
refSelectorVisible: false,
refSelectorCurrentRefId: null,
refSelectedRow: null,
refSelectorIsEdit: false,
refSelectedRows: [],
refSelectorSource: 'commonContent'
};
},
@@ -628,6 +641,29 @@ export default {
editPublicRefTableOnly
},
computed: {
refPreviewLabel() {
if (!this.refSelectedRows.length) return '';
const refs = Array.isArray(this.chanFerForm) ? this.chanFerForm : [];
const nums = this.refSelectedRows.map((row) => {
const idx = refs.findIndex((r) => r.p_refer_id === row.p_refer_id);
return idx >= 0 ? idx + 1 : null;
}).filter((n) => n != null);
if (!nums.length) return '?';
const sorted = [...new Set(nums)].sort((a, b) => a - b);
const result = [];
let i = 0;
while (i < sorted.length) {
let j = i;
while (j < sorted.length - 1 && sorted[j + 1] === sorted[j] + 1) j++;
if (j - i >= 2) {
result.push(`${sorted[i]}${sorted[j]}`);
} else {
for (let k = i; k <= j; k++) result.push(sorted[k]);
}
i = j + 1;
}
return result.join(', ');
},
catalogueContent() {
const base = Array.isArray(this.Main_List) ? this.Main_List : [];
if (!Array.isArray(this.chanFerForm) || this.chanFerForm.length === 0) return base;
@@ -721,41 +757,89 @@ 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.addContentVisible && this.$refs.addContent && this.$refs.addContent.refreshAutociteDisplay) {
this.$refs.addContent.refreshAutociteDisplay();
}
});
})
.catch((err) => {
console.log(err);
});
},
handleOpenRefSelector(data) {
this.refSelectorCurrentRefId = data && data.currentRefId ? data.currentRefId : null;
this.refSelectedRow = null;
if (this.editVisible) {
handleOpenRefSelectorFromManuscript(data) {
this.handleOpenRefSelector(data, 'manuscriptAutocite');
},
handleOpenRefSelector(data, sourceOverride) {
const currentIds = data && Array.isArray(data.currentRefIds) ? data.currentRefIds : [];
this.refSelectorIsEdit = currentIds.length > 0;
this.refSelectedRows = [];
if (sourceOverride === 'manuscriptAutocite' || (data && data.source === 'manuscript')) {
this.refSelectorSource = 'manuscriptAutocite';
} else if (this.editVisible) {
this.refSelectorSource = 'commonContent';
} else if (this.addContentVisible) {
this.refSelectorSource = 'addContent';
}
this.refSelectorVisible = true;
this.$nextTick(() => {
const table = this.$refs.refSelectorTable;
if (table) {
table.clearSelection();
if (currentIds.length > 0) {
const idSet = new Set(currentIds.map(String));
this.chanFerForm.forEach((row) => {
if (idSet.has(String(row.p_refer_id))) {
table.toggleRowSelection(row, true);
}
});
}
}
});
},
handleRefCurrentChange(row) {
this.refSelectedRow = row;
handleRefSelectionChange(rows) {
this.refSelectedRows = rows;
},
handleConfirmRefCite() {
if (!this.refSelectedRow) return;
if (this.refSelectedRows.length === 0) return;
const ids = this.refSelectedRows.map((r) => r.p_refer_id);
if (this.refSelectorSource === 'manuscriptAutocite') {
const w = this.$refs.commonWord;
if (w && typeof w.applyManuscriptAutocite === 'function') {
w.applyManuscriptAutocite(ids);
}
this.refSelectorVisible = false;
this.refSelectedRows = [];
return;
}
const ref = this.$refs[this.refSelectorSource];
if (ref) {
ref.insertAutocite(this.refSelectedRow.p_refer_id);
ref.insertAutocite(ids);
}
this.refSelectorVisible = false;
this.refSelectedRow = null;
this.refSelectedRows = [];
},
handleRemoveRefCite() {
const idsToStrip = (this.refSelectedRows || []).map((r) => r.p_refer_id);
if (this.refSelectorSource === 'manuscriptAutocite') {
const w = this.$refs.commonWord;
if (w && typeof w.stripManuscriptAutociteIds === 'function') {
w.stripManuscriptAutociteIds(idsToStrip);
}
this.refSelectorVisible = false;
this.refSelectedRows = [];
return;
}
const ref = this.$refs[this.refSelectorSource];
if (ref) {
if (ref && typeof ref.stripAutociteIds === 'function') {
ref.stripAutociteIds(idsToStrip);
} else if (ref) {
ref.removeAutocite();
}
this.refSelectorVisible = false;
this.refSelectedRow = null;
this.refSelectedRows = [];
},
ChanFerMashUp(e) {
this.$api
@@ -1825,6 +1909,16 @@ export default {
this.editVisible = true;
this.currentId = dataId;
if (this.p_article_id) {
this.fetchReferList();
}
this.$nextTick(() => {
this.$nextTick(() => {
if (this.$refs.commonContent && this.$refs.commonContent.refreshAutociteDisplay) {
this.$refs.commonContent.refreshAutociteDisplay();
}
});
});
}
},
onAddContent(dataId) {