diff --git a/src/actions/EmailActions.js b/src/actions/EmailActions.js index a2cbfaf..448a911 100644 --- a/src/actions/EmailActions.js +++ b/src/actions/EmailActions.js @@ -1,4 +1,4 @@ -import { fetchJSON, postForm } from '@/utils/request'; +import { fetchJSON, postForm, postJSON } from '@/utils/request'; import { API_HOST, EMAIL_HOST } from '@/config'; import { isEmpty } from '@/utils/commons'; @@ -136,3 +136,72 @@ export const fetchEmailBindOrderAction = async (params) => { const { errcode, result } = await fetchJSON(`${API_HOST}/mailinfo_bindorder`, params) return errcode === 0 ? true : false; } + +/** + * 顾问的邮箱目录 + * @param {object} { opi_sn } + */ +export const getEmailDirAction = async (params = { opi_sn: '' }) => { + const { errcode, result } = await fetchJSON(`${EMAIL_HOST}/email/dir`, params); + return errcode === 0 ? [] : result; +} ; + +/** + * 获取邮件列表 + * @usage 邮件目录下的邮件列表 + * @usage 订单的邮件列表 + * @usage 高级搜索 + */ +export const queryEmailListAction = async (params = { opi_sn: '', pagesize: 10, last_id: '', query: {}, order: {} }) => { + const { errcode, result } = await postJSON(`${EMAIL_HOST}/email/list`, params) + return errcode === 0 ? [] : result +} + +/** + * 获取收件箱下的订单目录 + */ +export const getEmailOrderListAction = async (params = { opi_sn: '', ordertype: 227001 }) => { + const { errcode, result } = await fetchJSON(`${EMAIL_HOST}/email/order`, params) + return errcode === 0 ? [] : result +} + +/** + * 更新邮件属性 + */ +export const updateEmailAction = async (params = { mai_sn_list: [], set: {} }) => { + const { errcode, result } = await postJSON(`${EMAIL_HOST}/email/update`, params) + return errcode === 0 ? {} : result +} + +/** + * 获取邮件模板 + */ +export const getEmailTemplateAction = async (template_name, params = { coli_sn: 0, lgc: 1 }) => { + const { errcode, result } = await fetchJSON(`${EMAIL_HOST}/email/template/${template_name}`, params) + return errcode === 0 ? {} : result +} + +/** + * 保存邮件草稿 + */ +export const saveEmailDraftAction = async (body) => { + const { attaList=[], atta, content, ...bodyData } = body; + bodyData.ordertype = 227001; + const formData = new FormData(); + Object.keys(bodyData).forEach(function (key) { + formData.append(key, bodyData[key]); + }); + attaList.forEach(function (item) { + formData.append('attachment', item); + }); + const { result } = await postForm(`${EMAIL_HOST}/email-draft/save`, formData); + return result; +}; + +/** + * 删除邮件草稿 + */ +export const deleteEmailDraftAction = async (id) => { + const { errcode, result } = await postJSON(`${EMAIL_HOST}/email-draft/delete`, { id }) + return errcode === 0 ? {} : result +};