|
|
|
@ -1,5 +1,5 @@
|
|
|
|
|
import { fetchJSON, postForm, postJSON } from '@/utils/request';
|
|
|
|
|
import { API_HOST, DATE_FORMAT, DATEEND_FORMAT, DATETIME_FORMAT, EMAIL_HOST } from '@/config';
|
|
|
|
|
import { API_HOST, API_HOST_V3, DATE_FORMAT, DATEEND_FORMAT, DATETIME_FORMAT, EMAIL_HOST } from '@/config';
|
|
|
|
|
import { buildTree, groupBy, isEmpty, objectMapper, omitEmpty, readIndexDB, uniqWith, writeIndexDB } from '@/utils/commons';
|
|
|
|
|
import dayjs from 'dayjs';
|
|
|
|
|
|
|
|
|
@ -167,7 +167,7 @@ const todoTypes = {
|
|
|
|
|
*/
|
|
|
|
|
export const getEmailDirAction = async (params = { opi_sn: '' }) => {
|
|
|
|
|
const defaultParams = { opi_sn: 0, year: dayjs().year(), by_start_date: -1, by_success: -1, important: -1, if_want_book: -1, if_thinking: -1 }
|
|
|
|
|
const { errcode, result } = await fetchJSON(`${API_HOST}/email_dir`, { ...defaultParams, ...params })
|
|
|
|
|
const { errcode, result } = await fetchJSON(`${API_HOST_V3}/email_dir`, { ...defaultParams, ...params })
|
|
|
|
|
const mailboxSort = result //.sort(sortBy('MDR_Order'));
|
|
|
|
|
let tree = buildTree(mailboxSort, { key: 'VKey', parent: 'VParent', name: 'VName', iconIndex: 'ImageIndex', rootKeys: [1], ignoreKeys: [-227001, -227002] })
|
|
|
|
|
tree = tree.filter((ele) => ele.key !== 1)
|
|
|
|
@ -309,7 +309,7 @@ export const queryEmailListAction = async ({ opi_sn = '', pagesize = 10, last_id
|
|
|
|
|
}
|
|
|
|
|
_params.mai_senddate1 = dayjs(_params.mai_senddate1).format(DATE_FORMAT)
|
|
|
|
|
const cacheKey = isEmpty(_params.coli_sn) ? `dir-${node.vkey}` : `order-${node.vkey}`;
|
|
|
|
|
const { errcode, result } = await fetchJSON(`${API_HOST}/mail_list`, _params)
|
|
|
|
|
const { errcode, result } = await fetchJSON(`${API_HOST_V3}/mail_list`, _params)
|
|
|
|
|
const ret = errcode === 0 ? result : []
|
|
|
|
|
if (!isEmpty(ret)) {
|
|
|
|
|
const listids = [...new Set(ret.map(ele => ele.MAI_SN))];
|
|
|
|
@ -322,8 +322,8 @@ export const queryEmailListAction = async ({ opi_sn = '', pagesize = 10, last_id
|
|
|
|
|
/**
|
|
|
|
|
* 更新邮件属性
|
|
|
|
|
*/
|
|
|
|
|
export const updateEmailAction = async (params = { mai_sn_list: [], set: {} }) => {
|
|
|
|
|
const { errcode, result } = await postJSON(`${EMAIL_HOST}/email/update`, params)
|
|
|
|
|
export const updateEmailAction = async (params = { opi_sn: '', mai_sn_list: [], set: {} }) => {
|
|
|
|
|
const { errcode, result } = await postJSON(`${API_HOST_V3}/mail_update`, params)
|
|
|
|
|
return errcode === 0 ? {} : result
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -337,7 +337,7 @@ export const updateEmailAction = async (params = { mai_sn_list: [], set: {} }) =
|
|
|
|
|
* @param {number} [params.remind_index] - Index of the reminder.
|
|
|
|
|
*/
|
|
|
|
|
export const getEmailTemplateAction = async (params = { coli_sn: 0, lgc: 1, opi_sn: 0, remind_type: '', remind_index: 0 }) => {
|
|
|
|
|
const { errcode, result } = await fetchJSON(`${API_HOST}/reminder_letter`, params)
|
|
|
|
|
const { errcode, result } = await fetchJSON(`${API_HOST_V3}/reminder_letter`, params)
|
|
|
|
|
const { html, bodyContent, bodyText } = parseHTMLString(result?.MailContent, true) ;
|
|
|
|
|
return errcode === 0 ? {...result, bodyContent }: {}
|
|
|
|
|
}
|
|
|
|
@ -348,7 +348,7 @@ export const getEmailTemplateAction = async (params = { coli_sn: 0, lgc: 1, opi_
|
|
|
|
|
* @param {boolean} [isDraft=false] - Whether the email is a draft.
|
|
|
|
|
*/
|
|
|
|
|
export const saveEmailDraftOrSendAction = async (body, isDraft = false) => {
|
|
|
|
|
const url = isDraft !== false ? `${API_HOST}/email_draft_save` : `${EMAIL_HOST}/sendmail`;
|
|
|
|
|
const url = isDraft !== false ? `${API_HOST_V3}/email_draft_save` : `${EMAIL_HOST}/sendmail`;
|
|
|
|
|
const { attaList=[], atta, content, ...bodyData } = body;
|
|
|
|
|
bodyData.ordertype = 227001;
|
|
|
|
|
const formData = new FormData();
|
|
|
|
@ -367,6 +367,6 @@ export const saveEmailDraftOrSendAction = async (body, isDraft = false) => {
|
|
|
|
|
* 删除邮件附件
|
|
|
|
|
*/
|
|
|
|
|
export const deleteEmailAttachmentAction = async (ati_sn_list) => {
|
|
|
|
|
const { errcode, result } = await postJSON(`${API_HOST}/mail_attachment_delete`, { ati_sn_list })
|
|
|
|
|
const { errcode, result } = await postJSON(`${API_HOST_V3}/mail_attachment_delete`, { ati_sn_list })
|
|
|
|
|
return errcode === 0 ? result : {}
|
|
|
|
|
};
|
|
|
|
|