+
+ {{ $t('mailboxSend.backToInbox') }}
+
- Mailbox Send
+ {{ $t('mailboxSend.title') }}
+
-
- Addressee :
-
- Select from library
-
-
-
-
-
- Mail Subject :
-
-
-
- CC :
-
-
-
-
-
Attachments :
-
-
- Upload
-
-
-
+
+
{{ $t('mailboxSend.to') }}
+
+
+
+
+ {{ item.name }}
+
+
+
+
+
+
+
+ {{ item.value }} | {{ item.realname }}
+
+
+
+
+
+
+ {{ $t('mailboxSend.selectFromLibrary') }}
+
+
+
+ {{ $t('mailboxSend.subject') }}
+
-
- Template selection
-
+
+
{{ $t('mailboxSend.cc') }}
+
+
+
+ {{ item.name }}
+
+
+
+
+
+ {{ item.value }} | {{ item.realname }}
+
+
+
+
+
+
-
- Sender :{{userMes.realname}} < {{userMes.email}} >
-
-
-
-
- Send
+
+
-
- Batch
- Selection
-
+
+
+ {{ $t('mailboxSend.batchSelection') }}
+
+
-
+
{{scope.row.email}}
-
-
+
+
- Select
+
+ {{ $t('mailboxSend.selectBtn') }}
+
@@ -83,22 +148,22 @@
-
+
-
-
-
+
+
+
-
+
@@ -118,6 +183,7 @@
// Quill.register('modules/imageResize', ImageResize)
import 'multi-items-input'
import 'multi-items-input/dist/multi-items-input.css'
+ import bus from '../common/bus'
export default {
data() {
return {
@@ -127,13 +193,7 @@
userMes: {},
queryMail: {
sendname: [],
- sendnamelist: [{
- id: null,
- name: "atr@tmrjournals.com"
- }, {
- id: null,
- name: "tmrtheory@tmrjournals.com"
- }],
+ sendnamelist: [],
sendtitle: '',
sendcc: '',
content: ''
@@ -158,7 +218,7 @@
Librarybox: false,
link_TotalLibry: 0,
editorOption: {
- placeholder: 'Please enter...',
+ placeholder: this.$t('mailboxSend.editorPlaceholder'),
modules: {
toolbar: {
container: [
@@ -229,46 +289,215 @@
// }
}
},
+ toInput: '',
+ toSelecting: false,
+ nextToUid: 1,
+ ccList: [],
+ ccInput: '',
+ ccSelecting: false,
+ nextCcUid: 1,
+ collapseValue: localStorage.getItem('collapse'),
+ sendLoading: false,
+ saveDraftLoading: false,
};
},
+ computed: {
+ footerBarLeft() {
+ const collapsed = this.collapseValue === true || this.collapseValue === 'true';
+ return (collapsed ? 64: 260) + 'px';
+ },
+ },
+ watch: {
+ collapseValue: {
+ handler() {
+ // 监听 collapseValue 变化,footerBarLeft 通过 computed 自动更新
+ },
+ immediate: true,
+ },
+ },
created() {
this.getDate();
- this.getLibary();
},
- // components: {
- // quillEditor
- // },
- computed: {
-
+ mounted() {
+ bus.$on('collapse-content', (msg) => {
+ this.collapseValue = msg;
+ });
+ },
+ beforeDestroy() {
+ bus.$off('collapse-content');
},
methods: {
- // 获取初始用户数据
- getDate() {
+ // 返回收件箱(邮箱列表),带上 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,
+ });
+ },
+ // 收件人自动补全 - 搜索用户
+ fetchUserSuggestions(queryString, cb) {
+ if (!queryString) {
+ cb([]);
+ return;
+ }
this.$api
- .post('api/User/getUserDetail', {
- 'user_id': localStorage.getItem('U_id')
+ .post('api/Reviewer/researchUser', {
+
+ keywords: queryString
})
.then(res => {
- if (res.code == 0) {
- this.userMes = res.data.user
+ 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 {
- this.$message.error(res.msg);
+ cb([]);
}
})
- .catch(err => {
- this.$message.error(err);
+ .catch(() => cb([]));
+ },
+ // 收件人输入框失焦:输入内容失去焦点则自动成为一条收件人数据(排除点击下拉项时)
+ handleToBlur(e) {
+ // 若失焦是因为点击了下拉建议区域,不执行任何逻辑,让 click 触发 select,否则点击会选不中
+ const related = e && e.relatedTarget;
+ if (related && typeof related.closest === 'function' && related.closest('.el-autocomplete-suggestion')) {
+ return;
+ }
+ const value = (this.toInput || '').trim();
+ setTimeout(() => {
+ if (this.toSelecting) {
+ this.toSelecting = false;
+ return;
+ }
+ if (!value) return;
+ if (value.indexOf('@') === -1) {
+ this.toInput = '';
+ return;
+ }
+ const exists = (this.queryMail.sendnamelist || []).some(item => item.name === value);
+ if (!exists) {
+ this.queryMail.sendnamelist.push({
+ id: null,
+ name: value,
+ _uid: this.nextToUid++,
+ });
+ this.queryMail.sendname = (this.queryMail.sendnamelist || []).map(i => i.name);
+ }
+ this.toInput = '';
+ }, 150);
+ },
+ // 选中某个用户作为收件人
+ handleSelectUser(user) {
+ this.toSelecting = true;
+ if (!user || !user.email) return;
+ const email = user.email;
+ // 去重
+ const exists = (this.queryMail.sendnamelist || []).some(item => item.name === email);
+ if (!exists) {
+ this.queryMail.sendnamelist.push({
+ id: user.user_id || user.id || null,
+ name: email,
+ _uid: this.nextToUid++,
+ });
+ // 同步简单数组
+ this.queryMail.sendname = (this.queryMail.sendnamelist || []).map(i => i.name);
+ }
+ // 清空输入框,便于继续输入下一个
+ this.toInput = '';
+ },
+ // 删除已选收件人
+ removeRecipient(index) {
+ if (index < 0) return;
+ this.queryMail.sendnamelist.splice(index, 1);
+ this.queryMail.sendname = (this.queryMail.sendnamelist || []).map(i => i.name);
+ },
+ // CC 输入框失焦:与 To 相同逻辑,输入失去焦点则自动成为一条数据(排除点击下拉项时)
+ handleCcBlur(e) {
+ const related = e && e.relatedTarget;
+ if (related && typeof related.closest === 'function' && related.closest('.el-autocomplete-suggestion')) {
+ return;
+ }
+ const value = (this.ccInput || '').trim();
+ setTimeout(() => {
+ if (this.ccSelecting) {
+ this.ccSelecting = false;
+ return;
+ }
+ if (!value) return;
+ if (value.indexOf('@') === -1) {
+ this.ccInput = '';
+ return;
+ }
+ const exists = (this.ccList || []).some(item => item.name === value);
+ if (!exists) {
+ this.ccList.push({
+ id: null,
+ name: value,
+ _uid: this.nextCcUid++,
+ });
+ }
+ this.ccInput = '';
+ }, 150);
+ },
+ // 选中某个用户作为 CC(与 To 相同逻辑)
+ handleSelectCc(user) {
+ this.ccSelecting = true;
+ if (!user || !user.email) return;
+ const email = user.email;
+ const exists = (this.ccList || []).some(item => item.name === email);
+ if (!exists) {
+ this.ccList.push({
+ id: user.user_id || user.id || null,
+ name: email,
+ _uid: this.nextCcUid++,
+ });
+ }
+ this.ccInput = '';
+ },
+ // 删除已选 CC
+ removeCc(index) {
+ if (index < 0) return;
+ this.ccList.splice(index, 1);
+ },
+ // 根据路由 j_email_id 获取发件邮箱信息,用于展示发件人
+ getDate() {
+ const jEmailId = this.$route.query.j_email_id;
+ if (!jEmailId) {
+ this.userMes = {};
+ return;
+ }
+ this.$api
+ .post('api/email_client/getOneEmail', { j_email_id: jEmailId })
+ .then(res => {
+ if (res && res.code === 0 && res.data && res.data.email) {
+ const email = res.data.email;
+ this.userMes = {
+ realname: email.smtp_from_name || email.smtp_user || '',
+ email: email.smtp_user || '',
+ };
+ } else {
+ this.userMes = {};
+ }
+ })
+ .catch(() => {
+ this.userMes = {};
});
-
-
},
// 获取通讯录数据
getLibary() {
this.$api
- .post('api/User/getAllUser', this.queryLibry)
+ .post('api/Reviewer/researchUser', {keywords: this.queryLibry.username})
.then(res => {
if (res.code == 0) {
- this.mail_List = res.data.users;
- this.link_TotalLibry = res.data.count || 0;
+ this.mail_List = res.data.list;
+ this.link_TotalLibry = res.data.list.length || 0;
for (let i = 0; i < this.mail_List.length; i++) {
this.mail_List[i].select_mark = 0
for (let j = 0; j < this.queryMail.sendnamelist.length; j++) {
@@ -286,9 +515,60 @@
});
},
- // 发送邮件
+ // 发送邮件:api/email_client/sendOne,to_email 为多邮箱字符串拼接(逗号分隔),发送成功后关闭当前页并跳转收件箱
handleSend() {
- console.log(this.queryMail)
+ 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;
+ const params = {
+ journal_id: journalId,
+ to_email: toList.join(','),
+ subject: this.queryMail.sendtitle,
+ content: this.queryMail.content || '',
+ };
+ 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.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;
+ });
+ },
+ // 保存草稿(防抖:请求中禁用按钮)
+ handleSaveDraft() {
+ if (this.saveDraftLoading) return;
+ this.saveDraftLoading = true;
+ // TODO: 调用保存草稿接口,此处仅防抖占位
+ this.$nextTick(() => {
+ setTimeout(() => {
+ this.saveDraftLoading = false;
+ }, 300);
+ });
},
// 选择通讯录-弹出框
@@ -320,7 +600,8 @@
this.queryMail.sendname.push(e.email)
this.queryMail.sendnamelist.push({
id: null,
- name: e.email
+ name: e.email,
+ _uid: this.nextToUid++,
})
this.getLibary();
},
@@ -331,7 +612,8 @@
this.queryMail.sendname.push(this.LibrarySelection[i].email)
this.queryMail.sendnamelist.push({
id: null,
- name: this.LibrarySelection[i].email
+ name: this.LibrarySelection[i].email,
+ _uid: this.nextToUid++,
})
}
this.getLibary();
@@ -433,7 +715,16 @@
};
-
diff --git a/src/router/index.js b/src/router/index.js
index f7718dd..37fb46c 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -1026,11 +1026,20 @@ export default new Router({
title: 'Mailbox send'
}
},
+ {
+ path: '/mailboxConfig', //邮箱系统-邮箱配置管理
+ component: () => import('../components/page/mailboxConfig'),
+ meta: {
+ title: 'Mailbox config',
+ titleKey: 'sidebar.mailboxConfig'
+ }
+ },
{
path: '/mailboxCollect', //邮箱系统-收邮件列表
component: () => import('../components/page/mailboxCollect'),
meta: {
- title: 'Mailbox list'
+ title: 'Mailbox list',
+ titleKey: 'sidebar.mailboxCollect'
}
},
{