feat:【ele】【erp】finance/account 的迁移

This commit is contained in:
YunaiV
2025-11-16 09:13:09 +08:00
parent bebe2ea547
commit b3b7d2c78b
10 changed files with 718 additions and 59 deletions

View File

@@ -3,7 +3,7 @@ import type { PageParam, PageResult } from '@vben/request';
import { requestClient } from '#/api/request';
export namespace ErpAccountApi {
/** ERP 结算账户信息 */
/** 结算账户信息 */
export interface Account {
id?: number; // 结算账户编号
no: string; // 账户编码
@@ -13,17 +13,10 @@ export namespace ErpAccountApi {
defaultStatus: boolean; // 是否默认
name: string; // 账户名称
}
/** 结算账户分页查询参数 */
export interface AccountPageParam extends PageParam {
name?: string;
no?: string;
status?: number;
}
}
/** 查询结算账户分页 */
export function getAccountPage(params: ErpAccountApi.AccountPageParam) {
export function getAccountPage(params: PageParam) {
return requestClient.get<PageResult<ErpAccountApi.Account>>(
'/erp/account/page',
{ params },

View File

@@ -3,19 +3,6 @@ import type { PageParam, PageResult } from '@vben/request';
import { requestClient } from '#/api/request';
export namespace ErpFinancePaymentApi {
/** 付款单项 */
export interface FinancePaymentItem {
id?: number;
row_id?: number; // 前端使用的临时ID
bizId: number; // 业务ID
bizType: number; // 业务类型
bizNo: string; // 业务编号
totalPrice: number; // 应付金额
paidPrice: number; // 已付金额
paymentPrice: number; // 本次付款
remark?: string; // 备注
}
/** 付款单信息 */
export interface FinancePayment {
id?: number; // 付款单编号
@@ -39,24 +26,22 @@ export namespace ErpFinancePaymentApi {
bizNo?: string; // 业务单号
}
/** 付款单分页查询参数 */
export interface FinancePaymentPageParams extends PageParam {
no?: string;
paymentTime?: [string, string];
supplierId?: number;
creator?: string;
financeUserId?: number;
accountId?: number;
status?: number;
remark?: string;
bizNo?: string;
/** 付款单 */
export interface FinancePaymentItem {
id?: number;
row_id?: number; // 前端使用的临时 ID
bizId: number; // 业务ID
bizType: number; // 业务类型
bizNo: string; // 业务编号
totalPrice: number; // 应付金额
paidPrice: number; // 已付金额
paymentPrice: number; // 本次付款
remark?: string; // 备注
}
}
/** 查询付款单分页 */
export function getFinancePaymentPage(
params: ErpFinancePaymentApi.FinancePaymentPageParams,
) {
export function getFinancePaymentPage(params: PageParam) {
return requestClient.get<PageResult<ErpFinancePaymentApi.FinancePayment>>(
'/erp/finance-payment/page',
{
@@ -103,9 +88,7 @@ export function deleteFinancePayment(ids: number[]) {
}
/** 导出付款单 Excel */
export function exportFinancePayment(
params: ErpFinancePaymentApi.FinancePaymentPageParams,
) {
export function exportFinancePayment(params: any) {
return requestClient.download('/erp/finance-payment/export-excel', {
params,
});

View File

@@ -6,7 +6,7 @@ export namespace ErpFinanceReceiptApi {
/** 收款单项 */
export interface FinanceReceiptItem {
id?: number;
row_id?: number; // 前端使用的临时ID
row_id?: number; // 前端使用的临时 ID
bizId: number; // 业务ID
bizType: number; // 业务类型
bizNo: string; // 业务编号
@@ -38,25 +38,10 @@ export namespace ErpFinanceReceiptApi {
items?: FinanceReceiptItem[]; // 收款明细
bizNo?: string; // 业务单号
}
/** 收款单分页查询参数 */
export interface FinanceReceiptPageParams extends PageParam {
no?: string;
receiptTime?: [string, string];
customerId?: number;
creator?: string;
financeUserId?: number;
accountId?: number;
status?: number;
remark?: string;
bizNo?: string;
}
}
/** 查询收款单分页 */
export function getFinanceReceiptPage(
params: ErpFinanceReceiptApi.FinanceReceiptPageParams,
) {
export function getFinanceReceiptPage(params: PageParam) {
return requestClient.get<PageResult<ErpFinanceReceiptApi.FinanceReceipt>>(
'/erp/finance-receipt/page',
{
@@ -103,9 +88,7 @@ export function deleteFinanceReceipt(ids: number[]) {
}
/** 导出收款单 Excel */
export function exportFinanceReceipt(
params: ErpFinanceReceiptApi.FinanceReceiptPageParams,
) {
export function exportFinanceReceipt(params: any) {
return requestClient.download('/erp/finance-receipt/export-excel', {
params,
});

View File

@@ -0,0 +1,61 @@
import type { PageParam, PageResult } from '@vben/request';
import { requestClient } from '#/api/request';
export namespace ErpAccountApi {
/** 结算账户信息 */
export interface Account {
id?: number; // 结算账户编号
no: string; // 账户编码
remark: string; // 备注
status: number; // 开启状态
sort: number; // 排序
defaultStatus: boolean; // 是否默认
name: string; // 账户名称
}
}
/** 查询结算账户分页 */
export function getAccountPage(params: PageParam) {
return requestClient.get<PageResult<ErpAccountApi.Account>>(
'/erp/account/page',
{ params },
);
}
/** 查询结算账户精简列表 */
export function getAccountSimpleList() {
return requestClient.get<ErpAccountApi.Account[]>('/erp/account/simple-list');
}
/** 查询结算账户详情 */
export function getAccount(id: number) {
return requestClient.get<ErpAccountApi.Account>(`/erp/account/get?id=${id}`);
}
/** 新增结算账户 */
export function createAccount(data: ErpAccountApi.Account) {
return requestClient.post('/erp/account/create', data);
}
/** 修改结算账户 */
export function updateAccount(data: ErpAccountApi.Account) {
return requestClient.put('/erp/account/update', data);
}
/** 修改结算账户默认状态 */
export function updateAccountDefaultStatus(id: number, defaultStatus: boolean) {
return requestClient.put('/erp/account/update-default-status', null, {
params: { id, defaultStatus },
});
}
/** 删除结算账户 */
export function deleteAccount(id: number) {
return requestClient.delete(`/erp/account/delete?id=${id}`);
}
/** 导出结算账户 Excel */
export function exportAccount(params: any) {
return requestClient.download('/erp/account/export-excel', { params });
}

View File

@@ -0,0 +1,95 @@
import type { PageParam, PageResult } from '@vben/request';
import { requestClient } from '#/api/request';
export namespace ErpFinancePaymentApi {
/** 付款单信息 */
export interface FinancePayment {
id?: number; // 付款单编号
no: string; // 付款单号
supplierId?: number; // 供应商编号
supplierName?: string; // 供应商名称
paymentTime?: Date; // 付款时间
totalPrice: number; // 合计金额,单位:元
discountPrice: number; // 优惠金额
paymentPrice: number; // 实际付款金额
status: number; // 状态
remark: string; // 备注
fileUrl?: string; // 附件
accountId?: number; // 付款账户
accountName?: string; // 账户名称
financeUserId?: number; // 财务人员
financeUserName?: string; // 财务人员姓名
creator?: string; // 创建人
creatorName?: string; // 创建人姓名
items?: FinancePaymentItem[]; // 付款明细
bizNo?: string; // 业务单号
}
/** 付款单项 */
export interface FinancePaymentItem {
id?: number;
row_id?: number; // 前端使用的临时 ID
bizId: number; // 业务ID
bizType: number; // 业务类型
bizNo: string; // 业务编号
totalPrice: number; // 应付金额
paidPrice: number; // 已付金额
paymentPrice: number; // 本次付款
remark?: string; // 备注
}
}
/** 查询付款单分页 */
export function getFinancePaymentPage(params: PageParam) {
return requestClient.get<PageResult<ErpFinancePaymentApi.FinancePayment>>(
'/erp/finance-payment/page',
{
params,
},
);
}
/** 查询付款单详情 */
export function getFinancePayment(id: number) {
return requestClient.get<ErpFinancePaymentApi.FinancePayment>(
`/erp/finance-payment/get?id=${id}`,
);
}
/** 新增付款单 */
export function createFinancePayment(
data: ErpFinancePaymentApi.FinancePayment,
) {
return requestClient.post('/erp/finance-payment/create', data);
}
/** 修改付款单 */
export function updateFinancePayment(
data: ErpFinancePaymentApi.FinancePayment,
) {
return requestClient.put('/erp/finance-payment/update', data);
}
/** 更新付款单的状态 */
export function updateFinancePaymentStatus(id: number, status: number) {
return requestClient.put('/erp/finance-payment/update-status', null, {
params: { id, status },
});
}
/** 删除付款单 */
export function deleteFinancePayment(ids: number[]) {
return requestClient.delete('/erp/finance-payment/delete', {
params: {
ids: ids.join(','),
},
});
}
/** 导出付款单 Excel */
export function exportFinancePayment(params: any) {
return requestClient.download('/erp/finance-payment/export-excel', {
params,
});
}

View File

@@ -0,0 +1,95 @@
import type { PageParam, PageResult } from '@vben/request';
import { requestClient } from '#/api/request';
export namespace ErpFinanceReceiptApi {
/** 收款单项 */
export interface FinanceReceiptItem {
id?: number;
row_id?: number; // 前端使用的临时 ID
bizId: number; // 业务ID
bizType: number; // 业务类型
bizNo: string; // 业务编号
totalPrice: number; // 应收金额
receiptedPrice: number; // 已收金额
receiptPrice: number; // 本次收款
remark?: string; // 备注
}
/** 收款单信息 */
export interface FinanceReceipt {
id?: number; // 收款单编号
no: string; // 收款单号
customerId: number; // 客户编号
customerName?: string; // 客户名称
receiptTime: Date; // 收款时间
totalPrice: number; // 合计金额,单位:元
discountPrice: number; // 优惠金额
receiptPrice: number; // 实际收款金额
status: number; // 状态
remark: string; // 备注
fileUrl?: string; // 附件
accountId?: number; // 收款账户
accountName?: string; // 账户名称
financeUserId?: number; // 财务人员
financeUserName?: string; // 财务人员姓名
creator?: string; // 创建人
creatorName?: string; // 创建人姓名
items?: FinanceReceiptItem[]; // 收款明细
bizNo?: string; // 业务单号
}
}
/** 查询收款单分页 */
export function getFinanceReceiptPage(params: PageParam) {
return requestClient.get<PageResult<ErpFinanceReceiptApi.FinanceReceipt>>(
'/erp/finance-receipt/page',
{
params,
},
);
}
/** 查询收款单详情 */
export function getFinanceReceipt(id: number) {
return requestClient.get<ErpFinanceReceiptApi.FinanceReceipt>(
`/erp/finance-receipt/get?id=${id}`,
);
}
/** 新增收款单 */
export function createFinanceReceipt(
data: ErpFinanceReceiptApi.FinanceReceipt,
) {
return requestClient.post('/erp/finance-receipt/create', data);
}
/** 修改收款单 */
export function updateFinanceReceipt(
data: ErpFinanceReceiptApi.FinanceReceipt,
) {
return requestClient.put('/erp/finance-receipt/update', data);
}
/** 更新收款单的状态 */
export function updateFinanceReceiptStatus(id: number, status: number) {
return requestClient.put('/erp/finance-receipt/update-status', null, {
params: { id, status },
});
}
/** 删除收款单 */
export function deleteFinanceReceipt(ids: number[]) {
return requestClient.delete('/erp/finance-receipt/delete', {
params: {
ids: ids.join(','),
},
});
}
/** 导出收款单 Excel */
export function exportFinanceReceipt(params: any) {
return requestClient.download('/erp/finance-receipt/export-excel', {
params,
});
}

View File

@@ -0,0 +1,188 @@
import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { ErpAccountApi } from '#/api/erp/finance/account';
import { CommonStatusEnum, DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
import { z } from '#/adapter/form';
/** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] {
return [
{
component: 'Input',
fieldName: 'id',
dependencies: {
triggerFields: [''],
show: () => false,
},
},
{
component: 'Input',
fieldName: 'name',
label: '名称',
rules: 'required',
componentProps: {
placeholder: '请输入名称',
},
},
{
fieldName: 'status',
label: '状态',
component: 'RadioGroup',
componentProps: {
options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
},
rules: z.number().default(CommonStatusEnum.ENABLE),
},
{
fieldName: 'sort',
label: '排序',
component: 'InputNumber',
componentProps: {
placeholder: '请输入排序',
precision: 0,
controlsPosition: 'right',
class: '!w-full',
},
rules: 'required',
defaultValue: 0,
},
{
fieldName: 'defaultStatus',
label: '是否默认',
component: 'RadioGroup',
componentProps: {
options: [
{
label: '是',
value: true,
},
{
label: '否',
value: false,
},
],
},
rules: z.boolean().default(false).optional(),
},
{
fieldName: 'no',
label: '编码',
component: 'Input',
componentProps: {
placeholder: '请输入编码',
},
},
{
fieldName: 'remark',
label: '备注',
component: 'Textarea',
componentProps: {
placeholder: '请输入备注',
rows: 3,
},
},
];
}
/** 列表的搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] {
return [
{
fieldName: 'name',
label: '名称',
component: 'Input',
componentProps: {
placeholder: '请输入名称',
allowClear: true,
},
},
{
fieldName: 'no',
label: '编码',
component: 'Input',
componentProps: {
placeholder: '请输入编码',
allowClear: true,
},
},
{
fieldName: 'remark',
label: '备注',
component: 'Input',
componentProps: {
placeholder: '请输入备注',
allowClear: true,
},
},
];
}
/** 列表的字段 */
export function useGridColumns(
onDefaultStatusChange?: (
newStatus: boolean,
row: ErpAccountApi.Account,
) => PromiseLike<boolean | undefined>,
): VxeTableGridOptions['columns'] {
return [
{
field: 'name',
title: '名称',
minWidth: 150,
},
{
field: 'no',
title: '编码',
minWidth: 120,
},
{
field: 'remark',
title: '备注',
minWidth: 150,
showOverflow: 'tooltip',
},
{
field: 'sort',
title: '排序',
minWidth: 80,
},
{
field: 'status',
title: '状态',
minWidth: 100,
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.COMMON_STATUS },
},
},
{
field: 'defaultStatus',
title: '是否默认',
minWidth: 100,
cellRender: {
attrs: { beforeChange: onDefaultStatusChange },
name: 'CellSwitch',
props: {
activeValue: true,
inactiveValue: false,
},
},
},
{
field: 'createTime',
title: '创建时间',
minWidth: 180,
formatter: 'formatDateTime',
},
{
title: '操作',
width: 130,
fixed: 'right',
slots: { default: 'actions' },
},
];
}

View File

@@ -0,0 +1,174 @@
<script lang="ts" setup>
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { ErpAccountApi } from '#/api/erp/finance/account';
import { confirm, DocAlert, Page, useVbenModal } from '@vben/common-ui';
import { downloadFileFromBlobPart } from '@vben/utils';
import { ElLoading, ElMessage } from 'element-plus';
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
import {
deleteAccount,
exportAccount,
getAccountPage,
updateAccountDefaultStatus,
} from '#/api/erp/finance/account';
import { $t } from '#/locales';
import { useGridColumns, useGridFormSchema } from './data';
import Form from './modules/form.vue';
const [FormModal, formModalApi] = useVbenModal({
connectedComponent: Form,
destroyOnClose: true,
});
/** 刷新表格 */
function handleRefresh() {
gridApi.query();
}
/** 导出表格 */
async function handleExport() {
const data = await exportAccount(await gridApi.formApi.getValues());
downloadFileFromBlobPart({ fileName: '结算账户信息.xls', source: data });
}
/** 创建结算账户 */
function handleCreate() {
formModalApi.setData(null).open();
}
/** 编辑结算账户 */
function handleEdit(row: ErpAccountApi.Account) {
formModalApi.setData(row).open();
}
/** 删除结算账户 */
async function handleDelete(row: ErpAccountApi.Account) {
const loadingInstance = ElLoading.service({
text: $t('ui.actionMessage.deleting', [row.name]),
});
try {
await deleteAccount(row.id as number);
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.name]));
handleRefresh();
} finally {
loadingInstance.close();
}
}
/** 修改默认状态 */
async function handleDefaultStatusChange(
newStatus: boolean,
row: ErpAccountApi.Account,
): Promise<boolean | undefined> {
return new Promise((resolve, reject) => {
const text = newStatus ? '设置' : '取消';
confirm({
content: `确认要${text}"${row.name}"默认吗?`,
})
.then(async () => {
// 更新默认状态
await updateAccountDefaultStatus(row.id!, newStatus);
// 提示并返回成功
ElMessage.success(`${text}默认成功`);
resolve(true);
})
.catch(() => {
reject(new Error('取消操作'));
});
});
}
const [Grid, gridApi] = useVbenVxeGrid({
formOptions: {
schema: useGridFormSchema(),
},
gridOptions: {
columns: useGridColumns(handleDefaultStatusChange),
height: 'auto',
keepSource: true,
proxyConfig: {
ajax: {
query: async ({ page }, formValues) => {
return await getAccountPage({
pageNo: page.currentPage,
pageSize: page.pageSize,
...formValues,
});
},
},
},
rowConfig: {
keyField: 'id',
isHover: true,
},
toolbarConfig: {
refresh: true,
search: true,
},
} as VxeTableGridOptions<ErpAccountApi.Account>,
});
</script>
<template>
<Page auto-content-height>
<template #doc>
<DocAlert
title="【财务】采购付款、销售收款"
url="https://doc.iocoder.cn/sale/finance-payment-receipt/"
/>
</template>
<FormModal @success="handleRefresh" />
<Grid table-title="结算账户列表">
<template #toolbar-tools>
<TableAction
:actions="[
{
label: $t('ui.actionTitle.create', ['结算账户']),
type: 'primary',
icon: ACTION_ICON.ADD,
auth: ['erp:account:create'],
onClick: handleCreate,
},
{
label: $t('ui.actionTitle.export'),
type: 'primary',
icon: ACTION_ICON.DOWNLOAD,
auth: ['erp:account:export'],
onClick: handleExport,
},
]"
/>
</template>
<template #actions="{ row }">
<TableAction
:actions="[
{
label: $t('common.edit'),
type: 'primary',
link: true,
icon: ACTION_ICON.EDIT,
auth: ['erp:account:update'],
onClick: handleEdit.bind(null, row),
},
{
label: $t('common.delete'),
type: 'danger',
link: true,
icon: ACTION_ICON.DELETE,
auth: ['erp:account:delete'],
popConfirm: {
title: $t('ui.actionMessage.deleteConfirm', [row.name]),
confirm: handleDelete.bind(null, row),
},
},
]"
/>
</template>
</Grid>
</Page>
</template>

View File

@@ -0,0 +1,86 @@
<script lang="ts" setup>
import type { ErpAccountApi } from '#/api/erp/finance/account';
import { computed, ref } from 'vue';
import { useVbenModal } from '@vben/common-ui';
import { ElMessage } from 'element-plus';
import { useVbenForm } from '#/adapter/form';
import {
createAccount,
getAccount,
updateAccount,
} from '#/api/erp/finance/account';
import { $t } from '#/locales';
import { useFormSchema } from '../data';
const emit = defineEmits(['success']);
const formData = ref<ErpAccountApi.Account>();
const getTitle = computed(() => {
return formData.value?.id
? $t('ui.actionTitle.edit', ['结算账户'])
: $t('ui.actionTitle.create', ['结算账户']);
});
const [Form, formApi] = useVbenForm({
commonConfig: {
componentProps: {
class: 'w-full',
},
formItemClass: 'col-span-2',
labelWidth: 80,
},
layout: 'horizontal',
schema: useFormSchema(),
showDefaultActions: false,
});
const [Modal, modalApi] = useVbenModal({
async onConfirm() {
const { valid } = await formApi.validate();
if (!valid) {
return;
}
modalApi.lock();
// 提交表单
const data = (await formApi.getValues()) as ErpAccountApi.Account;
try {
await (formData.value?.id ? updateAccount(data) : createAccount(data));
// 关闭并提示
await modalApi.close();
emit('success');
ElMessage.success($t('ui.actionMessage.operationSuccess'));
} finally {
modalApi.unlock();
}
},
async onOpenChange(isOpen: boolean) {
if (!isOpen) {
formData.value = undefined;
return;
}
// 加载数据
const data = modalApi.getData<ErpAccountApi.Account>();
if (!data || !data.id) {
return;
}
modalApi.lock();
try {
formData.value = await getAccount(data.id);
// 设置到 values
await formApi.setValues(formData.value);
} finally {
modalApi.unlock();
}
},
});
</script>
<template>
<Modal class="w-1/3" :title="getTitle">
<Form class="mx-4" />
</Modal>
</template>

View File

@@ -3,6 +3,7 @@
*
* 枚举类
*/
// TODO @AI后面拆分成 AI、ERP、OA 这种枚举
/**
* AI 平台的枚举