自动化推广【约稿】
This commit is contained in:
@@ -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="password"
|
||||
show-password
|
||||
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) {
|
||||
@@ -231,21 +267,23 @@
|
||||
}).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));
|
||||
@@ -268,6 +306,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,19 +337,27 @@
|
||||
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) {
|
||||
@@ -321,7 +376,7 @@
|
||||
// 删除邮箱配置:接口 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'
|
||||
@@ -345,5 +400,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>
|
||||
|
||||
Reference in New Issue
Block a user