29 Commits

Author SHA1 Message Date
685fadb043 Merge branch 'master' of https://git.nuttyreading.com/wangjinlei/tougao_web into Editorial-Board 2026-05-06 10:50:14 +08:00
052d0e4ca4 自动化配置 2026-04-27 09:53:19 +08:00
c6489e7af0 提交 2026-04-17 09:29:40 +08:00
5745a36393 批量选择 2026-04-16 15:44:35 +08:00
23b8a1d031 Merge branch 'master' of https://git.nuttyreading.com/wangjinlei/tougao_web into Editorial-Board 2026-04-16 13:23:39 +08:00
0b1bc06465 tijiao 2026-04-16 10:54:08 +08:00
2fe45fd693 tijiao 2026-04-15 13:08:14 +08:00
0babe7ef6a Merge branch 'master' of https://git.nuttyreading.com/wangjinlei/tougao_web into Editorial-Board 2026-04-15 10:51:00 +08:00
6cb5dbccf0 修改 参考文献排序 2026-04-14 11:18:04 +08:00
26981f83c4 Merge branch 'master' of https://git.nuttyreading.com/wangjinlei/tougao_web into Editorial-Board 2026-04-14 09:10:02 +08:00
a28d0d5079 提交 2026-04-13 17:00:49 +08:00
eff107aa15 表格参考文献的预览 2026-04-13 16:42:26 +08:00
563def58a5 tijiao 2026-04-13 14:42:13 +08:00
222a00c1c7 Merge branch 'master' of https://git.nuttyreading.com/wangjinlei/tougao_web into Editorial-Board 2026-04-13 14:20:03 +08:00
1deb5bba86 tijiao 2026-04-13 13:06:31 +08:00
d613aa7d0d tijiao 2026-04-10 15:53:15 +08:00
0a56b16fe4 Merge branch 'master' of https://git.nuttyreading.com/wangjinlei/tougao_web into Editorial-Board 2026-04-10 09:21:39 +08:00
7f725cad52 Merge branch 'master' of https://git.nuttyreading.com/wangjinlei/tougao_web into Editorial-Board 2026-04-10 09:13:17 +08:00
797ca258f8 提交 2026-04-10 09:12:40 +08:00
9c44064f51 参考文献 2026-04-09 11:52:33 +08:00
7527a6ef54 参考文献的暂存 2026-04-09 09:39:58 +08:00
c4b86be0d5 提交 2026-04-08 17:25:19 +08:00
4fc78e1fe7 提交 2026-04-08 13:09:02 +08:00
0d35b76c3a 提交 2026-04-08 13:03:54 +08:00
36f6c02376 提交 2026-04-03 09:58:39 +08:00
dd07a03d7b Merge branch 'master' of https://git.nuttyreading.com/wangjinlei/tougao_web into Editorial-Board 2026-04-03 09:52:11 +08:00
620a35f958 提交 2026-04-03 09:05:56 +08:00
95b52b4d06 提交 2026-04-02 10:56:37 +08:00
1f29fb5baf 根据标签autoCite显示参考文献 2026-04-01 17:30:40 +08:00
31 changed files with 8708 additions and 985 deletions

View File

@@ -19,8 +19,8 @@ const service = axios.create({
// baseURL: 'https://submission.tmrjournals.com/', //正式 记得切换
// baseURL: 'http://www.tougao.com/', //测试本地 记得切换
// baseURL: 'http://192.168.110.110/tougao/public/index.php/',
baseURL: '/api', //本地
// baseURL: '/', //正式
// baseURL: '/api', //本地
baseURL: '/', //正式
});
@@ -102,6 +102,22 @@ export default {
})
},
/**
* POST x-www-form-urlencoded数组字段序列化为 list[]=a&list[]=b兼容 PHP 批量接口)
*/
postFormBracket(url, params) {
return new Promise((resolve, reject) => {
service
.post(url, qs.stringify(params, { arrayFormat: 'brackets' }))
.then((res) => {
resolve(res.data)
})
.catch((err) => {
reject(err)
})
})
},
/**
* post方法对应post请求
* @param {String} url [请求的url地址]

View File

@@ -0,0 +1,169 @@
/**
* 表格弹窗预览:将单元格内空 mycite 转为可见 [n],与 word.vue renderCiteLabels 一致(纯函数,无 Vue 依赖)
*/
export function formatCiteNumbers(nums) {
if (!nums || !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(', ');
}
export function sortAutociteIdsByCiteNumber(ids, citeMap) {
const map = citeMap || {};
const uniq = [...new Set(ids.map(String))];
return uniq.sort((a, b) => {
const na = map[a];
const nb = map[b];
const ha = na != null && na !== '';
const hb = nb != null && nb !== '';
if (ha && hb) return Number(na) - Number(nb);
if (ha) return -1;
if (hb) return 1;
return String(a).localeCompare(String(b));
});
}
/**
* @param {Array} refs - chanFerForm项含 p_refer_id
* @param {Array<string|number>} bodyCiteIdOrder - 正文首次出现顺序;空则按列表行序 1..n
*/
export function buildCiteMapFromRefs(refs, bodyCiteIdOrder) {
const refList = Array.isArray(refs) ? refs : [];
const refIdSet = new Set(
refList.map((r) => (r && r.p_refer_id != null ? String(r.p_refer_id) : '')).filter(Boolean)
);
let orderedIds = [];
if (Array.isArray(bodyCiteIdOrder) && bodyCiteIdOrder.length > 0) {
orderedIds = bodyCiteIdOrder.map(String);
}
if (orderedIds.length === 0) {
const map = {};
refList.forEach((row, idx) => {
const key = row && row.p_refer_id != null ? String(row.p_refer_id) : '';
if (key) map[key] = idx + 1;
});
return map;
}
const filtered = [];
orderedIds.forEach((id) => {
if (refIdSet.has(id) && !filtered.includes(id)) filtered.push(id);
});
const map = {};
filtered.forEach((id, idx) => {
map[id] = idx + 1;
});
let next = filtered.length + 1;
refList.forEach((r) => {
const key = r && r.p_refer_id != null ? String(r.p_refer_id) : '';
if (!key || map[key] != null) return;
map[key] = next++;
});
return map;
}
function escAttr(s) {
return String(s || '')
.replace(/&/g, '&amp;')
.replace(/"/g, '&quot;')
.replace(/</g, '&lt;');
}
/**
* @param {string} html
* @param {Array} refs - chanFerForm
* @param {Object} citeMap - p_refer_id -> 显示序号
*/
export function renderCiteLabelsInHtml(html, refs, citeMap) {
if (!html || typeof html !== 'string') return html || '';
if (!Array.isArray(refs) || refs.length === 0) return html;
/** 与稿面一致:历史/表格 JSON 中可能为 <autocite> */
let h = html.replace(/<\/autocite>/gi, '</mycite>').replace(/<autocite\b/gi, '<mycite');
const refList = refs;
const refMap = refList.reduce((acc, item) => {
const key = item && item.p_refer_id != null ? String(item.p_refer_id) : '';
if (key) acc[key] = item;
return acc;
}, {});
let normalized = h.replace(/<mycite\b[^>]*\/?>[\s\S]*?(?:<\/mycite>)?/gi, (fullTag) => {
const attrMatch = fullTag.match(/\bdata-id\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/i);
const dataId = (attrMatch && (attrMatch[1] || attrMatch[2] || attrMatch[3])) || '';
if (!dataId) return '';
return `<mycite data-id="${escAttr(dataId)}"></mycite>`;
});
const citeGroupRe = /(?:<mycite\s+data-id="([^"]*)"\s*><\/mycite>\s*)+/gi;
normalized = normalized.replace(citeGroupRe, (groupMatch) => {
const ids = [];
const innerRe = /<mycite\s+data-id="([^"]*)"\s*><\/mycite>/gi;
let m;
while ((m = innerRe.exec(groupMatch)) !== null) {
m[1].split(',').forEach((part) => {
const id = part.trim();
if (id) ids.push(id);
});
}
const sortedAll = sortAutociteIdsByCiteNumber(ids, citeMap);
const validIds = sortedAll.filter((id) => refMap[id]);
const sortedIds = validIds.length ? sortAutociteIdsByCiteNumber(validIds, citeMap) : [];
const map = citeMap || {};
const parts = sortedIds.map((id) => {
const ref = refMap[id];
const no = ref ? map[id] : null;
const num = no != null && no !== '' ? String(no) : null;
return { id, ref, num };
});
const numsForLabel = parts
.map((p) => p.num)
.filter((n) => n != null && n !== '')
.map(Number);
const label = numsForLabel.length > 0 ? formatCiteNumbers(numsForLabel) : '';
if (!label) {
return '';
}
const dataIdAttr = escAttr(sortedIds.join(','));
return `<mycite data-id="${dataIdAttr}">[${label}]</mycite>`;
});
return normalized.replace(/<mycite[^>]*data-id=""[^>]*>[\s\S]*?<\/mycite>/gi, '');
}
export function applyCiteLabelsToTableRows(rows, refs, citeMap) {
if (!Array.isArray(rows) || !rows.length) return rows;
if (!Array.isArray(refs) || refs.length === 0) return rows;
return rows.map((row) => {
if (!Array.isArray(row)) return row;
const nextRow = row.map((cell) => {
if (!cell || typeof cell !== 'object') return cell;
const t = cell.text;
const lower = typeof t === 'string' ? t.toLowerCase() : '';
if (!lower || (!lower.includes('mycite') && !lower.includes('autocite'))) return cell;
const next = renderCiteLabelsInHtml(t, refs, citeMap);
if (next === t) return cell;
return { ...cell, text: next };
});
// TableUtils.addRowIdToData 会给数组行对象挂 rowId渲染 oddColor 依赖它,不能在 map 后丢失
if (row.rowId != null) {
nextRow.rowId = row.rowId;
}
return nextRow;
});
}

View File

@@ -71,7 +71,51 @@ function findExtentElement(blipElement) {
export default {
async searchTitleByDOI(doi) {
if (!doi) {
this.$message.warning('Please enter a DOI');
return null;
}
// 开启全局 Loading防止编辑重复点击
try {
// 1. 数据清洗
const cleanDoi = doi.trim()
.replace(/^doi:/i, '')
.replace(/https?:\/\/doi\.org\//i, '');
// 2. 请求 Crossref 接口
const response = await fetch(`https://api.crossref.org/works/${encodeURIComponent(cleanDoi)}`, {
method: 'GET',
headers: { 'Accept': 'application/json' }
});
if (!response.ok) throw new Error('DOI not found');
const data = await response.json();
// 3. 提取标题并跳转
const title = data.message?data.message.title?data.message.title[0]:'':'';
if (title) {
const searchUrl = `https://www.google.com/search?q=${encodeURIComponent(title)}`;
window.open(searchUrl, '_blank');
return title;
} else {
this.$message.error('Title not found in metadata.');
}
} catch (error) {
console.error("DOI Retrieval Error:", error);
this.$message.error('Failed to fetch title. Please check the DOI.');
} finally {
}
return null;
},
getJournalTypeName(value) {
var list = JSON.parse(localStorage.getItem('journalTypeDataAll'));
@@ -226,8 +270,7 @@ export default {
str = this.transformHtmlString(processedContent, 'table',{ keepBr: true })
console.log("🚀 ~ extractContentWithoutOuterSpan888888 ~ str:", str);
// 创建一个临时的 DOM 元素来解析 HTML
const div = document.createElement('div');
@@ -634,7 +677,7 @@ str = str.replace(regex, function (match, content, offset, fullString) {
});
mammoth.convertToHtml({ arrayBuffer }, {
convertImage: mammoth.images.inline(async function (image) {
console.log('image at line 163:', image)
const contentType = image.contentType.toLowerCase();
const allowedTypes = ['image/jpeg', 'image/jpg', 'image/png'];
if (!allowedTypes.includes(contentType)) {
@@ -917,9 +960,9 @@ str = str.replace(regex, function (match, content, offset, fullString) {
});
// 2. 删除所有不需要的标签 (除 `strong`, `em`, `sub`, `sup`, `b`, `i` 外的所有标签)
if (type == 'table') {
inputHtml = inputHtml.replace(/<(?!\/?(strong|em|sub|sup|b|i|blue|wmath|img|myfigure|mytable|myh3))[^>]+>/g, ''); // 删除不需要的标签
inputHtml = inputHtml.replace(/<(?!\/?(strong|em|sub|sup|b|i|blue|wmath|img|myfigure|mytable|myh3|mycite))[^>]+>/g, ''); // 删除不需要的标签
} else {
inputHtml = inputHtml.replace(/<(?!\/?(strong|em|sub|sup|b|i|blue|wmath|myfigure|mytable|myh3))[^>]+>/g, ''); // 删除不需要的标签
inputHtml = inputHtml.replace(/<(?!\/?(strong|em|sub|sup|b|i|blue|wmath|myfigure|mytable|myh3|mycite))[^>]+>/g, ''); // 删除不需要的标签
}
@@ -992,8 +1035,7 @@ str = str.replace(regex, function (match, content, offset, fullString) {
const cells = row.querySelectorAll('th, td'); // 获取每个行中的单元格(包括 <th> 和 <td>
return await Promise.all(
Array.from(cells).map(async (cell) => {
console.log("🚀 ~ parseTableToArray777 ~ cell:", cell);
const text = await this.extractMathJaxLatex(cell);
return {
text,
@@ -1243,8 +1285,7 @@ str = str.replace(regex, function (match, content, offset, fullString) {
return html;
},
getCleanTextForCount(html) {
getCleanTextForCount (html) {
if (!html) return "";
const tempDiv = document.createElement('div');
tempDiv.innerHTML = html;

View File

@@ -1243,7 +1243,6 @@ colTitle: 'Template title',
,
autoPromotionLogs: {
detail: 'Auto Promotion Details',
pipelineHistory: 'PIPELINE HISTORY',
factoryTaskSelectPlaceholder: 'Select promotion task',
configured: 'Configured',
editConfig: 'Edit auto promotion configuration',
@@ -1311,7 +1310,6 @@ colTitle: 'Template title',
taskLogState2: 'Failed',
taskLogState3: 'Bounced',
taskLogState4: 'Cancelled',
logColIndex: 'No.',
logColExpert: 'Expert',
logColSendTime: 'Sent at',
logColPreparedAt: 'Prepared at',
@@ -1338,6 +1336,9 @@ colTitle: 'Template title',
deleteLogSuccess: 'Deleted',
deleteLogFailed: 'Delete failed',
noFailureReason: 'No failure reason',
logDetailEditTitle: 'Edit delivery log',
logDetailPreviewTitle: 'Preview delivery log',
logLoadFailed: 'Failed to load logs',
deletedSuccess: 'Deleted',
mockPromotionSubject: 'Promotion for {journal}',
mockPromotionContent: '<p>Dear {name},</p><p>Check out our latest journal updates...</p>'
@@ -1349,6 +1350,32 @@ colTitle: 'Template title',
previewWithVariablesHint: 'The expert data is an example, used for variable spelling check only.',
close: 'Close',
placeholder: 'Please enter email content'
},
wordCite: {
noRefs: 'Reference list is not loaded yet. Please wait or refresh the page.',
missingBoundRef: 'The bound reference no longer exists. Please cite again.',
notFoundById: 'No reference found for citation ID {id}',
selectRef: 'Select Reference',
originalOrder: 'Original order',
reference: 'Reference',
uncited: 'Uncited',
cancel: 'Cancel',
confirm: 'Confirm',
remove: 'Remove',
selected: 'Selected',
modifyRef: 'Edit citation',
removeRefTag: 'Remove citation',
citeUpdateFail: 'Could not update the citation in the text. Try again or use Edit.',
matchBracketRefs: 'Auto-link References',
matchBracketRefsDone: 'Converted {n} bracket citation(s) to autocite.',
matchBracketRefsNone: "No active citation links were detected in the text. To enable automatic numbering, please use the 'Reference' tool to link your sources.",
removeRefNeedClickCite: 'Click a citation in the text first, then choose Reference remove.',
quickPickPlaceholder: 'Enter e.g. [5, 6, 10-15] to auto-select',
quickPickApply: 'Link References',
quickPickClear: 'Clear selection',
currentCiteNo: 'Current',
locateInBody: 'Click to scroll to citation in text',
locateInRefHint: 'Highlight this entry in the list below'
}

View File

@@ -1228,7 +1228,6 @@ const zh = {
,
autoPromotionLogs: {
detail: '自动推广详情',
pipelineHistory: '流水线历史',
factoryTaskSelectPlaceholder: '选择推广任务',
configured: '已配置',
editConfig: '修改期刊自动推广配置',
@@ -1296,7 +1295,6 @@ const zh = {
taskLogState2: '失败',
taskLogState3: '退信',
taskLogState4: '取消',
logColIndex: '序号',
logColExpert: '专家信息',
logColSendTime: '发送时间',
logColPreparedAt: '预处理完成时间',
@@ -1323,6 +1321,9 @@ const zh = {
deleteLogSuccess: '删除成功',
deleteLogFailed: '删除失败',
noFailureReason: '暂无失败原因',
logDetailEditTitle: '编辑发送记录',
logDetailPreviewTitle: '预览发送记录',
logLoadFailed: '加载日志失败',
deletedSuccess: '已删除',
mockPromotionSubject: '自动推广:{journal}',
mockPromotionContent: '<p>亲爱的 {name}</p><p>请查看我们最新的期刊更新...</p>'
@@ -1334,6 +1335,32 @@ const zh = {
previewWithVariablesHint: '专家数据仅为示例,仅用于变量拼写检查。',
close: '关闭',
placeholder: '请输入邮件内容'
},
wordCite: {
noRefs: '参考文献列表尚未加载,请稍候再试或刷新页面',
missingBoundRef: '当前绑定的参考文献不存在,请重新引用',
notFoundById: '未查询到编号{id}相关参考文献',
selectRef: '选择参考文献',
originalOrder: '原排序',
reference: '参考文献',
uncited: '未引用',
cancel: '取消',
confirm: '确认',
remove: '移除',
selected: '已选择',
modifyRef: '修改引用',
removeRefTag: '移除引用',
citeUpdateFail: '未能更新正文中的引用标签,请重试或进入编辑修改',
matchBracketRefs: '自动链接参考文献',
matchBracketRefsDone: '已转换 {n} 处 [n] 为可点击角标',
matchBracketRefsNone: '正文中未检测到可转换的纯文本引用 [n]。若要自动编号并关联参考文献请使用工具栏中的「Reference」插入引用。',
removeRefNeedClickCite: '请先在正文中点击要删除的引用角标,再点「移除参考文献」。',
quickPickPlaceholder: '输入如 [5, 6, 10-15] 自动勾选对应参考文献',
quickPickApply: '链接参考文献',
quickPickClear: '清空勾选',
currentCiteNo: '当前序号',
locateInBody: '点击定位正文角标',
locateInRefHint: '在下方列表中高亮该条'
}

View File

@@ -136,16 +136,7 @@
<!-- <div v-else style="padding: 20px; box-sizing: border-box"></div> -->
</div>
</div>
<div class="content_box mt20 stepbox">
<!-- 文章引用 -->
<div class="con">
<h4 class="con-title">{{ this.$t('PreAccept.step2') }}</h4>
<p style="color: #505050; font-size: 14px; padding: 20px; box-sizing: border-box">
<el-button @click="goGenerateCharts(thisArtcleId)" icon="el-icon-edit" type="text">Edit</el-button>
</p>
<!-- <div v-else style="padding: 20px; box-sizing: border-box"></div> -->
</div>
</div>
<div class="content_box mt20 stepbox">
<!-- 文章引用 -->
<div class="con">
@@ -170,7 +161,16 @@
<!-- <div v-else style="padding: 20px; box-sizing: border-box"></div> -->
</div>
</div>
<div class="content_box mt20 stepbox">
<!-- 文章引用 -->
<div class="con">
<h4 class="con-title">{{ this.$t('PreAccept.step2') }}</h4>
<p style="color: #505050; font-size: 14px; padding: 20px; box-sizing: border-box">
<el-button @click="goGenerateCharts(thisArtcleId)" icon="el-icon-edit" type="text">Edit</el-button>
</p>
<!-- <div v-else style="padding: 20px; box-sizing: border-box"></div> -->
</div>
</div>
<!-- 答疑 -->
<div class="mt20 helpcontent">
<div class="flexbox">

File diff suppressed because it is too large Load Diff

View File

@@ -332,11 +332,11 @@ export default {
// refName: 'setFiveRef',
// rongCont: 'Modify the article body.'
// },
{
name: 'Text Proofread',
refName: 'setThreeRef',
rongCont: 'HTML layout.'
}
// {
// name: 'Text Proofread',
// refName: 'setThreeRef',
// rongCont: 'HTML layout.'
// }
// {
// name: 'Create Build',
// refName: 'setSevenRef',
@@ -1337,7 +1337,7 @@ export default {
// 5----重新获取加载参考文献
changeRefer(val) {
console.log('重新获取参考文献');
this.$api
.post('api/Production/getReferList', {
p_article_id: this.p_article_id
@@ -1348,7 +1348,7 @@ export default {
for (var i = 0; i < this.chanFerForm.length; i++) {
this.chanFerForm[i].edit_mark = 1;
}
console.log(this.chanFerForm);
})
.catch((err) => {
console.log(err);

View File

@@ -1433,7 +1433,7 @@ export default {
// 5----重新获取加载参考文献
changeRefer(val) {
console.log('重新获取参考文献');
this.$api
.post('api/Production/getReferList', {
p_article_id: this.p_article_id
@@ -1444,7 +1444,7 @@ export default {
for (var i = 0; i < this.chanFerForm.length; i++) {
this.chanFerForm[i].edit_mark = 1;
}
console.log(this.chanFerForm);
})
.catch((err) => {
console.log(err);

View File

@@ -19,46 +19,19 @@
<el-select
v-if="config.initialized && selectedJournalId"
v-model="headerPromotionFactoryId"
class="header-factory-task-select custom-pipeline-select"
class="header-factory-task-select"
size="small"
filterable
:loading="factoryTasksHeaderLoading"
:placeholder="$t('autoPromotionLogs.factoryTaskSelectPlaceholder')"
@change="onHeaderFactoryTaskChange"
popper-class="pipeline-popper"
>
<el-option-group >
<el-option
v-for="opt in factoryTaskOptions"
:key="opt.value"
:label="opt.label"
:value="opt.value"
class="pipeline-option"
>
<div class="option-content">
<div class="row-top">
<span class="task-title">{{ mapFactoryTaskTypeLabel(opt.task.type) }}</span>
<el-tag :type="getStatusType(opt.task.start_promotion)" size="mini" effect="plain" class="status-tag">
{{ opt.task.start_promotion==1 ? $t('autoPromotion.running') : $t('autoPromotion.stopped') }}
</el-tag>
</div>
<div class="row-bottom">
<span class="meta-item database">{{ mapFactoryExpertTypeLabel(opt.task.expert_type) }}</span>
<template v-if="opt.task.expert_type==5">
<span class="separator"></span>
<span class="meta-item region">{{ opt.task.country_scope_label }}</span>
</template>
<span class="separator"></span>
<span class="meta-item time">{{ opt.task.ctime_text }}</span>
</div>
</div>
</el-option>
</el-option-group>
<el-option
v-for="opt in factoryTaskOptions"
:key="opt.value"
:label="opt.label"
:value="opt.value"
/>
</el-select>
<el-tag
v-if="config.initialized && selectedJournalId && headerFactoryTaskRunning !== null"
@@ -72,10 +45,19 @@
{{ headerFactoryTaskRunning ? $t('autoPromotion.running') : $t('autoPromotion.stopped') }}
</el-tag>
<el-button type="text" size="small" style="margin-left: 10px" @click="openFactoryTaskDialogFromLogs">
<i class="el-icon-edit"></i>
{{ config.initialized ? $t('autoPromotionLogs.editConfig') : $t('autoPromotionLogs.startConfig') }}
</el-button>
<!-- <template v-if="config.initialized"> -->
<!-- <el-tag type="success" size="small" effect="plain" style="margin-left: 10px">
<i class="el-icon-circle-check"></i> {{ $t('autoPromotionLogs.configured') }}
</el-tag> -->
<el-button type="text" size="small" style="margin-left: 10px" @click="openFactoryTaskDialogFromLogs">
<i class="el-icon-edit"></i>
{{ config.initialized ? $t('autoPromotionLogs.editConfig') : $t('autoPromotionLogs.startConfig') }}
</el-button>
<!-- </template> -->
<!-- <el-tag v-else type="info" size="small" effect="plain" style="margin-left: 10px">
<i class="el-icon-info"></i> {{ $t('autoPromotionLogs.notConfigured') }}
</el-tag> -->
</div>
<div v-if="config.initialized && selectedJournalId && headerPromotionFactoryId" class="right">
<el-button
@@ -118,6 +100,8 @@
<div v-else class="manage-mode">
<el-card shadow="never" class="list-card">
<div class="filter-header-row">
<div class="tmr-capsule-group">
<el-tabs v-model="query.state" type="card" @tab-click="handleTabClick">
@@ -151,9 +135,7 @@
<div class="task-column">
<div class="task-name">{{ scope.row.task_name || '-' }}</div>
<div class="task-id-tags">
<span class="id-tag"
>{{ $t('autoPromotionLogs.templateIdLabel') }}: {{ scope.row.template_id }}</span
>
<span class="id-tag">{{ $t('autoPromotionLogs.templateIdLabel') }}: {{ scope.row.template_id }}</span>
<span class="id-tag">{{ $t('autoPromotionLogs.styleIdLabel') }}: {{ scope.row.style_id }}</span>
</div>
</div>
@@ -242,11 +224,7 @@
:icon="String(scope.row.state) === '5' ? 'el-icon-edit-outline' : 'el-icon-view'"
@click="previewRow(scope.row)"
>
{{
String(scope.row.state) === '5'
? $t('autoPromotionLogs.editAction')
: $t('autoPromotionLogs.previewAction')
}}
{{ String(scope.row.state) === '5' ? $t('autoPromotionLogs.editAction') : $t('autoPromotionLogs.previewAction') }}
</el-button>
</div>
</template>
@@ -449,36 +427,6 @@ export default {
const opt = this.factoryTaskOptions.find((o) => String(o.value) === id);
if (opt && typeof opt.running === 'boolean') return opt.running;
return null;
},
/**
* 顶部 select 前缀展示用:与 headerPromotionFactoryId 对应的 option含 task
* URL 回退插入的占位项可能没有 task这里统一成可安全渲染的对象。
*/
currentSelectedTask() {
const emptyTask = { type: '', ctime_text: '' };
const id = String(this.headerPromotionFactoryId || '').trim();
if (!id || !Array.isArray(this.factoryTaskOptions) || !this.factoryTaskOptions.length) {
return { value: '', label: '', running: false, task: { ...emptyTask } };
}
const opt = this.factoryTaskOptions.find((o) => String(o.value) === id);
if (!opt) {
return { value: id, label: id, running: false, task: { ...emptyTask } };
}
const raw = opt.task && typeof opt.task === 'object' ? opt.task : {};
const ctimeText =
raw.ctime_text != null && String(raw.ctime_text).trim() !== ''
? String(raw.ctime_text).trim()
: this.formatFactoryHeaderTaskCreateTime(raw);
return {
value: opt.value,
label: opt.label,
running: typeof opt.running === 'boolean' ? opt.running : this.isFactoryHeaderTaskRunning(raw),
task: {
...raw,
type: raw.type != null ? String(raw.type) : '',
ctime_text: ctimeText || ''
}
};
}
},
watch: {
@@ -497,33 +445,12 @@ export default {
this.initPage();
},
methods: {
mapFactoryTaskTypeLabel(type) {
const t = String(type || '');
if (t === '1') return this.$t('autoPromotion.factoryScenarioSolicit');
if (t === '2') return this.$t('autoPromotion.factoryScenarioPromoteCitation');
if (t === '3') return this.$t('autoPromotion.factoryScenarioGeneralThanks');
if (t === '4') return this.$t('autoPromotion.autoSolicit');
return this.$t('autoPromotion.autoSolicit');
},
mapFactoryExpertTypeLabel(expertType) {
const t = String(expertType || '').trim();
if (t === '1') return this.$t('autoPromotion.factoryExpertChief');
if (t === '2') return this.$t('autoPromotion.factoryExpertBoard');
if (t === '3') return this.$t('autoPromotion.factoryExpertYoungBoard');
if (t === '4') return this.$t('autoPromotion.factoryExpertAuthor');
if (t === '5') return this.$t('autoPromotion.factoryExpertDb');
return '-';
},
getStatusType(status) {
return status==1?'success':'info';
},
handleTabClick(tab) {
// tab.name 对应的就是原来的 value ("0", "1" 等)
// 注意el-tabs 的 v-model 绑定的是字符串
this.query.state = tab.name;
this.handleStateChange(); // 触发你原有的搜索逻辑
},
// tab.name 对应的就是原来的 value ("0", "1" 等)
// 注意el-tabs 的 v-model 绑定的是字符串
this.query.state = tab.name;
this.handleStateChange(); // 触发你原有的搜索逻辑
},
getPercent(row) {
if (!row.total_count || row.total_count === 0) return 0;
// 计算已发送占比
@@ -627,7 +554,9 @@ export default {
this.hidePage = false;
var journal_id = (this.$route.query && this.$route.query.journal_id) || '';
var pfid =
(this.$route.query && this.$route.query.promotion_factory_id) || (this.$route.query && this.$route.query.taskId) || '';
(this.$route.query && this.$route.query.promotion_factory_id) ||
(this.$route.query && this.$route.query.taskId) ||
'';
this.routePromotionFactoryId = String(pfid || '');
this.headerPromotionFactoryId = this.routePromotionFactoryId;
this.selectedJournalId = String(journal_id);
@@ -733,7 +662,7 @@ export default {
}
if (!dt || isNaN(dt.getTime())) return String(raw).trim();
const pad = (v) => String(v).padStart(2, '0');
return `${dt.getFullYear()}-${pad(dt.getMonth() + 1)}-${pad(dt.getDate())}`;
return `${dt.getFullYear()}-${pad(dt.getMonth() + 1)}-${pad(dt.getDate())} ${pad(dt.getHours())}:${pad(dt.getMinutes())}:${pad(dt.getSeconds())}`;
},
isFactoryHeaderTaskRunning(task) {
if (!task || typeof task !== 'object') return false;
@@ -747,12 +676,9 @@ export default {
},
/** 下拉仅展示「类型 - 创建日期」,运行状态单独用 el-tag */
buildFactoryHeaderOptionMainLabel(task, pidFallback) {
console.log("🚀 ~ buildFactoryHeaderOptionMainLabel ~ task:", task);
const typePart = this.getFactoryHeaderTaskTypeLabel(task) || String(pidFallback || '').trim() || '—';
const expertTypePart = this.mapFactoryExpertTypeLabel(task.expert_type);
const datePart = this.formatFactoryHeaderTaskCreateTime(task);
return datePart ? `${typePart} | ${expertTypePart}${task.expert_type==5 ? ` | ${task.country_scope_label} ` :''} | ${datePart}` : typePart;
return datePart ? `${typePart} - ${datePart}` : typePart;
},
replacePromotionFactoryIdInUrl(promotionFactoryId) {
try {
@@ -778,20 +704,18 @@ export default {
});
const payload = (res && res.data) || {};
const list = this.findArray(payload) || this.findArray(res) || [];
let opts = (Array.isArray(list) ? list : [])
.map((task, idx) => {
const pid =
task && task.promotion_factory_id != null
? String(task.promotion_factory_id)
: task && task.id != null
? String(task.id)
: '';
if (!pid) return null;
const label = this.buildFactoryHeaderOptionMainLabel(task, pid);
const running = this.isFactoryHeaderTaskRunning(task);
return { value: pid, label, running,task:task }
})
.filter(Boolean);
let opts = (Array.isArray(list) ? list : []).map((task, idx) => {
const pid =
task && task.promotion_factory_id != null
? String(task.promotion_factory_id)
: task && task.id != null
? String(task.id)
: '';
if (!pid) return null;
const label = this.buildFactoryHeaderOptionMainLabel(task, pid);
const running = this.isFactoryHeaderTaskRunning(task);
return { value: pid, label, running };
}).filter(Boolean);
let cur = String(this.routePromotionFactoryId || this.headerPromotionFactoryId || '').trim();
const ids = new Set(opts.map((o) => o.value));
@@ -875,14 +799,10 @@ export default {
selectedPayload.country_fetch_ids != null
? selectedPayload.country_fetch_ids
: selectedPayload.country_ids != null
? selectedPayload.country_ids
: '';
? selectedPayload.country_ids
: '';
if (typeof raw === 'string' && raw.trim()) {
return raw
.split(',')
.map((s) => s.trim())
.filter(Boolean)
.map(String);
return raw.split(',').map((s) => s.trim()).filter(Boolean).map(String);
}
return [];
},
@@ -905,7 +825,7 @@ export default {
let availableArr = this.findArray(availablePayload);
if (!availableArr) availableArr = Array.isArray(availablePayload) ? availablePayload : [];
this.availableFields = availableArr.map((item, idx) => {
const id = item.expert_fetch_id || item.fetch_id || item.id || item.field_id || idx + 1;
const id = item.expert_fetch_id || item.fetch_id || item.id || item.field_id || (idx + 1);
const label = item.field || item.title || item.name || item.label || String(id);
return { id: String(id), label };
});
@@ -978,10 +898,10 @@ export default {
matched.promotion_factory_id != null
? String(matched.promotion_factory_id)
: matched.id != null
? String(matched.id)
: matched.task_id != null
? String(matched.task_id)
: '';
? String(matched.id)
: matched.task_id != null
? String(matched.task_id)
: '';
}
}
// promotion_factory/getDetail 必须使用地址栏 promotion_factory_id避免列表首行 id 与路由不一致
@@ -1128,7 +1048,11 @@ export default {
const runAt = item.run_at || item.run_time || item.plan_time || item.execute_time || item.send_date || '';
const state = String(item.state != null ? item.state : '');
const promotionFactoryId =
item.promotion_factory_id != null ? item.promotion_factory_id : item.id != null ? item.id : item.task_id;
item.promotion_factory_id != null
? item.promotion_factory_id
: item.id != null
? item.id
: item.task_id;
return {
id: item.id || item.task_id || `task_${idx + 1}`,
promotion_factory_id: promotionFactoryId != null ? String(promotionFactoryId) : '',
@@ -1282,16 +1206,16 @@ export default {
return Object.prototype.hasOwnProperty.call(stateTextMap, key) ? stateTextMap[key] : '-';
},
getTaskStatusClass(state) {
const stateClassMap = {
0: 'status-draft', // Draft - 浅灰色
5: 'status-preparing', // Preparing - 橘色
1: 'status-running', // Running - 深蓝色
2: 'status-paused', // Paused - 深灰色
3: 'status-completed', // Completed - 绿色
4: 'status-cancelled' // Cancelled - 浅红色
};
return stateClassMap[Number(state)] || '';
}
const stateClassMap = {
0: 'status-draft', // Draft - 浅灰色
5: 'status-preparing', // Preparing - 橘色
1: 'status-running', // Running - 深蓝色
2: 'status-paused', // Paused - 深灰色
3: 'status-completed', // Completed - 绿色
4: 'status-cancelled' // Cancelled - 浅红色
};
return stateClassMap[Number(state)] || '';
}
}
};
</script>
@@ -1305,13 +1229,11 @@ export default {
margin-bottom: 15px;
}
.config-bar {
width: 100%;
display: flex;
justify-content: space-between;
align-items: center;
}
.config-bar .left {
width: calc(100% - 100px);
display: flex;
flex-wrap: wrap;
align-items: center;
@@ -1836,96 +1758,96 @@ export default {
}
.filter-header-row {
display: flex;
align-items: center; /* 垂直居中对齐 */
gap: 16px; /* 胶囊和Search按钮之间的间距 */
margin-bottom: 16px;
background-color: transparent; /* 容器透明,不厚重 */
display: flex;
align-items: center; /* 垂直居中对齐 */
gap: 16px; /* 胶囊和Search按钮之间的间距 */
margin-bottom: 16px;
background-color: transparent; /* 容器透明,不厚重 */
}
/* 2. 彻底重置 el-tabs 的原生样式 (最丑的地方) */
.tmr-capsule-group {
flex: 1; /* 占据左侧空间 */
flex: 1; /* 占据左侧空间 */
}
/* 强制隐藏默认灰色横线和卡片灰边 */
.tmr-capsule-group .el-tabs__header {
margin: 0 !important;
border-bottom: none !important;
margin: 0 !important;
border-bottom: none !important;
}
.tmr-capsule-group .el-tabs__nav {
border: none !important;
border: none !important;
}
/* 3. 重新定义每个 Tab 的样式 (让其变成按钮) */
.tmr-capsule-group .el-tabs--card > .el-tabs__header .el-tabs__item {
height: 32px !important; /* 紧凑高度 */
line-height: 32px !important;
font-size: 13px; /* 紧凑字体 */
border: none !important; /* 彻底隐藏原生卡片边框 */
background-color: transparent; /* 默认状态下透明背景 */
color: #515a6e; /* 默认状态深灰文字,更专业 */
transition: all 0.2s ease-in-out;
padding: 0 16px !important; /* 适当内边距 */
margin-right: 8px; /* 每个 Tab 之间的间距 */
border-radius: 6px !important; /* 先统一圆角 */
overflow: visible; /* 确保选中的阴影显示完全 */
height: 32px !important; /* 紧凑高度 */
line-height: 32px !important;
font-size: 13px; /* 紧凑字体 */
border: none !important; /* 彻底隐藏原生卡片边框 */
background-color: transparent; /* 默认状态下透明背景 */
color: #515a6e; /* 默认状态深灰文字,更专业 */
transition: all 0.2s ease-in-out;
padding: 0 16px !important; /* 适当内边距 */
margin-right: 8px; /* 每个 Tab 之间的间距 */
border-radius: 6px !important; /* 先统一圆角 */
overflow: visible; /* 确保选中的阴影显示完全 */
}
/* 首尾 Tab 的圆角处理 (形成整体感) */
.tmr-capsule-group .el-tabs--card > .el-tabs__header .el-tabs__item:first-child {
border-top-left-radius: 6px;
border-bottom-left-radius: 6px;
border-top-left-radius: 6px;
border-bottom-left-radius: 6px;
}
.tmr-capsule-group .el-tabs--card > .el-tabs__header .el-tabs__item:last-child {
border-top-right-radius: 6px;
border-bottom-right-radius: 6px;
margin-right: 0;
border-top-right-radius: 6px;
border-bottom-right-radius: 6px;
margin-right: 0;
}
/* 中间 Tab 的处理 (去掉左右圆角,紧凑对齐) */
.tmr-capsule-group .el-tabs--card > .el-tabs__header .el-tabs__item:not(:first-child):not(:last-child) {
border-radius: 0;
border-radius: 0;
}
/* 4. **选中效果 (Active) - 胶囊浮动核心** */
.tmr-capsule-group .el-tabs--card > .el-tabs__header .el-tabs__item.is-active {
background-color: #ffffff !important; /* 白色底色 */
color: #409eff !important; /* 主题蓝色文字 */
font-weight: 500;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important; /* **关键:增加轻微阴影,浮动感** */
border-radius: 6px; /* 选中时恢复圆角 */
position: relative;
z-index: 2; /* 确保选中态在最前面,不被覆盖线破坏 */
background-color: #ffffff !important; /* 白色底色 */
color: #409eff !important; /* 主题蓝色文字 */
font-weight: 500;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important; /* **关键:增加轻微阴影,浮动感** */
border-radius: 6px; /* 选中时恢复圆角 */
position: relative;
z-index: 2; /* 确保选中态在最前面,不被覆盖线破坏 */
}
/* 5. 处理 Tab 之间的断层 (像素级微调) */
.tmr-capsule-group .el-tabs--card > .el-tabs__header .el-tabs__item {
position: relative;
position: relative;
}
/* 首尾 Tab 之间的像素级处理 */
.tmr-capsule-group .el-tabs--card > .el-tabs__header .el-tabs__item:not(:last-child)::after {
content: '';
position: absolute;
right: -5px; /* 让 Tab 之间紧密无缝 */
top: 0;
height: 100%;
width: 1px;
background: transparent; /* 移除灰线,不丑 */
content: '';
position: absolute;
right: -5px; /* 让 Tab 之间紧密无缝 */
top: 0;
height: 100%;
width: 1px;
background: transparent; /* 移除灰线,不丑 */
}
/* 6. 搜索按钮对齐微调 */
.filter-actions .el-button {
height: 32px; /* 与 Tab 高度一致 */
padding: 0 16px;
border-radius: 6px;
transition: all 0.2s;
height: 32px; /* 与 Tab 高度一致 */
padding: 0 16px;
border-radius: 6px;
transition: all 0.2s;
}
.filter-actions {
margin-left: auto;
margin-left: auto;
}
/* 基础 Badge 样式 */
.status-badge {
@@ -1972,25 +1894,21 @@ export default {
background-color: #f1f5f9;
color: #64748b;
}
.status-draft::before {
background-color: #94a3b8;
}
.status-draft::before { background-color: #94a3b8; }
/* 5: Preparing - 橘色 */
.status-preparing {
background-color: #fff7ed;
color: #c2410c;
}
.status-preparing::before {
background-color: #f97316;
}
.status-preparing::before { background-color: #f97316; }
/* 1: Running - 深蓝色 */
.status-running {
background-color: #eff6ff;
color: #1d4ed8;
}
.status-running::before {
.status-running::before {
background-color: #3b82f6;
box-shadow: 0 0 4px rgba(59, 130, 246, 0.5); /* 模拟运行中的发光感 */
}
@@ -2001,104 +1919,19 @@ export default {
color: #334155;
border: 1px solid #e2e8f0; /* 停用状态加个微边框增加分量感 */
}
.status-paused::before {
background-color: #475569;
}
.status-paused::before { background-color: #475569; }
/* 3: Completed - 绿色 */
.status-completed {
background-color: #f0fdf4;
color: #15803d;
}
.status-completed::before {
background-color: #22c55e;
}
.status-completed::before { background-color: #22c55e; }
/* 4: Cancelled - 浅红色 */
.status-cancelled {
background-color: #fef2f2;
color: #b91c1c;
}
.status-cancelled::before {
background-color: #ef4444;
}
/* 基础 Select 宽度 */
.custom-pipeline-select {
width: 580px;
}
/* 分组标题el-option-group避免在 ul 内放 div */
.pipeline-popper .el-select-group__title {
padding: 10px 20px;
font-size: 12px;
font-weight: bold;
color: #909399;
letter-spacing: 1px;
border-bottom: 1px solid #f0f2f5;
line-height: 1.2;
}
/* 单个选项容器 */
.pipeline-popper .el-select-dropdown__item {
height: auto; /* 允许高度自适应 */
padding: 12px 20px;
line-height: normal;
border-left: 3px solid transparent; /* 预留边框位置防止抖动 */
}
/* 选中状态 */
.pipeline-popper .el-select-dropdown__item.selected {
background-color: #f5f7fa;
border-left: 3px solid #409eff; /* 选中时的左侧蓝条 */
color: #606266; /* 覆盖 Element 默认高亮色 */
}
/* 选项内容布局 */
.pipeline-popper .option-content {
display: flex;
flex-direction: column;
gap: 6px;
}
/* 第一行:标题 + 状态标签 */
.pipeline-popper .option-content .row-top {
display: flex;
justify-content: space-between;
align-items: center;
}
.pipeline-popper .option-content .row-top .task-title {
font-weight: 600;
color: #303133;
font-size: 14px;
}
.pipeline-popper .option-content .row-top .status-tag {
border-radius: 12px;
padding: 0 8px;
height: 20px;
line-height: 18px;
}
/* 第二行:元数据信息 */
.pipeline-popper .option-content .row-bottom {
display: flex;
align-items: center;
font-size: 11px;
color: #909399;
}
.pipeline-popper .option-content .row-bottom .meta-item.database {
color: #5856d6;
font-weight: bold;
/* text-transform: uppercase; */
}
.pipeline-popper .option-content .row-bottom .separator {
margin: 0 6px;
color: #dcdfe6;
}
.status-cancelled::before { background-color: #ef4444; }
</style>

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,17 @@
<template>
<div class="tinymce-container editor-container">
<textarea class="tinymce-textarea" :id="tinymceId"></textarea>
<div class="tinymce-editor-surface">
<textarea class="tinymce-textarea" :id="tinymceId"></textarea>
</div>
<div
v-if="showRefButton && hasReferencesForAutoLink"
ref="autoLinkFooterWrap"
class="tinymce-autolink-footer"
>
<span @click="handleAutoLinkRefsClick" style="cursor: pointer;color: #409eff;font: 12px;font-weight: 700;">
<i class="el-icon-link"></i> {{ $t('wordCite.matchBracketRefs') }}
</span>
</div>
</div>
</template>
<script>
@@ -63,6 +74,107 @@ export default {
},
articleId: {
default: ''
},
chanFerForm: {
type: Array,
default: () => []
},
/** 由父级根据全文(稿面 + Edit Content 草稿合并)扫描得到,与 word.vue citeMap 一致 */
bodyCiteIdOrder: {
type: Array,
default: () => []
},
/** mytable(data-id) -> 该表内已出现引用的最大全局序号(由父组件计算) */
tableLinkCiteMaxMap: {
type: Object,
default: () => ({})
},
/** 为 false 时不显示 Ref 工具栏按钮,也不自动在 LateX 后注入 insertRef用于图表标题等 */
showRefButton: {
type: Boolean,
default: true
},
/**
* true仅「表格单元格编辑」场景角标/自动匹配 [n] 按 old_index+1或 order_index
* false与稿面一致始终用 bodyCiteIdOrder 的 citeMapEdit Content 等虽 type=table 放宽标签,也必须 false
*/
useTableLocalCitationIndex: {
type: Boolean,
default: false
}
},
computed: {
/** 是否启用表格局部序号(与全文 citeMap 互斥) */
tableLocalCiteActive() {
if (this.type !== 'table' || !this.useTableLocalCitationIndex) return false;
return Object.keys(this.tableBracketNumToRefIdMap || {}).length > 0;
},
citeMap() {
const refs = Array.isArray(this.chanFerForm) ? this.chanFerForm : [];
const refIdSet = new Set(
refs.map((r) => (r && r.p_refer_id != null ? String(r.p_refer_id) : '')).filter(Boolean)
);
if (!Array.isArray(this.bodyCiteIdOrder) || this.bodyCiteIdOrder.length === 0) {
const map = {};
refs.forEach((row, idx) => {
const key = row && row.p_refer_id != null ? String(row.p_refer_id) : '';
if (key) map[key] = idx + 1;
});
return map;
}
const orderedIds = this.bodyCiteIdOrder.map(String);
const filtered = [];
orderedIds.forEach((id) => {
if (refIdSet.has(id) && !filtered.includes(id)) filtered.push(id);
});
const map = {};
filtered.forEach((id, idx) => {
map[id] = idx + 1;
});
let next = filtered.length + 1;
refs.forEach((r) => {
const key = r && r.p_refer_id != null ? String(r.p_refer_id) : '';
if (!key || map[key] != null) return;
map[key] = next++;
});
return map;
},
/** 有参考文献列表时才显示「自动链接」:与 insertRef 一致,依赖 chanFerForm 中有效 p_refer_id */
hasReferencesForAutoLink() {
const refs = Array.isArray(this.chanFerForm) ? this.chanFerForm : [];
return refs.some((r) => r && r.p_refer_id != null && String(r.p_refer_id).trim() !== '');
},
/**
* 表格编辑器专用:单元格 [n] 中的 n → p_refer_id。
* - 有 old_index0 起n = old_index + 1
* - 仅有 order_index 时:按接口约定已为与 [n] 一致的序号n = order_index不再 +1
*/
tableBracketNumToRefIdMap() {
const refs = Array.isArray(this.chanFerForm) ? this.chanFerForm : [];
const map = {};
refs.forEach((r) => {
if (!r || r.p_refer_id == null) return;
const n = this._getTableBracketNoForRow(r);
if (n == null) return;
map[n] = String(r.p_refer_id);
});
return map;
},
/** p_refer_id → 表格角标数字 n与 [n] 一致) */
tableRefIdToBracketNum() {
const refs = Array.isArray(this.chanFerForm) ? this.chanFerForm : [];
const m = {};
refs.forEach((r) => {
if (!r || r.p_refer_id == null) return;
const n = this._getTableBracketNoForRow(r);
if (n == null) return;
m[String(r.p_refer_id)] = n;
});
return m;
}
},
data() {
@@ -124,22 +236,52 @@ export default {
hasChange: false,
hasInit: false,
editorInstance: null,
tinymceId: this.id || 'vue-tinymce-' + +new Date()
tinymceId: this.id || 'vue-tinymce-' + +new Date(),
/** 将底部栏移入 TinyMCE 容器前,记录原 DOM 位置以便销毁时移回 */
_autoLinkFooterRestore: null
};
},
watch: {
value: {
handler(val) {
if (!this.hasChange && this.hasInit) {
if (!this.hasChange && this.hasInit) {
this.$nextTick(() => {
this.handleSetContent(val);
});
}
},
immediate: true
},
chanFerForm: {
handler() {
this.$nextTick(() => {
window.tinymce.get(this.tinymceId).setContent(val);
if (this.editorInstance) {
this.renderAutociteInEditor(this.editorInstance);
}
});
},
deep: true
},
bodyCiteIdOrder: {
handler() {
this.$nextTick(() => {
if (this.editorInstance) {
this.renderAutociteInEditor(this.editorInstance);
}
});
},
deep: true
},
hasReferencesForAutoLink(val) {
if (!val) {
this.restoreAutoLinkFooterDom();
return;
}
if (this.showRefButton && this.editorInstance) {
this.$nextTick(() => {
this.mountAutoLinkFooterInsideEditor(this.editorInstance);
});
}
},
immediate: true
}
},
mounted() {
@@ -163,10 +305,526 @@ export default {
this.destroyTinymce();
},
methods: {
parseAutociteDataIds(attr) {
if (!attr || typeof attr !== 'string') return [];
return attr
.split(',')
.map((s) => s.trim())
.filter(Boolean);
},
/**
* 与正文 [n] 一致的角标数字 n。old_index 为 0 起 → n=old_index+1无 old_index 时用 order_index已为 n.
*/
_getTableBracketNoForRow(r) {
if (!r) return null;
const pick = (v) => {
if (v == null || v === '') return null;
const x = Number(v);
return Number.isNaN(x) ? null : x;
};
const oi =
r.old_index != null && r.old_index !== ''
? pick(r.old_index)
: pick(r.oldIndex);
if (oi != null) return oi + 1;
const ord =
r.order_index != null && r.order_index !== ''
? pick(r.order_index)
: pick(r.orderIndex);
return ord;
},
/** 与 word.vue renderCiteLabels合并角标 id 按 citeMap 序号排序 */
sortAutociteIdsByCiteNumber(ids) {
const uniq = [...new Set(ids.map(String))];
const map = this.citeMap || {};
return uniq.sort((a, b) => {
const na = map[a];
const nb = map[b];
const ha = na != null && na !== '';
const hb = nb != null && nb !== '';
if (ha && hb) return Number(na) - Number(nb);
if (ha) return -1;
if (hb) return 1;
return String(a).localeCompare(String(b));
});
},
/** 同 word.vue多 id 均在列表中时对全局序号做 13 区间合并 */
formatCiteNumbers(nums) {
if (!nums || !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(', ');
},
/** 全局角标序号 n → p_refer_id用于将正文中的 [n] 转为 mycite */
buildNumToRefIdMap() {
const citeMap = this.citeMap || {};
const map = {};
Object.keys(citeMap).forEach((id) => {
const n = citeMap[id];
if (n != null && n !== '' && !Number.isNaN(Number(n))) {
map[Number(n)] = String(id);
}
});
return map;
},
/** 自动匹配 [n]:表格内用 old_index+1 或 order_index(=n)mytable 之后段落仍用全局 citeMap */
_getBracketNumToIdMaps() {
const globalMap = this.buildNumToRefIdMap();
if (this.type !== 'table' || !this.useTableLocalCitationIndex) {
return { primary: globalMap, afterTable: globalMap };
}
const tm = this.tableBracketNumToRefIdMap || {};
const has = Object.keys(tm).length > 0;
return {
primary: has ? tm : globalMap,
afterTable: globalMap
};
},
sortAutociteIdsByTableBracketNumber(ids) {
const uniq = [...new Set(ids.map(String))];
const numById = this.tableRefIdToBracketNum || {};
return uniq.sort((a, b) => {
const na = numById[a];
const nb = numById[b];
const ha = na != null && na !== '' && !Number.isNaN(Number(na));
const hb = nb != null && nb !== '' && !Number.isNaN(Number(nb));
if (ha && hb) return Number(na) - Number(nb);
if (ha) return -1;
if (hb) return 1;
return String(a).localeCompare(String(b));
});
},
_sortAutociteIdsForDisplay(ids) {
if (this.tableLocalCiteActive) {
return this.sortAutociteIdsByTableBracketNumber(ids);
}
return this.sortAutociteIdsByCiteNumber(ids);
},
_sortIdsAfterBracketMatch(ids, tableOffset) {
if (this.tableLocalCiteActive && tableOffset === 0) {
return this.sortAutociteIdsByTableBracketNumber(ids);
}
return this.sortAutociteIdsByCiteNumber(ids);
},
/** 解析 [1]、[1,2]、[14]、[1, 23, 4] 等括号内数字列表(不含方括号) */
parseBracketInnerToNumbers(inner) {
if (!inner || typeof inner !== 'string') return [];
const t = inner.trim().replace(//g, ',');
// 先按逗号拆段,再对每段解析单号或区间;避免 parseInt('41-42') 只得到 41
if (/[,]/.test(t)) {
const parts = t.split(/[,]/).map((s) => String(s).trim()).filter(Boolean);
const out = [];
parts.forEach((part) => {
out.push(...this.parseBracketInnerToNumbers(part));
});
return out;
}
const range = t.match(/^(\d+)\s*[-–—]\s*(\d+)$/);
if (range) {
const a = Number(range[1]);
const b = Number(range[2]);
if (Number.isNaN(a) || Number.isNaN(b)) return [];
const lo = Math.min(a, b);
const hi = Math.max(a, b);
const out = [];
for (let i = lo; i <= hi; i++) out.push(i);
return out;
}
const n = parseInt(t, 10);
return Number.isNaN(n) ? [] : [n];
},
/**
* 将编辑器内纯文本形式的 [1]、[13]、[1, 2] 按当前 citeMap 转为 <mycite>(跳过已有 mycite/wmath 内文字)
* @returns {{ replaced: number }}
*/
convertPlainBracketCitesToAutocite() {
const ed = this.editorInstance;
if (!ed) return { replaced: 0 };
const refs = Array.isArray(this.chanFerForm) ? this.chanFerForm : [];
if (!refs.length) {
this.$message.warning(this.$t('wordCite.noRefs'));
return { replaced: 0 };
}
const maps = this._getBracketNumToIdMaps();
if (Object.keys(maps.primary).length === 0) {
this.$message.warning(this.$t('wordCite.noRefs'));
return { replaced: 0 };
}
const doc = ed.getDoc();
const body = ed.getBody();
if (!body) return { replaced: 0 };
let replaced = 0;
ed.undoManager.transact(() => {
// 先把被拆成多个 span 的 [13, 16, 2123] 规整成单段文本,再做自动匹配
this.normalizeSplitBracketCitesInTableCells(body);
replaced = this._replaceBracketCitesInDocOrder(body, doc, maps, { tableOffset: 0 });
});
this.renderAutociteInEditor(ed);
ed.fire('change');
return { replaced };
},
/**
* TinyMCE/粘贴可能把单元格里的 [1, 23] 拆成多个内联节点span/text 混排),
* 导致按文本节点匹配的自动链接无法命中。这里在匹配前把该类节点规整回纯文本。
*/
normalizeSplitBracketCitesInTableCells(root) {
if (!root || !root.querySelectorAll) return;
const cells = root.querySelectorAll('td, th');
cells.forEach((cell) => {
if (!cell || !cell.querySelectorAll) return;
if (cell.querySelector('mycite, autocite, wmath')) return;
if (!cell.querySelector('span')) return;
const raw = (cell.textContent || '').replace(/\u200b/g, '');
const compact = raw.replace(/\s+/g, ' ').trim();
if (!/^\[[\d\s,\-–—]+\]$/.test(compact)) return;
cell.textContent = compact;
});
},
/** 底部「自动链接参考文献」按钮,与原先工具栏 autoLinkRefs 行为一致 */
handleAutoLinkRefsClick() {
const r = this.convertPlainBracketCitesToAutocite();
if (!r) return;
if (r.replaced > 0) {
this.$message.success(this.$t('wordCite.matchBracketRefsDone', { n: r.replaced }));
return;
}
const refs = Array.isArray(this.chanFerForm) ? this.chanFerForm : [];
const maps = this._getBracketNumToIdMaps();
if (refs.length && Object.keys(maps.primary).length) {
this.$message.info(this.$t('wordCite.matchBracketRefsNone'));
}
},
/** 把「自动链接」栏挂到 TinyMCE 外壳 .tox-tinymce 内部底部,与工具栏/编辑区同一外框 */
mountAutoLinkFooterInsideEditor(ed) {
if (!this.showRefButton || !this.hasReferencesForAutoLink) return;
this.$nextTick(() => {
const el = this.$refs.autoLinkFooterWrap;
if (!el || !ed) return;
const container = ed.getContainer && ed.getContainer();
if (!container) return;
if (el.parentNode === container) return;
this._autoLinkFooterRestore = {
parent: el.parentNode,
next: el.nextSibling
};
container.appendChild(el);
});
},
/** 销毁编辑器前必须移回,否则节点会随 .tox-tinymce 一起被移除 */
restoreAutoLinkFooterDom() {
const el = this.$refs.autoLinkFooterWrap;
const r = this._autoLinkFooterRestore;
this._autoLinkFooterRestore = null;
if (!el || !r || !r.parent) return;
try {
if (r.next && r.next.parentNode === r.parent) {
r.parent.insertBefore(el, r.next);
} else {
r.parent.appendChild(el);
}
} catch (e) {
/* ignore */
}
},
/**
* 按文档顺序遍历,使「表格链接」后任意后续段落里的 [n] 都能用上该表的最大全局序号偏移。
* 旧实现只在同一父节点下、MYTABLE 与后续文本为兄弟时才生效MYTABLE 在上一段、角标在下一段时会失效。
*/
_replaceBracketCitesInDocOrder(node, doc, maps, state) {
if (node.nodeType === 3) {
return this._processTextNodeForBracketCites(node, doc, maps, state.tableOffset);
}
if (node.nodeType !== 1) return 0;
const name = node.nodeName;
if (name === 'AUTOCITE' || name === 'MYCITE' || name === 'WMATH' || name === 'SCRIPT' || name === 'STYLE') {
return 0;
}
const isMytable = name === 'MYTABLE' || (node.tagName && String(node.tagName).toLowerCase() === 'mytable');
if (isMytable) {
let total = 0;
Array.from(node.childNodes).forEach((c) => {
total += this._replaceBracketCitesInDocOrder(c, doc, maps, state);
});
const tid = (node.getAttribute && node.getAttribute('data-id')) || '';
const map = this.tableLinkCiteMaxMap || {};
const tableMax = Number(map[String(tid)]);
if (!Number.isNaN(tableMax) && tableMax > 0) {
state.tableOffset = tableMax;
}
return total;
}
let total = 0;
Array.from(node.childNodes).forEach((c) => {
total += this._replaceBracketCitesInDocOrder(c, doc, maps, state);
});
return total;
},
_processTextNodeForBracketCites(textNode, doc, maps, tableOffset = 0) {
const numToId = tableOffset > 0 ? maps.afterTable : maps.primary;
const text = textNode.textContent;
const re = /\[([\d\s,\-–—]+)\]/g;
let m;
let lastIndex = 0;
const pieces = [];
let replaced = 0;
let skippedSpecial = 0;
while ((m = re.exec(text)) !== null) {
const rawNums = this.parseBracketInnerToNumbers(m[1]);
// 仅 [0]、[-1]、[0, -1] 等「全是 0/-1」不转换与正常号混写时去掉 0/-1 再匹配
const onlyZeroOrNegOne =
rawNums.length > 0 && rawNums.every((n) => n === 0 || n === -1);
if (onlyZeroOrNegOne) {
pieces.push({ type: 'text', s: text.slice(lastIndex, m.index) });
pieces.push({ type: 'text', s: m[0] });
lastIndex = m.index + m[0].length;
skippedSpecial++;
continue;
}
const nums = rawNums.filter((n) => n !== 0 && n !== -1);
const mapNo = (n) => (n > 0 && tableOffset > 0 ? n + tableOffset - 1 : n);
if (!nums.length) {
pieces.push({ type: 'text', s: text.slice(lastIndex, m.index) });
pieces.push({ type: 'text', s: m[0] });
lastIndex = m.index + m[0].length;
continue;
}
const validNums = nums.filter((n) => numToId[mapNo(n)]);
const invalidNums = nums.filter((n) => !numToId[mapNo(n)]);
if (validNums.length === 0) {
pieces.push({ type: 'text', s: text.slice(lastIndex, m.index) });
pieces.push({ type: 'text', s: m[0] });
lastIndex = m.index + m[0].length;
continue;
}
const ids = [];
const seen = new Set();
validNums.forEach((n) => {
const mappedNo = mapNo(n);
const id = numToId[mappedNo];
if (id && !seen.has(id)) {
seen.add(id);
ids.push(id);
}
});
pieces.push({ type: 'text', s: text.slice(lastIndex, m.index) });
if (ids.length > 0) {
const sorted = this._sortIdsAfterBracketMatch(ids, tableOffset);
pieces.push({ type: 'cite', ids: sorted });
if (invalidNums.length) {
const invSorted = [...new Set(invalidNums)].sort((a, b) => a - b);
const invLabel = this.formatCiteNumbers(invSorted);
if (invLabel) {
pieces.push({ type: 'text', s: ', [' + invLabel + ']' });
}
}
replaced++;
} else {
pieces.push({ type: 'text', s: m[0] });
}
lastIndex = m.index + m[0].length;
}
if (replaced === 0) return 0;
pieces.push({ type: 'text', s: text.slice(lastIndex) });
const parent = textNode.parentNode;
if (!parent) return 0;
const frag = doc.createDocumentFragment();
pieces.forEach((p) => {
if (p.type === 'text') {
frag.appendChild(doc.createTextNode(p.s));
} else {
const ac = doc.createElement('mycite');
ac.setAttribute('data-id', p.ids.join(','));
ac.setAttribute('contenteditable', 'false');
ac.appendChild(doc.createTextNode('\u200b'));
frag.appendChild(ac);
}
});
parent.replaceChild(frag, textNode);
if (skippedSpecial > 0) {
// 提示:仅提示一次即可;这里在节点级别提示可能重复,放到宏任务末尾合并展示
clearTimeout(this._autoLinkSkipToastTimer);
this._autoLinkSkipToastTimer = setTimeout(() => {
this.$message.info(`Skipped ${skippedSpecial} bracket cite(s) containing only 0 or -1.`);
}, 0);
}
return replaced;
},
renderAutociteInEditor(ed) {
const body = ed.getBody();
if (!body) return;
const allAutocites = Array.from(
ed.dom && typeof ed.dom.select === 'function'
? ed.dom.select('mycite,autocite', body)
: body.querySelectorAll('mycite, autocite')
);
if (!allAutocites.length) return;
const refs = Array.isArray(this.chanFerForm) ? this.chanFerForm : [];
const refMap = {};
refs.forEach((item) => {
const key = item && item.p_refer_id != null ? String(item.p_refer_id) : '';
if (key) refMap[key] = item;
});
const citeMap = this.citeMap || {};
const tableNums = this.tableRefIdToBracketNum || {};
const useTableBracketNums = this.tableLocalCiteActive;
allAutocites.forEach((el) => {
ed.dom.setAttrib(el, 'contenteditable', 'false');
el.style.display = '';
const sortedAll = this._sortAutociteIdsForDisplay(this.parseAutociteDataIds(el.getAttribute('data-id')));
const validIds = sortedAll.filter((id) => refMap[String(id)]);
if (validIds.length < sortedAll.length) {
ed.dom.setAttrib(el, 'data-id', validIds.length ? validIds.join(',') : '');
}
const sortedIds = validIds.length ? this._sortAutociteIdsForDisplay(validIds) : [];
const parts = sortedIds.map((id) => {
const ref = refMap[String(id)];
const noCite = ref ? citeMap[String(id)] : null;
const noTable =
useTableBracketNums && tableNums[String(id)] != null ? tableNums[String(id)] : null;
// 单元格内 [n] 按 Original ordertable 序号)匹配;角标展示与正文一致,优先用 citeMap 对应序号
const num =
noCite != null && noCite !== '' && !Number.isNaN(Number(noCite))
? String(noCite)
: noTable != null && noTable !== '' && !Number.isNaN(Number(noTable))
? String(noTable)
: null;
return { id, ref, num };
});
const numsForLabel = parts
.map((p) => p.num)
.filter((n) => n != null && n !== '')
.map(Number);
const label = numsForLabel.length > 0 ? this.formatCiteNumbers(numsForLabel) : '';
if (!label) {
ed.dom.remove(el);
return;
}
el.textContent = `[${label}]`;
el.style.display = '';
if (el.removeAttribute) el.removeAttribute('title');
ed.dom.setAttrib(el, 'data-cite-missing', null);
if (String(el.tagName || '').toLowerCase() === 'autocite') {
const doc = ed.getDoc();
const nu = doc.createElement('mycite');
nu.setAttribute('data-id', el.getAttribute('data-id') || '');
nu.setAttribute('contenteditable', 'false');
const st = el.getAttribute('style');
if (st) nu.setAttribute('style', st);
nu.textContent = el.textContent;
el.parentNode.replaceChild(nu, el);
}
});
this.padAutociteCaretPlaceholder(ed);
},
/** 段尾不可编辑节点后浏览器/TinyMCE 容易把后续输入新开 <p>,在引用后补零宽空格让光标留在同一段 */
padAutociteCaretPlaceholder(ed) {
const doc = ed.getDoc();
const body = doc.body;
if (!body) return;
body.querySelectorAll('mycite, autocite').forEach((el) => {
const next = el.nextSibling;
if (next === null) {
el.parentNode.appendChild(doc.createTextNode('\u200b'));
return;
}
if (next.nodeType === 3) {
if (next.textContent === '\u200b') return;
if (next.textContent === '') {
next.textContent = '\u200b';
}
}
});
},
insertAutocite(refIds) {
const ed = this.editorInstance;
if (!ed) return;
const ids = (Array.isArray(refIds) ? refIds : [refIds]).map(String);
const dataId = ids.join(',');
const escaped = dataId.replace(/"/g, '&quot;');
if (this._editingAutocite) {
this._editingAutocite.setAttribute('data-id', dataId);
this._editingAutocite = null;
ed.fire('change');
} else {
if (this._refBookmark) {
ed.selection.moveToBookmark(this._refBookmark);
}
ed.insertContent(`<mycite data-id="${escaped}" contenteditable="false"></mycite>&#8203;`);
}
this.renderAutociteInEditor(ed);
},
removeAutocite() {
const ed = this.editorInstance;
if (!ed || !this._editingAutocite) return;
ed.dom.remove(this._editingAutocite);
this._editingAutocite = null;
ed.fire('change');
},
/**
* 从当前编辑的 mycite 中去掉指定 p_refer_id去掉后无 id 则删除整段标签。
* ids 为空:删除整段(与 removeAutocite 一致)。
*/
stripAutociteIds(idsToRemove) {
const ed = this.editorInstance;
if (!ed || !this._editingAutocite) return;
const remove = new Set((idsToRemove || []).map((id) => String(id)));
const el = this._editingAutocite;
this._editingAutocite = null;
if (remove.size === 0) {
ed.dom.remove(el);
ed.fire('change');
return;
}
const parts = this.parseAutociteDataIds(el.getAttribute('data-id') || '');
const remaining = parts.filter((id) => !remove.has(String(id)));
if (remaining.length === 0) {
ed.dom.remove(el);
} else {
const sorted = this.sortAutociteIdsByCiteNumber(remaining);
el.setAttribute('data-id', sorted.join(','));
this.renderAutociteInEditor(ed);
}
ed.fire('change');
},
/** TinyMCE 会剔除「空」的行内标签;空 mycite 必须在入编辑器前占位,否则合并引用 [13] 等整段消失 */
normalizeAutociteHtmlForEditor(html) {
if (!html || typeof html !== 'string') return html;
// 历史库/表格里可能为 <autocite>,与 mycite 统一,否则 renderAutociteInEditor 扫不到、无效 id 会残留
let out = html.replace(/<\/autocite>/gi, '</mycite>').replace(/<autocite\b/gi, '<mycite');
/** 角标显示一律由 renderAutociteInEditor 根据 data-id 生成,禁止保留库内遗留的 [1-4]、[14] 等旧文案 */
out = out.replace(/<mycite([^>]*)>[\s\S]*?<\/mycite>/gi, '<mycite$1>&#8203;</mycite>');
// 外侧:连续空格 / &nbsp; 合并为单个 &nbsp;,避免「普通空格 + &nbsp;」叠成大缝
out = out.replace(/(?:\s|&nbsp;|&#160;)+(?=<mycite\b)/gi, '&nbsp;');
out = out.replace(/(?<=<\/mycite>)(?:\s|&nbsp;|&#160;)+/gi, '&nbsp;');
return out;
},
handleSetContent(val) {
if (!this.editorInstance) return;
let finalContent = val || '';
let finalContent = this.normalizeAutociteHtmlForEditor(val || '');
// 你的业务逻辑:自动包裹 <p> 标签
if (!finalContent.includes('wordTableHtml') && !finalContent.startsWith('<p>')) {
finalContent = '<p>' + finalContent + '</p>';
@@ -174,8 +832,11 @@ export default {
this.editorInstance.setContent(finalContent);
// 渲染数学公式
// SetContent 回调里会 renderAutociteInEditor再补一次 nextTick避免时序下仍显示库内旧 [1-4]
this.$nextTick(() => {
if (this.editorInstance) {
this.renderAutociteInEditor(this.editorInstance);
}
if (window.renderMathJax) {
window.renderMathJax(this.tinymceId);
}
@@ -320,7 +981,10 @@ export default {
},
getDetail(val) {
if (this.hasInit == true) {
this.$nextTick(() => window.tinymce.get(this.tinymceId).setContent(val));
this.$nextTick(() => {
const ed = window.tinymce.get(this.tinymceId);
if (ed) ed.setContent(this.normalizeAutociteHtmlForEditor(val || ''));
});
}
},
//将字符串添加到富文本编辑器中
@@ -431,7 +1095,7 @@ export default {
return new Blob([u8arr], { type: mime });
},
formatHtml(val) {
const rawValue = val || ''; // 处理 null
const rawValue = this.normalizeAutociteHtmlForEditor(val || ''); // 须先于 cleanEmptyTags否则空 mycite 被删
const cleanEmptyTags = /<([a-zA-Z1-6]+)\b[^>]*><\/\1>/g;
const replaceSpaces = /\s+(?=<)|(?<=>)\s+/g;
const removeBr = /<br\s*\/?>/gi; // 移除所有 br 标签
@@ -456,7 +1120,7 @@ export default {
}
},
getSafeContent(val) {
const rawValue = val || '';
const rawValue = this.normalizeAutociteHtmlForEditor(val || '');
const cleanEmptyTags = /<([a-zA-Z1-6]+)\b[^>]*><\/\1>/g;
const replaceSpaces = /\s+(?=<)|(?<=>)\s+/g;
@@ -497,9 +1161,10 @@ export default {
window.tinymce.init({
..._this.tinymceOtherInit,
trim_span_elements: false, // 禁止修剪内联标签周围的空格
extended_valid_elements: 'blue[*]',
custom_elements: 'blue',
valid_children: '+blue[#text|i|em|b|strong|span],+body[blue],+p[blue]',
extended_valid_elements: 'blue[*],mycite[*]',
/* ~ 前缀:按行内(类似 span处理否则默认当块级会拆段导致引用后强制换行 */
custom_elements: 'blue,~mycite',
valid_children: '+blue[#text|i|em|b|strong|span],+body[blue|mycite],+p[blue|mycite]',
inline: false, // 使用 iframe 模式
selector: `#${this.tinymceId}`,
@@ -509,7 +1174,7 @@ export default {
valid_elements:
this.type == 'table'
? '*[*]'
: `img[src|alt|width|height],strong,em,sub,sup,blue,table,b,i,myfigure,mytable,wmath${this.valid_elements}`, // 允许的标签和属性
: `img[src|alt|width|height],strong,em,sub,sup,blue,table,b,i,myfigure,mytable,wmath,mycite[data-id|contenteditable|data-cite-missing|style]${this.valid_elements}`, // 允许的标签和属性mycite 不使用 title 悬停)
// valid_elements: '*[*]', // 允许所有 HTML 标签
noneditable_editable_class: 'MathJax',
height: this.height,
@@ -541,6 +1206,34 @@ export default {
font-weight: bold !important;
}
/* inline 与 blue 引用一致,避免 inline-block 在行尾产生多余换行感 */
mycite {
display: inline;
vertical-align: baseline;
color: rgb(0, 130, 170);
// font-weight: bold;
cursor: pointer;
padding: 0 2px;
border-radius: 3px;
background-color: rgba(0, 130, 170, 0.08);
user-select: all;
font-size: 12px;
white-space: nowrap;
}
mycite:hover {
background-color: rgba(0, 130, 170, 0.2);
text-shadow: 0 0 3px rgba(0, 130, 170, 0.3);
}
mycite[data-cite-missing] {
background-color: rgba(0, 130, 170, 0.08) !important;
color: rgb(0, 130, 170) !important;
text-shadow: 0 0 3px rgba(0, 130, 170, 0.3);
box-shadow: none !important;
}
mycite[data-cite-missing]:hover {
background-color: rgba(0, 130, 170, 0.2) !important;
}
@keyframes blueGlow {
0%,
100% {
@@ -559,7 +1252,37 @@ export default {
},
body_class: 'panel-body ',
object_resizing: false,
toolbar: this.toolbar.length > 0 ? this.toolbar : toolbar,
toolbar: (function () {
const tb = _this.toolbar;
const hasCustom =
(Array.isArray(tb) && tb.length > 0) ||
(typeof tb === 'string' && tb.length > 0);
const refInsert = _this.showRefButton ? ' insertRef' : '';
/* 自动匹配 [n] 为角标:底部蓝色按钮,见模板 tinymce-autolink-footer */
/* 与 content.vue 默认一致;含 insertRef 由 showRefButton 控制 */
const defaultToolbar = [
`bold italic |customBlue removeBlue|LateX${refInsert}| myuppercase myuppercasea Line MoreSymbols|subscript superscript|clearButton|searchreplace`
];
if (!hasCustom) return defaultToolbar;
const rows = Array.isArray(tb) ? tb : [tb];
return rows.map((row) => {
if (typeof row !== 'string') return row;
let out = row;
if (!_this.showRefButton) {
out = out
.replace(/\binsertRef\b/g, '')
.replace(/\bautoLinkRefs\b/g, '')
.replace(/\|\s*\|/g, '|')
.replace(/\|\s*$/g, '')
.replace(/^\s*\|/g, '');
} else if (out.indexOf('insertRef') === -1) {
out = out
.replace(/\|LateX\|/g, '|LateX insertRef|')
.replace(/\|\s*LateX\s*\|/g, '| LateX insertRef |');
}
return out;
});
})(),
menubar: false, // 启用菜单栏并保持必要的项目
statusbar: false, // 关闭底部状态栏
custom_colors: false,
@@ -626,7 +1349,27 @@ export default {
let currentPasteImages = [];
_this.$commonJS.initEditorButton(_this, ed);
var currentWmathElement = null;
ed.ui.registry.addButton('insertRef', {
text: 'Reference',
tooltip: 'Insert Reference',
onAction: function () {
_this._refBookmark = ed.selection.getBookmark(2);
_this._editingAutocite = null;
_this.$emit('openRefSelector', { currentRefIds: [] });
}
});
ed.on('click', function (e) {
const autociteEl = e.target.closest('mycite') || e.target.closest('autocite');
if (autociteEl) {
const dataIds = _this.parseAutociteDataIds(autociteEl.getAttribute('data-id'));
_this._refBookmark = ed.selection.getBookmark(2);
_this._editingAutocite = autociteEl;
_this.$emit('openRefSelector', { currentRefIds: dataIds });
return;
}
const wmathElement = e.target.closest('wmath');
if (wmathElement) {
currentWmathElement = wmathElement; // 保存当前点击的元素
@@ -757,6 +1500,8 @@ export default {
subtree: true,
characterData: true
});
_this.mountAutoLinkFooterInsideEditor(ed);
});
// 定义自定义按钮
@@ -791,14 +1536,20 @@ export default {
const editorBody = ed.getBody();
ed.dom.select('wmath', editorBody).forEach(function (wmathElement) {
ed.dom.setAttrib(wmathElement, 'contenteditable', 'false');
// ed.dom.addClass(wmathElement, 'non-editable-wmath');
});
_this.renderAutociteInEditor(ed);
e.content = e.content.replace(/<strong>/g, '<b>').replace(/<\/strong>/g, '</b>');
e.content = e.content.replace(/<em>/g, '<i>').replace(/<\/em>/g, '</i>');
});
ed.on('GetContent', function (e) {
e.content = e.content.replace(/<b>/g, '<strong>').replace(/<\/b>/g, '</strong>');
e.content = e.content.replace(/<i>/g, '<em>').replace(/<\/i>/g, '</em>');
e.content = e.content.replace(/<i>/g, '<em>').replace(/<\/em>/g, '</em>');
e.content = e.content.replace(/<\/mycite>\s*&#8203;/gi, '</mycite>');
e.content = e.content.replace(/<\/mycite>\s*\u200b/g, '</mycite>');
e.content = e.content.replace(/<mycite([^>]*)>[^<]*<\/mycite>/gi, function (match, attrs) {
var clean = attrs.replace(/\s*style="[^"]*"/gi, '').replace(/\s*title="[^"]*"/gi, '').replace(/\s*contenteditable="[^"]*"/gi, '');
return '<mycite' + clean + '></mycite>';
});
});
},
paste_preprocess: function (plugin, args) {
@@ -958,13 +1709,15 @@ export default {
//销毁富文本
destroyTinymce() {
this.onClear();
this.restoreAutoLinkFooterDom();
if (window.tinymce.get(this.tinymceId)) {
window.tinymce.get(this.tinymceId).destroy();
}
},
//设置内容
setContent(value) {
window.tinymce.get(this.tinymceId).setContent(value);
const ed = window.tinymce.get(this.tinymceId);
if (ed) ed.setContent(this.normalizeAutociteHtmlForEditor(value || ''));
},
//获取内容
async getContent(type) {
@@ -973,7 +1726,8 @@ export default {
content = content.replace(/<span[^>]*>/g, '').replace(/<\/span>/g, ''); // 去除span标签
content = content.replace(/<strong>/g, '<b>').replace(/<\/strong>/g, '</b>');
content = content.replace(/<em>/g, '<i>').replace(/<\/em>/g, '</i>');
content = content.replace(/&nbsp;/g, ' '); // 将所有 &nbsp; 替换为空格
content = content.replace(/&nbsp;/g, ' '); // 先统一为空格
content = this.normalizeAutociteHtmlForEditor(content); // mycite 两侧水平空白以 &nbsp; 存库(与入编辑器一致)
this.$emit('getContent', type, content);
},
@@ -1058,6 +1812,26 @@ export default {
};
</script>
<style scoped>
.tinymce-editor-surface {
width: 100%;
}
.tinymce-autolink-footer {
display: flex;
justify-content: flex-end;
align-items: center;
padding-top: 8px;
margin-top: 4px;
border-top: 1px solid #ebeef5;
}
/* 移入 .tox-tinymce 内部后:贴编辑区下沿、与编辑器同宽同框 */
::v-deep .tox-tinymce > .tinymce-autolink-footer {
margin-top: 0;
padding: 0px 10px;
box-sizing: border-box;
border-top: 1px solid #dcdfe6;
background: #fafafa;
flex-shrink: 0;
}
::v-deep .tox-tinymce-aux {
z-index: 9999 !important;
}

View File

@@ -59,22 +59,20 @@
<div class="drawer-body" v-loading="loading">
<div class="list-header">
<div class="col-index">{{ $t('autoPromotionLogs.logColIndex') }}</div>
<div class="col-info">{{ $t('autoPromotionLogs.logColExpert') }}</div>
<div class="col-send" style="font-size: 12px;">{{ $t('autoPromotionLogs.logColSendTime') }}</div>
<div class="col-prepared" style="font-size: 12px;">{{ $t('autoPromotionLogs.logColPreparedAt') }}</div>
<div class="col-status">{{ $t('autoPromotionLogs.logColStatus') }}</div>
<div class="col-action"></div>
<div class="col-action">{{ $t('autoPromotionLogs.logColAction') }}</div>
</div>
<div class="list-wrapper">
<div
v-for="(item, rowIndex) in fullData"
v-for="item in fullData"
:key="item.id"
class="log-row"
:class="{ 'row-error': item.isErrorRow }"
>
<div class="col-index">{{ (currentPage - 1) * pageSize + rowIndex + 1 }}</div>
<div class="col-info">
<div class="expert-main">
<span class="name">{{ item.expertName }}</span>
@@ -784,14 +782,6 @@ export default {
color: #475569;
}
.col-index {
flex: 0 0 52px;
width: 52px;
text-align: center;
color: #64748b;
font-variant-numeric: tabular-nums;
}
.col-info {
flex: 1.8;
}

View File

@@ -74,7 +74,7 @@
</div>
</div>
<div class="mail-body-content" v-html="mailBodyHtml"></div>
<div class="mail-body-content" v-html="mailData.content_html"></div>
<div v-if="mailData.attachments && mailData.attachments.length" class="attachment-section">
<div class="attachment-header">
@@ -123,7 +123,6 @@
<script>
import Common from '@/components/common/common';
import { normalizeEmailHtmlForInlineDisplay } from '@/utils/emailHtmlView';
import JSZip from 'jszip';
import { saveAs } from 'file-saver';
import FilePreviewDialog from './FilePreviewDialog.vue';
@@ -160,29 +159,9 @@ export default {
if (!this.mailData.attachments || !this.mailData.attachments.length) return '0B';
const total = this.mailData.attachments.reduce((sum, f) => sum + (Number(f.size) || 0), 0);
return this.formatFileSize(total);
},
/** 正文:兼容 content_html / body / html纯文本时包一层 pre */
mailBodyHtml() {
const m = this.mailData || {};
let raw = m.content_html || m.body_html || m.html || m.body || m.content || '';
raw = normalizeEmailHtmlForInlineDisplay(raw);
if (raw) return raw;
const text = m.content_text;
if (text != null && String(text).trim() !== '') {
return `<pre class="mail-plain-pre">${this.escapeHtml(String(text))}</pre>`;
}
return '';
}
},
methods: {
escapeHtml(text) {
if (text == null) return '';
return String(text)
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;');
},
scrollToAttachments() {
// 1. 获取目标元素的 DOM
const target = this.$el.querySelector('.attachment-section');
@@ -462,15 +441,6 @@ const res = await this.$api.post('api/email_client/getAttachment', {
margin-bottom: 50px;
}
/* v-html 注入的正文无 scoped 属性,用 deep 命中内部的 pre */
.mail-body-content >>> .mail-plain-pre {
margin: 0;
white-space: pre-wrap;
word-break: break-word;
font-family: inherit;
font-size: 14px;
}
/* 附件卡片 */
.attachment-section {
border-top: 1px solid #eee;

View File

@@ -344,7 +344,7 @@ export default {
},
async questionSubmit() {
if (this.questionform.is_anonymous == '' && this.questionform.is_anonymous != '0') {
this.$message.error('Please choose disclose your name or remain anonymous.');
@@ -390,8 +390,9 @@ export default {
this.questionform.comment
];
Char_Cter = this.$commonJS.getCleanTextForCount(contents.join(' '));
console.log("🚀 ~ questionSubmit ~ Char_Cter:", Char_Cter);
if (new RegExp('[\\u4E00-\\u9FFF]+', 'g').test(Char_Cter)) {
//中文

View File

@@ -58,9 +58,25 @@
<script>
import { TableUtils } from '@/common/js/TableUtils';
import { mediaUrl } from '@/common/js/commonJS.js';
import {
buildCiteMapFromRefs,
applyCiteLabelsToTableRows
} from '@/common/js/citeTablePreview.js';
export default {
name: 'TablePreviewer',
props: {
/** 与稿面 chanFerForm 一致,用于把单元格内 <mycite> 显示为 [n] */
referenceList: {
type: Array,
default: () => []
},
/** 正文引用首次出现顺序p_refer_id与 GenerateCharts articleCiteIdOrder 一致 */
bodyCiteIdOrder: {
type: Array,
default: () => []
}
},
data() {
return {
visible: false,
@@ -70,23 +86,32 @@ export default {
mediaUrl,
};
},
computed: {
previewCiteMap() {
return buildCiteMapFromRefs(this.referenceList, this.bodyCiteIdOrder);
}
},
methods: {
async open(type, item,isNoBg) {
async open(type, item, isNoBg) {
this.visible = true;
this.type = type;
const hideOddRowBg = isNoBg === true || isNoBg === 'true' || isNoBg === 1 || isNoBg === '1';
if (type === 'table') {
this.loading = true;
setTimeout(() => {
try {
const processed = this.processTableData(item.table);
const processed = this.processTableData(item.table, {
refs: this.referenceList,
citeMap: this.previewCiteMap
});
this.processedItem = Object.freeze({
...item,
table: {
...item.table,
tableHeader: processed.tableHeader,
tableContent: processed.tableContent,
oddRowIds: isNoBg ? [] : processed.oddRowIds
oddRowIds: hideOddRowBg ? [] : processed.oddRowIds
}
});
} catch (err) {
@@ -97,6 +122,7 @@ export default {
}, 50);
} else {
this.processedItem = item;
}
// 数学公式渲染
@@ -105,12 +131,20 @@ export default {
}, 500);
},
processTableData(rawContent) {
processTableData(rawContent, citeCtx) {
try {
const tableList = typeof rawContent === 'string' ? JSON.parse(rawContent) : rawContent;
const { header, content } = TableUtils.splitTable(tableList);
const { rowData, rowIds } = TableUtils.addRowIdToData(content);
return { tableHeader: header, tableContent: rowData, oddRowIds: rowIds };
const refs = citeCtx && citeCtx.refs;
const citeMap = citeCtx && citeCtx.citeMap;
let tableHeader = header;
let tableContent = rowData;
if (Array.isArray(refs) && refs.length > 0 && citeMap && typeof citeMap === 'object') {
tableHeader = applyCiteLabelsToTableRows(header, refs, citeMap);
tableContent = applyCiteLabelsToTableRows(rowData, refs, citeMap);
}
return { tableHeader, tableContent, oddRowIds: rowIds };
} catch (e) {
return { tableHeader: [], tableContent: [], oddRowIds: [] };
}
@@ -238,6 +272,16 @@ export default {
background: rgb(250, 231, 232) !important;
}
/* 与稿面 mycite 引用样式一致,弹窗内可见 [n] */
.table_Box ::v-deep mycite {
display: inline;
vertical-align: baseline;
color: rgb(0, 130, 170) !important;
cursor: inherit;
text-decoration: none;
background-color: rgba(0, 130, 170, 0.08);
}
.table-fade-enter-active, .table-fade-leave-active { transition: opacity 0.3s ease; }
.table-fade-enter, .table-fade-leave-to { opacity: 0; }
</style>

View File

@@ -10,13 +10,19 @@
ref="tinymceChild1"
:wordStyle="wordStyle"
:isAutomaticUpdate="isAutomaticUpdate"
:showRefButton="showRefButton"
@getContent="getContent"
@openLatexEditor="openLatexEditor"
@openRefSelector="openRefSelector"
@updateChange="updateChange"
@input="onTinymceInput"
:value="value"
:chanFerForm="chanFerForm"
:bodyCiteIdOrder="bodyCiteIdOrder"
:tableLinkCiteMaxMap="tableLinkCiteMaxMap"
:typesettingType="typesettingType"
class="paste-area text-container"
:toolbar="!isAutomaticUpdate?['bold italic |customBlue removeBlue|LateX| myuppercase myuppercasea Line MoreSymbols|subscript superscript|clearButton|searchreplace']:['bold italic |customBlue removeBlue| myuppercase myuppercasea Line MoreSymbols|subscript superscript|clearButton|searchreplace']"
:toolbar="toolbarConfig"
style="
/* white-space: pre-line; */
line-height: 12px;
@@ -36,10 +42,40 @@
<script>
import Tinymce from '@/components/page/components/Tinymce';
export default {
props: ['value','isAutomaticUpdate','height','id'],
props: {
value: {},
isAutomaticUpdate: {},
height: {},
id: {},
chanFerForm: {},
/** 全文 mycite 顺序,与稿面 word.vue 的 bodyCiteIdOrder 一致,用于弹窗内 [1][2] 与参考文献重排 */
bodyCiteIdOrder: {
type: Array,
default: () => []
},
/** mytable(data-id) 对应表格内已出现引用的最大全局序号,用于正文中 “See Table X. And see [2,3]” 的偏移映射 */
tableLinkCiteMaxMap: {
type: Object,
default: () => ({})
},
/** false标题等场景不显示 Ref */
showRefButton: {
type: Boolean,
default: true
}
},
components: {
Tinymce
},
computed: {
toolbarConfig() {
const refBtn = this.showRefButton ? ' insertRef' : '';
if (!this.isAutomaticUpdate) {
return [`bold italic |customBlue removeBlue|LateX${refBtn}| myuppercase myuppercasea Line MoreSymbols|subscript superscript|clearButton|searchreplace`];
}
return [`bold italic |customBlue removeBlue${refBtn}| myuppercase myuppercasea Line MoreSymbols|subscript superscript|clearButton|searchreplace`];
}
},
watch: {
lineStyle() {}
},
@@ -85,8 +121,40 @@ export default {
this.$refs.tinymceChild1.getContent(type);
},
getContent(type, content) {
this.$emit('getContent', type, content);
},
openRefSelector(data) {
this.$emit('openRefSelector', data);
},
onTinymceInput(html) {
this.$emit('editorInput', html);
},
insertAutocite(refId) {
this.$refs.tinymceChild1.insertAutocite(refId);
},
removeAutocite() {
this.$refs.tinymceChild1.removeAutocite();
},
/** 从当前 mycite 的 data-id 中移除指定 id无剩余则删标签未选 id 时删整段 */
stripAutociteIds(ids) {
if (this.$refs.tinymceChild1 && typeof this.$refs.tinymceChild1.stripAutociteIds === 'function') {
this.$refs.tinymceChild1.stripAutociteIds(ids);
}
},
/** 参考文献异步到达后刷新编辑器内 mycite 数字(供父组件在打开弹窗 / fetch 完成后调用) */
refreshAutociteDisplay() {
const t = this.$refs.tinymceChild1;
if (t && typeof t.renderAutociteInEditor === 'function' && t.editorInstance) {
t.renderAutociteInEditor(t.editorInstance);
}
},
/** 将正文中的 [1]、[13] 等按全局序号匹配为 <mycite> */
convertBracketRefsToAutocite() {
const t = this.$refs.tinymceChild1;
if (t && typeof t.convertPlainBracketCitesToAutocite === 'function') {
return t.convertPlainBracketCitesToAutocite();
}
return { replaced: 0 };
}
}
};

View File

@@ -2,11 +2,17 @@
<div>
<tinymce
type="table"
:use-table-local-citation-index="true"
:articleId="articleId"
ref="tinymceChild1"
:wordStyle="wordStyle"
:show-ref-button="showRefButton"
:chanFerForm="chanFerForm"
:bodyCiteIdOrder="bodyCiteIdOrder"
@getContent="getContent"
@openLatexEditor="openLatexEditor"
@openRefSelector="$emit('openRefSelector', $event)"
@input="onTableEditorInput"
:height="calcDynamicWidth()"
:value="updatedHtml"
:typesettingType="typesettingType"
@@ -22,7 +28,24 @@
<script>
import Tinymce from '@/components/page/components/Tinymce';
export default {
props: ['lineStyle', 'articleId'],
props: {
lineStyle: {},
articleId: {},
/** 与稿面/段落编辑一致,供 Ref 插入;未传时 TinyMCE 内为空会提示「参考文献尚未加载」 */
chanFerForm: {
type: Array,
default: () => []
},
bodyCiteIdOrder: {
type: Array,
default: () => []
},
/** 与 content.vue 一致:为 true 时显示 Reference、Auto-link References稿面表格编辑需文献角标时保持 true */
showRefButton: {
type: Boolean,
default: true
}
},
components: {
Tinymce
},
@@ -91,6 +114,9 @@ export default {
}
},
methods: {
onTableEditorInput(html) {
this.$emit('editorInput', html);
},
openLatexEditor(data) {
this.$emit('openLatexEditor', data);
},
@@ -121,6 +147,22 @@ export default {
} else {
this.$emit('getContent', type, { html_data: '', table: [] });
}
},
insertAutocite(refIds) {
if (this.$refs.tinymceChild1 && typeof this.$refs.tinymceChild1.insertAutocite === 'function') {
this.$refs.tinymceChild1.insertAutocite(refIds);
}
},
stripAutociteIds(ids) {
if (this.$refs.tinymceChild1 && typeof this.$refs.tinymceChild1.stripAutociteIds === 'function') {
this.$refs.tinymceChild1.stripAutociteIds(ids);
}
},
refreshAutociteDisplay() {
const t = this.$refs.tinymceChild1;
if (t && typeof t.renderAutociteInEditor === 'function' && t.editorInstance) {
t.renderAutociteInEditor(t.editorInstance);
}
}
}
};

File diff suppressed because it is too large Load Diff

View File

@@ -252,10 +252,11 @@
</ul>
</div>
<DynamicTable
ref="myTableModal"
/>
<DynamicTable
ref="myTableModal"
:reference-list="chanFerForm || []"
:body-cite-id-order="bodyCiteIdOrder || []"
/>
</div>
</template>
@@ -264,7 +265,18 @@
import { mediaUrl } from '@/common/js/commonJS.js'; // 引入通用逻辑
import DynamicTable from './DynamicTable.vue';
export default {
props: ['articleId', 'imgWidth', 'imgHeight', 'scale', 'isEdit', 'isShowEdit', 'urlList', 'content'],
props: [
'articleId',
'imgWidth',
'imgHeight',
'scale',
'isEdit',
'isShowEdit',
'urlList',
'content',
'chanFerForm',
'bodyCiteIdOrder'
],
data() {
return {
identity: localStorage.getItem('U_role'),

View File

@@ -464,10 +464,11 @@
</li>
</ul>
</div>
<DynamicTable
ref="myTableModal"
/>
<DynamicTable
ref="myTableModal"
:reference-list="chanFerForm || []"
:body-cite-id-order="bodyCiteIdOrder || []"
/>
</div>
</template>
@@ -476,7 +477,20 @@ import DynamicTable from './DynamicTable.vue';
import { mediaUrl } from '@/common/js/commonJS.js'; // 引入通用逻辑
export default {
props: ['articleId', 'imgWidth', 'imgHeight', 'scale', 'isEdit', 'isShowEdit', 'urlList', 'content'],
props: [
'articleId',
'imgWidth',
'imgHeight',
'scale',
'isEdit',
'isShowEdit',
'urlList',
'content',
/** 参考文献列表,供表格预览把 mycite 显示为 [n] */
'chanFerForm',
/** 正文引用顺序,与稿面 articleCiteIdOrder 一致 */
'bodyCiteIdOrder'
],
data() {
return {
isShowComment: false,

View File

@@ -239,18 +239,47 @@ export default {
openAddDialog() { this.addDialogVisible = true; },
resetAddForm() { this.addForm = { field: '', runNow: false }; this.addLoading = false; },
async submitAddKeyword() {
if (!this.addForm.field.trim()) return this.$message.warning(this.$t('crawlTask.enterKeyword'));
const raw = String(this.addForm.field || '').trim();
if (!raw) return this.$message.warning(this.$t('crawlTask.enterKeyword'));
// 支持一次录入多个:按换行/逗号/分号拆分,去重
const fields = raw
.split(/[\r\n,;]+/g)
.map((s) => s.trim())
.filter(Boolean);
const uniqFields = Array.from(new Set(fields));
if (uniqFields.length === 0) return this.$message.warning(this.$t('crawlTask.enterKeyword'));
this.addLoading = true;
try {
const res = await this.$api.post('api/expert_manage/addFetchField', { field: this.addForm.field });
if (res.code === 0) {
this.$message.success(this.$t('crawlTask.addKeywordSuccess'));
if (this.addForm.runNow) {
await this.$api.post('api/expert_finder/fetchOneField', { field: this.addForm.field });
const ok = [];
const fail = [];
for (const field of uniqFields) {
try {
const res = await this.$api.post('api/expert_manage/addFetchField', { field });
if (res && res.code === 0) {
ok.push(field);
if (this.addForm.runNow) {
// 不阻塞整体添加run once 失败也记录,不影响已添加成功
try {
await this.$api.post('api/expert_finder/fetchOneField', { field });
} catch (e) {
/* ignore */
}
}
} else {
fail.push({ field, msg: (res && res.msg) || this.$t('crawlTask.operationFail') });
}
} catch (e) {
fail.push({ field, msg: this.$t('crawlTask.operationFail') });
}
this.addDialogVisible = false;
this.fetchList();
}
if (ok.length > 0) {
this.$message.success(`${this.$t('crawlTask.addKeywordSuccess')} (${ok.length}/${uniqFields.length})`);
}
if (fail.length > 0) {
this.$message.warning(`Failed: ${fail.map((x) => x.field).join(', ')}`);
}
this.addDialogVisible = false;
this.fetchList();
} finally { this.addLoading = false; }
}
}

View File

@@ -71,6 +71,7 @@
Special note: If the number of authors is 6 or fewer, all authors should be listed.
</div>
<el-button
v-if="canDelete"
@click="StepBNext(1)"
type="primary"
plain
@@ -110,7 +111,7 @@
<span @click="handleContainerClick" style="margin-left: 5px" v-html="getRepeatRefHtml()"> </span>
</div>
<div class="topBtnBox btns" v-if="chanFerForm.length > 0 && role == 'editor'">
<div class="topBtnBox btns" v-if="chanFerForm.length > 0 && role == 'editor' && canDelete">
<el-button type="primary" plain @click="selectAllRef">Select all</el-button>
<el-button type="success" plain @click="toggleSelection">Select none</el-button>
<el-button type="danger" plain @click="deleteSomeRefs" :disabled="multipleSelection.length > 0 ? false : true"
@@ -154,11 +155,10 @@
class="status ok"
:class="scope.row.refer_type == 'journal' ? getJournalDateno(scope.row.dateno, 'status') : ''"
v-if="
(
(scope.row.refer_type == 'journal' && scope.row.doilink != '' && scope.row.cs == 1) ||
(scope.row.refer_type == 'book' && scope.row.isbn != '' && scope.row.cs == 1)
) && scope.row.retract == 0
"
((scope.row.refer_type == 'journal' && scope.row.doilink != '' && scope.row.cs == 1) ||
(scope.row.refer_type == 'book' && scope.row.isbn != '' && scope.row.cs == 1)) &&
scope.row.retract == 0
"
>
<i class="el-icon-circle-check"></i>
</span>
@@ -173,7 +173,9 @@
<!-- journal 形式 -->
<div style="text-align: left" v-if="scope.row.refer_type == 'journal'" class="reference-item">
<p>
{{ scope.row.author }}&nbsp;<span v-html="formatTitle(scope.row.title)"></span>. &nbsp;<em>{{ scope.row.joura }}</em
{{ scope.row.author }}&nbsp;<span v-html="formatTitle(scope.row.title)"></span>. &nbsp;<em>{{
scope.row.joura
}}</em
>.&nbsp;<span :class="getJournalDateno(scope.row.dateno, 'title')">{{ scope.row.dateno }}</span
>.<br />
</p>
@@ -181,13 +183,16 @@
</div>
<!-- book 形式 -->
<div style="text-align: left" v-if="scope.row.refer_type == 'book'" class="reference-item">
<p>{{ scope.row.author }}&nbsp;<span v-html="formatTitle(scope.row.title)"></span>.&nbsp;{{ scope.row.dateno }}.&nbsp;<br /></p>
<p>
{{ scope.row.author }}&nbsp;<span v-html="formatTitle(scope.row.title)"></span>.&nbsp;{{
scope.row.dateno
}}.&nbsp;<br />
</p>
<a class="doiLink" :href="scope.row.isbn" target="_blank">{{ scope.row.isbn }}</a>
</div>
<!-- other 形式 -->
<p class="wrongLine reference-item" style="text-align: left" v-if="scope.row.refer_type == 'other'">
<span v-html="formatTitle(scope.row.refer_frag)"></span>
</p>
</template>
</el-table-column>
@@ -242,7 +247,7 @@
</div>
</el-table-column>
</el-table>
<div class="bottomBtnBox btns" v-if="chanFerForm.length > 0 && role == 'editor'">
<div class="bottomBtnBox btns" v-if="chanFerForm.length > 0 && role == 'editor'&& canDelete">
<el-button type="primary" plain @click="selectAllRef">Select all</el-button>
<el-button type="success" plain @click="toggleSelection">Select none</el-button>
<el-button type="danger" plain @click="deleteSomeRefs" :disabled="multipleSelection.length > 0 ? false : true"
@@ -546,6 +551,7 @@ export default {
},
addLoading: false,
editboxVisible: false,
canDelete: true,
multipleSelection: [] // 多选
};
},
@@ -572,18 +578,19 @@ export default {
}
},
methods: {
formatTitle(title) {
if (!title) return '';
// 使用正则匹配,'gi' 表示全局匹配且不区分大小写
// \b 确保是完整单词匹配,防止误伤含有这些字母的其他单词
const reg = /\b(Retracted|Retraction)\b/gi;
return title.replace(reg, (match) => {
return `<span style="color: red; font-weight: bold;">${match}</span>`;
});
}
,
getCurrentRoute() {
this.canDelete = !['/articleListEditor_B1'].includes(this.$route.path);
},
formatTitle(title) {
if (!title) return '';
// 使用正则匹配,'gi' 表示全局匹配且不区分大小写
// \b 确保是完整单词匹配,防止误伤含有这些字母的其他单词
const reg = /\b(Retracted|Retraction)\b/gi;
return title.replace(reg, (match) => {
return `<span style="color: red; font-weight: bold;">${match}</span>`;
});
},
getJournalDateno(dateno, type) {
if (dateno && typeof dateno === 'string') {
const hasInvalidColon = !dateno.includes(':') || (dateno.includes(':') && dateno.split(':').pop().trim() === '');
@@ -682,7 +689,7 @@ export default {
.then((res) => {
if (res.status == 1) {
return res.data;
}
}
throw res.msg;
})
.catch((err) => {
@@ -697,6 +704,7 @@ export default {
return {};
},
init(e) {
this.getCurrentRoute();
this.chanFerForm = e;
this.bijiao();
////console.log('更新更新')

File diff suppressed because it is too large Load Diff

View File

@@ -109,11 +109,7 @@
<div class="mail-content-panel" v-if="selectedAccount" v-loading="detailLoading">
<template v-if="activeMailId && !detailLoading">
<div class="mail-page">
<mail-detail
v-if="detailMail && String(detailMail.inbox_id || '') !== ''"
:mailData="detailMail"
@close="closeDetail"
/>
<mail-detail v-if="detailMail" :mailData="detailMail" @close="closeDetail" />
</div>
</template>
@@ -172,7 +168,6 @@ const API = {
getAllJournal: 'api/Article/getJournal'
};
import MailDetail from '../../components/page/components/email/MailDetail.vue';
import { normalizeEmailHtmlForInlineDisplay } from '@/utils/emailHtmlView';
export default {
data() {
return {
@@ -298,14 +293,8 @@ import { normalizeEmailHtmlForInlineDisplay } from '@/utils/emailHtmlView';
this.$api
.post(API.getOneEmail, { j_email_id: jEmailId })
.then((res) => {
const raw = res && res.data != null ? res.data : null;
const email =
raw && typeof raw === 'object' && raw.email && typeof raw.email === 'object'
? raw.email
: raw && typeof raw === 'object' && (raw.j_email_id != null || raw.smtp_user)
? raw
: null;
if (res && Number(res.code) === 0 && email) {
const email = res && res.data ? res.data.email : null;
if (res && res.code === 0 && email) {
this.selectedAccount = email;
this.fetchData();
this.startInboxSse();
@@ -500,103 +489,28 @@ fetchLatestSingleMail(jEmailId, journalId) {
this.currentFolder = f;
this.activeMailId = null;
},
/** 接口 code 可能是数字 0 或字符串 "0" */
isEmailApiSuccess(res) {
if (!res || res.code === undefined || res.code === null) return false;
return Number(res.code) === 0;
},
escapeHtml(text) {
if (text == null) return '';
return String(text)
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;');
},
/** 解析 getEmailDetail 返回体,统一 content 字段;失败时用列表行兜底 */
buildDetailMailFromResponse(res, item, inboxId) {
const ok = this.isEmailApiSuccess(res);
let d = res && res.data != null ? res.data : null;
if (d && typeof d === 'string') {
try {
d = JSON.parse(d);
} catch (e) {
d = null;
}
}
if (Array.isArray(d) && d.length) {
d = d[0];
}
if (ok && d && typeof d === 'object' && d.data && typeof d.data === 'object' && !d.content_html && !d.content_text) {
d = { ...d, ...d.data };
}
if (ok && (!d || typeof d !== 'object') && res && (res.content_html != null || res.content_text != null || res.subject != null)) {
d = { ...res };
delete d.code;
delete d.msg;
if (Object.prototype.hasOwnProperty.call(d, 'data')) delete d.data;
}
const inboxKey = String(inboxId);
const listSnippet = (item && item.content) || '';
if (!ok || !d || typeof d !== 'object') {
return {
...item,
subject: (item && item.subject) || '',
from_name: (item && item.from_name) || '',
from_email: (item && item.email) || '',
email_date: item && item.email_date,
content_html: listSnippet,
inbox_id: inboxKey,
attachments: [],
has_attachment: (item && item.has_attachment) || 0
};
}
const html = d.content_html || d.body_html || d.html || d.body || '';
const text = d.content_text || '';
let content_html =
html ||
(text ? `<pre class="mail-plain-pre">${this.escapeHtml(text)}</pre>` : '') ||
listSnippet;
if (content_html && typeof content_html === 'string' && /^<!DOCTYPE|^<\s*html[\s>]/i.test(content_html.trim())) {
const normalized = normalizeEmailHtmlForInlineDisplay(content_html);
if (normalized && normalized.trim()) content_html = normalized;
}
return {
...item,
...d,
content_html,
inbox_id: inboxKey,
attachments: []
};
},
selectMail(item, index) {
selectMail(item,index) {
this.activeMailId = item.id;
this.detailLoading = true;
this.detailMail = {};
const inboxId = item.inbox_id || item.id;
this.$api
.post(API.getEmailDetail, { inbox_id: inboxId })
.then((res) => {
try {
const merged = this.buildDetailMailFromResponse(res, item, inboxId);
this.detailMail = merged;
if (item) item.state = 0;
const row = this.displayList[index];
if (row && merged && merged.is_read !== undefined && merged.is_read !== null) {
this.$set(row, 'is_read', merged.is_read);
}
if (Number(merged.has_attachment) === 1) {
const d = res && res.data;
if (res && res.code === 0 && d) {
this.detailMail = { ...d, inbox_id: String(inboxId), attachments: [] };
item.state = 0;
this.displayList[index].is_read = d.is_read;
if (Number(d.has_attachment) === 1) {
this.fetchAttachments(String(inboxId));
return;
} else {
this.detailLoading = false;
}
} catch (e) {
console.error(e);
this.detailMail = this.buildDetailMailFromResponse(null, item, inboxId);
} else {
this.detailLoading = false;
}
this.detailLoading = false;
})
.catch(() => {
this.detailMail = this.buildDetailMailFromResponse(null, item, inboxId);
this.detailLoading = false;
});
},

View File

@@ -279,11 +279,14 @@
journal_id: this.query.journal_id || (this.journalList[0] ? this.journalList[0].journal_id : null),
account: '',
password: '',
// password: '123456qwe..%%%',
smtp_from_name: '',
smtp_host: 'mail.tmrjournals.co.nz',
// smtp_host: 'smtp.mxhichina.com',
smtp_port: '465',
smtp_encryption: 'ssl',
imap_host: 'mail.tmrjournals.co.nz',
// imap_host: 'imap.qiye.aliyun.com',
imap_port: '993',
};
this.dialogVisible = true;

View File

@@ -96,13 +96,13 @@
<div class="body-editor-container">
<div class="subject-label" style="margin-bottom: 10px;">{{ $t('mailboxMouldDetail.emailBody') }}:</div>
<TmrEmailEditor
<!-- <TmrEmailEditor
v-model="form.body"
:journalList="journalList"
:journalId="form.journalId"
:language="form.lang"
placeholder=""
/>
/> -->
<CkeditorMail v-model="form.body" />
</div>
</el-card>

View File

@@ -124,7 +124,7 @@ export default {
},
// 5----重新获取加载参考文献
changeRefer(val) {
console.log('重新获取参考文献')
this.$api
.post('api/Production/getReferList', {
'p_article_id': this.p_article_id

22
src/utils/autociteHtml.js Normal file
View File

@@ -0,0 +1,22 @@
/**
* 从 HTML 字符串中按出现顺序收集引用标签的 data-idmycite / autocite 与稿面、TinyMCE、历史库一致
* 支持逗号多 id、属性任意顺序、单/双引号
*/
export function extractAutociteIdsFromHtmlString(raw) {
if (!raw || typeof raw !== 'string') return [];
const ids = [];
const tagRe = /<(mycite|autocite)\b[^>]*>/gi;
let m;
while ((m = tagRe.exec(raw)) !== null) {
const tag = m[0];
const dbl = tag.match(/\bdata-id\s*=\s*"([^"]*)"/i);
const sgl = tag.match(/\bdata-id\s*=\s*'([^']*)'/i);
const val = dbl ? dbl[1] : sgl ? sgl[1] : '';
if (!val) continue;
val.split(',').forEach((part) => {
const id = part.trim();
if (id && !ids.includes(id)) ids.push(id);
});
}
return ids;
}

View File

@@ -0,0 +1,161 @@
/**
* Main_List 全文首次出现顺序(与 Edit Content / 稿面 / 底部参考文献列表共用)。
* 正文中 <mytable> 占位处需先插入对应表格段在 Main_List 中的表题/表体/表注引用,再计其后的 mycite。
*/
import { extractAutociteIdsFromHtmlString } from '@/utils/autociteHtml.js';
export function collectCiteStringsDeep(source, out, depth = 0) {
if (!source || depth > 6) return;
if (typeof source === 'string') {
const s = source.trim();
if (!s) return;
const maybeCite = /<(?:mycite|autocite)\b/i.test(s) || /\[[\d\s,\-–—]+\]/.test(s);
if (maybeCite) out.push(s);
return;
}
if (Array.isArray(source)) {
source.forEach((item) => collectCiteStringsDeep(item, out, depth + 1));
return;
}
if (typeof source === 'object') {
Object.keys(source).forEach((k) => {
const v = source[k];
collectCiteStringsDeep(v, out, depth + 1);
});
}
}
export function collectCiteHtmlSourcesForMainListItem(p, draftAmId, draftHtml) {
if (draftAmId != null && p && p.am_id == draftAmId && draftHtml != null) {
return [draftHtml];
}
const out = [];
const typ = p != null && p.type != null ? Number(p.type) : NaN;
if (typ === 2 && p.table) {
const t = p.table;
if (typeof t.title === 'string' && t.title.trim()) out.push(t.title);
if (typeof t.html_data === 'string' && t.html_data.trim()) {
out.push(t.html_data);
} else {
const pushRows = (rows) => {
if (!Array.isArray(rows)) return;
rows.forEach((row) => {
if (!Array.isArray(row)) return;
row.forEach((cell) => {
if (cell && typeof cell.text === 'string' && cell.text) out.push(cell.text);
});
});
};
pushRows(t.tableHeader);
pushRows(t.tableContent);
}
if (typeof t.note === 'string' && t.note.trim()) out.push(t.note);
collectCiteStringsDeep(t, out);
return out;
}
if (typ === 1 && p.image) {
const img = p.image;
if (typeof img.title === 'string' && img.title.trim()) out.push(img.title);
if (typeof img.note === 'string' && img.note.trim()) out.push(img.note);
if (out.length === 0) {
if (p && typeof p.content === 'string' && p.content.trim()) out.push(p.content);
if (p && typeof p.text === 'string' && p.text.trim()) out.push(p.text);
}
return out;
}
if (p && typeof p.text === 'string' && p.text.trim()) out.push(p.text);
if (p && typeof p.content === 'string' && p.content.trim()) out.push(p.content);
return out;
}
export function findMainListTableByLinkId(mainList, rawId) {
if (rawId == null || String(rawId).trim() === '') return null;
const sid = String(rawId).trim();
const list = Array.isArray(mainList) ? mainList : [];
return (
list.find((p) => {
if (!p || Number(p.type) !== 2) return false;
if (String(p.amt_id) === sid) return true;
if (String(p.am_id) === sid) return true;
if (p.p_main_table_id != null && String(p.p_main_table_id) === sid) return true;
if (p.table && p.table.amt_id != null && String(p.table.amt_id) === sid) return true;
if (p.table && p.table.am_id != null && String(p.table.am_id) === sid) return true;
if (p.table && p.table.p_main_table_id != null && String(p.table.p_main_table_id) === sid)
return true;
if (p.table && p.table.table_id != null && String(p.table.table_id) === sid) return true;
return false;
}) || null
);
}
/**
* @param {object} [options]
* @param {number|string|null} [options.tableDraftAmId] 正在编辑的表格段 am_idEdit Table 抽屉)
* @param {string|null} [options.tableDraftHtml] 与该表对应的 Title+表体+Note 合并稿;正文里 mytable 展开到该表时用此稿替代 Main_List 已存内容,使「全文 mytable 之前」的序号与抽屉内一致
*/
export function extractAutociteOrderFromDraftHtmlWithInlineTables(html, mainList, options = {}) {
const order = [];
const pushUnique = (id) => {
if (id && !order.includes(id)) order.push(id);
};
const pushFromRaw = (raw) => {
extractAutociteIdsFromHtmlString(raw).forEach((id) => pushUnique(id));
};
if (!html || typeof html !== 'string') return order;
const re = /<mytable\b[^>]*>[\s\S]*?<\/mytable>/gi;
let last = 0;
let m;
while ((m = re.exec(html)) !== null) {
const before = html.slice(last, m.index);
if (before) pushFromRaw(before);
const openEnd = html.indexOf('>', m.index) + 1;
const openTag = html.slice(m.index, openEnd);
const dm = openTag.match(/\bdata-id\s*=\s*["']([^"']*)["']/i);
const tid = dm ? String(dm[1]).trim() : '';
const tableP = findMainListTableByLinkId(mainList, tid);
if (tableP) {
const useDraft =
options.tableDraftAmId != null &&
options.tableDraftHtml != null &&
String(tableP.am_id) === String(options.tableDraftAmId);
const sources = useDraft
? [options.tableDraftHtml]
: collectCiteHtmlSourcesForMainListItem(tableP, null, null);
sources.forEach((raw) => pushFromRaw(raw));
}
last = m.index + m[0].length;
}
const after = html.slice(last);
if (after) pushFromRaw(after);
return order;
}
export function extractAutociteOrderFromMainList(mainList, draftAmId, draftHtml, options = {}) {
const list = Array.isArray(mainList) ? mainList : [];
const order = [];
list.forEach((p) => {
if (draftAmId != null && p && p.am_id == draftAmId && draftHtml != null) {
extractAutociteOrderFromDraftHtmlWithInlineTables(draftHtml, list, options).forEach((id) => {
if (!order.includes(id)) order.push(id);
});
return;
}
const candidates = collectCiteHtmlSourcesForMainListItem(p, draftAmId, draftHtml);
candidates.forEach((raw) => {
if (typeof raw === 'string' && /<mytable\b/i.test(raw)) {
extractAutociteOrderFromDraftHtmlWithInlineTables(raw, list, options).forEach((id) => {
if (!order.includes(id)) order.push(id);
});
} else {
extractAutociteIdsFromHtmlString(raw).forEach((id) => {
if (!order.includes(id)) order.push(id);
});
}
});
});
return order;
}

View File

@@ -1,26 +0,0 @@
/**
* 将完整 HTML 邮件转为适合 div[v-html] 的片段:
* 取 body.innerHTML并前置 head 内 <style>,避免版式与改版前不一致。
*/
export function normalizeEmailHtmlForInlineDisplay(html) {
if (!html || typeof html !== 'string') return '';
const t = html.trim();
if (!/^<!DOCTYPE|^<\s*html[\s>]/i.test(t)) return html;
try {
const doc = new DOMParser().parseFromString(html, 'text/html');
const body = doc && doc.body;
if (!body) return html;
const inner = body.innerHTML;
if (!inner || !inner.trim()) return html;
let headInject = '';
const head = doc.head;
if (head) {
head.querySelectorAll('style').forEach((node) => {
headInject += node.outerHTML;
});
}
return headInject + inner;
} catch (e) {
return html;
}
}