import { request } from '@eciol/request'; import { replaceVariables } from '@eciol/shared'; import { useUserStoreWithOut } from '@/store/modules/user'; import type { ReceiptService } from './typing'; enum Api { GetReceiptList = '/api/ReceiveBill/QueryPage', GetReceiptDetail = '/api/ReceiveBill/{orgId}/{id}/Detail', GetAccountNumberList = '/api/ReceiveBill/{orgId}/{clientId}/AccountList', GetClientOrganizationList = '/api/ReceiveBill/QueryClientOrganization', CreateReceiptBill = '/api/ReceiveBill/{orgId}/Create', EditReceiptBill = '/api/ReceiveBill/{orgId}/{billId}/Edit', GetEditModel = '/api/ReceiveBill/{orgId}/{billId}/GetModel', CancelReceiptBill = '/api/ReceiveBill/{orgId}/{billId}/Cancel', SubmitReceiptBill = '/api/ReceiveBill/{orgId}/{billId}/{procInstId}/Submit', } /** * 获取收款单列表 */ function getReceiptList(data: ReceiptService.GetReceiptListParams) { const { getCompanyId } = useUserStoreWithOut(); return request.post( { url: Api.GetReceiptList, data: { ...data, orgId: getCompanyId }, }, { showLoading: true, }, ); } /** * 获取收款单详情 */ function getReceiptDetail(id: number) { const { getCompanyId } = useUserStoreWithOut(); return request.get( { url: replaceVariables(Api.GetReceiptDetail, { id, orgId: getCompanyId }), }, { showLoading: true, }, ); } /** * 查询收款账号列表 */ function getAccountNumberList(clientId: number) { const { getCompanyId } = useUserStoreWithOut(); return request.get({ url: replaceVariables(Api.GetAccountNumberList, { orgId: getCompanyId, clientId }), }); } /** * 获取收款单详情 */ async function getClientOrganizationList(contactUnitName: string) { return await request.get({ url: Api.GetClientOrganizationList, params: { contactUnitName }, }); } /** * 新建 */ function createReceiveBill(data: ReceiptService.CreateOrEditReceiveBillParams) { const { getCompanyId } = useUserStoreWithOut(); return request.post( { url: replaceVariables(Api.CreateReceiptBill, { orgId: getCompanyId }), data, }, { showLoading: true, loadingTip: 'EMPTY', successMessage: '新建成功', successMessageMode: 'message', }, ); } /** * 修改获取数据回显 */ function getEditModel(billId) { const { getCompanyId } = useUserStoreWithOut(); return request.get( { url: replaceVariables(Api.GetEditModel, { billId, orgId: getCompanyId }), }, { showLoading: true, }, ); } /** * 修改 */ function editReceiveBill(billId, data: ReceiptService.CreateOrEditReceiveBillParams) { const { getCompanyId } = useUserStoreWithOut(); return request.post( { url: replaceVariables(Api.EditReceiptBill, { billId, orgId: getCompanyId }), data, }, { showLoading: true, loadingTip: 'EMPTY', successMessage: '修改成功', successMessageMode: 'message', }, ); } /** * 作废 */ function cancelReceiveBill(billId: number) { const { getCompanyId } = useUserStoreWithOut(); return request.post( { url: replaceVariables(Api.CancelReceiptBill, { billId, orgId: getCompanyId }), }, { showLoading: true, loadingTip: 'EMPTY', successMessage: '作废成功', successMessageMode: 'message', }, ); } /** * 提交审核 */ function submitReceiveBill(billId: number, procInstId: string) { const { getCompanyId } = useUserStoreWithOut(); return request.put( { url: replaceVariables(Api.SubmitReceiptBill, { billId, orgId: getCompanyId, procInstId }), }, { showLoading: true, loadingTip: 'EMPTY', successMessage: '提交审核成功', successMessageMode: 'message', }, ); } export { cancelReceiveBill, createReceiveBill, editReceiveBill, getAccountNumberList, getClientOrganizationList, getEditModel, getReceiptDetail, getReceiptList, submitReceiveBill, }; export type { ReceiptService } from './typing';