自动化推广【约稿】
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user