5 Commits

Author SHA1 Message Date
3f53a6c7d0 关键字管理 2026-03-30 13:07:33 +08:00
7d3e6654fd 提交 2026-03-27 13:24:04 +08:00
c6c262169d tijiao 2026-03-24 13:38:11 +08:00
12760aaf44 自动化推广【约稿】 2026-03-23 09:28:56 +08:00
f44b3910a4 推广管理 2026-03-18 11:07:02 +08:00
32 changed files with 9681 additions and 1195 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: '/', //正式
});

View File

@@ -181,6 +181,8 @@ export default {
localStorage.removeItem('journalTypeData');
localStorage.removeItem('journalTypeDataAll');
localStorage.removeItem('opMedicalListData');
localStorage.removeItem('mailboxCollect_j_email_id');
localStorage.removeItem('mailboxCollect_journal_id');
this.$router.push('/login');
}
},

View File

@@ -179,6 +179,8 @@ export default {
localStorage.removeItem('journalTypeData');
localStorage.removeItem('journalTypeDataAll');
localStorage.removeItem('opMedicalListData');
localStorage.removeItem('mailboxCollect_j_email_id');
localStorage.removeItem('mailboxCollect_journal_id');
this.$router.push('/login');
}
},

View File

@@ -18,14 +18,14 @@
<span slot="title"> {{ item.title }}</span>
</template>
<template v-for="subItem in item.subs">
<el-submenu v-if="subItem.subs" :index="subItem.index" :key="subItem.index">
<el-submenu v-if="subItem.subs" :index="subItem.index" :key="subItem.index + '-submenu'">
<template slot="title">
{{ subItem.title }}
<!-- <el-badge is-dot :hidden="false">{{ subItem.title }}</el-badge> -->
</template>
<template v-for="(threeItem, i) in subItem.subs">
<el-submenu v-if="threeItem.subs" :index="threeItem.index" :key="threeItem.index">
<el-submenu v-if="threeItem.subs" :index="threeItem.index" :key="threeItem.index + '-submenu'">
<template slot="title">
{{ threeItem.title }}
<!-- <el-badge is-dot :hidden="false">{{ subItem.title }}</el-badge> -->
@@ -35,12 +35,12 @@
{{ fourItem.title }}
</el-menu-item>
</el-submenu>
<el-menu-item v-else :index="threeItem.index" :key="threeItem.index"
<el-menu-item v-else :index="threeItem.index" :key="threeItem.index + '-item'"
>{{ threeItem.title }}
</el-menu-item>
</template>
</el-submenu>
<el-menu-item v-else :index="subItem.index" :key="subItem.index">{{ subItem.title }} </el-menu-item>
<el-menu-item v-else :index="subItem.index" :key="subItem.index + '-item'">{{ subItem.title }} </el-menu-item>
</template>
</el-submenu>
</template>
@@ -155,8 +155,21 @@
<!-- 编辑 -->
<template v-if="this.userrole == 1">
<el-submenu index="mailboxManagement">
<template slot="title"> <i class="el-icon-message"></i> {{ $t('sidebar.mailboxManagement') }} </template>
<template slot="title"> <i class="el-icon-message"></i> {{ $t('sidebar.promotionManagement') }} </template>
<el-submenu index="expertDatabaseSub">
<template slot="title">
{{ $t('sidebar.expertDatabase') }}
</template>
<el-menu-item index="expertDatabase">
{{ $t('sidebar.expertList') }}
</el-menu-item>
<el-menu-item index="crawlTaskMonitor">
{{ $t('sidebar.crawlTasks') }}
</el-menu-item>
</el-submenu>
<el-menu-item index="mailboxConfig">
{{ $t('sidebar.mailboxManagement') }}
</el-menu-item>
@@ -166,6 +179,9 @@
<el-menu-item index="mailboxMould">
{{ $t('sidebar.emailTemplates') }}
</el-menu-item>
<el-menu-item index="autoPromotion">
{{ $t('sidebar.autoPromotion') }}
</el-menu-item>
</el-submenu>
@@ -174,9 +190,6 @@
<el-menu-item index="RejectedArticles">
{{ $t('sidebar.ReArticles') }}
</el-menu-item>
<el-menu-item index="scholarCrawlers">
{{ $t('sidebar.scholarCrawlers') }}
</el-menu-item>
<!-- <el-menu-item index="1" key="1"> -->
<a href="http://master.tmrjournals.com" target="_blank" class="linkBar"> Management System </a>
<!-- </el-menu-item> -->
@@ -896,10 +909,10 @@ export default {
border-right: 0;
}
.el-menu-item:hover {
/* color: #006699 !important;
background-color: #e3e9ef !important; */
}
/* .el-menu-item:hover {
color: #006699 !important;
background-color: #e3e9ef !important;
} */
.el-submenu__title i {
color: #fff !important;

View File

@@ -111,7 +111,27 @@
break;
}
}
})
});
// 按路径关闭指定标签(用于主动销毁 keep-alive 页面)
bus.$on('close_tag_by_path', (payload) => {
const targetPath = payload && payload.path ? payload.path : '';
const fallbackPath = payload && payload.fallback ? payload.fallback : '/';
const silent = payload && payload.silent === true;
if (!targetPath) return;
for (let i = 0, len = this.tagsList.length; i < len; i++) {
const item = this.tagsList[i];
if (item.path === targetPath) {
this.tagsList.splice(i, 1);
// 如果关闭的是当前激活标签,则跳到指定兜底路由
if (!silent && this.$route.fullPath === targetPath) {
this.$router.push(fallbackPath);
}
break;
}
}
bus.$emit('tags', this.tagsList);
});
},
// beforeDestroy() {
// // 销毁监听,防止内存泄漏

View File

@@ -129,7 +129,9 @@ const en = {
doubleConfirmContent: 'Are you sure you want to authorize this rate change? This adjustment will immediately synchronize with the billing system and impact all future financial settlements.',
// 3. 反馈
updateSuccess: 'The journal APC standard has been successfully updated.'
updateSuccess: 'The journal APC standard has been successfully updated.',
executiveEditor:'Executive Editor',
databases:'Database inclusion',
},
@@ -272,7 +274,14 @@ const en = {
emailStyles: 'Email Styles',
tools: 'Assistant tools',
mailboxManagement: 'Mailbox Management',
mailboxConfig: 'Mailbox Management',
scholarCrawlers: 'Scholar Crawlers',
crawlerKeywords: 'Crawl Keywords',
expertDatabase: 'Expert Database',
keywordManagement: 'Keyword Management',
crawlTasks: 'Crawl Tasks',
expertList: 'Expert List',
autoPromotion: 'Auto Promotion',
ReArticles: 'Rejected Manuscripts', // 被拒稿件
editorialBoard: 'Boss System',
editorialBoard1: 'Board Management',
@@ -283,6 +292,31 @@ const en = {
managingDirector: 'Managing Director',
GroupClassification: 'Group List',
JournalInstallment: 'Journal Installment',
mailboxCollect: 'Email List',
promotionManagement: 'Promotion Management',
},
expertDatabase: {
fieldSelectPlaceholder: 'Please select field',
keywordPlaceholder: 'Name / Email / Affiliation',
fieldPlaceholder: 'Please enter field',
searchBtn: 'Search',
resetBtn: 'Reset',
downloadExcelBtn: 'Download Excel',
table: {
no: 'No.'
},
columns: {
baseInfo: 'Base Information',
affiliation: 'Affiliation',
researchAreas: 'Research areas'
},
fields: {
nameLabel: 'Name:',
emailLabel: 'Email:',
acquisitionTimeLabel: 'Acquisition Time:'
},
exportWarn: 'Please select a research area, enter a keyword, or enter a field before exporting.',
exportFailed: 'Export failed'
},
mailboxConfig: {
mailSystem: 'Mailbox system',
@@ -290,9 +324,12 @@ const en = {
journal: 'Journal',
allJournal: 'All journals',
query: 'Search',
refresh: 'Refresh',
addAccount: 'Add email account',
noData: 'No data',
smtpFromName: 'Sender name',
no: 'No.',
loading: 'Loading...',
smtpFromName: 'Name',
smtpFromNamePlaceholder: 'Display name when sending',
smtpHost: 'SMTP host',
smtpPort: 'SMTP port',
@@ -310,7 +347,7 @@ const en = {
operation: 'Operation',
edit: 'Edit',
delete: 'Delete',
mailManage: 'Mail manage',
mailManage: 'Email List',
dialogAdd: 'Add email account',
dialogEdit: 'Edit email account',
selectJournal: 'Select journal',
@@ -328,6 +365,7 @@ const en = {
cancel: 'Cancel',
save: 'Save',
deleteConfirm: 'Delete this email config?',
deleteTitle: 'Delete email account',
confirm: 'Confirm',
addSuccess: 'Added successfully',
editSuccess: 'Updated successfully',
@@ -353,6 +391,7 @@ const en = {
mailboxMould: {
title: 'Email Templates',
subtitle: 'Manage and customize your journal email templates.',
no: 'No.',
searchPlaceholder: 'Search by title or scene...',
journalPlaceholder: 'Journal',
scenePlaceholder: 'Scene',
@@ -363,8 +402,8 @@ const en = {
languagePlaceholder: 'Language',
searchBtn: 'Search',
createTemplate: 'Create Template',
colTitle: 'Subject',
colSubject: 'Mail title',
colTitle: 'Template title',
colSubject: 'Email subject',
colScene: 'Scene',
colLanguage: 'Language',
colVersion: 'Version',
@@ -383,6 +422,7 @@ const en = {
mailboxStyle: {
title: 'Email Styles',
subtitle: 'Manage email header and footer styles.',
no: 'No.',
searchPlaceholder: 'Search by name or description...',
journalPlaceholder: 'Journal',
scenePlaceholder: 'Scene',
@@ -469,6 +509,7 @@ const en = {
time: 'Time',
look: 'Look',
emptyText: 'New messages (0)',
loading: 'Loading...',
detailTitle: 'Mail detail',
from: 'From',
to: 'To',
@@ -486,12 +527,142 @@ const en = {
nameColumn: 'Name',
switchColumn: 'Switch',
useBtn: 'Switch',
currentAccountText: 'Current account',
changeAccountBtn: 'Change account',
syncSuccess: 'Sync succeeded',
syncFail: 'Sync failed',
operation: 'Operation',
loadingMore: 'Loading more...',
noMore: 'No more',
yesterday: 'Yesterday',
selectAccountTip: 'Please select an email account first.',
attachmentCount: ' attachment(s)',
downloadFail: 'Download failed',
accountNotBelong: 'This account does not belong to you. Please select another one.',
totalAttachments: '{count} attachment(s) in total',
etcSuffix: '... etc.',
viewAttachments: 'View attachments',
newMailArrived: '{count} new mail(s) received, click to view',
downloadAllZip: 'Download all',
packingAttachments: 'Packing attachments, please wait...',
downloadBtn: 'Download',
printBtn: 'Print',
previewNotSupported: 'This file format cannot be previewed online',
downloadToView: 'Download to view locally',
},
crawlerKeywords: {
pageTitle: 'Keyword Configuration',
pageDesc: 'Manage core search terms for discovering experts.',
exportData: 'Export Data',
startCrawl: 'Start Crawl',
inputPlaceholder: 'Enter new keyword, e.g. deep learning, semiconductor expert...',
addKeyword: 'Add Keyword',
searchPlaceholder: 'Search keywords...',
searchBtn: 'Search',
totalCount: '{count} keyword(s) in total',
colKeyword: 'Keyword',
colCategory: 'Category',
colStatus: 'Status',
colExpertCount: 'Expert Count',
colLastCrawl: 'Last Crawl',
colAction: 'Action',
save: 'Save',
cancel: 'Cancel',
stateRunning: 'Running',
statePaused: 'Paused',
stateError: 'Error',
stateDone: 'Done',
emptyKeywordWarn: 'Please enter a keyword',
addSuccess: 'Added successfully',
addFail: 'Failed to add',
updateSuccess: 'Updated successfully',
updateFail: 'Failed to update',
deleteConfirm: 'Are you sure to delete this keyword? This action cannot be undone.',
confirmTitle: 'Confirm',
deleteSuccess: 'Deleted successfully',
deleteFail: 'Failed to delete',
refreshSuccess: 'Refreshed successfully',
refreshFail: 'Failed to refresh',
crawlStarted: 'Crawl task started',
crawlFail: 'Failed to start crawl',
exportFail: 'Failed to export',
},
crawlTask: {
pageTitle: 'Task Monitor',
pageDesc: 'View currently running and completed crawl tasks.',
exportData: 'Export Data',
startCrawl: 'Start Crawl',
searchPlaceholder: 'Search by keyword...',
searchBtn: 'Search',
allKeywords: 'All Keywords',
enabled: 'Enabled',
disabled: 'Disabled',
allStatus: 'All Status',
statusCrawling: 'Crawling',
statusDone: 'Done',
statusPaused: 'Paused',
statusError: 'Error',
source: 'Source',
startTime: 'Start Time',
endTime: 'End Time',
progress: 'Progress',
totalPages: 'Total Pages',
crawledPages: 'Crawled Pages',
expertCountLabel: 'Experts Stored',
expertCount: 'Expert Count',
created: 'Created',
completed: 'Completed',
updated: 'Updated',
viewDetail: 'View Detail',
viewLogs: 'View Logs',
pause: 'Pause',
resume: 'Resume',
restart: 'Restart',
delete: 'Delete',
deleteConfirm: 'Are you sure to delete this task? This cannot be undone.',
confirmTitle: 'Confirm',
confirmOk: 'OK',
confirmCancel: 'Cancel',
operationSuccess: 'Operation succeeded',
operationFail: 'Operation failed',
operationRetry: 'Operation failed, please try again later',
crawlStarted: 'Crawl task started',
crawlFail: 'Failed to start crawl',
exportFail: 'Failed to export',
detailTitle: 'Task Detail',
basicInfo: 'Basic Information',
taskName: 'Task Name',
status: 'Status',
resultSummary: 'Result Summary',
totalFound: 'Total Found',
newAdded: 'New Added',
duplicates: 'Duplicates',
failed: 'Failed',
logsTitle: 'Run Logs',
noLogs: 'No logs yet',
noData: 'No tasks',
emptyResult: 'No matching task records found',
addKeyword: 'Add Keyword',
keyword: 'Keyword',
keywordPlaceholder: 'Enter keyword, e.g.: Infectious Diseases',
runOnce: 'Single Crawl',
runOnceBtn: 'Single Crawl',
runOnceLoading: 'Crawling...',
yes: 'Yes',
no: 'No',
cancel: 'Cancel',
confirm: 'OK',
enterKeyword: 'Please enter a keyword',
addKeywordSuccess: 'Keyword added successfully',
addKeywordFailed: 'Failed to add keyword',
runOnceSuccess: 'Single crawl triggered',
runOnceFailed: 'Failed to trigger single crawl',
disabledMsg: 'Disabled',
enabledMsg: 'Enabled',
pauseFailed: 'Failed to pause',
resumeFailed: 'Failed to resume',
missingKeyword: 'Missing keyword, cannot perform single crawl',
restartSuccess: 'Sync restarted (local mock)',
},
mailboxSend: {
title: 'Write mail',
@@ -504,6 +675,7 @@ const en = {
templateSelection: 'Template selection',
sender: 'Sender:',
send: 'Send',
sending: 'Sending...',
selectUser: 'Select User',
batchSelection: 'Batch selection',
email: 'Email',
@@ -530,7 +702,10 @@ const en = {
sendFail: 'Send failed',
sendMock: 'Send (mock): will really send when api/Mail/sendMail is ready',
needAccount: 'Please select a sender account from the mailbox list first',
backToInbox: 'Back to inbox',
selectTemplateStyleFirst: 'Please select template and style first',
recipientLimit: 'You can add up to {count} recipient(s)',
recipientLimitPlaceholder: 'Limit reached (max {count})',
backToInbox: 'Back to email list',
},
home: {
authortop: 'Author guide',
@@ -817,8 +992,165 @@ const en = {
"imgLabel": "Img"
},
mailTemplate: {
noTemplateTip: 'No templates are available for the current journal. Please select another journal or contact the administrator to configure templates.'
}
noTemplateTip: 'No templates are available for the current journal. Please select another journal or go add templates first.',
addTemplateBtn: 'Go add templates',
templateTab: 'Template',
styleTab: 'Style',
loading: 'Loading...',
refresh: 'Refresh'
},
autoPromotion: {
title: 'Auto Promotion',
journal: 'Journal',
logs: 'Promotion History',
saved: 'Saved',
loading: 'Loading...',
refresh: 'Refresh',
autoSolicit: 'Auto Solicitation',
editConfig: 'Edit Configuration',
running: 'Running',
emailTemplate: 'Email Template',
emailStyle: 'Email Style',
notStarted: 'Auto solicitation plan is not enabled',
notInitializedTip: 'Auto solicitation is not enabled. Please configure template and style first, then enable the plan.',
journalManage: 'Journal Management',
loadListFailed: 'Failed to load journal list',
goConfig: 'Configure',
goManagePlan: 'Manage Plan',
startPlan: 'Start Plan',
startedPlan: 'plan enabled',
updateRetryFailed: 'Update failed, please try again later',
selectTemplateStyleFirst: 'Please select template and style before confirming',
configSaved: 'Configuration saved',
saveFailed: 'Save failed',
notInitializedSwitchTip: 'Auto solicitation is not initialized. Please configure templates first',
planEnabled: 'Plan enabled',
planDisabled: 'Plan disabled',
updateFailed: 'Update failed',
cancel: 'Cancel',
saveAndApply: 'Save and apply configuration',
selectTemplateStyleTitle: 'Choose journal template and style',
clickToChooseTemplate: 'Click to choose journal email template',
noPreview: 'No Preview',
templateName: 'Template Name',
styleName: 'Style Name',
defaultStyle: 'Default',
changeTemplate: 'Change Template',
selectPromotionFields: 'Select Promotion Fields',
choosePromotionFields: 'Choose Fields',
selectedCount: 'Selected {count}',
selectAll: 'Select All',
clearAll: 'Clear All',
selectPromotionFieldsTip: 'Multiple selection supported; leave empty for no field restriction.',
fieldSearchPlaceholder: 'Search promotion fields',
noFieldMatch: 'No matching fields',
confirm: 'Confirm',
fieldsSaved: 'Promotion fields saved',
confirmAndEnable: 'Confirm and Enable',
onlySaveConfig: 'Save configuration only',
enableNowNextDay: 'Enable auto promotion now (starts next day)'
}
,
autoPromotionLogs: {
detail: 'Auto Promotion Details',
configured: 'Configured',
editConfig: 'Edit auto promotion configuration',
startConfig: 'Start auto promotion configuration',
notConfigured: 'Not configured',
searchPlaceholder: 'Name / Email',
statusAll: 'All status',
searchBtn: 'Search',
index: 'No.',
taskName: 'Task Name',
taskParams: 'Parameters',
templateIdLabel: 'Template ID',
styleIdLabel: 'Style ID',
deliveryStats: 'Delivery Stats',
totalCount: 'Total',
sentCount: 'Sent',
failCount: 'Failed',
bounceCount: 'Bounce',
noDeliveryIssue: 'No delivery issues',
deliveryIssue: 'Delivery issues',
completedText: 'Completed',
expertInfo: 'Expert Info',
templateStyle: 'Template / Style',
stylePrefix: 'Style',
runAt: 'Execution time',
status: 'Status',
state0: 'Draft',
state1: 'Running',
state2: 'Paused',
state3: 'Completed',
state4: 'Cancelled',
state5: 'Preparing',
paused: 'Paused',
toRun: 'To run',
operation: 'Operation',
preview: 'Preview',
previewAction: 'Preview',
editAction: 'Edit',
enable: 'Enable',
pause: 'Pause',
previewEditTitle: 'Preview and edit promotion email',
receiver: 'Receiver:',
receiverImmutablePlaceholder: 'Receiver email cannot be changed',
subject: 'Subject:',
subjectPlaceholder: 'Please enter mail subject',
runAtPlaceholder: 'Please select execution time',
cancel: 'Cancel',
confirmEdit: 'Confirm Edit',
mailContentSaved: 'Mail content has been saved. It will be sent with this content.',
templateNotSelected: 'No template selected',
selectTemplateWarning: 'Please select a template before confirming',
configUpdated: 'Configuration updated',
pauseSuccess: 'Paused',
enableSuccess: 'Enabled',
operationFailed: 'Operation failed',
selectTaskForLogs: 'Please select a task first (click the view icon in the list)',
pushLogTitle: 'Task list',
logRefresh: 'Refresh',
taskLogStateFilter: 'Status',
taskLogStateAll: 'All',
taskLogState0: 'Pending',
taskLogState1: 'Sent',
taskLogState2: 'Failed',
taskLogState3: 'Bounced',
taskLogState4: 'Cancelled',
logColExpert: 'Expert',
logColSendTime: 'Sent at',
logColPreparedAt: 'Prepared at',
logColStatus: 'Status',
logColAction: 'Action',
emptyLogs: 'No logs',
viewFailureReason: 'Reason',
editLogTip: 'Edit',
deleteLogTip: 'Delete',
previewLogTip: 'Preview',
logFieldAffiliation: 'Affiliation',
logFieldSubject: 'Subject',
logFieldSendTime: 'Sent at',
logFieldExecutionTime: 'Executed at',
saveDetail: 'Save',
failureReasonTitle: 'Failure reason',
saveDetailSuccess: 'Saved',
saveDetailFailed: 'Save failed',
logDetailLoadFailed: 'Failed to load detail',
logIdMissing: 'Missing log id',
logAlreadySent: 'This record is no longer pending; switched to preview',
deleteLogConfirm: 'Delete this log entry?',
tipTitle: 'Tip',
deleteLogSuccess: 'Deleted',
deleteLogFailed: 'Delete failed',
noFailureReason: 'No failure reason',
deletedSuccess: 'Deleted',
mockPromotionSubject: 'Promotion for {journal}',
mockPromotionContent: '<p>Dear {name},</p><p>Check out our latest journal updates...</p>'
},
tmrEmailEditor: {
preview: 'Preview',
placeholder: 'Please enter email content'
}

View File

@@ -122,7 +122,10 @@ const zh = {
cancel: '取消',
doubleConfirmTitle: '最终操作确认',
doubleConfirmContent: '确定要授权此项金额变更吗?此操作具有法律效力上的即时性,将直接影响后续所有财务结算流程。',
updateSuccess: '期刊计费标准已成功更新。'
updateSuccess: '期刊计费标准已成功更新。',
executiveEditor:'责任编辑',
databases:'收录数据库',
},
paperArticleCount: {
Periodroll: '期卷',
@@ -257,13 +260,16 @@ const zh = {
emailStyles: '邮件风格',
tools: '辅助工具',
mailboxManagement: '邮箱管理',
<<<<<<< HEAD
mailboxConfig: '邮箱配置管理',
mailboxCollect: '邮箱列表',
scholarCrawlers: '学者抓取',
=======
scholarCrawlers: '学者数据库',
>>>>>>> 577a30aeb65a03b5b8b229e5b6a974645e171a0c
crawlerKeywords: '抓取关键词配置',
expertDatabase: '专家库',
keywordManagement: '关键词管理',
crawlTasks: '抓取任务',
expertList: '专家列表',
autoPromotion: '自动推广',
ReArticles: '被拒稿件', // 被拒稿件
editorialBoard: '编委管理',
editorialBoard1: '编委列表',
@@ -274,17 +280,45 @@ const zh = {
managingDirector: '总经理',
GroupClassification: '集团列表',
JournalInstallment: '分期列表',
mailboxCollect: '邮件列表',
promotionManagement: '推广管理',
},
expertDatabase: {
fieldSelectPlaceholder: '请选择研究领域',
keywordPlaceholder: '姓名 / 邮箱 / 单位',
fieldPlaceholder: '请输入领域 field',
searchBtn: '搜索',
resetBtn: '重置',
downloadExcelBtn: '下载 Excel',
table: {
no: '序号'
},
columns: {
baseInfo: '基础信息',
affiliation: '单位',
researchAreas: '研究领域'
},
fields: {
nameLabel: '姓名:',
emailLabel: '邮箱:',
acquisitionTimeLabel: '采集时间:'
},
exportWarn: '请选择研究领域或输入关键词或领域 field 后再导出。',
exportFailed: '导出失败'
},
mailboxConfig: {
mailSystem: '邮件系统',
title: '邮箱配置管理',
title: '邮箱账号管理',
journal: '所属期刊',
allJournal: '全部期刊',
query: '搜索',
refresh: '刷新',
addAccount: '添加邮箱账号',
noData: '暂无数据',
smtpFromName: '发件人名称',
no: '序号',
loading: '加载中...',
smtpFromName: '名称',
smtpFromNamePlaceholder: '发信时显示的名称',
smtpHost: 'SMTP 地址',
smtpPort: 'SMTP 端口',
@@ -302,7 +336,7 @@ const zh = {
operation: '操作',
edit: '编辑',
delete: '删除',
mailManage: '邮箱管理',
mailManage: '邮件列表',
dialogAdd: '添加邮箱账号',
dialogEdit: '修改邮箱账号信息',
selectJournal: '请选择期刊',
@@ -319,7 +353,8 @@ const zh = {
primaryTip: '每个期刊有且仅有一个主邮箱,用于默认发信与收信。',
cancel: '取消',
save: '保存',
deleteConfirm: '确定删除该邮箱配置',
deleteConfirm: '确定删除该邮箱账号',
deleteTitle: '删除邮箱账号',
confirm: '确定',
addSuccess: '添加成功',
editSuccess: '修改成功',
@@ -345,6 +380,7 @@ const zh = {
mailboxMould: {
title: '邮件模板',
subtitle: '管理并自定义期刊邮件模板。',
no: '序号',
searchPlaceholder: '按标题或场景搜索...',
journalPlaceholder: '期刊',
scenePlaceholder: '场景',
@@ -355,8 +391,8 @@ const zh = {
languagePlaceholder: '语言',
searchBtn: '搜索',
createTemplate: '新建模板',
colTitle: '题',
colSubject: '邮件题',
colTitle: '模版标题',
colSubject: '邮件题',
colScene: '场景',
colLanguage: '语言',
colVersion: '版本',
@@ -375,6 +411,7 @@ const zh = {
mailboxStyle: {
title: '邮件风格',
subtitle: '管理邮件头部和尾部样式。',
no: '序号',
searchPlaceholder: '按名称或描述搜索...',
journalPlaceholder: '期刊',
scenePlaceholder: '场景',
@@ -461,6 +498,7 @@ const zh = {
time: '时间',
look: '查看',
emptyText: '暂无邮件',
loading: '加载中...',
detailTitle: '邮件详情',
from: '发件人',
to: '收件人',
@@ -478,12 +516,142 @@ const zh = {
nameColumn: '名称',
switchColumn: '切换',
useBtn: '切换',
currentAccountText: '当前账号',
changeAccountBtn: '切换邮箱账号',
syncSuccess: '同步成功',
syncFail: '同步失败',
operation: '操作',
loadingMore: '加载更多...',
noMore: '没有更多了',
yesterday: '昨天',
selectAccountTip: '请先选择一个邮箱账号.',
attachmentCount: '个附件',
downloadFail: '下载失败',
accountNotBelong: '该邮箱账号不属于当前用户,请重新选择',
totalAttachments: '共{count}个附件',
etcSuffix: '... 等',
viewAttachments: '查看附件',
newMailArrived: '收到 {count} 封新邮件,点击查看',
downloadAllZip: '打包下载',
packingAttachments: '正在打包附件,请稍后...',
downloadBtn: '下载',
printBtn: '打印',
previewNotSupported: '该文件格式无法在线预览',
downloadToView: '下载到本地查看',
},
crawlerKeywords: {
pageTitle: '关键词配置',
pageDesc: '管理用于发现专家的核心搜索词。',
exportData: '导出数据',
startCrawl: '开始抓取',
inputPlaceholder: '输入新关键词,例如:深度学习、半导体专家...',
addKeyword: '添加关键词',
searchPlaceholder: '搜索关键词...',
searchBtn: '搜索',
totalCount: '共 {count} 个词条',
colKeyword: '关键词',
colCategory: '分类',
colStatus: '状态',
colExpertCount: '专家数量',
colLastCrawl: '最后抓取',
colAction: '操作',
save: '保存',
cancel: '取消',
stateRunning: '运行中',
statePaused: '已暂停',
stateError: '异常',
stateDone: '已完成',
emptyKeywordWarn: '请输入关键词',
addSuccess: '添加成功',
addFail: '添加失败',
updateSuccess: '更新成功',
updateFail: '更新失败',
deleteConfirm: '确定删除该关键词吗?删除后无法恢复。',
confirmTitle: '提示',
deleteSuccess: '删除成功',
deleteFail: '删除失败',
refreshSuccess: '刷新成功',
refreshFail: '刷新失败',
crawlStarted: '抓取任务已启动',
crawlFail: '启动抓取失败',
exportFail: '导出失败',
},
crawlTask: {
pageTitle: '任务监控',
pageDesc: '查看当前正在运行和已完成的抓取任务。',
exportData: '导出数据',
startCrawl: '开始抓取',
searchPlaceholder: '按关键词搜索...',
searchBtn: '搜索',
allKeywords: '全部关键词',
enabled: '启用',
disabled: '停用',
allStatus: '全部状态',
statusCrawling: '抓取中',
statusDone: '已完成',
statusPaused: '已暂停',
statusError: '异常',
source: '来源',
startTime: '开始时间',
endTime: '结束时间',
progress: '进度',
totalPages: '总页数',
crawledPages: '已抓取页数',
expertCountLabel: '入库专家数',
expertCount: '专家数量',
created: '创建',
completed: '完成',
updated: '更新',
viewDetail: '查看详情',
viewLogs: '查看日志',
pause: '暂停',
resume: '继续',
restart: '重新抓取',
delete: '删除',
deleteConfirm: '确定删除该任务吗?删除后无法恢复。',
confirmTitle: '提示',
confirmOk: '确定',
confirmCancel: '取消',
operationSuccess: '操作成功',
operationFail: '操作失败',
operationRetry: '操作失败,请稍后重试',
crawlStarted: '抓取任务已启动',
crawlFail: '启动抓取失败',
exportFail: '导出失败',
detailTitle: '任务详情',
basicInfo: '基本信息',
taskName: '任务名称',
status: '状态',
resultSummary: '抓取结果',
totalFound: '发现总数',
newAdded: '新增',
duplicates: '重复',
failed: '失败',
logsTitle: '运行日志',
noLogs: '暂无日志',
noData: '暂无任务',
emptyResult: '未发现匹配的任务记录',
addKeyword: '新建关键词',
keyword: '关键词',
keywordPlaceholder: '请输入关键词Infectious Diseases',
runOnce: '单次抓取',
runOnceBtn: '单次抓取',
runOnceLoading: '抓取中...',
yes: '是',
no: '否',
cancel: '取消',
confirm: '确定',
enterKeyword: '请输入关键词',
addKeywordSuccess: '新增关键词成功',
addKeywordFailed: '新增关键词失败',
runOnceSuccess: '已触发单次抓取',
runOnceFailed: '单次抓取触发失败',
disabledMsg: '已停用',
enabledMsg: '已启用',
pauseFailed: '暂停失败',
resumeFailed: '恢复失败',
missingKeyword: '缺少关键词,无法执行单次抓取',
restartSuccess: '已重启同步(本地模拟)',
},
mailboxSend: {
title: '写邮件',
@@ -496,6 +664,7 @@ const zh = {
templateSelection: '模板选择',
sender: '发件人:',
send: '发送',
sending: '发送中...',
selectUser: '选择用户',
batchSelection: '批量选择',
email: '邮箱',
@@ -522,6 +691,9 @@ const zh = {
sendFail: '发送失败',
sendMock: '发送(模拟):接口 api/Mail/sendMail 就绪后将真实发送',
needAccount: '请从邮箱列表选择发件账号后再发送',
selectTemplateStyleFirst: '请先选择模板和风格',
recipientLimit: '最多只能添加 {count} 个收件人',
recipientLimitPlaceholder: '已达上限(最多 {count} 个)',
backToInbox: '返回收件箱',
},
home: {
@@ -805,7 +977,164 @@ const zh = {
},
mailTemplate: {
// 如果已经有 mailTemplate就只加这一行
noTemplateTip: '当前期刊暂无可用模板,请重新选择期刊或联系管理员配置模板。'
noTemplateTip: '当前期刊暂无可用模板,请重新选择期刊或先去新增模板。',
addTemplateBtn: '去新增模板',
templateTab: '模版',
styleTab: '样式',
loading: '加载中...',
refresh: '刷新'
},
autoPromotion: {
title: '自动推广',
journal: '期刊',
logs: '历史推广记录',
saved: '已保存',
loading: '加载中...',
refresh: '刷新',
autoSolicit: '自动约稿',
editConfig: '修改配置',
running: '运行中',
emailTemplate: '邮件模板',
emailStyle: '邮件风格',
notStarted: '未开启自动约稿计划',
notInitializedTip: '自动约稿未启用,请先完成期刊模版风格配置并开启计划',
journalManage: '期刊管理',
loadListFailed: '期刊列表加载失败',
goConfig: '去配置',
goManagePlan: '去管理约稿计划',
startPlan: '开启约稿计划',
startedPlan: '已开启约稿计划',
updateRetryFailed: '更新失败,请稍后重试',
selectTemplateStyleFirst: '请选择模板和风格后再确认',
configSaved: '约稿配置已保存',
saveFailed: '保存失败',
notInitializedSwitchTip: '自动化约稿没有初始化,请先配置模版',
planEnabled: '已开启约稿计划',
planDisabled: '已关闭约稿计划',
updateFailed: '更新失败',
cancel: '取消',
saveAndApply: '保存并应用配置',
selectTemplateStyleTitle: '选择期刊模版风格',
clickToChooseTemplate: '点击选择期刊邮件模版',
noPreview: '暂无预览',
templateName: '模版名称',
styleName: '风格名称',
defaultStyle: '默认风格',
changeTemplate: '更换模版',
selectPromotionFields: '选择推广领域',
choosePromotionFields: '选择领域',
selectedCount: '已选 {count} 项',
selectAll: '全选',
clearAll: '取消全选',
selectPromotionFieldsTip: '可多选;未选择则不限制推广领域。',
fieldSearchPlaceholder: '搜索推广领域',
noFieldMatch: '没有匹配的领域',
confirm: '确定',
fieldsSaved: '推广领域已保存',
confirmAndEnable: '确认并开启',
onlySaveConfig: '仅保存配置',
enableNowNextDay: '立即激活自动推广(次日开始自动推广)'
}
,
autoPromotionLogs: {
detail: '自动推广详情',
configured: '已配置',
editConfig: '修改期刊自动推广配置',
startConfig: '立即开始期刊自动推广配置',
notConfigured: '尚未配置',
searchPlaceholder: '姓名 / 邮箱',
statusAll: '全部状态',
searchBtn: '搜索',
index: '序号',
taskName: '任务名称',
taskParams: '参数内容',
templateIdLabel: '模板ID',
styleIdLabel: '风格ID',
deliveryStats: '投递统计',
totalCount: '总量',
sentCount: '已发送',
failCount: '失败',
bounceCount: '退信',
noDeliveryIssue: '无发送异常',
deliveryIssue: '投递异常',
completedText: '已完成',
expertInfo: '专家信息',
templateStyle: '模板 / 风格',
stylePrefix: '风格',
runAt: '执行时间',
status: '状态',
state0: '草稿',
state1: '运行中',
state2: '暂停',
state3: '完成',
state4: '取消',
state5: '准备',
paused: '已暂停',
toRun: '待执行',
operation: '操作',
preview: '查看预览',
previewAction: '预览',
editAction: '编辑',
enable: '开启',
pause: '暂停',
previewEditTitle: '预览并修改推广邮件',
receiver: '收件人:',
receiverImmutablePlaceholder: '收件人邮箱不可更改',
subject: '主题:',
subjectPlaceholder: '请输入邮件主题',
runAtPlaceholder: '请选择执行时间',
cancel: '取消',
confirmEdit: '确认修改',
mailContentSaved: '邮件内容已保存,将按此内容执行发送',
templateNotSelected: '未选择模板',
selectTemplateWarning: '请选择一个模板后再确认',
configUpdated: '配置已更新',
pauseSuccess: '已暂停',
enableSuccess: '已开启',
operationFailed: '操作失败',
selectTaskForLogs: '请先选择一条任务(点击列表「查看」图标)',
pushLogTitle: '任务列表',
logRefresh: '刷新',
taskLogStateFilter: '发送状态',
taskLogStateAll: '全部',
taskLogState0: '待发送',
taskLogState1: '已发送',
taskLogState2: '失败',
taskLogState3: '退信',
taskLogState4: '取消',
logColExpert: '专家信息',
logColSendTime: '发送时间',
logColPreparedAt: '预处理完成时间',
logColStatus: '状态',
logColAction: '操作',
emptyLogs: '暂无日志',
viewFailureReason: '原因',
editLogTip: '编辑',
deleteLogTip: '删除',
previewLogTip: '预览',
logFieldAffiliation: '单位/机构',
logFieldSubject: '主题',
logFieldSendTime: '发送时间',
logFieldExecutionTime: '执行时间',
saveDetail: '保存',
failureReasonTitle: '失败原因',
saveDetailSuccess: '保存成功',
saveDetailFailed: '保存失败',
logDetailLoadFailed: '加载详情失败',
logIdMissing: '缺少日志 ID',
logAlreadySent: '该记录已非待发送状态,已切换为预览',
deleteLogConfirm: '确定删除该条发送记录?',
tipTitle: '提示',
deleteLogSuccess: '删除成功',
deleteLogFailed: '删除失败',
noFailureReason: '暂无失败原因',
deletedSuccess: '已删除',
mockPromotionSubject: '自动推广:{journal}',
mockPromotionContent: '<p>亲爱的 {name}</p><p>请查看我们最新的期刊更新...</p>'
},
tmrEmailEditor: {
preview: '预览效果',
placeholder: '请输入邮件内容'
}

View File

@@ -37,6 +37,10 @@
<span class="title">{{ $t('JournalCitationAnalysis.editorinchief') }} :</span
><span>{{ scope.row.editorinchief }}</span>
</div>
<div class="item">
<span class="title">{{ $t('JournalCitationAnalysis.executiveEditor') }} :</span
><span>{{ scope.row.editor_name }}</span>
</div>
<div class="item">
<span class="title">{{ $t('JournalCitationAnalysis.email') }} :</span><span>{{ scope.row.email }}</span>
</div>
@@ -46,6 +50,9 @@
<div class="item">
<span class="title">{{ $t('JournalCitationAnalysis.level') }} :</span><span>{{ scope.row.level }}</span>
</div>
<div class="item">
<span class="title">{{ $t('JournalCitationAnalysis.databases') }} :</span><span>{{ scope.row.databases }}</span>
</div>
<div class="item" v-if="scope.row.journal_topic">
<span class="title">{{ $t('JournalCitationAnalysis.journal_topic') }} :</span
@@ -228,6 +235,12 @@
<el-form-item label="Journal publisher :" prop="publish_author">
<el-input v-model="detailForm.publish_author" placeholder="eg:TMR编辑部"></el-input>
</el-form-item>
<el-form-item label="Journal executive editor :" prop="editor_name">
<el-input v-model="detailForm.editor_name" placeholder=""></el-input>
</el-form-item>
<el-form-item label="Database inclusion :" prop="databases">
<el-input v-model="detailForm.databases" placeholder=""></el-input>
</el-form-item>
<el-form-item label="WeChat Code :" prop="editor_qrcode">
<div class="portrait WeChatCode">
@@ -470,6 +483,20 @@ export default {
trigger: 'blur'
}
],
editor_name: [
{
required: true,
message: 'Please input journal executive editor',
trigger: 'blur'
}
],
databases: [
{
required: true,
message: 'Please input database inclusion',
trigger: 'blur'
}
],
kfen: [
{
required: true,
@@ -666,6 +693,7 @@ export default {
handleEdit() {
this.$refs.detail_form.validate((valid) => {
if (valid) {
if (this.detailForm.editor_qrcode == '' || !this.detailForm.editor_qrcode) {
this.$message.error('Please upload WeChat Code!');
return false;
@@ -861,6 +889,7 @@ export default {
publish_author: data.publish_author,
wechat_name: data.wechat_name,
wechat_app_id: data.wechat_app_id,
editor_name: data.editor_name,
wechat_app_secret: data.wechat_app_secret,
areas: data.journal_topic ? data.journal_topic.split(',') : ['']
};

View File

@@ -0,0 +1,564 @@
<template>
<div class="auto-promo-container" v-loading="loading" :element-loading-text="$t('autoPromotion.loading')">
<div class="page-header">
<el-breadcrumb separator="/">
<el-breadcrumb-item>
<i class="el-icon-s-promotion"></i> {{ $t('autoPromotion.title') }}
</el-breadcrumb-item>
</el-breadcrumb>
<el-button
type="text"
icon="el-icon-refresh"
class="auto-promo-refresh-btn"
:disabled="loading"
:title="$t('autoPromotion.refresh')"
@click="refreshAll"
/>
</div>
<div class="journal-grid">
<div v-for="journal in allJournals" :key="journal.journal_id" class="journal-item">
<div class="item-header">
<div class="journal-info">
<div class="icon-box">
<i class="el-icon-notebook-2"></i>
</div>
<span class="journal-name">{{ journal.title }}</span>
</div>
</div>
<div class="module-wrapper">
<div :class="['module-card', journal.solicit.initialized ? 'is-solicit-active' : 'is-empty']">
<div class="module-top">
<div class="module-top-left">
<span class="module-title">{{ $t('autoPromotion.autoSolicit') }}</span>
<el-button
v-if="journal.solicit.initialized"
type="text"
size="mini"
icon="el-icon-refresh"
class="config-inline-btn"
:disabled="promotionUpdating && String(promotionUpdatingJournalId) === String(journal.journal_id)"
@click="openWizardForJournal(journal)"
>
{{ $t('autoPromotion.editConfig') }}
</el-button>
</div>
<el-switch
v-model="journal.solicit.enabled"
active-color="#409EFF"
@change="handleSwitch(journal, 'solicit', $event)"
size="small"
:disabled="promotionUpdating && String(promotionUpdatingJournalId) === String(journal.journal_id)"
/>
</div>
<div class="module-content">
<template v-if="journal.solicit.initialized">
<div class="status-row" v-if="journal.solicit.enabled">
<span class="dot-running"></span>
<span class="status-text">{{ $t('autoPromotion.running') }}</span>
</div>
<div class="template-info-row">
<div>
<div class="template-info blue-text">{{ $t('autoPromotion.emailTemplate') }}: {{ journal.solicit.templateName || '-' }}</div>
<div class="template-info blue-text">{{ $t('autoPromotion.emailStyle') }}: {{ journal.solicit.styleName || '-' }}</div>
</div>
</div>
</template>
<div v-else class="empty-text">
{{ isSolicitConfigured(journal) ? $t('autoPromotion.notStarted') : $t('autoPromotion.notInitializedTip') }}
</div>
</div>
<div class="module-footer">
<button
class="action-btn btn-blue"
:disabled="promotionUpdating && String(promotionUpdatingJournalId) === String(journal.journal_id)"
@click="handleSolicitAction(journal)"
>
<span v-if="promotionUpdating && String(promotionUpdatingJournalId) === String(journal.journal_id)">
{{ $t('autoPromotion.loading') }}
</span>
<span v-else>
{{ getSolicitActionText(journal) }}
</span>
</button>
</div>
</div>
</div>
</div>
</div>
<journal-detail-dialog v-if="detailVisible" :visible.sync="detailVisible" :journal="currentJournal" />
<auto-promotion-wizard
mode="dialog"
:visible.sync="showWizardDialog"
:config="wizardConfig"
:wizardStartDate.sync="wizardStartDate"
:selectedFieldIds.sync="selectedFieldIds"
:availableFields="availableFields"
:fieldsLoading="fieldsLoading"
:fieldsSaving="fieldsSaving"
:currentJournalName="wizardJournal ? wizardJournal.title : ''"
:selectedTemplateThumbHtml="selectedTemplateThumbHtml"
:selectedTemplateName="selectedTemplateName"
:selectedStyleName="selectedStyleName"
:saving="saving"
:title="`${$t('autoPromotion.journalManage')}: ${wizardJournal ? wizardJournal.title : ''}`"
@open-template-selector="openTemplateSelector"
@confirm-fields="savePromotionFieldsNow"
@cancel="showWizardDialog = false"
@confirm="saveWizardConfig"
/>
<template-selector-dialog
v-if="showTemplateDialog"
:visible.sync="showTemplateDialog"
:journalId="wizardJournal ? wizardJournal.journal_id : ''"
:journalLabel="wizardJournal ? wizardJournal.title : ''"
:initial-style-id="templateDialogInitialStyleId"
:initial-template-id="templateDialogInitialTemplateId"
:return-source="'autoPromotion'"
@confirm="handleTemplateApply"
@close-all-dialogs="closeAllDialogs"
/>
</div>
</template>
<script>
import JournalDetailDialog from './components/autoPromotion/JournalDetailDialog.vue';
import AutoPromotionWizard from './components/autoPromotion/AutoPromotionWizard.vue';
import TemplateSelectorDialog from '@/components/page/components/email/TemplateSelectorDialog.vue';
export default {
components: { JournalDetailDialog, AutoPromotionWizard, TemplateSelectorDialog },
data() {
return {
loading: true,
detailVisible: false,
currentJournal: null,
showWizardDialog: false,
showTemplateDialog: false,
saving: false,
promotionUpdating: false,
promotionUpdatingJournalId: '',
wizardJournal: null,
wizardStartDate: '',
wizardConfig: {
defaultTemplateId: '',
defaultStyleId: '',
enabled: false
},
selectedTemplateThumbHtml: '',
selectedTemplateName: '',
selectedStyleName: '',
selectedFieldIds: [],
availableFields: [],
fieldsLoading: false,
fieldsSaving: false,
templateDialogInitialStyleId: '',
templateDialogInitialTemplateId: '',
templateNameMap: {},
allJournals: []
};
},
created() {
this.fetchPromotionJournals();
},
methods: {
openTemplateSelector() {
// 更换模板时优先回显当前已选 style/template没有则由选择器回落到第一项
this.templateDialogInitialStyleId = this.wizardConfig && this.wizardConfig.defaultStyleId
? String(this.wizardConfig.defaultStyleId)
: '';
this.templateDialogInitialTemplateId = this.wizardConfig && this.wizardConfig.defaultTemplateId
? String(this.wizardConfig.defaultTemplateId)
: '';
this.showTemplateDialog = true;
},
closeAllDialogs() {
// 进入“新增模板/跳转列表页”前,先关闭当前页所有弹窗,减少卡顿
this.showWizardDialog = false;
this.showTemplateDialog = false;
this.detailVisible = false;
},
/**
* 核心逻辑抽象:统一解析详情接口返回的数据结构
*/
_parseJournalDetail(data) {
const journalInfo = data.journal || data || {};
const tpl = journalInfo.template || data.template || {};
const style = journalInfo.style || data.style || {};
const tplId = String(journalInfo.default_template_id || '0');
const styleId = String(journalInfo.default_style_id || '0');
return {
title: journalInfo.title || journalInfo.journal_title || '',
templateId: tplId,
styleId: styleId,
templateName: tpl.name || tpl.title || journalInfo.default_template_name || (tplId !== '0' ? `模板#${tplId}` : ''),
styleName: style.name || style.title || journalInfo.default_style_name || (styleId !== '0' ? `风格#${styleId}` : ''),
html: `${style.header_html || ''}${tpl.body_html || ''}${style.footer_html || ''}`,
enabled: String(journalInfo.start_promotion || '0') === '1',
initialized: tplId !== '0' && styleId !== '0'
};
},
async fetchPromotionJournals() {
this.loading = true;
try {
const userId = localStorage.getItem('U_id') || '';
const res = await this.$api.post('api/email_client/getPromotionJournalList', { user_id: userId });
const raw = (res && res.data && (res.data.list || res.data.journals || res.data)) || [];
if (Array.isArray(raw) && raw.length) {
this.allJournals = await Promise.all(raw.map(async (item) => {
const journalId = item.journal_id || item.id;
const tplId = String(item.default_template_id || item.template_id || '0');
const styleId = String(item.default_style_id || item.style_id || '0');
const initialized = tplId !== '0' && styleId !== '0';
const enabled = String(item.start_promotion || item.enabled || '0') === '1';
// 初始简单结构:先用列表接口回填基础状态
let journalObj = {
journal_id: journalId,
title: item.title || item.journal_title || item.name || `Journal ${journalId}`,
solicit: {
enabled,
initialized,
templateId: tplId,
styleId: styleId,
templateName: '',
styleName: '',
html: ''
}
};
// 只有在“有模板id和风格id”时才拉取详情避免未初始化期刊的无意义请求
if (initialized) {
await this.refreshJournalByDetail(journalObj);
}
return journalObj;
}));
} else {
this.allJournals = [];
}
} catch (e) {
this.$message.error(this.$t('autoPromotion.loadListFailed'));
} finally {
this.loading = false;
}
},
// 右上角刷新:重新拉取列表,并重新拉取每个期刊对应的模版/风格详情
async refreshAll() {
this.templateNameMap = {};
this.allJournals = [];
await this.fetchPromotionJournals();
},
async refreshJournalByDetail(journal) {
if (!journal || !journal.journal_id) return;
const journalId = String(journal.journal_id);
try {
const res = await this.$api.post('api/email_client/getPromotionJournalDetail', { journal_id: journalId });
const detail = this._parseJournalDetail(res.data);
// 更新缓存(供原本的 fetchJournalTemplateAndStyleNames 逻辑兼容)
this.$set(this.templateNameMap, 'j_' + journalId, detail);
// 使用 $set 确保响应式更新
this.$set(journal, 'title', detail.title || journal.title);
this.$set(journal, 'solicit', {
...(journal.solicit || {}),
enabled: detail.enabled,
initialized: detail.initialized,
templateId: detail.templateId,
styleId: detail.styleId,
templateName: detail.templateName,
styleName: detail.styleName,
html: detail.html
});
} catch (e) {
console.error('Refresh detail failed:', e);
}
},
// 保持此方法以兼容 wizard 内的逻辑(实际上逻辑已被 _parseJournalDetail 整合)
async fetchJournalTemplateAndStyleNames(journalId) {
const cacheKey = 'j_' + journalId;
if (this.templateNameMap[cacheKey]) return this.templateNameMap[cacheKey];
try {
const res = await this.$api.post('api/email_client/getPromotionJournalDetail', { journal_id: String(journalId) });
const detail = this._parseJournalDetail(res.data);
this.$set(this.templateNameMap, cacheKey, detail);
return detail;
} catch (e) {
return { templateName: '', styleName: '', html: '' };
}
},
isSolicitConfigured(journal) {
const s = journal && journal.solicit ? journal.solicit : {};
return !!(s.initialized && s.templateId !== '0' && s.styleId !== '0');
},
getSolicitActionText(journal) {
if (!this.isSolicitConfigured(journal)) return this.$t('autoPromotion.goConfig');
return journal && journal.solicit && journal.solicit.enabled
? this.$t('autoPromotion.goManagePlan')
: this.$t('autoPromotion.startPlan');
},
findArray(obj) {
if (Array.isArray(obj)) return obj;
if (!obj || typeof obj !== 'object') return null;
const keys = ['list', 'fields', 'rows', 'items', 'data', 'result'];
for (const k of keys) {
if (Array.isArray(obj[k])) return obj[k];
}
const values = Object.values(obj);
if (values.length && Array.isArray(values[0])) return values[0];
return null;
},
async loadPromotionFields(journalId) {
this.fieldsLoading = true;
this.availableFields = [];
this.selectedFieldIds = [];
try {
const availableRes = await this.$api.post('api/email_client/getAvailableFields', { journal_id: String(journalId) });
console.log('[getAvailableFields] raw response:', JSON.stringify(availableRes));
const availablePayload = (availableRes && availableRes.data) || availableRes || {};
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 label = item.field || item.title || item.name || item.label || String(id);
return { id: String(id), label };
});
console.log('[getAvailableFields] parsed fields:', this.availableFields.length, this.availableFields.slice(0, 3));
} catch (e) {
console.error('[getAvailableFields] error:', e);
this.availableFields = [];
}
try {
const selectedRes = await this.$api.post('api/email_client/getJournalPromotionFields', { journal_id: String(journalId) });
console.log('[getJournalPromotionFields] raw response:', JSON.stringify(selectedRes));
const selectedPayload = (selectedRes && selectedRes.data) || selectedRes || {};
let selectedArr = this.findArray(selectedPayload);
if (selectedArr) {
this.selectedFieldIds = selectedArr.map((it) => {
return String(it.expert_fetch_id || it.fetch_id || it.id || it.field_id || it);
});
} else if (typeof selectedPayload === 'string') {
this.selectedFieldIds = selectedPayload.split(',').map((s) => s.trim()).filter(Boolean);
} else if (typeof selectedPayload.fetch_ids === 'string') {
this.selectedFieldIds = selectedPayload.fetch_ids.split(',').map((s) => s.trim()).filter(Boolean);
}
console.log('[getJournalPromotionFields] parsed selected:', this.selectedFieldIds);
} catch (e) {
console.error('[getJournalPromotionFields] error:', e);
this.selectedFieldIds = [];
}
this.fieldsLoading = false;
},
async savePromotionFieldsNow() {
if (!this.wizardJournal || !this.wizardJournal.journal_id) return;
this.fieldsSaving = true;
try {
await this.$api.post('api/email_client/setJournalPromotionFields', {
journal_id: String(this.wizardJournal.journal_id),
fetch_ids: (this.selectedFieldIds || []).join(',')
});
this.$message.success(this.$t('autoPromotion.fieldsSaved'));
} catch (e) {
this.$message.error(this.$t('autoPromotion.saveFailed'));
} finally {
this.fieldsSaving = false;
}
},
async handleSolicitAction(journal) {
if (!this.isSolicitConfigured(journal)) {
this.openWizardForJournal(journal);
return;
}
// 未开启时:必须等待 setDefaultPromotion 成功后才继续打开详情
if (!journal.solicit.enabled) {
const journalId = journal && journal.journal_id ? String(journal.journal_id) : '';
this.promotionUpdating = true;
this.promotionUpdatingJournalId = journalId;
try {
const userId = localStorage.getItem('U_id') || '';
await this.$api.post('api/email_client/setDefaultPromotion', {
journal_id: String(journal.journal_id),
default_template_id: String(journal.solicit.templateId),
default_style_id: String(journal.solicit.styleId),
start_promotion: '1',
user_id: userId
});
this.$message.success(`${journal.title} ${this.$t('autoPromotion.startedPlan')}`);
await this.refreshJournalByDetail(journal);
this.openDetail(journal);
} catch (e) {
// 接口失败时不要做后续动作(避免进入详情后数据未就绪)
this.$message.error(this.$t('autoPromotion.updateRetryFailed'));
return;
} finally {
this.promotionUpdating = false;
this.promotionUpdatingJournalId = '';
}
return;
}
// 已开启:直接打开详情
this.openDetail(journal);
},
async openWizardForJournal(journal) {
this.wizardJournal = journal;
const s = journal.solicit || {};
this.wizardConfig = {
defaultTemplateId: s.templateId !== '0' ? s.templateId : '',
defaultStyleId: s.styleId !== '0' ? s.styleId : '',
enabled: !!s.enabled
};
this.selectedTemplateName = s.templateName || '';
this.selectedStyleName = s.styleName || '';
this.selectedTemplateThumbHtml = `<div style="zoom:0.18; pointer-events:none; user-select:none;">${s.html || ''}</div>`;
this.selectedFieldIds = [];
this.availableFields = [];
if (journal && journal.journal_id) {
await this.loadPromotionFields(journal.journal_id);
}
this.showWizardDialog = true;
},
handleTemplateApply(payload) {
if (!payload || !payload.template_id || !payload.style_id) {
this.$message.warning(this.$t('autoPromotion.selectTemplateStyleFirst'));
return;
}
this.wizardConfig.defaultTemplateId = String(payload.template_id);
this.wizardConfig.defaultStyleId = String(payload.style_id);
this.selectedTemplateName = payload.template && payload.template.name ? payload.template.name : '';
this.selectedStyleName = payload.style && payload.style.name ? payload.style.name : '';
this.selectedTemplateThumbHtml = `<div style="zoom:0.18; pointer-events:none; user-select:none;">${payload.html || ''}</div>`;
this.showTemplateDialog = false;
},
async saveWizardConfig() {
if (!this.wizardJournal || !this.wizardJournal.solicit) return;
if (!this.wizardConfig.defaultTemplateId || !this.wizardConfig.defaultStyleId) {
this.$message.warning(this.$t('autoPromotion.selectTemplateStyleFirst'));
return;
}
this.saving = true;
try {
const userId = localStorage.getItem('U_id') || '';
await this.$api.post('api/email_client/setDefaultPromotion', {
journal_id: String(this.wizardJournal.journal_id),
default_template_id: this.wizardConfig.defaultTemplateId,
default_style_id: this.wizardConfig.defaultStyleId,
start_promotion: this.wizardConfig.enabled ? '1' : '0',
user_id: userId
});
await this.$api.post('api/email_client/setJournalPromotionFields', {
journal_id: String(this.wizardJournal.journal_id),
fetch_ids: (this.selectedFieldIds || []).join(',')
});
await this.refreshJournalByDetail(this.wizardJournal);
this.$message.success(this.$t('autoPromotion.configSaved'));
this.showWizardDialog = false;
} catch (e) {
this.$message.error(this.$t('autoPromotion.saveFailed'));
} finally {
this.saving = false;
}
},
openDetail(journal) {
this.$router.push({
path: '/autoPromotionLogs',
query: { journal_id: journal && journal.journal_id ? String(journal.journal_id) : '' }
});
},
async handleSwitch(journal, type, nextVal) {
if (!this.isSolicitConfigured(journal)) {
this.$set(journal.solicit, 'enabled', false);
this.$message.warning(this.$t('autoPromotion.notInitializedSwitchTip'));
return;
}
try {
this.promotionUpdating = true;
this.promotionUpdatingJournalId = journal && journal.journal_id ? String(journal.journal_id) : '';
const userId = localStorage.getItem('U_id') || '';
await this.$api.post('api/email_client/setDefaultPromotion', {
journal_id: String(journal.journal_id),
default_template_id: String(journal.solicit.templateId),
default_style_id: String(journal.solicit.styleId),
start_promotion: nextVal ? '1' : '0',
user_id: userId
});
this.$message.success(nextVal ? this.$t('autoPromotion.planEnabled') : this.$t('autoPromotion.planDisabled'));
} catch (e) {
this.$set(journal.solicit, 'enabled', !nextVal);
this.$message.error(this.$t('autoPromotion.updateFailed'));
} finally {
this.promotionUpdating = false;
this.promotionUpdatingJournalId = '';
}
}
}
};
</script>
<style scoped>
/* 保持您原始的 CSS 样式不变 */
.auto-promo-container { padding: 20px 24px; background-color: #f5f7f9; min-height: 100vh; font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto; }
.page-header { margin-bottom: 16px; display: flex; justify-content: flex-start; align-items: center; }
.auto-promo-refresh-btn { margin-left: 12px; }
.journal-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.journal-item { background: #fff; border-radius: 10px; padding: 16px; border: 1px solid #ebedf0; box-shadow: 0 2px 6px rgba(0,0,0,0.03); }
.item-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.journal-info { display: flex; align-items: center; }
.icon-box { width: 28px; height: 28px; background: #edf5ff; border-radius: 4px; display: flex; align-items: center; justify-content: center; margin-right: 10px; }
.icon-box i { color: #409eff; font-size: 14px; }
.journal-name { font-size: 14px; font-weight: 600; color: #1f2d3d; }
.module-wrapper { display: grid; grid-template-columns: 1fr; }
.module-card { border-radius: 6px; padding: 14px; display: flex; flex-direction: column; min-height: 160px; border: 1px solid transparent; }
.is-solicit-active { background: #f4f9ff; border-color: #e1eeff; }
.is-empty { background: #fafafa; border-color: #f0f0f0; }
.module-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.module-top-left { display: flex; align-items: center; gap: 8px; }
.module-title { font-size: 14px; font-weight: 600; color: #333; }
.config-inline-btn { padding: 0; }
.module-content { flex: 1; }
.status-row { display: flex; align-items: center; margin-bottom: 4px; }
.status-text { font-size: 12px; font-weight: 600; color: #52c41a; }
.template-info { font-size: 12px; color: #bbb; margin-bottom: 2px; }
.blue-text { color: #409eff; }
.template-info-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.empty-text { font-size: 12px; color: #bbb; height: 60px; display: flex; align-items: center; }
.dot-running { width: 6px; height: 6px; background: #52c41a; border-radius: 50%; margin-right: 6px; }
.module-footer { margin-top: 12px; }
.action-btn { width: 100%; padding: 6px 0; border: none; border-radius: 4px; font-size: 12px; font-weight: 600; cursor: pointer; transition: 0.2s; }
.btn-blue { background: #e8f3ff; color: #409eff; }
.btn-blue:hover { background: #409eff; color: #fff; }
@media (min-width: 1280px) { .journal-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1680px) { .journal-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
</style>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,158 @@
<template>
<el-dialog
v-if="mode === 'dialog'"
:visible.sync="dialogVisible"
:close-on-click-modal="false"
width="1200px"
top="5vh"
destroy-on-close
:title="title"
custom-class="vertical-wizard-dialog"
>
<auto-promotion-wizard-content
:config="config"
:wizardStartDate="wizardStartDateProxy"
:currentJournalName="currentJournalName"
:selectedTemplateThumbHtml="selectedTemplateThumbHtml"
:selectedTemplateName="selectedTemplateName"
:selectedStyleName="selectedStyleName"
:availableFields="availableFields"
:fieldsLoading="fieldsLoading"
:fieldsSaving="fieldsSaving"
:selectedFieldIds.sync="selectedFieldIdsProxy"
@open-template-selector="emitOpenTemplateSelector"
@confirm-fields="emitConfirmFields"
@update:wizardStartDate="onWizardStartDateUpdate"
/>
<div slot="footer" class="dialog-footer">
<el-button size="small" @click="handleCancel">{{ $t('autoPromotion.cancel') }}</el-button>
<el-button
type="success"
size="small"
:loading="saving"
:disabled="!canConfirm"
@click="handleConfirm"
>
{{ $t('autoPromotion.saveAndApply') }}
</el-button>
</div>
</el-dialog>
<!-- inline 模式直接渲染内容不包裹 el-dialog -->
<div v-else class="vertical-wizard-inline">
<auto-promotion-wizard-content
:config="config"
:wizardStartDate="wizardStartDateProxy"
:currentJournalName="currentJournalName"
:selectedTemplateThumbHtml="selectedTemplateThumbHtml"
:selectedTemplateName="selectedTemplateName"
:selectedStyleName="selectedStyleName"
:availableFields="availableFields"
:fieldsLoading="fieldsLoading"
:fieldsSaving="fieldsSaving"
:selectedFieldIds.sync="selectedFieldIdsProxy"
@open-template-selector="emitOpenTemplateSelector"
@confirm-fields="emitConfirmFields"
@update:wizardStartDate="onWizardStartDateUpdate"
/>
<div class="dialog-footer">
<el-button
type="success"
size="small"
:loading="saving"
:disabled="!canConfirm"
@click="handleConfirm"
>
{{ $t('autoPromotion.saveAndApply') }}
</el-button>
</div>
</div>
</template>
<script>
import AutoPromotionWizardContent from '@/components/page/components/autoPromotion/AutoPromotionWizardContent.vue'
export default {
name: 'AutoPromotionWizard',
components: { AutoPromotionWizardContent },
props: {
mode: { type: String, default: 'dialog' }, // 'dialog' | 'inline'
visible: { type: Boolean, default: false },
title: { type: String, default: '' },
config: { type: Object, required: true },
wizardStartDate: { type: [String, Date], default: '' },
currentJournalName: { type: String, default: '' },
selectedTemplateThumbHtml: { type: String, default: '' },
selectedTemplateName: { type: String, default: '' },
selectedStyleName: { type: String, default: '' },
saving: { type: Boolean, default: false },
availableFields: { type: Array, default: () => [] },
fieldsLoading: { type: Boolean, default: false },
fieldsSaving: { type: Boolean, default: false },
selectedFieldIds: { type: Array, default: () => [] }
},
computed: {
dialogVisible: {
get() {
return this.visible;
},
set(val) {
this.$emit('update:visible', val);
}
},
wizardStartDateProxy: {
get() {
return this.wizardStartDate;
},
set(val) {
this.$emit('update:wizardStartDate', val);
}
},
selectedFieldIdsProxy: {
get() {
return this.selectedFieldIds;
},
set(val) {
this.$emit('update:selectedFieldIds', val);
}
},
canConfirm() {
const id = this.config && this.config.defaultTemplateId != null ? String(this.config.defaultTemplateId) : '';
return id !== '' && id !== '0';
}
},
methods: {
emitOpenTemplateSelector() {
this.$emit('open-template-selector');
},
emitConfirmFields() {
this.$emit('confirm-fields');
},
onWizardStartDateUpdate(val) {
// 由内容组件回传日期,继续走父组件的 .sync 链路
this.wizardStartDateProxy = val;
},
handleCancel() {
this.$emit('cancel');
if (this.mode === 'dialog') {
this.$emit('update:visible', false);
}
},
handleConfirm() {
this.$emit('confirm');
}
}
};
</script>
<style scoped>
.dialog-footer {
display: flex;
justify-content: flex-end;
gap: 10px;
align-items: center;
}
</style>

View File

@@ -0,0 +1,571 @@
<template>
<div class="vertical-wizard-container">
<div class="main-form-content">
<section class="form-section">
<h4 class="section-title">
<i class="el-icon-magic-stick"></i> 1. {{ $t('autoPromotion.selectTemplateStyleTitle') }}
</h4>
<div class="template-card" @click="emitOpenTemplateSelector">
<div v-if="!hasSelectedTemplate" class="empty-state">
<i class="el-icon-plus"></i>
<p>{{ $t('autoPromotion.clickToChooseTemplate') }}</p>
</div>
<div v-else class="selected-content">
<div class="thumb-wrapper">
<div class="thumb-box-mini" v-if="selectedTemplateThumbHtml" >
<div v-html="selectedTemplateThumbHtml" style="zoom:0.7; pointer-events:none; user-select:none;">
</div></div>
<div v-else class="thumb-placeholder">{{ $t('autoPromotion.noPreview') }}</div>
</div>
<div class="info-wrapper">
<div class="tpl-name">{{ $t('autoPromotion.templateName') }}: {{ displayTemplateName }}</div>
<div class="tpl-style">{{ $t('autoPromotion.styleName') }}: {{ selectedStyleName || $t('autoPromotion.defaultStyle') }}</div>
</div>
<div class="action-wrapper">
<el-button type="primary" size="small" plain icon="el-icon-refresh">{{ $t('autoPromotion.changeTemplate') }}</el-button>
</div>
</div>
</div>
</section>
<!-- <el-divider></el-divider>
<section class="form-section">
<h4 class="section-title">
<i class="el-icon-date"></i> 2. 规划发送计划
</h4>
<el-form label-width="120px" size="small">
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="每日执行时间">
<el-time-picker
v-model="config.defaultTime"
value-format="HH:mm:ss"
placeholder="选择时间"
style="width: 100%"
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="任务生效日期">
<el-date-picker
:value="wizardStartDate"
type="date"
placeholder="选择开始日期"
style="width: 100%"
@input="$emit('update:wizardStartDate', $event)"
/>
</el-form-item>
</el-col>
</el-row>
</el-form>
</section> -->
<el-divider></el-divider>
<section class="form-section">
<h4 class="section-title">
<i class="el-icon-collection-tag"></i> 2. {{ $t('autoPromotion.selectPromotionFields') }}
<span class="selected-count">
{{ $t('autoPromotion.selectedCount', { count: selectedFieldIdsProxy.length }) }}
</span>
<el-button
size="small"
type="primary"
plain
icon="el-icon-edit-outline"
class="section-action-btn"
@click="fieldDialogVisible = true"
>
{{ $t('autoPromotion.choosePromotionFields') }}
</el-button>
</h4>
<div class="status-confirm-box">
<div v-if="selectedFieldLabels.length" class="selected-tags">
<el-tag v-for="label in selectedFieldLabels" :key="label" size="mini" type="info" effect="plain">{{ label }}</el-tag>
</div>
<div class="field-tip">{{ $t('autoPromotion.selectPromotionFieldsTip') }}</div>
</div>
</section>
<el-divider></el-divider>
<section class="form-section">
<h4 class="section-title">
<i class="el-icon-finished"></i> 3. {{ $t('autoPromotion.confirmAndEnable') }}
</h4>
<div class="status-confirm-box">
<el-radio-group v-model="config.enabled">
<el-radio :label="false">{{ $t('autoPromotion.onlySaveConfig') }}</el-radio>
<el-radio :label="true">{{ $t('autoPromotion.enableNowNextDay') }}</el-radio>
</el-radio-group>
</div>
</section>
</div>
<el-dialog
:title="$t('autoPromotion.selectPromotionFields')"
:visible.sync="fieldDialogVisible"
width="1200px"
append-to-body
:close-on-click-modal="false"
>
<div class="field-dialog-toolbar">
<el-input
v-model="fieldSearchText"
size="small"
clearable
class="field-search-input"
prefix-icon="el-icon-search"
:placeholder="$t('autoPromotion.fieldSearchPlaceholder')"
/>
<el-button size="mini" @click="selectAllFields">{{ $t('autoPromotion.selectAll') }}</el-button>
<el-button size="mini" @click="clearAllFields">{{ $t('autoPromotion.clearAll') }}</el-button>
</div>
<div class="field-dialog-body" v-loading="fieldsLoading">
<el-checkbox-group v-model="selectedFieldIdsProxy" class="field-check-group">
<el-checkbox v-for="f in sortedFilteredFields" :key="String(f.id)" :label="String(f.id)">
{{ f.label }}
</el-checkbox>
</el-checkbox-group>
<div v-if="!fieldsLoading && sortedFilteredFields.length === 0" class="field-empty-tip">
{{ $t('autoPromotion.noFieldMatch') }}
</div>
</div>
<span slot="footer">
<el-button size="small" @click="fieldDialogVisible = false">{{ $t('autoPromotion.cancel') }}</el-button>
<el-button size="small" type="primary" :loading="fieldsSaving" @click="emitConfirmFields">{{ $t('autoPromotion.confirm') }}</el-button>
</span>
</el-dialog>
</div>
</template>
<script>
export default {
name: 'AutoPromotionWizardContent',
data() {
return {
fieldSearchText: '',
fieldDialogVisible: false
};
},
props: {
config: { type: Object, required: true },
wizardStartDate: { type: [String, Date], default: '' },
currentJournalName: { type: String, default: '' },
selectedTemplateThumbHtml: { type: String, default: '' },
selectedTemplateName: { type: String, default: '' },
selectedStyleName: { type: String, default: '' },
availableFields: { type: Array, default: () => [] },
fieldsLoading: { type: Boolean, default: false },
fieldsSaving: { type: Boolean, default: false },
selectedFieldIds: { type: Array, default: () => [] }
},
computed: {
hasSelectedTemplate() {
const id = this.config && this.config.defaultTemplateId != null ? String(this.config.defaultTemplateId) : '';
return id !== '' && id !== '0';
},
displayTemplateName() {
return this.selectedTemplateName || (this.hasSelectedTemplate ? String(this.config.defaultTemplateId) : '');
},
selectedFieldIdsProxy: {
get() {
return this.selectedFieldIds;
},
set(val) {
this.$emit('update:selectedFieldIds', val);
}
},
sortedFilteredFields() {
const kw = (this.fieldSearchText || '').trim().toLowerCase();
const list = (this.availableFields || []).filter((item) => {
if (!kw) return true;
return String(item.label || '').toLowerCase().includes(kw);
});
return list.slice().sort((a, b) => String(a.label || '').localeCompare(String(b.label || '')));
},
selectedFieldLabels() {
const map = {};
(this.availableFields || []).forEach((i) => { map[String(i.id)] = i.label; });
return (this.selectedFieldIdsProxy || [])
.map((id) => map[String(id)])
.filter(Boolean);
}
},
methods: {
emitOpenTemplateSelector() {
this.$emit('open-template-selector');
},
selectAllFields() {
this.selectedFieldIdsProxy = (this.availableFields || []).map((f) => String(f.id));
},
clearAllFields() {
this.selectedFieldIdsProxy = [];
},
emitConfirmFields() {
this.$emit('confirm-fields');
this.fieldDialogVisible = false;
}
}
};
</script>
<style scoped>
.template-placeholder .inner {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
min-height: 150px;
}
.template-placeholder .inner.selected {
display: block;
min-height: unset;
color: #333;
}
.template-placeholder .inner i {
font-size: 30px;
}
.selected-text {
flex: 1;
min-width: 0;
}
.tpl-line {
color: #606266;
line-height: 20px;
}
.style-line {
color: #909399;
font-size: 12px;
line-height: 18px;
margin-top: 2px;
}
.vertical-wizard-container {
display: flex;
gap: 30px;
padding: 0;
align-items: flex-start;
}
.side-nav {
width: 120px;
flex-shrink: 0;
padding-top: 0;
}
.main-form-content {
flex: 1;
max-height: 80vh;
padding-top: 0;
padding-right: 15px;
}
.form-section {
margin-bottom: 10px;
}
.section-title {
margin: 0 0 20px 0;
font-size: 15px;
color: #303133;
display: flex;
align-items: center;
}
.section-title i {
margin-right: 8px;
color: #409EFF;
font-size: 18px;
}
.section-action-btn {
margin-left: 0;
}
/* 优化后的模板选择框 */
.template-placeholder.mini-mode {
width: 100%;
padding: 15px;
min-height: 60px;
box-sizing: border-box;
background: #f8f9fb;
}
.template-placeholder.mini-mode .inner {
min-height: 60px;
}
.status-confirm-box {
padding: 15px;
/* background: #f0f9eb; */
border-radius: 4px;
/* border: 1px inset #e1f3d8; */
}
.selected-meta {
display: flex;
align-items: center;
}
/* 调整分割线间距 */
.el-divider--horizontal {
margin: 24px 0;
}
.vertical-wizard-container {
display: flex;
gap: 40px;
padding: 20px;
background: #fff;
}
/* 侧边导航核心样式 */
.side-nav {
width: 240px; /* 调宽一点以容纳副标题 */
flex-shrink: 0;
}
.step-item {
display: flex;
gap: 15px;
min-height: 80px; /* 虚线的高度由这个控制 */
}
.step-node {
display: flex;
flex-direction: column;
align-items: center;
width: 32px;
}
/* 圆圈样式 */
.step-node .circle {
width: 28px;
height: 28px;
border: 2px solid #555; /* 默认深灰色 */
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-size: 14px;
font-weight: bold;
color: #555;
background: #fff;
z-index: 2;
}
/* 激活状态的蓝色圆圈 */
.step-item.active .circle {
background: #006699; /* 对应图片里的蓝色 */
border-color: #006699;
color: #fff;
}
/* 虚线连接 */
.step-node .line {
flex: 1;
width: 0;
border-left: 2px dotted #ccc; /* 灰色虚线 */
margin: 4px 0;
}
/* 文字内容 */
.step-content {
padding-top: 2px;
}
.step-content .title {
font-family: "Georgia", serif; /* 模仿图片里的衬线字体感 */
font-size: 16px;
font-weight: bold;
color: #333;
margin-bottom: 4px;
}
.step-item.active .step-content .title {
color: #006699;
}
.step-content .sub {
font-size: 13px;
color: #999;
line-height: 1.4;
}
/* 最后一个节点不需要虚线 */
.step-item.last {
min-height: auto;
}
/* 右侧内容滚动优化 */
.main-form-content {
flex: 1;
max-height: 80vh;
overflow-y: auto;
}
/* 模板选择卡片整体 */
.template-card {
border: 1px solid #ebeef5;
border-radius: 8px;
background: #fcfdfe;
transition: all 0.3s;
cursor: pointer;
overflow: hidden;
}
.template-card:hover {
border-color: #006699;
box-shadow: 0 4px 12px rgba(0, 102, 153, 0.1);
}
/* 空状态 */
.empty-state {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 40px 0;
color: #909399;
}
.empty-state i {
font-size: 28px;
margin-bottom: 10px;
}
/* 已选择内容布局 */
.selected-content {
display: flex;
align-items: center;
padding: 16px 20px;
}
/* 缩略图容器 - 保持比例 */
.thumb-wrapper {
margin-right: 20px;
}
.thumb-box-mini {
width: 120px; /* 稍微调小一点,显得精致 */
height: 160px;
border: 1px solid #e4e7ed;
border-radius: 4px;
overflow: hidden;
background: #fff;
display: flex;
align-items: center;
justify-content: center;
}
/* 处理 v-html 内部图片的样式 */
.thumb-box-mini >>> img {
width: 100%;
height: 100%;
object-fit: contain;
}
/* 文字信息 */
.info-wrapper {
flex: 1;
}
.tpl-name {
font-size: 16px;
font-weight: 600;
color: #303133;
margin-bottom: 6px;
font-family: "Georgia", serif;
}
.tpl-style {
font-size: 13px;
color: #909399;
}
/* 操作按钮靠右 */
.action-wrapper {
margin-left: auto;
}
/* 激活自动推广的 Radio 样式美化 */
.status-confirm-box {
padding: 20px;
background: #f4f7f9;
border-radius: 6px;
}
/* 覆盖 Element Radio 样式,使其更醒目 */
.status-confirm-box >>> .el-radio-group {
display: flex;
gap: 30px;
}
.field-check-group {
display: grid;
grid-template-columns: repeat(4, minmax(180px, 1fr));
gap: 8px 14px;
margin-bottom: 10px;
}
.field-dialog-toolbar {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 12px;
}
.field-search-input {
width: 320px;
}
.field-choose-row {
display: flex;
align-items: center;
justify-content: flex-end;
margin-bottom: 10px;
}
.selected-count {
font-size: 13px;
color: #606266;
margin-left: auto;
margin-right: 10px;
}
.selected-tags {
display: flex;
flex-wrap: wrap;
gap: 6px;
margin-bottom: 10px;
}
.field-dialog-body {
max-height: none;
overflow: visible;
}
.field-empty-tip {
font-size: 12px;
color: #909399;
margin-bottom: 8px;
}
.field-check-group >>> .el-checkbox {
margin-right: 0;
line-height: 20px;
}
.field-check-group >>> .el-checkbox__label {
font-size: 13px;
}
.field-tip {
font-size: 12px;
color: #909399;
}
</style>

View File

@@ -0,0 +1,68 @@
<template>
<el-dialog
:title="`期刊管理: ${journal.title}`"
:visible.sync="localVisible"
width="1200px"
top="5vh"
destroy-on-close
>
<div v-if="mode === 'wizard' || mode === 'config'" class="wizard-container">
<auto-promotion-wizard
mode="inline"
:config="config"
@confirm="handleConfigSuccess"
/>
</div>
<div v-else class="manage-container">
<div class="list-header" style="margin-bottom: 20px;">
<el-button size="small" icon="el-icon-back" @click="mode = 'config'">修改全局配置</el-button>
<el-button size="small" type="primary" icon="el-icon-plus" style="float:right">添加特例任务</el-button>
</div>
<el-table :data="list" border stripe size="small">
</el-table>
</div>
</el-dialog>
</template>
<script>
import AutoPromotionWizard from './AutoPromotionWizard.vue';
export default {
components: { AutoPromotionWizard },
props: {
visible: Boolean,
journal: Object,
initialMode: String // 'list' | 'wizard' | 'config'
},
data() {
return {
mode: this.initialMode,
list: [], // 列表数据
config: { initialized: false } // 配置数据
};
},
computed: {
localVisible: {
get() { return this.visible; },
set(val) { this.$emit('update:visible', val); }
}
},
mounted() {
this.initData();
},
methods: {
async initData() {
// 1. 加载 Config
// 2. 如果是 list 模式,加载 fetchList
},
handleConfigSuccess() {
this.$message.success("配置更新成功");
this.mode = 'list'; // 自动切换回列表模式
this.$emit('refresh'); // 通知父级刷新大盘状态
}
}
}
</script>

File diff suppressed because it is too large Load Diff

View File

@@ -12,7 +12,9 @@ export default {
props: {
value: { type: String, default: '' },
id: { type: String, default: () => 'tiny-' + +new Date() },
showSelectTemplateButton: { type: Boolean, default: false }
showSelectTemplateButton: { type: Boolean, default: false },
// 仅在需要的页面开启“安全初始化内容”
useSafeInitContent: { type: Boolean, default: false }
},
data() {
return {
@@ -125,7 +127,7 @@ autoInlineStyles(htmlContent) {
height: 500,
// 核心配置:允许所有 HTML 标签和样式,这对比邮件模板至关重要
valid_children: '+body[tr],+body[thead],+body[tbody],+body[table],+body[style],+p[style],+div[style]',
extended_valid_elements: 'style,meta,title',
extended_valid_elements: 'div[*],table[*],tr[*],td[*],img[*],style',
custom_elements: 'style,meta,title',
verify_html: false, // 关闭 HTML 校验,防止自动删掉你的邮件结构
forced_root_block: '', // 停止自动包裹 <p> 标签
@@ -162,7 +164,10 @@ autoInlineStyles(htmlContent) {
init_instance_callback: (editor) => {
this.editor = editor;
if (this.value) {
editor.setContent(this.value);
const initContent = this.useSafeInitContent
? this.prepareContentForEditor(this.value)
: this.value;
editor.setContent(initContent);
}
// 监听内容变化
@@ -172,6 +177,21 @@ autoInlineStyles(htmlContent) {
}
});
},
// 假设 rawHtml 是你那一大串完整的 HTML
prepareContentForEditor(rawHtml) {
// 1. 分离出 Head 及其之前的部分 (包含 doctype, html, head)
const headMatch = rawHtml.match(/([\s\S]*?)<body([\s\S]*?)>/i);
this.originalFullHead = headMatch ? headMatch[0] : ''; // 备份头部
// 2. 提取 Body 内部内容,并将 <body> 换成 <div>
// 这样 TinyMCE 就不会因为 fullpage 插件失效而删掉它
let bodyContent = rawHtml.replace(/([\s\S]*?)<body([\s\S]*?)>/i, '')
.replace(/<\/body>([\s\S]*?)<\/html>/i, '');
// 返回给编辑器的内容:用一个特殊的 div 包裹
return `<div id="mail-body-temp" style="margin:0;padding:0;">${bodyContent}</div>`;
},
// 获取经过行内样式转换后的内容
getInlinedContent() {
if (!this.editor) return '';

View File

@@ -0,0 +1,237 @@
<template>
<el-dialog
:visible.sync="visible"
fullscreen
append-to-body
:show-close="false"
custom-class="mail-preview-dialog"
>
<div slot="title" class="preview-navbar">
<div class="navbar-left">
<div class="file-icon-box" :class="getFileTypeClass(file.name)">
<i :class="getFileIcon(file.name)"></i>
</div>
<span class="file-name" :title="file.name">{{ file.name }}</span>
</div>
<div class="navbar-right">
<div class="action-item" @click="handleDownload" :title="$t('mailboxCollect.downloadBtn')">
<i class="el-icon-download"></i>
</div>
<div class="action-item" @click="handlePrint" v-if="isPdf" :title="$t('mailboxCollect.printBtn')">
<i class="el-icon-printer"></i>
</div>
<div class="nav-divider"></div>
<div class="action-item close-btn" @click="visible = false">
<i class="el-icon-close"></i>
</div>
</div>
</div>
<div class="preview-body" v-loading="loading" element-loading-background="rgba(0, 0, 0, 0.7)">
<iframe
v-if="previewUrl"
:src="previewUrl"
class="preview-iframe"
frameborder="0"
@load="loading = false"
></iframe>
<div v-else-if="isImage" class="image-viewer">
<img :src="rawUrl" alt="preview" @load="loading = false" />
</div>
<div v-else-if="!loading" class="error-state">
<el-empty :description="$t('mailboxCollect.previewNotSupported')">
<el-button type="primary" size="small" @click="handleDownload">{{ $t('mailboxCollect.downloadToView') }}</el-button>
</el-empty>
</div>
</div>
</el-dialog>
</template>
<script>
export default {
name: 'FilePreviewDialog',
data() {
return {
visible: false,
loading: false,
file: {},
rawUrl: '', // 原始地址
previewUrl: '', // 拼接后的预览地址
}
},
computed: {
fileExt() {
return this.file.name ? this.file.name.split('.').pop().toLowerCase() : '';
},
isImage() {
return ['png', 'jpg', 'jpeg', 'gif', 'bmp'].includes(this.fileExt);
},
isPdf() {
return this.fileExt === 'pdf';
}
},
methods: {
/**
* 父组件调用此方法打开弹窗
* @param file 附件对象 {name: '', ...}
* @param url 文件的公网绝对路径
*/
init(file, url) {
this.file = file;
this.rawUrl = url;
this.loading = true;
this.visible = true;
const ext = this.fileExt;
// 策略选择
if (['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx'].includes(ext)) {
// Office系列使用微软接口
this.previewUrl = `https://view.officeapps.live.com/op/view.aspx?src=${url}`;
} else if (['pdf', 'txt'].includes(ext) || this.isImage) {
// 浏览器原生支持
this.previewUrl = url;
} else {
this.previewUrl = '';
this.loading = false;
}
},
handleDownload() {
this.$emit('download', this.file);
},
handlePrint() {
window.print();
},
// 复用你之前的图标逻辑
getFileIcon(name) {
if (!name) return 'el-icon-files';
var ext = name.split('.').pop().toLowerCase();
if (['doc', 'docx'].includes(ext)) return 'el-icon-document';
if (['jpg', 'png', 'jpeg'].includes(ext)) return 'el-icon-picture';
return 'el-icon-files';
},
getFileTypeClass(name) {
if (!name) return 'default';
var ext = name.split('.').pop().toLowerCase();
if (['doc', 'docx'].includes(ext)) return 'word';
if (['jpg', 'png', 'jpeg'].includes(ext)) return 'img';
return 'default';
}
}
}
</script>
<style lang="css">
/* 弹窗全屏覆盖与背景 */
.mail-preview-dialog {
background: #000 !important;
}
.mail-preview-dialog .el-dialog__header {
padding: 0;
}
.mail-preview-dialog .el-dialog__body {
padding: 0;
height: calc(100vh - 56px);
background: #333;
}
/* 顶部导航栏 */
.preview-navbar {
height: 56px;
background: #1a1a1a;
display: flex;
justify-content: space-between;
align-items: center;
padding: 0 20px;
}
.navbar-left {
display: flex;
align-items: center;
color: #fff;
max-width: 70%;
}
.file-icon-box {
width: 30px;
height: 30px;
border-radius: 4px;
display: flex;
align-items: center;
justify-content: center;
margin-right: 12px;
font-size: 18px;
}
.file-icon-box.word { background: #0052d9; }
.file-icon-box.img { background: #e34d59; }
.file-icon-box.default { background: #737b85; }
.navbar-left .file-name {
font-size: 16px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
/* 右侧操作栏 */
.navbar-right {
display: flex;
align-items: center;
}
.action-item {
width: 40px;
height: 40px;
display: flex;
align-items: center;
justify-content: center;
color: #ccc;
cursor: pointer;
font-size: 20px;
transition: all 0.2s;
border-radius: 4px;
}
.action-item:hover {
background: #333;
color: #fff;
}
.close-btn:hover {
background: #e34d59;
}
.nav-divider {
width: 1px;
height: 20px;
background: #444;
margin: 0 10px;
}
/* 内容区域 */
.preview-body {
width: 100%;
height: 100%;
}
.preview-iframe {
width: 100%;
height: 100%;
background: #fff;
}
.image-viewer {
display: flex;
justify-content: center;
align-items: center;
height: 100%;
}
.image-viewer img {
max-width: 90%;
max-height: 90%;
box-shadow: 0 0 20px rgba(0,0,0,0.5);
}
.error-state {
padding-top: 100px;
}
</style>

View File

@@ -1,202 +1,662 @@
<template>
<div class="mail-detail-container">
<div class="detail-toolbar">
<div class="toolbar-left">
<!-- <el-tooltip content="回复" placement="bottom"><i class="el-icon-chat-line-square action-icon"></i></el-tooltip>
<el-tooltip content="转发" placement="bottom"><i class="el-icon-position action-icon"></i></el-tooltip>
<el-tooltip content="删除" placement="bottom"><i class="el-icon-delete action-icon" style="color: #fb2c36;"></i></el-tooltip>
-->
</div>
<div class="toolbar-right">
<!-- <i class="el-icon-star-off action-icon"></i> -->
<i class="el-icon-close action-icon" @click="$emit('close')"></i>
<div class="detail-toolbar">
<div class="toolbar-left">
<h1 class="mail-subject-top">{{ $t('mailboxCollect.subject') }}{{ mailData.subject }}</h1>
</div>
<div class="toolbar-right">
<!-- <i class="el-icon-star-off action-icon"></i> -->
<i class="el-icon-close action-icon" @click="$emit('close')"></i>
</div>
</div>
<div class="detail-scroll-content">
<div class="mail-header-info">
<el-avatar :size="40" class="sender-avatar">{{ (mailData.from_name || 'U')[0] }}</el-avatar>
<div class="info-main">
<div class="first-line">
<span class="sender-name">{{ mailData.from_name }}</span>
<span class="sender-email">&lt;{{ mailData.from_email }}&gt;</span>
<span class="send-time">{{ formatDisplayTime(mailData.email_date) }}</span>
<span
class="detail-toggle"
@click="isDetailExpanded = !isDetailExpanded"
v-if="mailData.to_list && mailData.to_list.length > 0"
>
{{ isDetailExpanded ? '收起' : '详情' }}
<i :class="isDetailExpanded ? 'el-icon-arrow-up' : 'el-icon-arrow-down'"></i>
</span>
</div>
<div v-if="isDetailExpanded" class="expanded-info">
<div class="info-row">
<span class="label">收件人</span>
<div class="recipient-tags">
<el-tag v-for="(to, index) in mailData.to_list" :key="'to-' + index" size="mini" type="info">{{
to.name || to.email
}}</el-tag>
</div>
</div>
<div v-if="mailData.cc_list && mailData.cc_list.length" class="info-row">
<span class="label">抄送</span>
<div class="recipient-tags">
<el-tag
v-for="(cc, index) in mailData.cc_list"
:key="'cc-' + index"
size="mini"
type="warning"
effect="plain"
>{{ cc.name || cc.email }}</el-tag
>
</div>
</div>
</div>
<div v-else class="simple-info" v-if="mailData.to_list && mailData.to_list.length > 0">
发送给
{{ mailData.to_list && mailData.to_list[0] ? mailData.to_list[0].name || mailData.to_list[0].email : '' }} {{
mailData.to_list.length
}}
</div>
<div v-if="mailData.attachments && mailData.attachments.length" class="attachment-brief-bar">
<span class="brief-info">
{{ $t('mailboxCollect.totalAttachments', { count: mailData.attachments.length }) }}
<i class="el-icon-document" style="color: #409EFF;"></i>
<span class="first-file-name">{{ mailData.attachments[0].name }}{{ mailData.attachments.length > 1 ? $t('mailboxCollect.etcSuffix') : '' }}</span>
</span>
<el-link type="primary" :underline="false" @click="scrollToAttachments" class="jump-link">
{{ $t('mailboxCollect.viewAttachments') }}
</el-link>
</div>
</div>
</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">
<div class="header-left">
<span>{{ mailData.attachments.length }}{{ $t('mailboxCollect.attachmentCount') }} ({{ totalAttachmentSize }})</span>
<span class="divider">|</span>
<span class="download-all" @click="downloadAll">
<template v-if="packingAll"><i class="el-icon-loading"></i> {{ $t('mailboxCollect.packingAttachments') }}</template>
<template v-else>{{ $t('mailboxCollect.downloadAllZip') }}</template>
</span>
</div>
</div>
<div class="attachment-list">
<div v-for="(file, index) in mailData.attachments" :key="index" class="attachment-card">
<div class="file-icon" :class="getFileTypeClass(file.name)">
<i :class="getFileIcon(file.name)"></i>
</div>
<div class="detail-scroll-content">
<h1 class="mail-subject">{{ mailData.subject }}</h1>
<div class="mail-header-info">
<el-avatar :size="40" class="sender-avatar">{{ (mailData.from_name || 'U')[0] }}</el-avatar>
<div class="info-main">
<div class="first-line">
<span class="sender-name">{{ mailData.from_name }}</span>
<span class="sender-email">&lt;{{ mailData.from_email }}&gt;</span>
<span class="send-time">{{ formatDisplayTime(mailData.email_date) }}</span>
<span class="detail-toggle" @click="isDetailExpanded = !isDetailExpanded" v-if="mailData.to_list&&mailData.to_list.length>0">
{{ isDetailExpanded ? '收起' : '详情' }} <i :class="isDetailExpanded ? 'el-icon-arrow-up' : 'el-icon-arrow-down'"></i>
</span>
</div>
<div v-if="isDetailExpanded" class="expanded-info">
<div class="info-row">
<span class="label">收件人</span>
<div class="recipient-tags">
<el-tag v-for="(to, index) in mailData.to_list" :key="'to-'+index" size="mini" type="info">{{ to.name || to.email }}</el-tag>
</div>
</div>
<div v-if="mailData.cc_list && mailData.cc_list.length" class="info-row">
<span class="label">抄送</span>
<div class="recipient-tags">
<el-tag v-for="(cc, index) in mailData.cc_list" :key="'cc-'+index" size="mini" type="warning" effect="plain">{{ cc.name || cc.email }}</el-tag>
</div>
</div>
</div>
<div v-else class="simple-info" v-if="mailData.to_list&&mailData.to_list.length>0">
发送给 {{ mailData.to_list && mailData.to_list[0] ? (mailData.to_list[0].name || mailData.to_list[0].email) : '' }} {{ mailData.to_list.length }}
</div>
</div>
</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">
<span>{{ mailData.attachments.length }}个附件 ({{ totalAttachmentSize }})</span>
<el-button type="text" size="small">打包下载</el-button>
<span class="security-tip"><i class="el-icon-success"></i> 附件中未发现病毒</span>
</div>
<div class="attachment-list">
<div v-for="(file, index) in mailData.attachments" :key="index" class="attachment-card">
<div class="file-icon">
<i :class="getFileIcon(file.name)"></i>
</div>
<div class="file-info">
<div class="file-name" :title="file.name">{{ file.name }}</div>
<div class="file-size">{{ file.size }}</div>
</div>
</div>
</div>
<div class="file-info">
<div class="file-name" :title="file.name">{{ file.name }}</div>
<div class="file-size-row">
<span class="file-size">{{ formatFileSize(file.size) }}</span>
<span class="file-actions">
<!-- <i class="el-icon-view" title="预览" @click.stop="previewAttachment(file)"></i> -->
<i
:class="downloadingIndex === index ? 'el-icon-loading' : 'el-icon-download'"
:title="downloadingIndex === index ? '' : '下载'"
@click.stop="downloadAttachment(file, index)"
></i>
</span>
</div>
</div>
</div>
</template>
<script>
export default {
</div>
</div>
</div>
<file-preview-dialog
ref="previewDialog"
@download="downloadAttachment"
/>
</div>
</template>
<script>
import Common from '@/components/common/common';
import JSZip from 'jszip';
import { saveAs } from 'file-saver';
import FilePreviewDialog from './FilePreviewDialog.vue';
export default {
components: {
FilePreviewDialog
},
name: 'MailDetail',
props: {
mailData: {
type: Object,
default: () => ({
subject: '',
from_name: '',
from_email: '',
send_time: '',
to_list: [],
cc_list: [],
content: '',
attachments: []
})
}
mailData: {
type: Object,
default: () => ({
subject: '',
from_name: '',
from_email: '',
send_time: '',
to_list: [],
cc_list: [],
content: '',
attachments: []
})
}
},
data() {
return {
isDetailExpanded: false
};
return {
mediaUrl: Common.mediaUrl,
isDetailExpanded: false,
downloadingIndex: -1,
packingAll: false
};
},
computed: {
totalAttachmentSize() {
// 简单模拟计算总量,实际可根据逻辑累加
return "11MB";
}
totalAttachmentSize() {
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);
}
},
methods: {
formatDisplayTime(timestamp) {
if (!timestamp) return '';
// 1. 处理 10 位秒级时间戳,转为毫秒并实例化 Date 对象
const date = new Date(Number(timestamp) * 1000);
const now = new Date();
// 提取日期信息用于比较
const dateYear = date.getFullYear();
const dateMonth = date.getMonth() + 1;
const dateDay = date.getDate();
const nowYear = now.getFullYear();
// 获取昨天日期
const yesterday = new Date(now);
yesterday.setDate(now.getDate() - 1);
// 获取具体时分并补零 (例如 09:05)
const hours = date.getHours().toString().padStart(2, '0');
const minutes = date.getMinutes().toString().padStart(2, '0');
const timePart = `${hours}:${minutes}`;
// --- 按照图示规则判断返回 ---
// 1. 如果是今天:只显示时间,如 "15:57"
if (date.toDateString() === now.toDateString()) {
return timePart;
}
// 2. 如果是昨天:只显示 "昨天"
if (date.toDateString() === yesterday.toDateString()) {
return '昨天';
}
// 3. 如果是今年(非今天/昨天):显示 "月-日",如 "3月8日"
if (dateYear === nowYear) {
return `${dateMonth}${dateDay}`;
}
// 4. 如果是往年:显示完整年月日,如 "2025-12-05"
const fullMonth = dateMonth.toString().padStart(2, '0');
const fullDay = dateDay.toString().padStart(2, '0');
return `${dateYear}-${fullMonth}-${fullDay}`;
},
getFileIcon(fileName) {
if (fileName.includes('.doc')) return 'el-icon-document text-blue';
if (fileName.includes('.pdf')) return 'el-icon-document text-red';
return 'el-icon-document';
}
scrollToAttachments() {
// 1. 获取目标元素的 DOM
const target = this.$el.querySelector('.attachment-section');
if (target) {
// 2. 使用原生 scrollIntoView 实现平滑滚动
target.scrollIntoView({
behavior: 'smooth', // 平滑滚动
block: 'start' // 滚动到元素顶部
});
}
};
</script>
},
getFileTypeClass(fileName) {
if (!fileName) return 'txt';
const ext = fileName.split('.').pop().toLowerCase();
if (['jpg', 'jpeg', 'png', 'gif'].includes(ext)) return 'img';
if (['doc', 'docx'].includes(ext)) return 'word';
if (['html', 'htm'].includes(ext)) return 'html';
return 'txt';
},
// 你原有的 getFileIcon 也要对应修改
getFileIcon(fileName) {
const ext = fileName.split('.').pop().toLowerCase();
if (['jpg', 'jpeg', 'png', 'gif'].includes(ext)) return 'el-icon-picture';
if (['doc', 'docx'].includes(ext)) return 'el-icon-document'; // 这里可以用Word图标
if (['html', 'htm'].includes(ext)) return 'el-icon-document-remove';
return 'el-icon-tickets';
},
formatFileSize(bytes) {
const b = Number(bytes);
if (!b || b <= 0) return '-';
if (b < 1024) return b + 'B';
if (b < 1024 * 1024) return (b / 1024).toFixed(1) + 'KB';
if (b < 1024 * 1024 * 1024) return (b / (1024 * 1024)).toFixed(1) + 'MB';
return (b / (1024 * 1024 * 1024)).toFixed(2) + 'GB';
},
async ensureFileUrl(file) {
if (file.file_url) return file.file_url;
const inboxId = this.mailData.inbox_id;
const partIndex = file.part_index != null ? file.part_index : 0;
if (!inboxId) return '';
const res = await this.$api.post('api/email_client/getAttachment', {
inbox_id: String(inboxId),
part_index: String(partIndex)
});
if (res && res.data && res.data.file_url) {
file.file_url = res.data.file_url;
return res.data.file_url;
}
return '';
},
async downloadAll() {
if (this.packingAll) return;
this.packingAll = true;
try {
const zip = new JSZip();
const promises = this.mailData.attachments.map(async (file) => {
const url = await this.ensureFileUrl(file);
if (!url) return;
const fileUrl = this.mediaUrl + url;
const resp = await fetch(fileUrl);
const blob = await resp.blob();
zip.file(file.name || 'attachment', blob);
});
await Promise.all(promises);
const content = await zip.generateAsync({ type: 'blob' });
const zipName = (this.mailData.subject || 'attachments') + '.zip';
saveAs(content, zipName);
} catch (e) {
this.$message.error(this.$t('mailboxCollect.downloadFail') || '下载失败');
} finally {
this.packingAll = false;
}
},
async previewAttachment(file){
console.log("🚀 ~ previewAttachment ~ file:", file);
var that = this;
that.$refs.previewDialog.init(file, this.mediaUrl+file.file_url || '');
// 1. 获取后端返回的 URL
const res = await this.$api.post('api/email_client/getAttachment', {
inbox_id: String(this.mailData.inbox_id),
part_index: String(file.part_index || 0)
});
if (res.data && res.data.file_url) {
const fullUrl = this.mediaUrl + res.data.file_url;
// 2. 调用弹窗组件的 init 方法
// 注意:微软预览要求 fullUrl 必须是公网可访问的!
}
},
async downloadAttachment(file, index) {
if (this.downloadingIndex >= 0) return;
this.downloadingIndex = index;
try {
const url = await this.ensureFileUrl(file);
if (!url) {
this.$message.warning(this.$t('mailboxCollect.downloadFail') || '下载失败');
return;
}
const fileUrl = this.mediaUrl + url;
const fileName = file.name || 'attachment';
const resp = await fetch(fileUrl);
const blob = await resp.blob();
saveAs(blob, fileName);
} catch (e) {
this.$message.error(this.$t('mailboxCollect.downloadFail') || '下载失败');
} finally {
this.downloadingIndex = -1;
}
},
formatDisplayTime(timestamp) {
if (!timestamp) return '';
// 1. 处理 10 位秒级时间戳,转为毫秒并实例化 Date 对象
const date = new Date(Number(timestamp) * 1000);
const now = new Date();
// 提取日期信息用于比较
const dateYear = date.getFullYear();
const nowYear = now.getFullYear();
const lang = localStorage.getItem('langs') === 'zh' ? 'zh-CN' : 'en-US';
// 获取昨天日期
const yesterday = new Date(now);
yesterday.setDate(now.getDate() - 1);
// 获取具体时分并补零 (例如 09:05)
const hours = date.getHours().toString().padStart(2, '0');
const minutes = date.getMinutes().toString().padStart(2, '0');
const timePart = `${hours}:${minutes}`;
// --- 按照图示规则判断返回 ---
// 1. 如果是今天:只显示时间,如 "15:57"
if (date.toDateString() === now.toDateString()) {
return timePart;
}
// 2. 如果是昨天:显示 "昨天 15:57"
if (date.toDateString() === yesterday.toDateString()) {
return this.$t('mailboxCollect.yesterday') + ' ' + timePart;
}
// 3. 如果是今年(非今天/昨天):按语言显示月日
if (dateYear === nowYear) {
return new Intl.DateTimeFormat(lang, { month: 'short', day: 'numeric' }).format(date);
}
// 4. 如果是往年:显示完整年月日,如 "2025-12-05"
const dateMonth = date.getMonth() + 1;
const dateDay = date.getDate();
const fullMonth = dateMonth.toString().padStart(2, '0');
const fullDay = dateDay.toString().padStart(2, '0');
return `${dateYear}-${fullMonth}-${fullDay}`;
},
}
};
</script>
<style scoped>
.mail-detail-container {
height: 100%;
display: flex;
flex-direction: column;
background: #fff;
}
/* 顶部工具栏 */
.detail-toolbar {
padding: 10px 20px;
border-bottom: 1px solid #f0f0f0;
display: flex;
justify-content: space-between;
align-items: center;
}
.toolbar-left {
flex: 1;
min-width: 0;
}
.mail-subject-top {
margin: 0;
font-size: 18px;
font-weight: bold;
color: #303133;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.action-icon {
font-size: 18px;
color: #606266;
cursor: pointer;
}
.action-icon:hover {
color: #409eff;
}
.detail-scroll-content {
flex: 1;
overflow-y: auto;
padding: 20px 20px;
}
/* 头部信息 */
.mail-header-info {
display: flex;
margin-bottom: 20px;
}
.info-main {
flex: 1;
margin-left: 15px;
}
.first-line {
display: flex;
align-items: center;
margin-bottom: 5px;
font-size: 14px;
}
.sender-name {
font-weight: bold;
color: #303133;
}
.sender-email {
color: #909399;
margin-left: 5px;
}
.send-time {
margin-left: auto;
color: #909399;
}
.detail-toggle {
margin-left: 10px;
color: #409eff;
cursor: pointer;
font-size: 12px;
}
.expanded-info {
background: #f8f9fa;
padding: 10px;
border-radius: 4px;
margin-top: 10px;
}
.info-row {
display: flex;
margin-bottom: 8px;
}
.info-row .label {
width: 60px;
color: #909399;
font-size: 13px;
}
.recipient-tags {
flex: 1;
display: flex;
flex-wrap: wrap;
gap: 5px;
}
.simple-info {
font-size: 12px;
color: #909399;
}
/* 正文 */
.mail-body-content {
line-height: 1.6;
font-size: 14px;
color: #303133;
min-height: 200px;
margin-bottom: 50px;
}
/* 附件卡片 */
.attachment-section {
border-top: 1px solid #eee;
padding-top: 20px;
}
.attachment-header {
margin-bottom: 15px;
font-size: 13px;
color: #606266;
display: flex;
align-items: center;
}
.security-tip {
margin-left: auto;
color: #67c23a;
}
.attachment-list {
display: flex;
flex-wrap: wrap;
gap: 15px;
}
.attachment-card {
/* width: 260px; */
/* border: 1px solid #e4e7ed; */
border-radius: 4px;
display: flex;
align-items: center;
padding: 10px;
background: #fbfbfc;
cursor: pointer;
transition: border-color 0.2s, box-shadow 0.2s;
}
.attachment-card:hover {
border-color: #409eff;
box-shadow: 0 2px 8px rgba(64, 158, 255, 0.12);
}
.file-icon {
font-size: 32px;
color: #409eff;
margin-right: 12px;
}
.file-info {
flex: 1;
overflow: hidden;
}
.file-name {
font-size: 13px;
color: #303133;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.file-size {
font-size: 12px;
color: #909399;
margin-top: 4px;
}
.file-download {
font-size: 18px;
color: #909399;
margin-left: 8px;
}
.attachment-card:hover .file-download {
color: #409eff;
}
.text-blue {
color: #409eff;
}
.text-red {
color: #f56c6c;
}
.attachment-section {
padding-top: 10px;
background-color: #fff;
border-top: 1px solid #f0f0f0;
}
/* 头部样式 */
.attachment-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 12px;
font-size: 13px;
color: #666;
}
.attachment-header .divider {
margin: 0 10px;
color: #e0e0e0;
}
.attachment-header .download-all {
color: #409eff;
cursor: pointer;
}
.attachment-header .header-right {
color: #2ba471; /* 安全绿色 */
font-size: 12px;
}
/* 列表布局 */
.attachment-list {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
gap: 10px;
}
/* 附件卡片 */
.attachment-card {
display: flex;
align-items: center;
padding: 10px;
background-color: #f3f5f8; /* 浅灰色背景 */
border-radius: 2px;
cursor: default;
transition: background-color 0.2s;
height: 54px;
box-sizing: border-box;
}
.attachment-card:hover {
background-color: #e7eaf0;
}
/* 图标颜色控制 */
.file-icon {
width: 32px;
height: 32px;
display: flex;
align-items: center;
justify-content: center;
margin-right: 12px;
border-radius: 2px;
font-size: 20px;
color: #fff;
}
/* 根据类型设置背景色 (需在 getFileTypeClass 中返回) */
.file-icon.img { background-color: #e34d59; } /* 红色 */
.file-icon.word { background-color: #0052d9; } /* 蓝色 */
.file-icon.html { background-color: #ed7b2f; } /* 橙色 */
.file-icon.txt { background-color: #737b85; } /* 灰色 */
/* 信息部分 */
.file-info {
flex: 1;
overflow: hidden;
}
.file-name {
font-size: 13px;
color: #333;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
margin-bottom: 2px;
}
.file-size-row {
display: flex;
justify-content: space-between;
align-items: center;
height: 18px;
}
.file-size {
font-size: 12px;
color: #999;
}
/* 悬浮图标控制 */
.file-actions {
align-items: center;
}
.attachment-card:hover .file-actions {
display: flex;
}
.file-actions i {
margin-left: 12px;
font-size: 16px;
color: #666;
cursor: pointer;
}
.file-actions i:hover {
color: #0052d9;
}
.attachment-brief-bar {
display: flex;
align-items: center;
padding: 8px 0;
font-size: 13px;
color: #606266;
border-top: 1px solid #ebeef5;
<style scoped>
.mail-detail-container { height: 100%; display: flex; flex-direction: column; background: #fff; }
/* 顶部工具栏 */
.detail-toolbar { padding: 10px 20px; border-bottom: 1px solid #f0f0f0; display: flex; justify-content: space-between; align-items: center; }
.action-icon { font-size: 18px; color: #606266; cursor: pointer; margin-right: 20px; }
.action-icon:hover { color: #409EFF; }
.detail-scroll-content { flex: 1; overflow-y: auto; padding: 20px 40px; }
/* 邮件标题 */
.mail-subject { font-size: 20px; font-weight: bold; margin-bottom: 25px; color: #303133; }
/* 头部信息 */
.mail-header-info { display: flex; margin-bottom: 30px; }
.info-main { flex: 1; margin-left: 15px; }
.first-line { display: flex; align-items: center; margin-bottom: 5px; font-size: 14px; }
.sender-name { font-weight: bold; color: #303133; }
.sender-email { color: #909399; margin-left: 5px; }
.send-time { margin-left: auto; color: #909399; }
.detail-toggle { margin-left: 10px; color: #409EFF; cursor: pointer; font-size: 12px; }
.expanded-info { background: #f8f9fa; padding: 10px; border-radius: 4px; margin-top: 10px; }
.info-row { display: flex; margin-bottom: 8px; }
.info-row .label { width: 60px; color: #909399; font-size: 13px; }
.recipient-tags { flex: 1; display: flex; flex-wrap: wrap; gap: 5px; }
.simple-info { font-size: 12px; color: #909399; }
/* 正文 */
.mail-body-content { line-height: 1.6; font-size: 14px; color: #303133; min-height: 200px; margin-bottom: 50px; }
/* 附件卡片 */
.attachment-section { border-top: 1px solid #eee; padding-top: 20px; }
.attachment-header { margin-bottom: 15px; font-size: 13px; color: #606266; display: flex; align-items: center; }
.security-tip { margin-left: auto; color: #67C23A; }
.attachment-list { display: flex; flex-wrap: wrap; gap: 15px; }
.attachment-card { width: 260px; border: 1px solid #e4e7ed; border-radius: 4px; display: flex; padding: 10px; background: #fbfbfc; }
.file-icon { font-size: 32px; color: #409EFF; margin-right: 12px; }
.file-info { flex: 1; overflow: hidden; }
.file-name { font-size: 13px; color: #303133; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-size { font-size: 12px; color: #909399; margin-top: 4px; }
.text-blue { color: #409EFF; }
.text-red { color: #F56C6C; }
</style>
}
.attachment-brief-bar .brief-info {
}
.attachment-brief-bar .first-file-name {
color: #909399;
margin-left: 4px;
}
.jump-link {
margin-left: 15px;
font-size: 13px;
}
.attachment-section {
margin-top: 30px;
padding-top: 20px;
border-top: 2px solid #f0f2f5;
}
</style>

View File

@@ -1,274 +1,534 @@
<template>
<el-dialog
title="Template Selection"
:visible.sync="visible"
:close-on-click-modal="false"
width="90%"
top="5vh"
destroy-on-close
:before-close="handleClose"
custom-class="template-modal"
:title="dialogTitle"
:visible.sync="visible"
:close-on-click-modal="false"
width="90%"
top="5vh"
destroy-on-close
:before-close="handleClose"
custom-class="template-modal"
>
<div class="template-wrapper">
<div class="selection-panel">
<el-tabs v-model="activeStep">
<el-tab-pane label="1.Choose Style" name="style">
<div class="card-grid">
<div
v-for="(item,index) in headerStyles" :key="item.id"
:class="['card-item', { active: selectedHeaderId === item.id }]"
@click="selectedHeaderId = item.id"
<div class="template-wrapper">
<div class="selection-panel">
<div class="selection-header">
<el-button
type="text"
size="mini"
icon="el-icon-refresh"
:disabled="initLoading || contentLoading || !selectedJournalId"
:title="$t('mailTemplate.refresh')"
@click="refreshTemplatesAndStyles"
/>
</div>
<el-tabs v-model="activeStep">
<el-tab-pane :label="$t('mailTemplate.templateTab')" name="content">
<div class="card-grid" v-loading="contentLoading">
<div
v-for="(item, index) in contentTemplates"
:key="item.id"
:class="['card-item', { active: selectedContentId === item.id }]"
@click="selectedContentId = item.id"
>
<p class="card-title" style="text-align: left; margin-top: 0">
<span>{{ index + 1 }}. </span>{{ item.name }}<br /><span style="color: #888">{{ item.subject }}</span>
</p>
</div>
</div>
</el-tab-pane>
<el-tab-pane :label="$t('mailTemplate.styleTab')" name="style">
<div class="card-grid">
<div
v-for="(item, index) in headerStyles"
:key="item.id"
:class="['card-item', { active: selectedHeaderId === item.id }]"
@click="selectedHeaderId = item.id"
>
<div class="card-img" @click.stop="selectedHeaderId = item.id">
<div
v-html="item.htmlHeader + item.htmlFooter"
style="zoom: 0.15; pointer-events: none; user-select: none"
></div>
</div>
<p class="card-title">
<span>{{ index + 1 }}. </span>{{ item.name }}
</p>
<p class="card-desc" :class="{ expanded: expandedHeaderId === item.id }" @click.stop="toggleDesc(item.id)">
{{ item.description }}
</p>
</div>
</div>
</el-tab-pane>
</el-tabs>
</div>
<div class="preview-panel">
<div class="preview-head">
<div class="preview-label">LIVE PREVIEW</div>
<div class="selected-info-inline">Selected: <strong>{{ currentSelectionText }}</strong></div>
</div>
<div class="preview-container" v-loading="initLoading" :element-loading-text="$t('mailTemplate.loading')">
<div v-if="!initLoading && !hasValidPreview" class="preview-empty-state">
<div class="preview-empty-text">{{ $t('mailTemplate.noTemplateTip') }}</div>
<el-button type="primary" size="mini" class="preview-empty-btn" @click="goToMailTemplateList">
{{ $t('mailTemplate.addTemplateBtn') }}
</el-button>
</div>
<div v-else-if="hasValidPreview" class="mail-render-box" v-html="combinedHtml"></div>
</div>
</div>
</div>
<div slot="footer" class="dialog-footer">
<div>
<el-button @click="handleClose" style="">Cancel</el-button>
<el-button
type="primary"
icon="el-icon-check"
:disabled="applyDisabled"
:class="{ 'apply-btn-disabled-soft': applyDisabled }"
@click="submit"
>
<div class="card-img" @click.stop="selectedHeaderId = item.id">
<div v-html="item.htmlHeader+item.htmlFooter" style="zoom: 0.15;pointer-events: none; user-select: none;"></div>
</div>
<p class="card-title"><span>{{ index+1 }}. </span>{{ item.name }}</p>
<p
class="card-desc"
:class="{ expanded: expandedHeaderId === item.id }"
@click.stop="toggleDesc(item.id)"
>
{{ item.description }}
</p>
</div>
</div>
</el-tab-pane>
<el-tab-pane label="2.Choose Template" name="content">
<div style="margin-bottom: 15px; padding: 0 5px;">
<p style="font-size: 12px; color: #999; margin-bottom: 5px;">Journal:</p>
<el-select
v-model="selectedJournalId"
placeholder="All Journals"
clearable
size="small"
style="width: 100%"
@change="handleJournalChange"
>
<el-option
v-for="item in journalOptions"
:key="item.id"
:label="item.label"
:value="item.id"
/>
</el-select>
</div>
<div
class="card-grid"
v-loading="contentLoading"
>
<div
v-for="(item,index) in contentTemplates" :key="item.id"
:class="['card-item', { active: selectedContentId === item.id }]"
@click="selectedContentId = item.id"
>
<p class="card-title" style="text-align: left;margin-top: 0;"><span>{{ index+1 }}. </span>{{ item.name }}<br><span style="color:#888 ;">{{ item.subject }}</span></p>
</div>
</div>
</el-tab-pane>
</el-tabs>
Apply Template
</el-button>
</div>
</div>
<div class="preview-panel">
<div class="preview-label">LIVE PREVIEW</div>
<div class="preview-container">
<div class="mail-render-box" v-html="combinedHtml"></div>
</div>
</div>
</div>
<div slot="footer" class="dialog-footer">
<div class="footer-info">
Selected: <strong>{{ currentSelectionText }}</strong>
</div>
<div>
<el-button @click="handleClose" style="">Cancel</el-button>
<el-button type="primary" icon="el-icon-check" @click="submit">Apply Template</el-button>
</div>
</div>
</el-dialog>
</template>
<script>
export default {
</template>
<script>
export default {
props: {
visible: Boolean
visible: Boolean,
// 非发送邮件页面可由父组件显式传入期刊 ID发送邮件页不传则自动读取本地缓存
journalId: { type: [String, Number], default: '' },
// 可选:由父组件传入期刊名称,避免单期刊场景显示为 journal_id
journalLabel: { type: String, default: '' },
// 可选:打开时回显的风格/模板
initialStyleId: { type: [String, Number], default: '' },
initialTemplateId: { type: [String, Number], default: '' },
// 可选:来源页面标识,用于回跳时决定 mailboxMouldDetail 返回到哪里
// 例如:'autoPromotion':返回自动化推广;默认返回邮件模版列表
returnSource: { type: String, default: '' }
},
data() {
return {
activeStep: 'style',
// 期刊过滤
journalOptions: [],
selectedJournalId: null,
selectedHeaderId: null,
selectedContentId: null,
expandedHeaderId: null,
// 头部样式列表(通过接口获取)
headerStyles: [],
contentTemplates: [],
contentLoading: false
};
return {
activeStep: 'content',
// 期刊过滤
journalOptions: [],
selectedJournalId: null,
selectedHeaderId: null,
selectedContentId: null,
expandedHeaderId: null,
// 头部样式列表(通过接口获取)
headerStyles: [],
contentTemplates: [],
contentLoading: false,
// 右侧预览整体加载态:等风格/模版接口都返回后再展示“无数据提示”
initLoading: false
};
},
watch: {
// 父组件动态切换期刊时,弹窗内同步刷新(不依赖地址栏)
journalId: {
handler(val) {
if (val == null || val === '') return;
const next = String(val);
if (String(this.selectedJournalId) === next) return;
// 不依赖期刊列表:直接切换期刊并刷新样式/模板
this.selectedJournalId = Number(next);
if (!Array.isArray(this.journalOptions) || !this.journalOptions.some((j) => String(j.id) === next)) {
const label = this.journalLabel ? this.journalLabel : next;
this.journalOptions = [{ id: this.selectedJournalId, label: label }];
}
this.handleJournalChange();
},
immediate: false
},
visible(val) {
if (val) this.applyInitialSelection();
}
},
created() {
this.fetchJournals();
this.fetchHeaderStyles();
// 初始化:优先父组件传入 journalId其次本地缓存发送邮件页最后默认第一本期刊
if (this.journalId != null && this.journalId !== '') {
this.initForSingleJournal();
} else {
this.fetchJournals();
}
},
computed: {
// 【关键】拼接 HTML
combinedHtml() {
const header = this.headerStyles.find(h => h.id === this.selectedHeaderId);
const content = this.contentTemplates.find(c => c.id === this.selectedContentId);
// 没有可用模板时,右侧显示提示文案(走国际化)
if (!header || !content) {
const msg = this.$t('mailTemplate.noTemplateTip');
return `<div style="padding: 40px; text-align: center; color: #999; font-size: 14px;">
${msg}
</div>`;
applyDisabled() {
return this.initLoading || this.contentLoading || !this.selectedHeaderId || !this.selectedContentId;
},
hasValidPreview() {
const header = this.headerStyles.find((h) => h.id === this.selectedHeaderId);
const content = this.contentTemplates.find((c) => c.id === this.selectedContentId);
return !!(header && content);
},
// 【关键】拼接 HTML
combinedHtml() {
if (this.initLoading) return '';
if (!this.hasValidPreview) return '';
const header = this.headerStyles.find((h) => h.id === this.selectedHeaderId);
const content = this.contentTemplates.find((c) => c.id === this.selectedContentId);
return `${header.htmlHeader}${content.bodyHtml}${header.htmlFooter}`;
},
currentSelectionText() {
const h = this.headerStyles.find((h) => h.id === this.selectedHeaderId);
const c = this.contentTemplates.find((c) => c.id === this.selectedContentId);
return `${c ? c.name : ''} + ${h ? h.name : ''}`;
},
currentJournalLabel() {
const j = (this.journalOptions || []).find((item) => String(item.id) === String(this.selectedJournalId));
return j ? j.label : '-';
},
dialogTitle() {
return `Template Selection - ${this.currentJournalLabel}`;
}
// 返回完整的拼接代码,使用内联样式以兼容邮件
return `${header.htmlHeader}${content.bodyHtml}${header.htmlFooter}`;
},
currentSelectionText() {
const h = this.headerStyles.find(h => h.id === this.selectedHeaderId);
const c = this.contentTemplates.find(c => c.id === this.selectedContentId);
return `${h ? h.name : ''} + ${c ? c.name : ''}`;
}
},
methods: {
// 获取期刊列表用于过滤模板
async fetchJournals() {
try {
const res = await this.$api.post('api/Journal/getAllJournal', {});
if (!res || res.code !== 0) {
return;
}
this.journalOptions = res.data.journals.map(j => ({
id: j.journal_id,
label:j.title,
}));
if (this.journalOptions.length && !this.selectedJournalId) {
this.selectedJournalId = this.journalOptions[0].id;
this.fetchContentTemplates();
}
} catch (e) {
// 静默失败
}
},
toggleDesc(id) {
this.expandedHeaderId = this.expandedHeaderId === id ? null : id;
},
async handleJournalChange() {
// 切换期刊时重新拉取样式和模板(按需可改为带 journal_id 过滤)
this.contentTemplates=[]
await this.fetchContentTemplates();
if (this.contentTemplates.length) {
this.selectedContentId = this.contentTemplates[0].id;
}
},
// 调用接口获取头部样式列表
async fetchHeaderStyles() {
try {
const res = await this.$api.post('api/mail_template/listStyles', {
journal_id: this.selectedJournalId
});
if (!res || res.code !== 0 ) {
return;
}
async refreshTemplatesAndStyles() {
if (!this.selectedJournalId) return;
this.initLoading = true;
try {
// 清空后重新拉取,避免接口数据变更后列表仍展示旧内容
this.headerStyles = [];
this.contentTemplates = [];
this.selectedHeaderId = null;
this.selectedContentId = null;
// 后端返回字段style_id, name, header_html, footer_html
this.headerStyles = res.data.list.map(item => ({
id: item.style_id,
name: item.name,
description:item.description || '',
htmlHeader: item.header_html || '',
htmlFooter: item.footer_html || ''
}));
console.log("🚀 ~ headerStyles:", this.headerStyles);
// 默认选中第一条
if (this.headerStyles.length && !this.selectedHeaderId) {
this.selectedHeaderId = this.headerStyles[0].id;
}
} catch (e) {
// 静默失败,避免打断用户流程
}
},
// 调用接口获取内容模板列表
async fetchContentTemplates() {
try {
this.contentLoading = true;
const res = await this.$api.post('api/mail_template/listTemplates', {
journal_id: this.selectedJournalId
});
if (!res || res.code !== 0 ) {
return;
}
await this.fetchHeaderStyles();
await this.fetchContentTemplates();
// 后端返回字段template_id, title, body_html 等
this.contentTemplates = res.data.list.map(item => ({
id: item.template_id,
name: item.title,
subject: item.subject,
bodyHtml: item.body_html || ''
}));
// 优先按父组件传入的初始 id 回填;如果找不到就使用默认第一条
this.applyInitialSelection();
} finally {
this.initLoading = false;
}
},
async initForSingleJournal() {
const idStr = this.journalId != null ? String(this.journalId) : '';
if (!idStr) return;
// 默认选中第一条
if (this.contentTemplates.length && !this.selectedContentId) {
this.selectedContentId = this.contentTemplates[0].id;
}
} catch (e) {
// 静默失败
} finally {
this.contentLoading = false;
this.initLoading = true;
try {
this.selectedJournalId = Number(idStr);
// 单期刊场景:不需要拉取期刊列表
const label = this.journalLabel ? this.journalLabel : idStr;
this.journalOptions = [{ id: this.selectedJournalId, label: label }];
await this.fetchHeaderStyles();
await this.fetchContentTemplates();
this.applyInitialSelection();
} finally {
this.initLoading = false;
}
},
// 获取期刊列表用于过滤模板
async fetchJournals() {
this.initLoading = true;
try {
const res = await this.$api.post('api/Journal/getAllJournal', {});
if (!res || res.code !== 0) {
return;
}
this.journalOptions = res.data.journals.map((j) => ({
id: j.journal_id,
label: j.title
}));
if (this.journalOptions.length) {
// 选择期刊优先级:父组件传入 > 本地缓存 > 第一条
const propJournalId = this.journalId != null && this.journalId !== '' ? String(this.journalId) : '';
const storedJournalId = localStorage.getItem('mailboxCollect_journal_id') || '';
const hasProp = propJournalId && this.journalOptions.some((j) => String(j.id) === propJournalId);
const hasStored = storedJournalId && this.journalOptions.some((j) => String(j.id) === String(storedJournalId));
this.selectedJournalId = hasProp
? Number(propJournalId)
: hasStored
? Number(storedJournalId)
: this.journalOptions[0].id;
// 根据选中的期刊加载风格与模板
await this.fetchHeaderStyles();
await this.fetchContentTemplates();
this.applyInitialSelection();
}
} catch (e) {
// 静默失败
} finally {
this.initLoading = false;
}
},
toggleDesc(id) {
this.expandedHeaderId = this.expandedHeaderId === id ? null : id;
},
async handleJournalChange() {
// 切换期刊时重新拉取样式和模板
this.contentTemplates = [];
this.selectedContentId = null;
this.initLoading = true;
try {
await this.fetchHeaderStyles();
await this.fetchContentTemplates();
this.applyInitialSelection();
if (this.contentTemplates.length && !this.selectedContentId) {
this.selectedContentId = this.contentTemplates[0].id;
}
} finally {
this.initLoading = false;
}
},
// 调用接口获取头部样式列表
async fetchHeaderStyles() {
try {
const res = await this.$api.post('api/mail_template/listStyles', {
journal_id: this.selectedJournalId
});
if (!res || res.code !== 0) {
return;
}
// 后端返回字段style_id, name, header_html, footer_html
this.headerStyles = res.data.list.map((item) => ({
id: item.style_id,
name: item.name,
description: item.description || '',
htmlHeader: item.header_html || '',
htmlFooter: item.footer_html || ''
}));
// 默认选中第一条
if (this.headerStyles.length && !this.selectedHeaderId) {
this.selectedHeaderId = this.headerStyles[0].id;
}
} catch (e) {
// 静默失败,避免打断用户流程
}
},
// 调用接口获取内容模板列表
async fetchContentTemplates() {
try {
this.contentLoading = true;
const res = await this.$api.post('api/mail_template/listTemplates', {
journal_id: this.selectedJournalId
});
if (!res || res.code !== 0) {
return;
}
// 后端返回字段template_id, title, body_html 等
this.contentTemplates = res.data.list.map((item) => ({
id: item.template_id,
name: item.title,
subject: item.subject,
bodyHtml: item.body_html || ''
}));
// 默认选中第一条
if (this.contentTemplates.length && !this.selectedContentId) {
this.selectedContentId = this.contentTemplates[0].id;
}
} catch (e) {
// 静默失败
} finally {
this.contentLoading = false;
}
},
applyInitialSelection() {
const initStyle = this.initialStyleId != null && this.initialStyleId !== '' ? String(this.initialStyleId) : '';
const initTpl = this.initialTemplateId != null && this.initialTemplateId !== '' ? String(this.initialTemplateId) : '';
if (initStyle && Array.isArray(this.headerStyles)) {
const matchedStyle = this.headerStyles.find((h) => String(h.id) === initStyle);
if (matchedStyle) this.selectedHeaderId = matchedStyle.id;
}
if (initTpl && Array.isArray(this.contentTemplates)) {
const matchedTpl = this.contentTemplates.find((t) => String(t.id) === initTpl);
if (matchedTpl) this.selectedContentId = matchedTpl.id;
}
},
goToMailTemplateList() {
// 点击“去新增模板”时:除了关闭自身弹窗,还通知父级关闭其它弹窗,避免路由跳转时卡顿
this.$emit('close-all-dialogs');
this.handleClose();
this.$nextTick(() => {
const journalId =
this.selectedJournalId != null && this.selectedJournalId !== ''
? String(this.selectedJournalId)
: this.journalId != null && this.journalId !== ''
? String(this.journalId)
: '';
this.$router.push({
path: '/mailboxMouldDetail',
query: Object.assign(
{},
journalId ? { journal_id: journalId } : {},
this.returnSource === 'autoPromotion' ? { from_auto_promotion: '1' } : {}
),
});
});
},
handleClose() {
this.$emit('update:visible', false);
},
submit() {
if (this.applyDisabled) return;
// 将拼接好的 HTML 及选择信息抛给父组件(兼容:父组件也可只用 html
const header = this.headerStyles.find((h) => h.id === this.selectedHeaderId);
const content = this.contentTemplates.find((c) => c.id === this.selectedContentId);
this.$emit('confirm', {
html: this.combinedHtml,
journal_id: this.selectedJournalId,
style_id: this.selectedHeaderId,
template_id: this.selectedContentId,
style: header || null,
template: content || null
});
this.handleClose();
}
},
handleClose() {
this.$emit('update:visible', false);
},
submit() {
// 将拼接好的 HTML 抛给父组件
this.$emit('confirm', this.combinedHtml);
this.handleClose();
}
}
};
</script>
<style scoped>
.template-wrapper { display: flex; height: 70vh; gap: 20px; }
.selection-panel { width: 260px; border-right: 1px solid #eee; padding-right: 10px; overflow-y: auto; }
.journal-filter-form { padding-right: 8px; }
.preview-panel { flex: 1; background: #f4f6f8; padding: 20px; display: flex; flex-direction: column; }
.preview-label { font-weight: bold; color: #999; font-size: 12px; margin-bottom: 10px; }
.preview-container { background: #fff; flex: 1; border-radius: 4px; overflow-y: auto; box-shadow: 0 4px 12px rgba(0,0,0,0.05); }
.card-grid { display: flex; flex-direction: column; gap: 12px; margin-top: 15px; }
.card-item { border: 1px solid #ddd; border-radius: 8px; padding: 8px; cursor: pointer; transition: 0.3s; }
.card-item.active { border-color: #6366f1; background: #f5f7ff; outline: 1px solid #6366f1; }
.card-img { width: 100%; height: auto; border-radius: 4px; }
.card-title { font-size: 13px; margin: 8px 0 0; text-align: center; color: #666; }
};
</script>
<style scoped>
.template-wrapper {
display: flex;
height: 70vh;
gap: 20px;
}
.selection-panel {
width: 260px;
border-right: 1px solid #eee;
padding-right: 10px;
overflow-y: auto;
position: relative;
}
.selection-header {
position: absolute;
top: 8px;
right: 8px;
padding: 0;
display: flex;
justify-content: flex-end;
z-index: 2;
}
.journal-filter-form {
padding-right: 8px;
}
.preview-panel {
flex: 1;
background: #f4f6f8;
padding: 20px;
display: flex;
flex-direction: column;
}
.preview-label {
font-weight: bold;
color: #999;
font-size: 12px;
}
.preview-head {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 10px;
}
.selected-info-inline {
color: #666;
font-size: 12px;
white-space: nowrap;
}
.preview-container {
background: #fff;
flex: 1;
border-radius: 4px;
overflow-y: auto;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}
.preview-empty-state {
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 40px 20px;
color: #999;
text-align: center;
}
.preview-empty-text {
font-size: 14px;
line-height: 1.6;
margin-bottom: 14px;
}
.preview-empty-btn {
margin-top: 0;
}
.card-grid {
display: flex;
flex-direction: column;
gap: 12px;
margin-top: 15px;
}
.card-item {
border: 1px solid #ddd;
border-radius: 8px;
padding: 8px;
cursor: pointer;
transition: 0.3s;
}
.card-item.active {
border-color: #6366f1;
background: #f5f7ff;
outline: 1px solid #6366f1;
}
.card-img {
width: 100%;
height: auto;
border-radius: 4px;
}
.card-title {
font-size: 13px;
margin: 8px 0 0;
text-align: center;
color: #666;
}
.card-desc {
font-size: 12px;
color: #888;
margin-top: 4px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
cursor: pointer;
font-size: 12px;
color: #888;
margin-top: 4px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
cursor: pointer;
}
.card-desc.expanded {
white-space: normal;
overflow: visible;
white-space: normal;
overflow: visible;
}
.dialog-footer { display: flex; justify-content: space-between; align-items: center; width: 100%; }
.footer-info { color: #666; font-size: 14px; }
</style>
.dialog-footer {
display: flex;
justify-content: flex-end;
align-items: center;
width: 100%;
}
/* 加载中/未选择时:按钮禁用且浅蓝色 */
.apply-btn-disabled-soft.is-disabled {
background-color: #d9ecff !important;
border-color: #d9ecff !important;
color: #8fbef5 !important;
}
</style>

View File

@@ -0,0 +1,249 @@
<template>
<div class="tmr-editor-container">
<div class="editor-header">
<div class="title-slot">
<slot name="title"></slot>
</div>
<button @click="showModal = true" class="preview-trigger-btn">
<i class="icon-eye"></i> {{ $t('tmrEmailEditor.preview') || '预览' }}
</button>
</div>
<textarea
ref="editorRef"
class="tmr-textarea"
:value="plainText"
@input="handleInput"
:placeholder="resolvedPlaceholder"
></textarea>
<transition name="fade">
<div v-if="showModal" class="tmr-modal-mask" @click.self="showModal = false">
<div class="tmr-modal-container">
<div class="modal-header">
<span>{{ $t('tmrEmailEditor.preview') || '邮件预览' }}</span>
<button class="close-btn" @click="showModal = false">&times;</button>
</div>
<div class="modal-body">
<div class="common_tmr_email_box" v-html="htmlContentForPreview"></div>
</div>
<div class="modal-footer">
<button class="confirm-btn" @click="showModal = false">关闭</button>
</div>
</div>
</div>
</transition>
</div>
</template>
<script>
export default {
name: 'TmrEmailEditor',
props: {
// 预期格式: <div class="common_tmr_email_box">内容...</div>
value: {
type: String,
default: ''
},
placeholder: {
type: String,
default: ''
}
},
data() {
return {
showModal: false
}
},
computed: {
resolvedPlaceholder() {
return this.placeholder || (this.$t && this.$t('tmrEmailEditor.placeholder')) || '请输入邮件内容...';
},
// 将传入的 HTML 还原为 textarea 可读的纯文本
plainText() {
if (!this.value) return '';
return this.extractContent(this.value);
},
// 用于预览的 HTML保持与输出一致
htmlContentForPreview() {
return this.value || '';
}
},
methods: {
/**
* 核心:剥离外层容器和换行符
* 将 <div class="...">line1<br>line2</div> 还原为 line1\nline2
*/
extractContent(html) {
if (!html) return '';
// 1. 匹配最外层 div 内部的内容
const wrapperRegex = /<div class="common_tmr_email_box">([\s\S]*)<\/div>/i;
const match = html.match(wrapperRegex);
let content = match ? match[1] : html;
// 2. 将 <br> 或 <br /> 替换为换行符 \n
content = content.replace(/<br\s*\/?>/gi, '\n');
// 3. (可选) 如果还有其他标签可以进一步清洗,目前保持原样
return content;
},
/**
* 输入处理:实时包装并提交
*/
handleInput(e) {
const text = e.target.value;
// 将换行符转回 HTML 换行
const htmlContent = text.replace(/\n/g, '<br>');
// 包装外层容器
const finalResult = `<div class="common_tmr_email_box">${htmlContent}</div>`;
// 触发 v-model 更新
this.$emit('input', finalResult);
}
}
}
</script>
<style scoped>
/* 1. 基础布局 */
.tmr-editor-container {
width: 100%;
position: relative;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.editor-header {
display: flex;
justify-content: space-between;
align-items: center;
padding-bottom: 8px;
}
.preview-trigger-btn {
background: #fff;
border: 1px solid #dcdfe6;
padding: 6px 15px;
border-radius: 4px;
cursor: pointer;
color: #606266;
font-size: 13px;
transition: all 0.2s;
}
.preview-trigger-btn:hover {
color: #409eff;
border-color: #c6e2ff;
background: #ecf5ff;
}
/* 2. 编辑器样式 */
.tmr-textarea {
width: 100%;
min-height: 400px;
padding: 15px;
border: 1px solid #e4e7ed;
border-radius: 4px;
font-size: 14px;
line-height: 1.6;
box-sizing: border-box;
resize: vertical;
outline: none;
color: #333;
}
.tmr-textarea:focus {
border-color: #409eff;
}
/* 3. 弹窗动画 */
.fade-enter-active, .fade-leave-active { transition: opacity 0.3s; }
.fade-enter, .fade-leave-to { opacity: 0; }
/* 4. 弹窗样式 */
.tmr-modal-mask {
position: fixed;
z-index: 9999;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
display: flex;
justify-content: center;
align-items: center;
}
.tmr-modal-container {
width: 800px;
max-width: 90%;
background-color: #fff;
border-radius: 8px;
box-shadow: 0 4px 16px rgba(0,0,0,0.15);
overflow: hidden;
display: flex;
flex-direction: column;
}
.modal-header {
padding: 15px 20px;
border-bottom: 1px solid #f0f0f0;
display: flex;
justify-content: space-between;
align-items: center;
font-weight: 600;
color: #303133;
}
.close-btn {
border: none;
background: none;
font-size: 24px;
cursor: pointer;
color: #909399;
line-height: 1;
}
.close-btn:hover { color: #f56c6c; }
.modal-body {
padding: 30px;
min-height: 300px;
max-height: 70vh;
overflow-y: auto;
background-color: #fafafa; /* 模拟邮件阅读背景 */
}
/* 模拟邮件内容容器样式 */
.common_tmr_email_box {
background: #fff;
padding: 20px;
border: 1px solid #eee;
word-break: break-word;
line-height: 1.6;
white-space: pre-wrap; /* 保证换行显示 */
min-height: 100px;
}
.modal-footer {
padding: 12px 20px;
border-top: 1px solid #f0f0f0;
text-align: right;
}
.confirm-btn {
background: #409eff;
color: #fff;
border: none;
padding: 8px 24px;
border-radius: 4px;
cursor: pointer;
}
.confirm-btn:hover { background: #66b1ff; }
</style>

View File

@@ -0,0 +1,511 @@
<template>
<div class="monitor-container">
<div class="control-panel">
<div class="panel-left">
<el-radio-group v-model="filterStatus" size="small" class="status-group" @change="handleFilter">
<el-radio-button label="">{{ $t('crawlTask.allKeywords') }}</el-radio-button>
<el-radio-button label="0">{{ $t('crawlTask.enabled') }}</el-radio-button>
<el-radio-button label="1">{{ $t('crawlTask.disabled') }}</el-radio-button>
</el-radio-group>
<el-input
v-model="searchText"
:placeholder="$t('crawlTask.searchPlaceholder')"
prefix-icon="el-icon-search"
size="small"
class="search-box"
clearable
@input="handleFilter"
/>
<el-button
type="primary"
size="small"
icon="el-icon-search"
@click="handleSearchClick"
>
{{ $t('crawlTask.searchBtn') }}
</el-button>
</div>
<div class="panel-right">
<el-button type="primary" size="small" icon="el-icon-plus" @click="openAddDialog">{{ $t('crawlTask.addKeyword') }}</el-button>
</div>
</div>
<el-dialog
:title="$t('crawlTask.addKeyword')"
:visible.sync="addDialogVisible"
width="500px"
:close-on-click-modal="false"
@closed="resetAddForm"
>
<el-form label-width="120px" size="small">
<el-form-item :label="$t('crawlTask.keyword')">
<el-input
v-model="addForm.field"
:placeholder="$t('crawlTask.keywordPlaceholder')"
clearable
/>
</el-form-item>
<el-form-item :label="$t('crawlTask.runOnce')">
<el-switch
v-model="addForm.runNow"
:active-text="$t('crawlTask.yes')"
:inactive-text="$t('crawlTask.no')"
/>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button size="small" @click="addDialogVisible = false">{{ $t('crawlTask.cancel') }}</el-button>
<el-button type="primary" size="small" :loading="addLoading" @click="submitAddKeyword">
{{ $t('crawlTask.confirm') }}
</el-button>
</span>
</el-dialog>
<div v-loading="loading" class="task-list">
<el-empty v-if="list.length === 0" :description="$t('crawlTask.emptyResult')" />
<div v-for="item in list" :key="item.id" class="task-row" :class="'status-' + item.stateClass">
<div class="col-base">
<div class="status-dot"></div>
<div class="id-info">
<span class="task-id">#{{ item.id}}</span>
<span class="task-name">{{ item.task_name }}</span>
</div>
</div>
<div class="col-metrics">
<div class="metric-item">
<span class="m-label">{{ $t('crawlTask.source') }}</span>
<span class="m-value mini-text">{{ item.source }}</span>
</div>
<div class="metric-item highlight">
<span class="m-label">{{ $t('crawlTask.totalPages') }}</span>
<span class="m-value">{{ item.total_pages }}</span>
</div>
<div class="metric-item highlight">
<span class="m-label">{{ $t('crawlTask.crawledPages') }}</span>
<span class="m-value">{{ item.last_page }}</span>
</div>
<div class="metric-item highlight">
<span class="m-label">{{ $t('crawlTask.expertCountLabel') }}</span>
<span class="m-value expert-num">{{ item.expert_count }}</span>
</div>
</div>
<div class="col-timeline">
<div class="time-block">
<i class="el-icon-time"></i>
<div class="time-detail">
<span>{{ $t('crawlTask.created') }}: {{ item.create_time }}</span>
<span :class="item.state === 'done' ? 'success-text' : ''">
{{ item.state === 'done' ? $t('crawlTask.completed') : $t('crawlTask.updated') }}: {{ item.update_time }}
</span>
</div>
</div>
<div class="duration-tag" v-if="item.duration">
<i class="el-icon-odometer"></i> {{ item.duration }}
</div>
</div>
<div class="col-action">
<div class="prog-box">
<span class="prog-num">{{ item.progress }}%</span>
<el-progress
:percentage="item.progress"
:show-text="false"
:stroke-width="4"
:status="item.state === 'error' ? 'exception' : (item.state === 'done' ? 'success' : '')"
/>
</div>
<div class="btn-group">
<!-- <el-tooltip content="查看日志" placement="top">
<el-button type="text" icon="el-icon-document" @click="handleAction('logs', item)"></el-button>
</el-tooltip> -->
<!-- <el-tooltip content="执行单次抓取" placement="top" > -->
<el-button
type="text"
:icon="runOnceLoadingId === item.id ? 'el-icon-loading' : 'el-icon-finished'"
class="op-run-once"
:disabled="runOnceLoadingId === item.id"
@click="handleRunOnce(item)"
>{{ runOnceLoadingId === item.id ? $t('crawlTask.runOnceLoading') : $t('crawlTask.runOnceBtn') }}</el-button>
<!-- </el-tooltip> -->
<!-- <el-tooltip :content="item.state == 'running' ? '暂停抓取' : '恢复抓取'" placement="top"> -->
<el-button
type="text"
:icon="item.state === 'running' ? 'el-icon-video-pause' : 'el-icon-video-play'"
:class="['toggle-btn', item.state === 'running' ? 'op-pause' : 'op-resume']"
@click="handleToggleTask(item)"
>{{ item.state === 'running' ? $t('crawlTask.disabled') : $t('crawlTask.enabled') }}</el-button>
<!-- </el-tooltip> -->
</div>
</div>
</div>
</div>
<div class="pagination-container">
<el-pagination
background
layout="total, sizes, prev, pager, next, jumper"
:current-page.sync="currentPage"
:page-size="pageSize"
:page-sizes="[5, 10, 20, 50]"
:total="total"
@size-change="handleSizeChange"
@current-change="handlePageChange"
/>
</div>
</div>
</template>
<script>
export default {
data() {
return {
loading: false,
searchText: '',
filterStatus: '',
currentPage: 1,
pageSize: 10,
total: 0,
list: [],
addDialogVisible: false,
addLoading: false,
runOnceLoading: false,
runOnceLoadingId: null,
addForm: {
field: '',
runNow: false
}
};
},
created() {
this.fetchList();
},
methods: {
calcProgress(lastPage, totalPages) {
const current = Number(lastPage || 0);
const total = Number(totalPages || 0);
if (total <= 0) return 0;
let percent = (current / total) * 100;
if (percent > 100) percent = 100;
return Number(percent.toFixed(2));
},
normalizeItem(item) {
const totalPages = Number(item.total_pages || 0);
const lastPage = Number(item.last_page || 0);
const percent = this.calcProgress(lastPage, totalPages);
const stateNum = Number(item.state);
const stateClass = stateNum === 0 ? 'running' : 'paused';
const source = (item.source || '').toUpperCase() === 'PUBMED' ? 'PubMed' : (item.source || '-');
return {
id: item.expert_fetch_id || item.id || 0,
field: item.field || '',
expert_count: item.expert_count || 0,
task_name: item.field ? `${item.field}`:'-',
source,
state: stateClass,
stateClass,
progress: percent,
create_time: item.ctime_text || '-',
update_time: item.last_time_text || '-',
duration: '',
total_pages: Number(item.total_pages || 0),
last_page: Number(item.last_page || 0),
duplicates: 0,
failed: 0
};
},
async fetchList() {
this.loading = true;
try {
const params = {
keyword: this.searchText || '',
pageIndex: this.currentPage,
pageSize: this.pageSize
};
if (this.filterStatus !== '') {
params.state = this.filterStatus;
}
const res = await this.$api.post('api/expert_manage/getFetchList', params);
if (res && res.code === 0 && res.data) {
const rows = res.data.list || [];
this.list = rows.map(this.normalizeItem);
this.total = Number(res.data.total || rows.length || 0);
} else {
this.list = [];
this.total = 0;
}
} catch (e) {
this.list = [];
this.total = 0;
} finally {
this.loading = false;
}
},
handleFilter() {
this.currentPage = 1;
this.fetchList();
},
handleSearchClick() {
this.handleFilter();
},
handleSizeChange(val) {
this.pageSize = val;
this.currentPage = 1;
this.fetchList();
},
handlePageChange(val) {
this.currentPage = val;
this.fetchList();
window.scrollTo({ top: 0, behavior: 'smooth' });
},
resetQuery() {
this.searchText = '';
this.filterStatus = '';
this.currentPage = 1;
this.fetchList();
},
openAddDialog() {
this.addDialogVisible = true;
},
resetAddForm() {
this.addLoading = false;
this.runOnceLoading = false;
this.addForm = {
field: '',
runNow: false
};
},
async submitAddKeyword() {
const field = (this.addForm.field || '').trim();
if (!field) {
this.$message.warning(this.$t('crawlTask.enterKeyword'));
return;
}
const runNow = !!this.addForm.runNow;
this.addLoading = true;
try {
const addRes = await this.$api.post('api/expert_manage/addFetchField', { field });
if (!addRes || addRes.code !== 0) {
this.$message.error((addRes && addRes.msg) || this.$t('crawlTask.addKeywordFailed'));
return;
}
this.$message.success(this.$t('crawlTask.addKeywordSuccess'));
this.addDialogVisible = false;
this.currentPage = 1;
await this.fetchList();
if (runNow) {
// 勾选“单次抓取”时,在列表对应行按钮上显示 loading
const lowerField = field.toLowerCase();
const target = this.list.find(
(row) => ((row.field || '').trim().toLowerCase() === lowerField)
);
this.runOnceLoading = true;
this.runOnceLoadingId = target ? target.id : null;
const runRes = await this.$api.post('api/expert_finder/fetchOneField', { field });
if (!runRes || runRes.code !== 0) {
this.$message.warning((runRes && runRes.msg) || this.$t('crawlTask.runOnceFailed'));
} else {
this.$message.success(this.$t('crawlTask.runOnceSuccess'));
}
await this.fetchList();
}
} catch (e) {
this.$message.error(this.$t('crawlTask.operationRetry'));
} finally {
this.addLoading = false;
this.runOnceLoading = false;
this.runOnceLoadingId = null;
this.loading = false;
}
},
async handleToggleTask(item) {
const isRunning = item.state === 'running';
const newState = isRunning ? '1' : '0';
try {
this.loading = true;
const res = await this.$api.post('api/expert_manage/editFetchField', {
expert_fetch_id: item.id,
state: newState
});
if (res && res.code === 0) {
item.state = isRunning ? 'paused' : 'running';
item.stateClass = item.state;
this.$message.success(isRunning ? this.$t('crawlTask.disabledMsg') : this.$t('crawlTask.enabledMsg'));
} else {
this.$message.error((res && res.msg) || (isRunning ? this.$t('crawlTask.pauseFailed') : this.$t('crawlTask.resumeFailed')));
}
} catch (e) {
this.$message.error(isRunning ? this.$t('crawlTask.pauseFailed') : this.$t('crawlTask.resumeFailed'));
} finally {
this.loading = false;
}
},
handleRestart(item) {
item.state = 'running';
item.stateClass = 'running';
item.progress = 0;
this.$message.success(this.$t('crawlTask.restartSuccess'));
},
async handleRunOnce(item) {
const field = (item.field || item.task_name || '').trim();
if (!field) {
this.$message.warning(this.$t('crawlTask.missingKeyword'));
return;
}
this.runOnceLoadingId = item.id;
try {
const res = await this.$api.post('/api/expert_finder/fetchOneField', { field });
if (res && res.code === 0) {
this.$message.success(this.$t('crawlTask.runOnceSuccess'));
await this.fetchList();
} else {
this.$message.error((res && res.msg) || this.$t('crawlTask.runOnceFailed'));
}
} catch (e) {
this.$message.error(this.$t('crawlTask.runOnceFailed'));
} finally {
this.runOnceLoadingId = null;
}
},
handleAction(msg, item) {
if (msg === 'logs') {
this.$message.info(`${this.$t('crawlTask.viewLogs')}: #${item.id}`);
return;
}
this.$message.info(msg);
}
}
};
</script>
<style scoped>
.monitor-container {
padding:0px 20px;
background: #f4f7f9;
min-height: 100vh;
color: #334155;
}
/* 统计卡片 */
.stat-overview { display: flex; gap: 16px; margin-bottom: 24px; }
.stat-card {
background: #fff;
padding: 16px 20px;
border-radius: 8px;
flex: 1;
box-shadow: 0 1px 3px rgba(0,0,0,0.04);
border-top: 3px solid #0a3088; /* 呼应你偏好的深蓝色 */
}
.stat-val { font-size: 22px; font-weight: bold; color: #0a3088; display: block; }
.stat-label { font-size: 12px; color: #64748b; margin-top: 4px; }
/* 过滤工具栏 */
.control-panel {
display: flex;
justify-content: space-between;
margin-bottom: 16px;
background: #fff;
padding: 12px;
border-radius: 8px;
align-items: center;
}
.panel-left { display: flex; align-items: center; gap: 12px; }
.search-box { width: 200px; }
.date-picker { width: 240px !important; }
/* 任务行核心样式 */
.task-list { min-height: 400px; }
.task-row {
background: #fff;
margin-bottom: 8px;
border-radius: 6px;
display: flex;
align-items: center;
padding: 12px 20px;
transition: all 0.2s;
border: 1px solid transparent;
}
.status-paused {
background: #f3f4f6;
}
.task-row:hover {
border-color: #cbd5e1;
box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
}
/* 列定义 */
.col-base { flex: 1.5; display: flex; align-items: center; gap: 15px; }
.col-metrics { flex: 2; display: flex; justify-content: space-around; border-left: 1px solid #f1f5f9; border-right: 1px solid #f1f5f9; }
.col-timeline { flex: 1.1; padding: 0 25px; display: flex; align-items: center; justify-content: space-between; }
.col-action { flex:1.8; display: flex; align-items: center; gap: 15px; }
/* 状态点 */
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #94a3b8; position: relative; }
.status-dot { width: 10px; height: 10px; }
.status-running .status-dot { background: #3b82f6; }
.status-running .status-dot::after {
content: ''; position: absolute; width: 100%; height: 100%; background: inherit;
border-radius: 50%; animation: pulse 1.5s infinite;
}
.status-done .status-dot { background: #10b981; }
.status-paused .status-dot { background: #ef4444; }
.status-error .status-dot { background: #ef4444; }
/* 文字样式 */
.task-id { font-family: monospace; color: #94a3b8; font-size: 12px; display: block; }
.task-name { font-weight: 600; font-size: 14px; color: #1e293b; }
.metric-item { text-align: center; }
.m-label { font-size: 11px; color: #94a3b8; display: block; margin-bottom: 2px; }
.m-value { font-size: 16px; font-weight: bold; color: #475569; }
.m-value.mini-text { font-size: 12px; font-weight: normal; }
.m-value.expert-num { color: #006699; }
.success-text { color: #10b981; }
.danger { color: #ef4444; }
/* 时间线样式 */
.time-block { display: flex; align-items: center; gap: 10px; color: #64748b; font-size: 12px; }
.time-block i { font-size: 16px; }
.time-detail span { display: block; line-height: 1.4; }
.duration-tag { background: #f1f5f9; padding: 2px 8px; border-radius: 4px; font-size: 11px; color: #475569; }
/* 进度与分页 */
.prog-box { flex: 1; }
.prog-num { font-size: 12px; font-weight: bold; display: block; text-align: right; margin-bottom: 4px; min-width: 56px; }
.pagination-container { margin-top: 20px; display: flex; justify-content: flex-end; padding: 10px; }
.btn-group .el-button.op-pause,
.btn-group .el-button.op-pause i { color: #fc4d4d !important; }
.btn-group .el-button.op-resume,
.btn-group .el-button.op-resume i { color: #67c23a !important; }
.btn-group .el-button.op-restart,
.btn-group .el-button.op-restart i { color: #409eff !important; }
.btn-group .el-button.op-run-once,
.btn-group .el-button.op-run-once i { color: #006699 !important; }
.btn-group .el-button {
font-size: 20px;
padding: 6px;
}
.btn-group .el-button.op-run-once {
font-size: 13px;
padding: 4px 6px;
}
.btn-group .el-button.toggle-btn {
font-size: 13px;
padding: 4px 6px;
}
@keyframes pulse {
0% { transform: scale(1); opacity: 0.8; }
100% { transform: scale(2.5); opacity: 0; }
}
</style>

View File

@@ -240,7 +240,7 @@ If you're still having trouble with Chrome, you could use other browsers to comp
<el-dialog :visible.sync="questionVisible" width="1000px" :close-on-click-modal="false">
<!-- 审稿人表单修改 -->
<!-- 不显示给编辑的话 -->
<common-review-article
<common-review-article v-if="questionVisible"
:form="questionform1"
type="questionform"
:txt_mess="txt_mess"

View File

@@ -0,0 +1,334 @@
<template>
<div class="scholar-db-container">
<div class="crumbs">
<el-breadcrumb separator="/">
<el-breadcrumb-item>
<i class="el-icon-user"></i> {{ $t('sidebar.expertDatabase') }}
</el-breadcrumb-item>
</el-breadcrumb>
</div>
<div class="toolbar">
<div class="filters">
<el-form :inline="true" :model="query" size="small">
<el-form-item label="">
<el-cascader
ref="cascader"
@change="handleChange"
v-model="major_id"
:placeholder="$t('expertDatabase.fieldSelectPlaceholder')"
:options="options"
:props="getProps()"
style="width: 260px"
></el-cascader>
</el-form-item>
<el-form-item label="">
<el-input
v-model="query.keyword"
:placeholder="$t('expertDatabase.keywordPlaceholder')"
clearable
style="width: 260px"
/>
</el-form-item>
<el-form-item label="">
<el-input
v-model="query.field"
:placeholder="$t('expertDatabase.fieldPlaceholder')"
clearable
style="width: 260px"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" :loading="loading" @click="handleSearch">
{{ $t('expertDatabase.searchBtn') }}
</el-button>
<el-button @click="handleReset">{{ $t('expertDatabase.resetBtn') }}</el-button>
</el-form-item>
</el-form>
</div>
<div class="actions">
<el-button type="success" icon="el-icon-download" @click="handleExport" :loading="exportLoading">
{{ $t('expertDatabase.downloadExcelBtn') }}
</el-button>
</div>
</div>
<el-card class="table-card" shadow="never">
<el-table :data="list" border stripe v-loading="loading" header-row-class-name="dark-table-header">
<el-table-column type="index" :label="$t('expertDatabase.table.no')" width="70" align="center"></el-table-column>
<el-table-column prop="name" :label="$t('expertDatabase.columns.baseInfo')" min-width="220">
<template slot-scope="scope">
<div>
<p class="info-row">
<span class="label">{{ $t('expertDatabase.fields.nameLabel') }}</span><span class="value bold">{{ scope.row.name }}</span>
</p>
<p class="info-row">
<span class="label">{{ $t('expertDatabase.fields.emailLabel') }}</span><span class="value link">{{ scope.row.email }}</span>
</p>
<p class="info-row" style="margin-top: 10px; font-size: 12px">
<span class="label">{{ $t('expertDatabase.fields.acquisitionTimeLabel') }}</span>
<span class="value time">{{ scope.row.ctime_text ? scope.row.ctime_text : '-' }}</span>
</p>
<span class="custom-tag">{{ scope.row.state_text }}</span>
</div>
</template>
</el-table-column>
<el-table-column prop="affiliation" :label="$t('expertDatabase.columns.affiliation')" min-width="260" />
<el-table-column prop="fieldDisplay" :label="$t('expertDatabase.columns.researchAreas')" min-width="200">
<template slot-scope="scope">
<div v-for="(field, index) in scope.row.fields" :key="index">
<span>
<span style="color: #006699">{{ index + 1 }}.</span>
{{ field.field }}
</span>
</div>
</template>
</el-table-column>
</el-table>
<div class="pagination">
<el-pagination
background
layout="total, sizes, prev, pager, next, jumper"
:current-page="query.pageIndex"
:page-size="query.pageSize"
:page-sizes="[10, 20, 50]"
:total="total"
@size-change="handleSizeChange"
@current-change="handlePageChange"
/>
</div>
</el-card>
</div>
</template>
<script>
import Common from '@/components/common/common';
export default {
name: 'expertDatabase',
data() {
return {
mediaUrl: Common.mediaUrl,
major_id: [],
query: {
major_id: null,
keyword: '',
field: '',
pageIndex: 1,
pageSize: 10
},
options: [],
list: [],
total: 0,
loading: false,
exportLoading: false
};
},
created() {
this.loadFields();
this.fetchList();
},
methods: {
loadFields() {
this.$api.post('api/Major/getMajorList', {}).then((res) => {
const transformData = (data) => {
return data.map((item) => {
const transformedItem = {
...item,
value: item.major_id,
label: `${item.major_title}`
};
if (item.children && item.children.length > 0) {
transformedItem.children = transformData(item.children);
}
return transformedItem;
});
};
const root = (res.data.majors || []).find((item) => item.major_id == 1);
const data = root && root.children ? transformData(root.children) : [];
this.options = [...data];
});
},
handleChange() {
this.$nextTick(() => {
if (this.$refs.cascader && this.$refs.cascader.dropDownVisible !== undefined) {
this.$refs.cascader.dropDownVisible = false;
}
this.query.major_id = this.major_id[this.major_id.length - 1] || null;
this.query.pageIndex = 1;
this.fetchList();
});
},
getProps() {
return {
value: 'value',
label: 'label',
children: 'children',
checkStrictly: true,
expandTrigger: 'hover'
};
},
async fetchList() {
this.loading = true;
try {
const params = {
major_id: this.query.major_id,
keyword: this.query.keyword,
field: this.query.field,
pageIndex: this.query.pageIndex,
pageSize: this.query.pageSize
};
const res = await this.$api.post('api/expert_manage/getList', params);
if (res && res.code === 0 && res.data) {
const rawList = res.data.list || [];
this.list = rawList.map((item) => {
const fieldArray = item.fields || [];
const fieldNames = fieldArray.map((f) => f.field).join(', ');
return {
...item,
fieldDisplay: fieldNames
};
});
this.total = res.data.total || 0;
} else {
this.list = [];
this.total = 0;
}
} catch (e) {
this.list = [];
this.total = 0;
} finally {
this.loading = false;
}
},
handleSearch() {
this.query.pageIndex = 1;
this.fetchList();
},
handleReset() {
this.major_id = [];
this.query = {
major_id: null,
keyword: '',
field: '',
pageIndex: 1,
pageSize: 10
};
this.fetchList();
},
handleSizeChange(size) {
this.query.pageSize = size;
this.query.pageIndex = 1;
this.fetchList();
},
handlePageChange(page) {
this.query.pageIndex = page;
this.fetchList();
},
async handleExport() {
if (!this.query.major_id && !this.query.keyword && !this.query.field) {
this.$message.warning(this.$t('expertDatabase.exportWarn'));
return;
}
this.exportLoading = true;
try {
const params = {
major_id: this.query.major_id,
keyword: this.query.keyword,
field: this.query.field
};
const res = await this.$api.post('api/expert_manage/exportExcel', params);
if (res && res.code === 0 && res.data && res.data.file_url) {
window.open(this.mediaUrl + res.data.file_url, '_blank');
} else {
this.$message.error(res.msg || this.$t('expertDatabase.exportFailed'));
}
} catch (e) {
this.$message.error(e.msg || this.$t('expertDatabase.exportFailed'));
} finally {
this.exportLoading = false;
}
}
}
};
</script>
<style scoped>
.scholar-db-container {
padding: 0 10px;
}
.toolbar {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 15px;
margin-top: 15px;
}
.filters {
flex: 1;
margin: 0 20px;
margin-left: 0;
}
.form-line-break {
flex-basis: 100%;
width: 100%;
height: 0;
}
.actions {
white-space: nowrap;
}
.table-card {
margin-top: 10px;
}
.pagination {
margin-top: 15px;
text-align: right;
}
::v-deep .dark-table-header th {
background-color: #f5f7fa;
font-weight: 600;
}
::v-deep .el-form-item--mini.el-form-item,
.el-form-item--small.el-form-item {
margin-bottom: 0;
}
.custom-tag {
display: inline-block;
position: absolute;
right: 6px;
top: 0px;
color: #ce4f15;
font-size: 12px;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.info-row {
margin-bottom: 4px;
font-size: 14px;
display: flex;
align-items: center;
line-height: 1.2;
font-family: Arial, sans-serif;
}
.label {
color: #999;
margin-right: 8px;
flex-shrink: 0;
}
.value {
color: #333;
}
.value.bold {
font-weight: bold;
font-size: 15px;
}
.value.link {
color: #0066a1;
}
.value.time {
color: #888;
}
</style>

File diff suppressed because it is too large Load Diff

View File

@@ -2,8 +2,8 @@
<div>
<div class="crumbs">
<el-breadcrumb separator="/">
<el-breadcrumb-item><i class="el-icon-setting"></i> {{ $t('mailboxConfig.mailSystem') }}</el-breadcrumb-item>
<el-breadcrumb-item>{{ $t('mailboxConfig.title') }}</el-breadcrumb-item>
<el-breadcrumb-item><i class="el-icon-setting"></i> {{ $t('sidebar.promotionManagement') }}</el-breadcrumb-item>
<el-breadcrumb-item>{{ $t('sidebar.mailboxManagement') }}</el-breadcrumb-item>
</el-breadcrumb>
</div>
<div class="container">
@@ -15,13 +15,25 @@
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="getList">{{ $t('mailboxConfig.query') }}</el-button>
<el-button type="primary" icon="el-icon-plus" @click="handleAdd">{{ $t('mailboxConfig.addAccount') }}</el-button>
<el-button type="primary" icon="el-icon-refresh" @click="getList">{{ $t('mailboxConfig.refresh') }}</el-button>
<el-button type="primary" plain icon="el-icon-plus" class="add-account-btn" @click="handleAdd">
{{ $t('mailboxConfig.addAccount') }}
</el-button>
</el-form-item>
</el-form>
</div>
<el-table :data="tableData" border stripe class="table" header-cell-class-name="table-header" :empty-text="$t('mailboxConfig.noData')">
<el-table
:data="tableData"
border
stripe
class="table"
header-cell-class-name="table-header"
:empty-text="$t('mailboxConfig.noData')"
v-loading="loading"
:element-loading-text="$t('mailboxConfig.loading')"
>
<!-- <el-table-column prop="journal_name" :label="$t('mailboxConfig.journal')" min-width="140"></el-table-column> -->
<el-table-column type="index" :label="$t('mailboxConfig.no')" width="70" align="center"></el-table-column>
<el-table-column prop="account" :label="$t('mailboxConfig.account')" min-width="160"></el-table-column>
<el-table-column prop="smtp_from_name" :label="$t('mailboxConfig.smtpFromName')" min-width="120"></el-table-column>
<!-- <el-table-column prop="smtp_host" :label="$t('mailboxConfig.smtpHost')" min-width="120"></el-table-column> -->
@@ -45,15 +57,21 @@
<el-dialog :title="dialogTitle" :visible.sync="dialogVisible" width="580px" :close-on-click-modal="false">
<el-form ref="formRef" :model="form" :rules="rules" label-width="140px">
<el-form-item :label="$t('mailboxConfig.journal')" prop="journal_id">
<el-select v-model="form.journal_id" :placeholder="$t('mailboxConfig.selectJournal')" style="width: 100%;">
<el-select :disabled="form.id" v-model="form.journal_id" :placeholder="$t('mailboxConfig.selectJournal')" style="width: 100%;">
<el-option v-for="item in journalList" :key="item.journal_id" :label="item.title" :value="item.journal_id"></el-option>
</el-select>
</el-form-item>
<el-form-item :label="$t('mailboxConfig.account')" prop="account">
<el-input v-model="form.account" ></el-input>
<el-input v-model="form.account" placeholder="eg: test@tmrjournals.co.nz"></el-input>
</el-form-item>
<el-form-item :label="$t('mailboxConfig.password')" prop="password">
<el-input v-model="form.password" type="password" show-password autocomplete="new-password"></el-input>
<el-input
v-model="form.password"
type="text"
clearable
autocomplete="new-password"
></el-input>
<!-- <span class="form-tip">{{ $t('mailboxConfig.passwordTip') }}</span> -->
</el-form-item>
<el-form-item :label="$t('mailboxConfig.smtpFromName')" prop="smtp_from_name">
@@ -77,7 +95,15 @@
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false">{{ $t('mailboxConfig.cancel') }}</el-button>
<el-button type="primary" @click="submitForm">{{ $t('mailboxConfig.save') }}</el-button>
<el-button
type="primary"
@click="submitForm"
:loading="saveLoading"
:disabled="saveLoading"
:loading-text="$t('mailboxConfig.loading')"
>
{{ $t('mailboxConfig.save') }}
</el-button>
</span>
</el-dialog>
</div>
@@ -86,7 +112,7 @@
<script>
// 期刊邮箱列表POST api/email_client/getAccounts 参数 journal_id返回 data[]: j_email_id, journal_id, smtp_host, smtp_port, smtp_user, imap_host, imap_port, daily_limit, today_sent, state, remaining_today 等
const API = {
getAllJournal: 'api/Journal/getAllJournal',
getAllJournal: 'api/Article/getJournal',
getAccounts: 'api/email_client/getAccounts',
addAccount: 'api/email_client/addAccount',
updateAccount: 'api/email_client/updateAccount',
@@ -105,6 +131,9 @@
tableData: [],
total: 0,
journalList: [],
loading: false,
saveLoading: false,
saveDebounceTimer: null,
dialogVisible: false,
dialogTitle: '',
form: {
@@ -145,11 +174,17 @@
created() {
this.loadJournals();
},
beforeDestroy() {
if (this.saveDebounceTimer) {
clearTimeout(this.saveDebounceTimer);
this.saveDebounceTimer = null;
}
},
methods: {
// 期刊下拉框:调用 api/Journal/getAllJournal 获取列表
// 期刊下拉框:调用 api/Article/getJournal 获取列表
loadJournals() {
var self = this;
this.$api.post(API.getAllJournal, {}).then(function(res) {
this.$api.post(API.getAllJournal, {username: localStorage.getItem('U_name')}).then(function(res) {
var list = [];
if (res && res.code === 0 && res.data) {
if (Array.isArray(res.data.journals)) {
@@ -194,6 +229,7 @@
return j ? j.title : '';
},
getList() {
this.loading = true;
var journalId = this.query.journal_id;
var params = {};
if (journalId !== 0 && journalId !== '' && journalId != null) {
@@ -220,6 +256,7 @@
today_sent: item.today_sent,
state: item.state,
remaining_today: item.remaining_today,
smtp_password: item.smtp_password,
};
}.bind(this));
this.tableData = list;
@@ -231,32 +268,36 @@
}).catch(function() {
this.tableData = [];
this.total = 0;
}.bind(this));
}.bind(this)).finally(() => {
this.loading = false;
});
},
handleAdd() {
this.dialogTitle = this.$t('mailboxConfig.dialogAdd');
this.form = {
id: null,
journal_id: this.journalList[0] ? this.journalList[0].journal_id : null,
journal_id: this.query.journal_id || (this.journalList[0] ? this.journalList[0].journal_id : null),
account: '',
password: '',
smtp_from_name: '',
smtp_host: '',
smtp_port: '',
smtp_encryption: '',
imap_host: '',
imap_port: '',
smtp_host: 'mail.tmrjournals.co.nz',
smtp_port: '465',
smtp_encryption: 'ssl',
imap_host: 'mail.tmrjournals.co.nz',
imap_port: '993',
};
this.dialogVisible = true;
this.$nextTick(function() { if (this.$refs.formRef) this.$refs.formRef.clearValidate(); }.bind(this));
},
handleEdit(row) {
console.log("🚀 ~ handleEdit ~ row:", row);
this.dialogTitle = this.$t('mailboxConfig.dialogEdit');
this.form = {
id: row.id,
journal_id: row.journal_id,
account: row.account || row.smtp_user || '',
password: '',
password: row.smtp_password || '',
smtp_from_name: row.smtp_from_name || '',
smtp_host: row.smtp_host || '',
smtp_port: row.smtp_port != null && row.smtp_port !== '' ? String(row.smtp_port) : '',
@@ -268,6 +309,15 @@
this.$nextTick(function() { if (this.$refs.formRef) this.$refs.formRef.clearValidate(); }.bind(this));
},
submitForm() {
// 保存防抖:连续点击只触发一次
if (this.saveLoading) return;
if (this.saveDebounceTimer) clearTimeout(this.saveDebounceTimer);
this.saveDebounceTimer = setTimeout(() => {
this.saveDebounceTimer = null;
this._doSubmitForm();
}, 600);
},
_doSubmitForm() {
var self = this;
this.$refs.formRef.validate(function(valid) {
if (!valid) return;
@@ -290,34 +340,46 @@
payload.smtp_password = String(self.form.password || '');
}
self.$api.post(url, payload).then(function(res) {
if (res && res.code === 0) {
self.$message.success(isEdit ? self.$t('mailboxConfig.editSuccess') : self.$t('mailboxConfig.addSuccess'));
self.saveLoading = true;
self.$api
.post(url, payload)
.then(function(res) {
if (res && res.code === 0) {
self.$message.success(isEdit ? self.$t('mailboxConfig.editSuccess') : self.$t('mailboxConfig.addSuccess'));
self.dialogVisible = false;
self.getList();
} else {
self.$message.error((res && res.msg) || (isEdit ? self.$t('mailboxConfig.editFail') : self.$t('mailboxConfig.addFail')));
}
})
.catch(function() {
// Mock fallback保留原逻辑
self.$message.success(isEdit ? self.$t('mailboxConfig.editSuccessMock') : self.$t('mailboxConfig.addSuccessMock'));
self.dialogVisible = false;
self.getList();
} else {
self.$message.error((res && res.msg) || (isEdit ? self.$t('mailboxConfig.editFail') : self.$t('mailboxConfig.addFail')));
}
}).catch(function() {
self.$message.success(isEdit ? self.$t('mailboxConfig.editSuccessMock') : self.$t('mailboxConfig.addSuccessMock'));
self.dialogVisible = false;
self.getList();
});
})
.finally(function() {
self.saveLoading = false;
});
});
},
handleMailManage(row) {
// 进入邮箱列表前,把当前选择的邮箱账号写入本地,供 mailboxCollect 使用
if (row && row.j_email_id) {
localStorage.setItem('mailboxCollect_j_email_id', String(row.j_email_id));
}
if (row && row.journal_id) {
localStorage.setItem('mailboxCollect_journal_id', String(row.journal_id));
}
this.$router.push({
path: '/mailboxCollect',
query: {
journal_id: row.journal_id,
j_email_id: row.j_email_id
}
});
},
// 删除邮箱配置:接口 api/email_client/deleteAccount传参 j_email_id
handleDelete(row) {
const self = this;
this.$confirm(self.$t('mailboxConfig.deleteConfirm'), self.$t('mailboxConfig.title'), {
this.$confirm(self.$t('mailboxConfig.deleteConfirm'), self.$t('mailboxConfig.deleteTitle'), {
confirmButtonText: self.$t('mailboxConfig.confirm'),
cancelButtonText: self.$t('mailboxConfig.cancel'),
type: 'warning'
@@ -341,5 +403,6 @@
<style scoped>
.handle-box { margin-bottom: 16px; }
.filter-form { margin: 0; }
.add-account-btn { margin-left: 10px; }
.form-tip { font-size: 12px; color: #909399; margin-top: 4px; }
</style>

View File

@@ -55,6 +55,7 @@
</div>
<el-table :data="tplTableData" border style="width: 100%; margin-top: 20px;" v-loading="tplLoading">
<el-table-column type="index" :label="$t('mailboxMould.no')" width="70" align="center"></el-table-column>
<el-table-column prop="title" :label="$t('mailboxMould.colTitle')" min-width="220">
<template slot-scope="scope">
<div class="title-cell"><strong>{{ scope.row.title }}</strong></div>
@@ -65,7 +66,7 @@
<span>{{ scope.row.subject || '-' }}</span>
</template>
</el-table-column>
<el-table-column prop="scene" :label="$t('mailboxMould.colScene')">
<el-table-column prop="scene" :label="$t('mailboxMould.colScene')" width="160">
<template slot-scope="scope">
<el-tag size="small" type="info">{{ scope.row.scene }}</el-tag>
</template>
@@ -78,8 +79,8 @@
<el-table-column prop="version" :label="$t('mailboxMould.colVersion')" width="100"></el-table-column>
<el-table-column :label="$t('mailboxMould.colStatus')" width="120">
<template slot-scope="scope">
<span :class="['status-dot', scope.row.status]"></span>
{{ scope.row.status === 'active' ? $t('mailboxMould.active') : $t('mailboxMould.inactive') }}
<span :class="['status-dot', scope.row.is_active==1?'active':'inactive']"></span>
{{ scope.row.is_active == 1 ? $t('mailboxMould.active') : $t('mailboxMould.inactive') }}
</template>
</el-table-column>
<el-table-column width="160">
@@ -102,6 +103,7 @@
</div>
<el-table :data="styleTableData" border style="width: 100%; margin-top: 20px;" v-loading="styleLoading">
<el-table-column type="index" :label="$t('mailboxStyle.no')" width="70" align="center"></el-table-column>
<el-table-column prop="name" :label="$t('mailboxStyle.colName')" min-width="220">
<template slot-scope="scope">
<div class="title-cell"><strong>{{ scope.row.title }}</strong></div>
@@ -141,7 +143,7 @@
const API = {
listTemplates: 'api/mail_template/listTemplates',
listStyles: 'api/mail_template/listStyles',
getAllJournal: 'api/Journal/getAllJournal',
getAllJournal: 'api/Article/getJournal',
deleteTemplate: 'api/mail_template/deleteTemplate',
deleteStyle: 'api/mail_template/deleteStyle'
};
@@ -151,6 +153,8 @@ export default {
return {
activeTab: 'templates',
journalList: [],
// 用于避免 ElementUI 初始化时触发的 tab 事件把 localStorage 写回 templates
tabChangeLocked: true,
// --- Templates ---
tplLoading: false,
@@ -171,15 +175,28 @@ export default {
};
},
created() {
const q = (this.$route && this.$route.query) || {};
const routeTab = q && (q.activeTab || q.tab || q.mouldTab) ? String(q.activeTab || q.tab || q.mouldTab) : '';
let savedTab = localStorage.getItem('mailboxMouldActiveTab') || '';
savedTab = String(savedTab).trim();
const normalized = (routeTab && (routeTab === 'styles' || routeTab === 'templates')) ? routeTab : savedTab;
if (normalized === 'styles' || normalized === 'templates') this.activeTab = normalized;
// 初始化期间不要响应 tab-click避免覆盖 localStorage
this.tabChangeLocked = true;
this.loadJournals();
this.$nextTick(() => {
this.tabChangeLocked = false;
});
},
methods: {
// ========== 公共 ==========
loadJournals() {
this.$api
.post(API.getAllJournal, {})
.post(API.getAllJournal, {username: localStorage.getItem('U_name')})
.then(res => {
const list = (res && res.data && res.data.journals) || res.data || [];
const list = res || [];
const mapped = (Array.isArray(list) ? list : []).map(j => ({
journal_id: j.journal_id || j.id,
title: j.title || j.name || ''
@@ -188,13 +205,19 @@ export default {
if (mapped.length > 0) {
this.tplFilters.journalId = String(mapped[0].journal_id);
}
this.fetchTemplates();
if (this.activeTab === 'styles') {
this.fetchStyles();
} else {
this.fetchTemplates();
}
})
.catch(() => {
this.journalList = [];
});
},
handleTabChange(tab) {
if (this.tabChangeLocked) return;
localStorage.setItem('mailboxMouldActiveTab', tab.name);
if (tab.name === 'templates' && this.tplTableData.length === 0) {
this.fetchTemplates();
} else if (tab.name === 'styles' && this.styleTableData.length === 0) {
@@ -225,7 +248,7 @@ export default {
scene: item.scene,
language: item.language,
version: item.version,
status: item.status || 'active'
is_active: item.is_active || 0
}));
})
.catch(() => {
@@ -234,11 +257,17 @@ export default {
});
},
handleCreateTemplate() {
this.$router.push({ path: '/mailboxMouldDetail' });
// 传入当前模板列表选中的期刊,详情页用于默认回填
const journalId = this.tplFilters && this.tplFilters.journalId ? String(this.tplFilters.journalId) : '';
this.$router.push({ path: '/mailboxMouldDetail', query: journalId ? { journal_id: journalId } : {} });
},
handleEditTemplate(row) {
const templateId = row && (row.template_id || row.id);
this.$router.push({ path: '/mailboxMouldDetail', query: templateId ? { template_id: String(templateId) } : {} });
const journalId = this.tplFilters && this.tplFilters.journalId ? String(this.tplFilters.journalId) : '';
const query = templateId ? { template_id: String(templateId) } : {};
// 编辑时一般会由模板详情回填期刊,但带上也能避免个别场景先展示错误默认值
if (journalId && !query.journal_id) query.journal_id = journalId;
this.$router.push({ path: '/mailboxMouldDetail', query });
},
handlePreviewTemplate(row) {
this.previewContent = row && row.body_html ? row.body_html : '';
@@ -354,6 +383,9 @@ export default {
.status-dot.active {
background-color: #52c41a;
}
.status-dot.inactive {
background-color: #f5222d;
}
.delete-btn {
color: #f5222d !important;
}
@@ -363,5 +395,6 @@ export default {
padding: 10px;
border: 1px solid #eee;
background: #fff;
box-sizing: border-box;
}
</style>

View File

@@ -9,7 +9,17 @@
</div>
<div class="right">
<el-button size="mini" @click="goBack">{{ $t('mailboxMouldDetail.cancel') }}</el-button>
<el-button type="primary" size="mini" icon="el-icon-document-checked" @click="handleSave">{{ $t('mailboxMouldDetail.save') }}</el-button>
<el-button
type="primary"
size="mini"
icon="el-icon-document-checked"
@click="handleSave"
:loading="saveLoading"
:disabled="saveLoading || journalLoading"
:loading-text="$t('mailboxMouldDetail.loading')"
>
{{ $t('mailboxMouldDetail.save') }}
</el-button>
</div>
</header>
@@ -86,7 +96,11 @@
<div class="body-editor-container">
<div class="subject-label" style="margin-bottom: 10px;">{{ $t('mailboxMouldDetail.emailBody') }}:</div>
<CkeditorMail v-model="form.body" />
<TmrEmailEditor
v-model="form.body"
placeholder=""
/>
<!-- <CkeditorMail v-model="form.body" /> -->
</div>
</el-card>
</section>
@@ -96,20 +110,23 @@
<script>
import CkeditorMail from '@/components/page/components/email/CkeditorMail.vue';
import TmrEmailEditor from '@/components/page/components/email/TmrEmailEditor.vue';
const API = {
getAllJournal: 'api/Journal/getAllJournal',
getAllJournal: 'api/Article/getJournal',
getTemplate: 'api/mail_template/getTemplate',
saveTemplate: 'api/mail_template/saveTemplate'
};
export default {
name: 'mailboxMouldDetail',
components: { CkeditorMail },
components: { CkeditorMail,TmrEmailEditor },
data() {
return {
journalLoading: true,
journalList: [],
saveLoading: false,
// 防抖:避免重复点击“保存”导致多次请求
saveDebounceTimer: null,
rules: {
journalId: [{ required: true, message: this.$t('mailboxMouldDetail.rulesJournal'), trigger: 'change' }],
scene: [{ required: true, message: this.$t('mailboxMouldDetail.rulesScene'), trigger: 'change' }],
@@ -139,21 +156,31 @@ export default {
created() {
this.loadJournals();
},
beforeDestroy() {
if (this.saveDebounceTimer) {
clearTimeout(this.saveDebounceTimer);
this.saveDebounceTimer = null;
}
},
methods: {
loadJournals() {
this.journalLoading = true;
const q = this.$route && this.$route.query ? this.$route.query : {};
const fromRouteJournalId = q.journal_id || q.journalId || '';
this.$api
.post(API.getAllJournal, {})
.post(API.getAllJournal, { username: localStorage.getItem('U_name') })
.then(res => {
const list = (res && res.data && res.data.journals) || res.data || [];
const list = res || [];
const mapped = (Array.isArray(list) ? list : []).map(j => ({
journal_id: j.journal_id || j.id,
title: j.title || j.name || ''
}));
this.journalList = mapped;
if (!this.form.journalId && mapped.length > 0) {
this.form.journalId = String(mapped[0].journal_id);
if (fromRouteJournalId) {
const has = mapped.some(j => String(j.journal_id) === String(fromRouteJournalId));
if (has) this.form.journalId = String(fromRouteJournalId);
}
if (!this.form.journalId && mapped.length > 0) this.form.journalId = String(mapped[0].journal_id);
})
.catch(() => {
this.journalList = [];
@@ -188,51 +215,81 @@ export default {
});
},
goBack() {
const q = (this.$route && this.$route.query) || {};
if (q.from_auto_promotion === '1') {
this.$router.push({ path: '/autoPromotion' });
return;
}
this.$router.push({ path: '/mailboxMould' });
},
handleSave() {
const formRef = this.$refs.detailForm;
const validatePromise = formRef && formRef.validate ? new Promise(resolve => formRef.validate(ok => resolve(ok))) : Promise.resolve(true);
validatePromise.then(ok => {
if (!ok) return;
if (!this.form.subject) {
this.$message.warning(this.$t('mailboxMouldDetail.rulesSubject'));
return;
}
if (!this.form.body) {
this.$message.warning(this.$t('mailboxMouldDetail.rulesBody'));
return;
}
// 若已在保存中,直接忽略重复点击
if (this.saveLoading) return;
const q = this.$route.query;
const templateId = q.template_id || q.id || '';
const bodyHtml = this.form.body || '';
const bodyText = bodyHtml.replace(/<[^>]+>/g, ' ').replace(/\s+/g, ' ').trim();
const params = {
journal_id: String(this.form.journalId || ''),
scene: String(this.form.scene || 'invite_submission'),
language: String(this.form.lang || 'en'),
title: String(this.form.title || ''),
subject: String(this.form.subject || ''),
body_html: bodyHtml,
body_text: bodyText || '',
variables_json: String(this.form.variables || ''),
version: String(this.form.version || '1.0.0'),
is_active: this.form.is_active === 1 ? '1' : '0'
};
if (templateId) params.template_id = String(templateId);
this.$api.post(API.saveTemplate, params).then(res => {
// 防抖:连续点击只触发最后一次
if (this.saveDebounceTimer) {
clearTimeout(this.saveDebounceTimer);
}
this.saveDebounceTimer = setTimeout(() => {
this.saveDebounceTimer = null;
this._doSave();
}, 600);
}
,
async _doSave() {
const formRef = this.$refs.detailForm;
const validatePromise =
formRef && formRef.validate
? new Promise(resolve => formRef.validate(ok => resolve(ok)))
: Promise.resolve(true);
const ok = await validatePromise;
if (!ok) return;
if (!this.form.subject) {
this.$message.warning(this.$t('mailboxMouldDetail.rulesSubject'));
return;
}
if (!this.form.body) {
this.$message.warning(this.$t('mailboxMouldDetail.rulesBody'));
return;
}
this.saveLoading = true;
try {
const q = this.$route.query;
const templateId = q.template_id || q.id || '';
const bodyHtml = this.form.body || '';
const bodyText = bodyHtml.replace(/<[^>]+>/g, ' ').replace(/\s+/g, ' ').trim();
const params = {
journal_id: String(this.form.journalId || ''),
scene: String(this.form.scene || 'invite_submission'),
language: String(this.form.lang || 'en'),
title: String(this.form.title || ''),
subject: String(this.form.subject || ''),
body_html: bodyHtml,
body_text: bodyText || '',
variables_json: String(this.form.variables || ''),
version: String(this.form.version || '1.0.0'),
is_active: this.form.is_active === 1 ? '1' : '0'
};
if (templateId) params.template_id = String(templateId);
const res = await this.$api.post(API.saveTemplate, params);
if (res && res.code === 0) {
this.$message.success(this.$t('mailboxMouldDetail.saveSuccess'));
this.goBack();
} else {
this.$message.error((res && res.msg) || this.$t('mailboxMouldDetail.saveFail'));
}
}).catch(() => {
} catch (e) {
this.$message.error(this.$t('mailboxMouldDetail.saveFail'));
});
});
} finally {
this.saveLoading = false;
}
}
}
};

View File

@@ -11,7 +11,7 @@
</el-breadcrumb>
</div>
<div class="container" style="padding-top: 0px;">
<div class="container" style="padding-top: 0px;" v-if="showSendEmail">
<div class="mail_shuru" style="position: relative; display: flex; align-items: center;">
<span class="mail_tit">{{ $t('mailboxSend.to') }}</span>
@@ -31,6 +31,7 @@
</div>
<el-autocomplete
v-if="!isToRecipientLimitReached()"
ref="autocompleteTo"
class="mail_inp"
v-model="toInput"
@@ -106,7 +107,7 @@
:source-content.sync="sourceContent"
:source-rows="16"
:source-placeholder="$t('mailboxSend.sourcePlaceholder')"
:show-select-template-button="true"
:show-select-template-button="false"
@onSelectTemplate="showTemplateDialog = true"
/>
</div>
@@ -119,7 +120,14 @@
</div>
<div class="action-buttons">
<el-button type="primary" icon="el-icon-s-promotion" :loading="sendLoading" :disabled="sendLoading" @click="handleSend">
<el-button
type="primary"
icon="el-icon-s-promotion"
:loading="sendLoading"
:disabled="sendLoading"
:loading-text="$t('mailboxSend.sending')"
@click="handleSend"
>
{{ $t('mailboxSend.send') }}
</el-button>
<!-- <el-button size="medium" :loading="saveDraftLoading" :disabled="saveDraftLoading" @click="handleSaveDraft">{{ $t('mailboxSend.saveDraft') }}</el-button> -->
@@ -155,9 +163,11 @@
</div>
</el-dialog>
<template-selector-dialog v-if="showTemplateDialog"
<template-selector-dialog
v-if="showTemplateDialog"
:visible.sync="showTemplateDialog"
@confirm="handleTemplateApply"
@close-all-dialogs="closeAllDialogs"
/>
</div>
</template>
@@ -180,7 +190,8 @@ import TemplateSelectorDialog from '@/components/page/components/email/TemplateS
sendnamelist: [],
sendtitle: '',
sendcc: '',
content: ''
content: '',
expert_id: ''
},
mail_List: [],
fileL_atta: [],
@@ -206,6 +217,8 @@ import TemplateSelectorDialog from '@/components/page/components/email/TemplateS
sourceContent: '',
toInput: '',
// 默认只允许 1 个收件人,后续可按需动态修改
maxToRecipients: 1,
toSelecting: false,
nextToUid: 1,
ccList: [],
@@ -214,7 +227,21 @@ import TemplateSelectorDialog from '@/components/page/components/email/TemplateS
nextCcUid: 1,
collapseValue: localStorage.getItem('collapse'),
sendLoading: false,
sendDebounceTimer: null,
saveDraftLoading: false,
selectedTemplateId: '',
selectedStyleId: '',
recipientSuggest: {
keyword: '',
pageIndex: 1,
pageSize: 10,
totalPages: 1,
loading: false,
options: [],
cb: null
},
recipientSuggestScrollHandler: null,
showSendEmail:true
};
},
components: {
@@ -225,7 +252,7 @@ import TemplateSelectorDialog from '@/components/page/components/email/TemplateS
footerBarLeft() {
const collapsed = this.collapseValue === true || this.collapseValue === 'true';
return (collapsed ? 64: 260) + 'px';
},
}
},
watch: {
collapseValue: {
@@ -236,27 +263,164 @@ import TemplateSelectorDialog from '@/components/page/components/email/TemplateS
},
},
created() {
this.showSendEmail=true
this.getDate();
},
activated(){
this.showSendEmail=true
},
mounted() {
bus.$on('collapse-content', (msg) => {
this.collapseValue = msg;
});
document.addEventListener('click', this.handleOutsideAutocompleteClick, true);
},
beforeDestroy() {
bus.$off('collapse-content');
this.detachRecipientSuggestScroll();
if (this.sendDebounceTimer) {
clearTimeout(this.sendDebounceTimer);
this.sendDebounceTimer = null;
}
document.removeEventListener('click', this.handleOutsideAutocompleteClick, true);
},
methods: {
handleTemplateApply(htmlContent) {
// 假设你使用的是 TinyMCE
if (window.tinymce && window.tinymce.activeEditor) {
// 建议:如果你想保留已有内容,用 insertContent
// 如果想彻底更换模板,用 setContent。
window.tinymce.activeEditor.setContent(htmlContent);
this.$message.success('Template applied successfully!');
}
},
closeAllDialogs() {
// 点击“去新增模板”后:关闭模板选择弹窗以及可能打开的其它弹窗
this.Librarybox = false;
this.showTemplateDialog = false;
},
handleOutsideAutocompleteClick(e) {
const target = e && e.target;
if (!target) return;
const inputRef = this.$refs.autocompleteTo;
const inputEl = inputRef && inputRef.$el ? inputRef.$el : null;
const inInput = inputEl && inputEl.contains(target);
const inSuggestion = typeof target.closest === 'function' && !!target.closest('.el-autocomplete-suggestion');
if (inInput || inSuggestion) return;
if (inputRef && typeof inputRef.close === 'function') {
inputRef.close();
}
if (inputRef && inputRef.$refs && inputRef.$refs.input && typeof inputRef.$refs.input.blur === 'function') {
inputRef.$refs.input.blur();
}
},
isToRecipientLimitReached() {
const max = Number(this.maxToRecipients || 0);
if (!max) return false;
return (this.queryMail.sendnamelist || []).length >= max;
},
showToRecipientLimitWarning() {
const max = Number(this.maxToRecipients || 1);
this.$message.warning(this.$t('mailboxSend.recipientLimit', { count: max }));
},
attachRecipientSuggestScroll() {
this.detachRecipientSuggestScroll();
this.$nextTick(() => {
const wraps = document.querySelectorAll('.el-autocomplete-suggestion__wrap');
if (!wraps || !wraps.length) return;
const wrap = wraps[wraps.length - 1];
const handler = () => {
if (this.recipientSuggest.loading) return;
if (this.recipientSuggest.pageIndex >= this.recipientSuggest.totalPages) return;
const threshold = 24;
const reachBottom = wrap.scrollTop + wrap.clientHeight >= wrap.scrollHeight - threshold;
if (reachBottom) {
this.loadMoreRecipientSuggestions();
}
};
wrap.addEventListener('scroll', handler);
this.recipientSuggestScrollHandler = { el: wrap, fn: handler };
});
},
detachRecipientSuggestScroll() {
const h = this.recipientSuggestScrollHandler;
if (h && h.el && h.fn) {
h.el.removeEventListener('scroll', h.fn);
}
this.recipientSuggestScrollHandler = null;
},
normalizeExpertList(list) {
if (!Array.isArray(list)) return [];
return list.map((u) => ({
...u,
value: u.email || '',
realname: u.name || u.realname || u.username || '',
expert_id: u.expert_id || u.id || ''
}));
},
async queryRecipientSuggestions(reset) {
if (this.recipientSuggest.loading) return;
const st = this.recipientSuggest;
if (!st.keyword) {
st.options = [];
if (st.cb) st.cb([]);
return;
}
if (reset) {
st.pageIndex = 1;
st.totalPages = 1;
st.options = [];
} else if (st.pageIndex >= st.totalPages) {
if (st.cb) st.cb(st.options);
return;
} else {
st.pageIndex += 1;
}
st.loading = true;
try {
const res = await this.$api.post('api/expert_manage/getList', {
major_id: '',
keyword: st.keyword,
pageIndex: st.pageIndex,
pageSize: st.pageSize
});
const data = (res && res.data) || {};
const list = this.normalizeExpertList(data.list || []);
st.totalPages = Number(data.totalPages || data.total_pages || 1) || 1;
st.options = reset ? list : st.options.concat(list);
if (st.cb) st.cb(st.options);
this.attachRecipientSuggestScroll();
} catch (e) {
if (st.cb) st.cb(st.options || []);
} finally {
st.loading = false;
}
},
loadMoreRecipientSuggestions() {
this.queryRecipientSuggestions(false);
},
handleTemplateApply(payload) {
// TemplateSelectorDialog 现在返回对象:{ html, journal_id, style_id, template_id, ... }
const html = payload && typeof payload === 'object' ? (payload.html || '') : String(payload || '');
const templateId = payload && typeof payload === 'object' ? (payload.template_id || '') : '';
const styleId = payload && typeof payload === 'object' ? (payload.style_id || '') : '';
const templateSubject = payload && typeof payload === 'object'
? ((payload.template && payload.template.subject) || payload.subject || '')
: '';
if (!html) {
this.$message.warning(this.$t('mailTemplate.noTemplateTip') || '未获取到模板内容');
return;
}
// 始终维护一份内容状态,确保源码模式/富文本模式都能回填
this.queryMail.content = html;
this.sourceContent = html;
// 优先回填 TinyMCE 实例
if (window.tinymce && window.tinymce.activeEditor && window.tinymce.activeEditor.setContent) {
window.tinymce.activeEditor.setContent(html);
}
this.selectedTemplateId = templateId ? String(templateId) : '';
this.selectedStyleId = styleId ? String(styleId) : '';
// 模板自带 subject仅当当前主题为空时自动回填
if (!this.queryMail.sendtitle && templateSubject) {
this.queryMail.sendtitle = String(templateSubject);
}
// this.$message.success(this.$t('mailboxSend.templateApplied') || 'Template applied successfully!');
},
// 切换富文本 / 源代码编辑模式(源码用 sourceContent 保留完整 HTML可自由来回切换
toggleSourceMode() {
if (this.isSourceMode) {
@@ -276,41 +440,34 @@ import TemplateSelectorDialog from '@/components/page/components/email/TemplateS
}
this.isSourceMode = !this.isSourceMode;
},
// 返回收件箱(邮箱列表),带上 journal_id 和 j_email_id
// 返回收件箱(邮箱列表),账号信息从本地缓存读取
goBackInbox() {
const q = this.$route.query;
const query = {};
if (q.journal_id) query.journal_id = q.journal_id;
if (q.j_email_id) query.j_email_id = q.j_email_id;
this.$router.push({
path: '/mailboxCollect',
query,
this.showSendEmail=false
const currentPath = this.$route.fullPath;
// 先静默关闭当前标签,强制销毁 keep-alive 缓存,再执行跳转
bus.$emit('close_tag_by_path', {
path: currentPath,
silent: true
});
this.$nextTick(() => {
this.$router.push({ path: '/mailboxCollect' });
});
},
// 收件人自动补全 - 搜索用户
fetchUserSuggestions(queryString, cb) {
if (!queryString) {
if (this.isToRecipientLimitReached()) {
cb([]);
return;
}
this.$api
.post('api/Reviewer/researchUser', {
keywords: queryString
})
.then(res => {
if (res && res.code === 0 && res.data && res.data.list) {
const list = res.data.list.map(u => ({
...u,
value: u.email,
realname: u.realname || u.username || ''
}));
cb(list);
} else {
cb([]);
}
})
.catch(() => cb([]));
const keyword = (queryString || '').trim();
this.recipientSuggest.keyword = keyword;
this.recipientSuggest.cb = cb;
if (!keyword) {
this.detachRecipientSuggestScroll();
cb([]);
return;
}
this.queryRecipientSuggestions(true);
},
// 收件人输入框失焦:输入内容失去焦点则自动成为一条收件人数据(排除点击下拉项时)
handleToBlur(e) {
@@ -332,11 +489,17 @@ import TemplateSelectorDialog from '@/components/page/components/email/TemplateS
}
const exists = (this.queryMail.sendnamelist || []).some(item => item.name === value);
if (!exists) {
if (this.isToRecipientLimitReached()) {
this.showToRecipientLimitWarning();
this.toInput = '';
return;
}
this.queryMail.sendnamelist.push({
id: null,
name: value,
_uid: this.nextToUid++,
});
this.queryMail.expert_id = '';
this.queryMail.sendname = (this.queryMail.sendnamelist || []).map(i => i.name);
}
this.toInput = '';
@@ -350,11 +513,17 @@ import TemplateSelectorDialog from '@/components/page/components/email/TemplateS
// 去重
const exists = (this.queryMail.sendnamelist || []).some(item => item.name === email);
if (!exists) {
if (this.isToRecipientLimitReached()) {
this.showToRecipientLimitWarning();
this.toInput = '';
return;
}
this.queryMail.sendnamelist.push({
id: user.user_id || user.id || null,
id: user.expert_id || user.user_id || user.id || null,
name: email,
_uid: this.nextToUid++,
});
this.queryMail.expert_id = user.expert_id || user.user_id || user.id || '';
// 同步简单数组
this.queryMail.sendname = (this.queryMail.sendnamelist || []).map(i => i.name);
}
@@ -366,6 +535,9 @@ import TemplateSelectorDialog from '@/components/page/components/email/TemplateS
if (index < 0) return;
this.queryMail.sendnamelist.splice(index, 1);
this.queryMail.sendname = (this.queryMail.sendnamelist || []).map(i => i.name);
if (!this.queryMail.sendnamelist.length) {
this.queryMail.expert_id = '';
}
},
// CC 输入框失焦:与 To 相同逻辑,输入失去焦点则自动成为一条数据(排除点击下拉项时)
handleCcBlur(e) {
@@ -415,9 +587,11 @@ import TemplateSelectorDialog from '@/components/page/components/email/TemplateS
if (index < 0) return;
this.ccList.splice(index, 1);
},
// 根据路由 j_email_id 获取发件邮箱信息,用于展示发件人
// 根据本地缓存(优先)或路由参数获取发件邮箱信息,用于展示发件人
getDate() {
const jEmailId = this.$route.query.j_email_id;
// 1. 优先从本地缓存读取
const storedEmailId = localStorage.getItem('mailboxCollect_j_email_id');
const jEmailId = storedEmailId || this.$route.query.j_email_id;
if (!jEmailId) {
this.userMes = {};
return;
@@ -464,52 +638,81 @@ import TemplateSelectorDialog from '@/components/page/components/email/TemplateS
});
},
// 发送邮件api/email_client/sendOneto_email 为多邮箱字符串拼接(逗号分隔),发送成功后关闭当前页并跳转收件箱
// 发送邮件api/email_client/sendTemplateStyleText
handleSend() {
// 防抖:快速连点只触发最后一次
if (this.sendLoading) return;
const toList = (this.queryMail.sendnamelist || []).map((item) => item.name).filter(Boolean);
if (!toList.length) {
this.$message.warning(this.$t('mailboxSend.validateTo'));
return;
}
if (!this.queryMail.sendtitle) {
this.$message.warning(this.$t('mailboxSend.validateSubject'));
return;
}
const journalId = this.$route.query.journal_id;
if (!journalId) {
this.$message.warning(this.$t('mailboxSend.needAccount'));
return;
}
this.sendLoading = true;
// 优先发送完整 HTMLsourceContent这样富文本编辑后也能保持 head/style/table 等结构(像阿里邮箱)
const bodyContent = this.sourceContent || (this.queryMail.content || '');
const params = {
journal_id: journalId,
to_email: toList.join(','),
subject: this.queryMail.sendtitle,
content: bodyContent,
};
const self = this;
this.$api.post('api/email_client/sendOne', params).then((res) => {
if (res && res.code === 0) {
self.$message.success(self.$t('mailboxSend.sendSuccess'));
self.queryMail.sendnamelist = [];
self.queryMail.sendtitle = '';
self.queryMail.sendcc = '';
self.ccList = [];
self.queryMail.content = '';
self.sourceContent = '';
self.fileL_atta = [];
self.goBackInbox();
} else {
self.$message.error((res && res.msg) || self.$t('mailboxSend.sendFail'));
if (this.sendDebounceTimer) clearTimeout(this.sendDebounceTimer);
this.sendDebounceTimer = setTimeout(() => {
this.sendDebounceTimer = null;
if (this.sendLoading) return;
const toList = (this.queryMail.sendnamelist || []).map((item) => item.name).filter(Boolean);
const expert_id_list = (this.queryMail.sendnamelist || []).map((item) => item.expert_id).filter(Boolean);
if (!toList.length) {
this.$message.warning(this.$t('mailboxSend.validateTo'));
return;
}
}).catch(() => {
self.$message.error(self.$t('mailboxSend.sendFail'));
}).finally(() => {
self.sendLoading = false;
});
if (!this.queryMail.sendtitle) {
this.$message.warning(this.$t('mailboxSend.validateSubject'));
return;
}
// journal_id 优先从本地缓存获取,兼容旧的路由参数
const storedJournalId = localStorage.getItem('mailboxCollect_journal_id');
const journalId = storedJournalId || this.$route.query.journal_id;
const storedEmailId = localStorage.getItem('mailboxCollect_j_email_id');
const jEmailId = storedEmailId || this.$route.query.j_email_id;
if (!journalId) {
this.$message.warning(this.$t('mailboxSend.needAccount'));
return;
}
if (!jEmailId) {
this.$message.warning(this.$t('mailboxSend.needAccount'));
return;
}
// if (!this.selectedTemplateId || !this.selectedStyleId) {
// this.$message.warning(this.$t('mailboxSend.selectTemplateStyleFirst'));
// return;
// }
this.sendLoading = true;
const params = {
to_email: toList.join(','),
subject: this.queryMail.sendtitle || '',
content: this.queryMail.content || '',
j_email_id: String(jEmailId),
journal_id: String(journalId),
};
const self = this;
this.$api
.post('api/email_client/sendOne', params)
.then((res) => {
if (res && res.code === 0) {
self.$message.success(self.$t('mailboxSend.sendSuccess'));
self.queryMail.sendnamelist = [];
self.queryMail.sendtitle = '';
self.queryMail.sendcc = '';
self.ccList = [];
self.queryMail.content = '';
self.sourceContent = '';
self.selectedTemplateId = '';
self.selectedStyleId = '';
self.fileL_atta = [];
self.goBackInbox();
} else {
self.$message.error((res && res.msg) || self.$t('mailboxSend.sendFail'));
}
})
.catch(() => {
self.$message.error(self.$t('mailboxSend.sendFail'));
})
.finally(() => {
self.sendLoading = false;
});
}, 600);
},
// 保存草稿(防抖:请求中禁用按钮)
handleSaveDraft() {
@@ -549,6 +752,10 @@ import TemplateSelectorDialog from '@/components/page/components/email/TemplateS
},
// 保存通讯录
mailLibAdd(e) {
if (this.isToRecipientLimitReached()) {
this.showToRecipientLimitWarning();
return;
}
this.queryMail.sendname.push(e.email)
this.queryMail.sendnamelist.push({
id: null,
@@ -560,7 +767,15 @@ import TemplateSelectorDialog from '@/components/page/components/email/TemplateS
// 批量保存通讯录
mailLiyAll() {
console.log(this.LibrarySelection)
const max = Number(this.maxToRecipients || 0);
const current = (this.queryMail.sendnamelist || []).length;
const remain = max > 0 ? Math.max(0, max - current) : this.LibrarySelection.length;
if (remain <= 0) {
this.showToRecipientLimitWarning();
return;
}
for (let i = 0; i < this.LibrarySelection.length; i++) {
if (i >= remain) break;
this.queryMail.sendname.push(this.LibrarySelection[i].email)
this.queryMail.sendnamelist.push({
id: null,

View File

@@ -12,6 +12,7 @@
</div>
<el-table :data="tableData" border style="width: 100%; margin-top: 20px;" v-loading="loading">
<el-table-column type="index" :label="$t('mailboxStyle.no')" width="70" align="center"></el-table-column>
<el-table-column prop="name" :label="$t('mailboxStyle.colName')" min-width="220">
<template slot-scope="scope">
<div class="title-cell">

View File

@@ -8,7 +8,17 @@
</div>
<div class="right">
<el-button size="mini" @click="goBack">{{ $t('mailboxStyleDetail.cancel') }}</el-button>
<el-button type="primary" size="mini" icon="el-icon-document-checked" @click="handleSave">{{ $t('mailboxStyleDetail.save') }}</el-button>
<el-button
type="primary"
size="mini"
icon="el-icon-document-checked"
@click="handleSave"
:loading="loading"
:disabled="loading"
:loading-text="$t('mailboxStyleDetail.loading')"
>
{{ $t('mailboxStyleDetail.save') }}
</el-button>
</div>
</header>
@@ -57,6 +67,7 @@ export default {
data() {
return {
loading: false,
saveDebounceTimer: null,
form: {
style_id: '',
name: '',
@@ -85,6 +96,12 @@ export default {
this.loadDetail(String(styleId));
}
},
beforeDestroy() {
if (this.saveDebounceTimer) {
clearTimeout(this.saveDebounceTimer);
this.saveDebounceTimer = null;
}
},
methods: {
loadDetail(styleId) {
this.loading = true;
@@ -104,15 +121,30 @@ export default {
});
},
goBack() {
this.$router.push({ path: '/mailboxStyle' });
localStorage.setItem('mailboxMouldActiveTab', 'styles');
this.$router.push({ path: '/mailboxMould' });
},
handleSave() {
if (this.loading) return;
// 防抖:连续点击只触发最后一次
if (this.saveDebounceTimer) clearTimeout(this.saveDebounceTimer);
this.saveDebounceTimer = setTimeout(() => {
this.saveDebounceTimer = null;
this._doSave();
}, 600);
},
async _doSave() {
const formRef = this.$refs.styleForm;
const validatePromise =
formRef && formRef.validate ? new Promise(resolve => formRef.validate(ok => resolve(ok))) : Promise.resolve(true);
validatePromise.then(ok => {
if (!ok) return;
this.loading = true;
formRef && formRef.validate
? new Promise(resolve => formRef.validate(ok => resolve(ok)))
: Promise.resolve(true);
const ok = await validatePromise;
if (!ok) return;
this.loading = true;
try {
const q = this.$route && this.$route.query ? this.$route.query : {};
const styleId = q.style_id || q.id || '';
const params = {
@@ -122,23 +154,19 @@ export default {
header_html: this.form.header_html || '',
footer_html: this.form.footer_html || ''
};
this.$api
.post(API.saveStyle, params)
.then(res => {
if (res && res.code === 0) {
this.$message.success(this.$t('mailboxStyleDetail.saveSuccess'));
this.goBack();
} else {
this.$message.error((res && res.msg) || this.$t('mailboxStyleDetail.saveFail'));
}
})
.catch(() => {
this.$message.error(this.$t('mailboxStyleDetail.saveFail'));
})
.finally(() => {
this.loading = false;
});
});
const res = await this.$api.post(API.saveStyle, params);
if (res && res.code === 0) {
this.$message.success(this.$t('mailboxStyleDetail.saveSuccess'));
this.goBack();
} else {
this.$message.error((res && res.msg) || this.$t('mailboxStyleDetail.saveFail'));
}
} catch (e) {
this.$message.error(this.$t('mailboxStyleDetail.saveFail'));
} finally {
this.loading = false;
}
}
}
};

View File

@@ -0,0 +1,545 @@
<template>
<div class="keywords-container">
<transition name="el-zoom-in-top" appear>
<div class="page-header">
<div class="header-left">
<h2 class="page-title">{{ $t('crawlerKeywords.pageTitle') }}</h2>
<p class="page-desc">
<i class="el-icon-info"></i> {{ $t('crawlerKeywords.pageDesc') }}
</p>
</div>
<div class="header-actions">
<!-- <el-button
type="primary"
icon="el-icon-video-play"
@click="handleStartCrawl"
:loading="crawlLoading"
class="glow-button"
round
>
{{ $t('crawlerKeywords.startCrawl') }}
</el-button> -->
</div>
</div>
</transition>
<div class="add-section shadow-hover">
<el-input
v-model="newKeyword"
:placeholder="$t('crawlerKeywords.inputPlaceholder')"
class="add-input-custom"
prefix-icon="el-icon-collection-tag"
clearable
@keyup.enter.native="handleAdd"
/>
<el-button
type="primary"
icon="el-icon-plus"
@click="handleAdd"
:loading="addLoading"
class="add-btn"
>
{{ $t('crawlerKeywords.addKeyword') }}
</el-button>
</div>
<el-card shadow="never" class="table-card animated-card">
<div class="table-toolbar">
<el-input
v-model="searchText"
:placeholder="$t('crawlerKeywords.searchPlaceholder')"
prefix-icon="el-icon-search"
clearable
class="search-input"
@input="handleSearch"
/>
<el-button style="margin-left: 20px;"
type="primary"
icon="el-icon-search"
@click="handleSearchNow"
>
{{ $t('crawlerKeywords.searchBtn') }}
</el-button>
</div>
<el-table
:data="list"
v-loading="loading"
border
stripe
highlight-current-row
header-row-class-name="custom-header"
style="width: 100%"
class="modern-table"
>
<el-table-column prop="keyword" :label="$t('crawlerKeywords.colKeyword')" min-width="180">
<template slot-scope="scope">
<transition name="fade-slide" mode="out-in">
<span :key="'t'+scope.row.id" v-if="editingId !== scope.row.id" class="keyword-text">
{{ scope.row.keyword }}
</span>
<el-input
:key="'e'+scope.row.id"
v-else
v-model="editForm.keyword"
size="small"
v-focus
class="edit-input"
/>
</transition>
</template>
</el-table-column>
<el-table-column prop="category" :label="$t('crawlerKeywords.colCategory')" width="150">
<template slot-scope="scope">
<transition name="fade-slide" mode="out-in">
<div :key="editingId === scope.row.id">
<el-tag
v-if="editingId !== scope.row.id"
:type="scope.row.category ? 'success' : 'info'"
size="small"
effect="light"
>
{{ scope.row.category || 'Default' }}
</el-tag>
<el-input v-else v-model="editForm.category" size="small" />
</div>
</transition>
</template>
</el-table-column>
<el-table-column prop="state" :label="$t('crawlerKeywords.colStatus')" width="140" align="center">
<template slot-scope="scope">
<div class="status-container">
<span :class="['status-dot', 'pulse', 'status-' + scope.row.state]"></span>
<span :class="['status-label', 'text-' + scope.row.state]">
{{ getStateText(scope.row.state) }}
</span>
</div>
</template>
</el-table-column>
<el-table-column prop="expert_count" :label="$t('crawlerKeywords.colExpertCount')" width="120" align="center">
<template slot-scope="scope">
<span class="count-badge">{{ scope.row.expert_count }}</span>
</template>
</el-table-column>
<el-table-column prop="last_crawl_time" :label="$t('crawlerKeywords.colLastCrawl')" width="180" />
<el-table-column :label="$t('crawlerKeywords.colAction')" width="160" align="center" fixed="right">
<template slot-scope="scope">
<div class="action-wrapper">
<template v-if="editingId === scope.row.id">
<el-button type="text" icon="el-icon-circle-check" class="save-btn" @click="handleSaveEdit(scope.row)">
{{ $t('crawlerKeywords.save') }}
</el-button>
<el-button type="text" icon="el-icon-circle-close" class="cancel-btn" @click="editingId = null">
{{ $t('crawlerKeywords.cancel') }}
</el-button>
</template>
<template v-else>
<el-tooltip :content="$t('crawlerKeywords.refresh')" placement="top">
<el-button
type="text"
icon="el-icon-refresh"
:class="['refresh-icon', { 'is-spinning': scope.row._refreshing }]"
@click="handleRefresh(scope.row)"
/>
</el-tooltip>
<el-tooltip :content="$t('crawlerKeywords.edit')" placement="top">
<el-button type="text" icon="el-icon-edit-outline" @click="handleEdit(scope.row)" />
</el-tooltip>
<el-tooltip :content="$t('crawlerKeywords.delete')" placement="top">
<el-button type="text" icon="el-icon-delete" class="del-btn" @click="handleDelete(scope.row)" />
</el-tooltip>
</template>
</div>
</template>
</el-table-column>
</el-table>
<div class="pagination-wrapper">
<el-pagination
background
layout="total, sizes, prev, pager, next, jumper"
:current-page="query.pageIndex"
:page-size="query.pageSize"
:page-sizes="[10, 20, 50]"
:total="total"
@size-change="handleSizeChange"
@current-change="handlePageChange"
/>
</div>
</el-card>
</div>
</template>
<script>
import Common from '@/components/common/common';
const API = {
list: 'api/expert_manage/getKeywordList',
add: 'api/expert_manage/addKeyword',
update: 'api/expert_manage/updateKeyword',
delete: 'api/expert_manage/deleteKeyword',
refresh: 'api/expert_manage/refreshKeyword',
startCrawl: 'api/expert_manage/startCrawl',
exportData: 'api/expert_manage/exportKeywords'
};
export default {
name: 'scholarCrawlersKeywords',
directives: {
focus: {
inserted: (el) => el.querySelector('input').focus()
}
},
data() {
return {
mediaUrl: Common.mediaUrl,
newKeyword: '',
searchText: '',
loading: false,
addLoading: false,
exportLoading: false,
crawlLoading: false,
editingId: null,
editForm: { keyword: '', category: '' },
query: { pageIndex: 1, pageSize: 10 },
list: [],
total: 0,
searchTimer: null
};
},
created() {
this.fetchList();
},
methods: {
getStateText(state) {
const map = {
running: this.$t('crawlerKeywords.stateRunning'),
paused: this.$t('crawlerKeywords.statePaused'),
error: this.$t('crawlerKeywords.stateError'),
done: this.$t('crawlerKeywords.stateDone')
};
return map[state] || state || '-';
},
async fetchList() {
this.loading = true;
try {
const params = {
keyword: this.searchText || '',
pageIndex: this.query.pageIndex,
pageSize: this.query.pageSize
};
const res = await this.$api.post(API.list, params);
if (res && res.code === 0 && res.data) {
this.list = (res.data.list || []).map(item => ({
...item,
_refreshing: false
}));
this.total = res.data.total || 0;
}
} catch (e) {
console.error(e);
} finally {
setTimeout(() => { this.loading = false; }, 300); // 增加微小延迟让加载动画更平滑
}
},
handleSearch() {
if (this.searchTimer) clearTimeout(this.searchTimer);
this.searchTimer = setTimeout(() => {
this.query.pageIndex = 1;
this.fetchList();
}, 400);
},
handleSearchNow() {
if (this.searchTimer) {
clearTimeout(this.searchTimer);
this.searchTimer = null;
}
this.query.pageIndex = 1;
this.fetchList();
},
async handleAdd() {
const kw = (this.newKeyword || '').trim();
if (!kw) {
this.$message.warning(this.$t('crawlerKeywords.emptyKeywordWarn'));
return;
}
this.addLoading = true;
try {
const res = await this.$api.post(API.add, { keyword: kw });
if (res && res.code === 0) {
this.$notify({ title: 'Success', message: this.$t('crawlerKeywords.addSuccess'), type: 'success' });
this.newKeyword = '';
this.query.pageIndex = 1;
this.fetchList();
}
} finally {
this.addLoading = false;
}
},
handleEdit(row) {
this.editingId = row.id;
this.editForm = { keyword: row.keyword, category: row.category || '' };
},
async handleSaveEdit(row) {
if (!(this.editForm.keyword || '').trim()) {
this.$message.warning(this.$t('crawlerKeywords.emptyKeywordWarn'));
return;
}
try {
const res = await this.$api.post(API.update, {
id: String(row.id),
keyword: this.editForm.keyword.trim(),
category: this.editForm.category || ''
});
if (res && res.code === 0) {
this.$message.success(this.$t('crawlerKeywords.updateSuccess'));
this.editingId = null;
this.fetchList();
}
} catch (e) {
this.$message.error(this.$t('crawlerKeywords.updateFail'));
}
},
handleDelete(row) {
this.$confirm(`确定要删除关键词 "${row.keyword}" 吗?`, '安全警告', {
confirmButtonText: '确定删除',
cancelButtonText: '取消',
type: 'warning',
center: true,
roundButton: true
}).then(async () => {
const res = await this.$api.post(API.delete, { id: String(row.id) });
if (res && res.code === 0) {
this.$notify({ title: 'Deleted', type: 'success', duration: 2000 });
this.fetchList();
}
}).catch(() => {});
},
async handleRefresh(row) {
row._refreshing = true;
try {
const res = await this.$api.post(API.refresh, { id: String(row.id) });
if (res && res.code === 0) {
this.$message.success(this.$t('crawlerKeywords.refreshSuccess'));
this.fetchList();
}
} finally {
row._refreshing = false;
}
},
async handleStartCrawl() {
this.crawlLoading = true;
try {
const res = await this.$api.post(API.startCrawl, {});
if (res && res.code === 0) {
this.$message({ message: this.$t('crawlerKeywords.crawlStarted'), type: 'success', showClose: true });
this.fetchList();
}
} finally {
this.crawlLoading = false;
}
},
async handleExport() {
this.exportLoading = true;
try {
const res = await this.$api.post(API.exportData, {});
if (res && res.code === 0 && res.data.file_url) {
window.open(this.mediaUrl + res.data.file_url, '_blank');
}
} finally {
this.exportLoading = false;
}
},
handleSizeChange(size) {
this.query.pageSize = size;
this.fetchList();
},
handlePageChange(page) {
this.query.pageIndex = page;
this.fetchList();
}
}
};
</script>
<style scoped>
/* 容器及整体布局 */
.keywords-container {
padding: 10px;
margin: 0 auto;
background-color: #f8fafc;
/* min-height: 100vh; */
}
/* 头部样式 */
.page-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 24px;
}
.page-title {
margin: 0 0 6px;
font-size: 24px;
font-weight: 700;
color: #1e293b;
letter-spacing: -0.5px;
}
.page-desc {
margin: 0;
font-size: 14px;
color: #64748b;
}
/* 新增区域:卡片化 */
.add-section {
display: flex;
gap: 16px;
margin-bottom: 24px;
background: #ffffff;
border-radius: 12px;
padding: 20px;
border: 1px solid #e2e8f0;
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.shadow-hover:hover {
box-shadow: 0 10px 20px -5px rgba(0, 0, 0, 0.05);
transform: translateY(-2px);
}
.add-input-custom ::v-deep .el-input__inner {
border-radius: 8px;
background-color: #f1f5f9;
border-color: transparent;
}
.add-input-custom ::v-deep .el-input__inner:focus {
background-color: #fff;
border-color: #409eff;
}
/* 按钮发光 */
.glow-button {
box-shadow: 0 4px 12px rgba(64, 158, 255, 0.3);
}
.glow-button:hover {
box-shadow: 0 6px 16px rgba(64, 158, 255, 0.4);
}
/* 表格卡片 */
.table-card {
border-radius: 12px;
border: 1px solid #e2e8f0;
padding: 10px;
}
.table-toolbar {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 18px;
}
.search-input ::v-deep .el-input__inner {
border-radius: 20px;
}
/* 状态标签与脉冲 */
.status-container {
display: flex;
align-items: center;
justify-content: center;
}
.status-dot {
width: 8px;
height: 8px;
border-radius: 50%;
margin-right: 8px;
}
.pulse {
animation: shadow-pulse 2s infinite;
}
@keyframes shadow-pulse {
0% { box-shadow: 0 0 0 0px rgba(103, 194, 58, 0.4); }
70% { box-shadow: 0 0 0 8px rgba(103, 194, 58, 0); }
100% { box-shadow: 0 0 0 0px rgba(103, 194, 58, 0); }
}
.status-running { background: #67C23A; }
.status-paused { background: #E6A23C; }
.status-error { background: #F56C6C; animation-name: shadow-pulse-error; }
.status-done { background: #94a3b8; }
@keyframes shadow-pulse-error {
0% { box-shadow: 0 0 0 0px rgba(245, 108, 108, 0.4); }
70% { box-shadow: 0 0 0 8px rgba(245, 108, 108, 0); }
100% { box-shadow: 0 0 0 0px rgba(245, 108, 108, 0); }
}
.text-running { color: #67C23A; font-weight: 600; }
.text-error { color: #F56C6C; font-weight: 600; }
/* 表格定制 */
::v-deep .custom-header th {
/* background-color: #f8fafc !important; */
color: #475569;
font-weight: 600;
/* height: 50px; */
}
.count-badge {
background: #eff6ff;
color: #2563eb;
padding: 2px 8px;
border-radius: 12px;
font-weight: 700;
font-size: 13px;
}
/* 操作按钮 */
.action-wrapper .el-button {
font-size: 18px;
padding: 0 6px;
transition: all 0.2s;
}
.action-wrapper .el-button:hover {
transform: scale(1.2);
}
.del-btn { color: #ef4444 !important; }
.save-btn { color: #10b981 !important; font-size: 14px !important; }
.cancel-btn { color: #64748b !important; font-size: 14px !important; }
/* 刷新旋转 */
.is-spinning {
animation: rotate 1s linear infinite;
color: #409eff;
}
@keyframes rotate {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
/* 过渡动画 */
.fade-slide-enter-active, .fade-slide-leave-active {
transition: all 0.25s ease;
}
.fade-slide-enter {
opacity: 0;
transform: translateY(5px);
}
.fade-slide-leave-to {
opacity: 0;
transform: translateY(-5px);
}
.pagination-wrapper {
margin-top: 24px;
display: flex;
justify-content: flex-end;
}
::v-deep .el-card__body{
padding: 10px !important;
}
</style>

View File

@@ -1097,6 +1097,41 @@ export default new Router({
title: 'Scholar Database'
}
},
{
path: '/crawlTaskMonitor',
component: () => import('../components/page/crawlTaskMonitor'),
meta: {
title: 'Crawl Task Monitor'
}
},
{
path: '/scholarCrawlersKeywords',
component: () => import('../components/page/scholarCrawlersKeywords'),
meta: {
title: 'Crawl Keywords Config'
}
},
{
path: '/expertDatabase', //专家库
component: () => import('../components/page/expertDatabase'),
meta: {
title: 'Expert Database'
}
},
{
path: '/autoPromotion', // 自动推广
component: () => import('../components/page/autoPromotion'),
meta: {
title: 'Auto Promotion'
}
},
{
path: '/autoPromotionLogs', // 历史推广记录
component: () => import('../components/page/autoPromotionLogs'),
meta: {
title: 'Promotion History'
}
},
{
path: '/PreIngested', //预收录-完善资料页面
component: () => import('../components/page/Complete_profile'),

View File

@@ -60,7 +60,7 @@ module.exports = {
assetsDir: 'static',
productionSourceMap: false,
devServer: {
// public: 'http://192.168.110.159:8080/', // 你自己本地的ip地址:端口号
port: '8080',
open: true,
@@ -77,7 +77,16 @@ module.exports = {
changeOrigin: true,
pathRewrite: {
'^/api': ''
}
},
compress: false, // 💡 关键:禁止压缩,否则 SSE 流会被攒着不发
// 增加超时时间,防止长连接被代理提前掐断
proxyTimeout: 10 * 60 * 1000,
timeout: 10 * 60 * 1000
},
'/public': {
target: 'https://submission.tmrjournals.com/',
changeOrigin: true
}
}
},