import { request } from '@eciol/request'; import { replaceVariables } from '@eciol/shared'; import { useUserStoreWithOut } from '@/store/modules/user'; import type { SendInvoiceService } from './typing'; enum Api { GetSendTaxInvoiceList = '/api/InvoiceVAT/QueryPage', GetSendTaxInvoiceDetail = '/api/InvoicePublic/{orgId}/{id}', ReturnTaxInvoice = '/api/InvoiceVAT/ReturnPrevious', GetSendTaxListById = '/api/InvoiceVAT/GetListByid', GetSendTaxListByClient = '/api/InvoiceVAT/GetListByClient', SaveTaxExpress = '/api/InvoiceVAT/SaveExpress', GetSendOnlineInvoiceList = '/api/InvoiceOnlineSend/QueryPage', GetSendOnlineInvoiceDetail = '/api/InvoicePublic/{orgId}/{id}', ReturnOnlineInvoice = '/api/InvoiceOnlineSend/ReturnPrevious', GetSendOnlineListById = '/api/InvoiceOnlineSend/GetListByid', GetSendOnlineListByClient = '/api/InvoiceOnlineSend/GetListByClient', SaveOnlineExpress = '/api/InvoiceOnlineSend/SaveOnlineExpress', GetSendPDFInvoiceList = '/api/InvoicePDFSend/QueryPage', GetSendPDFInvoiceDetail = '/api/InvoicePublic/{orgId}/{Id}', GetSendPDFInvoicePreview = '/api/InvoicePDFSend/{orgId}/preview', GetSendPDFInvoicePreviewEmail = '/api/InvoicePDFSend/{orgId}/preview-email', SendPDFInvoiceSendEmail = '/api/InvoicePDFSend/{orgId}/send-email', ReturnPDFInvoice = '/api/InvoicePDFSend/ReturnPrevious', } /** * 税务发票列表 * @param data */ function getSendTaxInvoiceList(data: SendInvoiceService.GetSendInvoiceListParams) { const { getCompanyId } = useUserStoreWithOut(); return request.post( { url: Api.GetSendTaxInvoiceList, data: { ...data, orgId: getCompanyId }, }, { showLoading: true, }, ); } /** * 获取税务发票详情 * @param id */ function getSendTaxInvoiceDetail(id: number) { const { getCompanyId } = useUserStoreWithOut(); return request.get( { url: replaceVariables(Api.GetSendTaxInvoiceDetail, { id, orgId: getCompanyId }), }, { showLoading: true, }, ); } /** * 税务发票返回 * @param ids */ function returnTaxInvoice(ids: number[]) { const empID = useUserStoreWithOut().getUserInfo.id; return request.post( { url: Api.ReturnTaxInvoice, data: { ids, empID }, }, { showLoading: true, loadingTip: 'EMPTY', successMessage: '返回成功', successMessageMode: 'message', }, ); } /** * 税务发票返根据一级列表选择ID返回二级列表数据 * @param ids */ function getSendTaxListById(ids: number[]) { const { getCompanyId } = useUserStoreWithOut(); return request.post( { url: Api.GetSendTaxListById, data: { ids, orgId: getCompanyId }, }, { showLoading: true, }, ); } /** * 税务发票返根据二级列表请求参数查询 * @param data */ function getSendTaxListByClient(data: SendInvoiceService.GetSendTaxListClientParams) { const { getCompanyId } = useUserStoreWithOut(); return request.post( { url: Api.GetSendTaxListByClient, data: { orgId: getCompanyId, ...data }, }, { showLoading: true, }, ); } /** * 保存税务发票发送编辑信息 * @param data */ function sendTaxExpress(data: SendInvoiceService.SendTaxExpressParams) { const { getCompanyId } = useUserStoreWithOut(); return request.post( { url: Api.SaveTaxExpress, data: { orgId: getCompanyId, ...data }, }, { showLoading: true, loadingTip: 'EMPTY', successMessage: '发送成功', successMessageMode: 'message', }, ); } /** * 在线发票列表 * @param data */ function getSendOnlineInvoiceList(data: SendInvoiceService.GetSendInvoiceListParams) { const { getCompanyId } = useUserStoreWithOut(); return request.post( { url: Api.GetSendOnlineInvoiceList, data: { ...data, orgId: getCompanyId }, }, { showLoading: true, }, ); } /** * 获取在线发票详情 * @param id */ function getSendOnlineInvoiceDetail(id: number) { const { getCompanyId } = useUserStoreWithOut(); return request.get( { url: replaceVariables(Api.GetSendOnlineInvoiceDetail, { id, orgId: getCompanyId }), }, { showLoading: true, }, ); } /** * 在线发票返回 * @param ids */ function returnOnlineInvoice(ids: number[]) { const empID = useUserStoreWithOut().getUserInfo.id; return request.post( { url: Api.ReturnOnlineInvoice, data: { ids, empID }, }, { showLoading: true, loadingTip: 'EMPTY', successMessage: '返回成功', successMessageMode: 'message', }, ); } /** * 在线发票返根据一级列表选择ID返回二级列表数据 * @param ids */ function getSendOnlineListById(ids: number[]) { const { getCompanyId } = useUserStoreWithOut(); return request.post( { url: Api.GetSendOnlineListById, data: { ids, orgId: getCompanyId }, }, { showLoading: true, }, ); } /** * 在线发票返根据二级列表请求参数查询 * @param data */ function getSendOnlineListByClient(data: SendInvoiceService.GetSendOnlineListClientParams) { const { getCompanyId } = useUserStoreWithOut(); return request.post( { url: Api.GetSendOnlineListByClient, data: { orgId: getCompanyId, ...data }, }, { showLoading: true, }, ); } /** * 保存在线发票发送编辑信息 * @param data */ function sendOnlineExpress(data: SendInvoiceService.SendOnlineExpressParams) { const { getCompanyId } = useUserStoreWithOut(); return request.post( { url: Api.SaveOnlineExpress, data: { orgId: getCompanyId, ...data }, }, { showLoading: true, loadingTip: 'EMPTY', successMessage: '发送成功', successMessageMode: 'message', }, ); } /** * PDF发票列表 * @param data */ function getSendPDFInvoiceList(data: SendInvoiceService.GetSendInvoiceListParams) { const { getCompanyId } = useUserStoreWithOut(); return request.post( { url: Api.GetSendPDFInvoiceList, data: { ...data, orgId: getCompanyId }, }, { showLoading: true, }, ); } /** * 获取税务发票详情 * @param Id */ function getSendPDFInvoiceDetail(Id: number) { const { getCompanyId } = useUserStoreWithOut(); return request.get( { url: replaceVariables(Api.GetSendPDFInvoiceDetail, { Id, orgId: getCompanyId }), }, { showLoading: true, }, ); } /** * 预览PDF发送发票详情 * @param clientId * @param ids * @param no */ function getSendPDFInvoicePreview(clientId: number, ids: string, no: string, currencyId: string) { const { getCompanyId } = useUserStoreWithOut(); return request.get( { url: replaceVariables(Api.GetSendPDFInvoicePreview, { orgId: getCompanyId }), params: { clientId, ids, no, currencyId }, }, { showLoading: true, }, ); } /** * 获取发送PDF预览Email * @param ids */ function getSendPDFInvoicePreviewEmail(ids: string) { const { getCompanyId } = useUserStoreWithOut(); return request.get( { url: replaceVariables(Api.GetSendPDFInvoicePreviewEmail, { orgId: getCompanyId }), params: { ids }, }, { showLoading: true, }, ); } /** * 发送Email * @param data * @constructor */ function sendPDFInvoiceSendEmail(data: SendInvoiceService.GetSendPDFInvoicePreviewEmail) { const { getCompanyId } = useUserStoreWithOut(); return request.post( { url: replaceVariables(Api.SendPDFInvoiceSendEmail, { orgId: getCompanyId }), data, }, { showLoading: true, loadingTip: 'EMPTY', successMessage: '发送成功', successMessageMode: 'message', }, ); } /** * PDF发票返回 * @param ids */ function returnPDFInvoice(ids: number[]) { const empID = useUserStoreWithOut().getUserInfo.id; return request.post( { url: Api.ReturnPDFInvoice, data: { ids, empID }, }, { showLoading: true, loadingTip: 'EMPTY', successMessage: '返回成功', successMessageMode: 'message', }, ); } export { getSendOnlineInvoiceDetail, getSendOnlineInvoiceList, getSendOnlineListByClient, getSendOnlineListById, getSendPDFInvoiceDetail, getSendPDFInvoiceList, getSendPDFInvoicePreview, getSendPDFInvoicePreviewEmail, getSendTaxInvoiceDetail, getSendTaxInvoiceList, getSendTaxListByClient, getSendTaxListById, returnOnlineInvoice, returnPDFInvoice, returnTaxInvoice, sendOnlineExpress, sendPDFInvoiceSendEmail, sendTaxExpress, }; export type { SendInvoiceService } from './typing';