feat:【ele】【erp】finance/receipt 的迁移
This commit is contained in:
@@ -3,7 +3,7 @@ import type { PageParam, PageResult } from '@vben/request';
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace ErpCustomerApi {
|
||||
/** ERP 客户信息 */
|
||||
/** 客户信息 */
|
||||
export interface Customer {
|
||||
id?: number; // 客户编号
|
||||
name: string; // 客户名称
|
||||
@@ -21,17 +21,10 @@ export namespace ErpCustomerApi {
|
||||
bankAccount: string; // 开户账号
|
||||
bankAddress: string; // 开户地址
|
||||
}
|
||||
|
||||
/** 客户分页查询参数 */
|
||||
export interface CustomerPageParam extends PageParam {
|
||||
name?: string;
|
||||
mobile?: string;
|
||||
status?: number;
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询客户分页 */
|
||||
export function getCustomerPage(params: ErpCustomerApi.CustomerPageParam) {
|
||||
export function getCustomerPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<ErpCustomerApi.Customer>>(
|
||||
'/erp/customer/page',
|
||||
{ params },
|
||||
|
||||
@@ -3,7 +3,7 @@ import type { PageParam, PageResult } from '@vben/request';
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace ErpSaleOrderApi {
|
||||
/** ERP 销售订单信息 */
|
||||
/** 销售订单信息 */
|
||||
export interface SaleOrder {
|
||||
id?: number; // 订单工单编号
|
||||
no: string; // 销售订单号
|
||||
@@ -25,6 +25,7 @@ export namespace ErpSaleOrderApi {
|
||||
items?: SaleOrderItem[]; // 销售订单产品明细列表
|
||||
}
|
||||
|
||||
/** 销售订单项 */
|
||||
export interface SaleOrderItem {
|
||||
id?: number; // 订单项编号
|
||||
orderId?: number; // 采购订单编号
|
||||
@@ -43,17 +44,10 @@ export namespace ErpSaleOrderApi {
|
||||
remark?: string; // 备注
|
||||
stockCount?: number; // 库存数量(显示字段)
|
||||
}
|
||||
|
||||
/** 销售订单分页查询参数 */
|
||||
export interface SaleOrderPageParam extends PageParam {
|
||||
no?: string;
|
||||
customerId?: number;
|
||||
status?: number;
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询销售订单分页 */
|
||||
export function getSaleOrderPage(params: ErpSaleOrderApi.SaleOrderPageParam) {
|
||||
export function getSaleOrderPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<ErpSaleOrderApi.SaleOrder>>(
|
||||
'/erp/sale-order/page',
|
||||
{ params },
|
||||
|
||||
@@ -24,6 +24,7 @@ export namespace ErpSaleOutApi {
|
||||
items?: SaleOutItem[];
|
||||
}
|
||||
|
||||
/** 销售出库项 */
|
||||
export interface SaleOutItem {
|
||||
count?: number;
|
||||
id?: number;
|
||||
@@ -43,17 +44,10 @@ export namespace ErpSaleOutApi {
|
||||
warehouseId?: number;
|
||||
outCount?: number;
|
||||
}
|
||||
|
||||
/** 销售出库分页查询参数 */
|
||||
export interface SaleOutPageParams extends PageParam {
|
||||
no?: string;
|
||||
customerId?: number;
|
||||
status?: number;
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询销售出库分页 */
|
||||
export function getSaleOutPage(params: ErpSaleOutApi.SaleOutPageParams) {
|
||||
export function getSaleOutPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<ErpSaleOutApi.SaleOut>>(
|
||||
'/erp/sale-out/page',
|
||||
{
|
||||
@@ -94,7 +88,7 @@ export function deleteSaleOut(ids: number[]) {
|
||||
}
|
||||
|
||||
/** 导出销售出库 Excel */
|
||||
export function exportSaleOut(params: ErpSaleOutApi.SaleOutPageParams) {
|
||||
export function exportSaleOut(params: any) {
|
||||
return requestClient.download('/erp/sale-out/export-excel', {
|
||||
params,
|
||||
});
|
||||
|
||||
@@ -23,6 +23,7 @@ export namespace ErpSaleReturnApi {
|
||||
items?: SaleReturnItem[];
|
||||
}
|
||||
|
||||
/** 销售退货项 */
|
||||
export interface SaleReturnItem {
|
||||
count?: number;
|
||||
id?: number;
|
||||
@@ -42,21 +43,10 @@ export namespace ErpSaleReturnApi {
|
||||
warehouseId?: number;
|
||||
returnCount?: number;
|
||||
}
|
||||
|
||||
/** 销售退货分页查询参数 */
|
||||
export interface SaleReturnPageParams extends PageParam {
|
||||
no?: string;
|
||||
customerId?: number;
|
||||
status?: number;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询销售退货分页
|
||||
*/
|
||||
export function getSaleReturnPage(
|
||||
params: ErpSaleReturnApi.SaleReturnPageParams,
|
||||
) {
|
||||
/** 查询销售退货分页 */
|
||||
export function getSaleReturnPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<ErpSaleReturnApi.SaleReturn>>(
|
||||
'/erp/sale-return/page',
|
||||
{
|
||||
@@ -65,41 +55,31 @@ export function getSaleReturnPage(
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询销售退货详情
|
||||
*/
|
||||
/** 查询销售退货详情 */
|
||||
export function getSaleReturn(id: number) {
|
||||
return requestClient.get<ErpSaleReturnApi.SaleReturn>(
|
||||
`/erp/sale-return/get?id=${id}`,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增销售退货
|
||||
*/
|
||||
/** 新增销售退货 */
|
||||
export function createSaleReturn(data: ErpSaleReturnApi.SaleReturn) {
|
||||
return requestClient.post('/erp/sale-return/create', data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改销售退货
|
||||
*/
|
||||
/** 修改销售退货 */
|
||||
export function updateSaleReturn(data: ErpSaleReturnApi.SaleReturn) {
|
||||
return requestClient.put('/erp/sale-return/update', data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新销售退货的状态
|
||||
*/
|
||||
/** 更新销售退货的状态 */
|
||||
export function updateSaleReturnStatus(id: number, status: number) {
|
||||
return requestClient.put('/erp/sale-return/update-status', null, {
|
||||
params: { id, status },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除销售退货
|
||||
*/
|
||||
/** 删除销售退货 */
|
||||
export function deleteSaleReturn(ids: number[]) {
|
||||
return requestClient.delete('/erp/sale-return/delete', {
|
||||
params: {
|
||||
@@ -108,12 +88,8 @@ export function deleteSaleReturn(ids: number[]) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出销售退货 Excel
|
||||
*/
|
||||
export function exportSaleReturn(
|
||||
params: ErpSaleReturnApi.SaleReturnPageParams,
|
||||
) {
|
||||
/** 导出销售退货 Excel */
|
||||
export function exportSaleReturn(params: any) {
|
||||
return requestClient.download('/erp/sale-return/export-excel', {
|
||||
params,
|
||||
});
|
||||
|
||||
@@ -385,7 +385,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 220,
|
||||
width: 260,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
|
||||
@@ -196,6 +196,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
{
|
||||
label: row.status === 10 ? '审批' : '反审批',
|
||||
type: 'link',
|
||||
icon: ACTION_ICON.AUDIT,
|
||||
auth: ['erp:finance-receipt:update-status'],
|
||||
popConfirm: {
|
||||
title: `确认${row.status === 10 ? '审批' : '反审批'}${row.no}吗?`,
|
||||
@@ -210,7 +211,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
label: $t('common.delete'),
|
||||
type: 'link',
|
||||
danger: true,
|
||||
color: 'error',
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['erp:finance-receipt:delete'],
|
||||
popConfirm: {
|
||||
title: $t('ui.actionMessage.deleteConfirm', [row.no]),
|
||||
|
||||
@@ -201,6 +201,7 @@ const [Modal, modalApi] = useVbenModal({
|
||||
@update:items="handleUpdateItems"
|
||||
@update:total-price="handleUpdateTotalPrice"
|
||||
@update:receipt-price="handleUpdateReceiptPrice"
|
||||
class="w-full"
|
||||
/>
|
||||
</template>
|
||||
</Form>
|
||||
|
||||
66
apps/web-ele/src/api/erp/sale/customer/index.ts
Normal file
66
apps/web-ele/src/api/erp/sale/customer/index.ts
Normal file
@@ -0,0 +1,66 @@
|
||||
import type { PageParam, PageResult } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace ErpCustomerApi {
|
||||
/** 客户信息 */
|
||||
export interface Customer {
|
||||
id?: number; // 客户编号
|
||||
name: string; // 客户名称
|
||||
contact: string; // 联系人
|
||||
mobile: string; // 手机号码
|
||||
telephone: string; // 联系电话
|
||||
email: string; // 电子邮箱
|
||||
fax: string; // 传真
|
||||
remark: string; // 备注
|
||||
status: number; // 开启状态
|
||||
sort: number; // 排序
|
||||
taxNo: string; // 纳税人识别号
|
||||
taxPercent: number; // 税率
|
||||
bankName: string; // 开户行
|
||||
bankAccount: string; // 开户账号
|
||||
bankAddress: string; // 开户地址
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询客户分页 */
|
||||
export function getCustomerPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<ErpCustomerApi.Customer>>(
|
||||
'/erp/customer/page',
|
||||
{ params },
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询客户精简列表 */
|
||||
export function getCustomerSimpleList() {
|
||||
return requestClient.get<ErpCustomerApi.Customer[]>(
|
||||
'/erp/customer/simple-list',
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询客户详情 */
|
||||
export function getCustomer(id: number) {
|
||||
return requestClient.get<ErpCustomerApi.Customer>(
|
||||
`/erp/customer/get?id=${id}`,
|
||||
);
|
||||
}
|
||||
|
||||
/** 新增客户 */
|
||||
export function createCustomer(data: ErpCustomerApi.Customer) {
|
||||
return requestClient.post('/erp/customer/create', data);
|
||||
}
|
||||
|
||||
/** 修改客户 */
|
||||
export function updateCustomer(data: ErpCustomerApi.Customer) {
|
||||
return requestClient.put('/erp/customer/update', data);
|
||||
}
|
||||
|
||||
/** 删除客户 */
|
||||
export function deleteCustomer(id: number) {
|
||||
return requestClient.delete(`/erp/customer/delete?id=${id}`);
|
||||
}
|
||||
|
||||
/** 导出客户 Excel */
|
||||
export function exportCustomer(params: any) {
|
||||
return requestClient.download('/erp/customer/export-excel', { params });
|
||||
}
|
||||
98
apps/web-ele/src/api/erp/sale/order/index.ts
Normal file
98
apps/web-ele/src/api/erp/sale/order/index.ts
Normal file
@@ -0,0 +1,98 @@
|
||||
import type { PageParam, PageResult } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace ErpSaleOrderApi {
|
||||
/** 销售订单信息 */
|
||||
export interface SaleOrder {
|
||||
id?: number; // 订单工单编号
|
||||
no: string; // 销售订单号
|
||||
customerId: number; // 客户编号
|
||||
accountId?: number; // 收款账户编号
|
||||
orderTime: Date; // 订单时间
|
||||
totalCount: number; // 合计数量
|
||||
totalPrice: number; // 合计金额,单位:元
|
||||
status: number; // 状态
|
||||
remark: string; // 备注
|
||||
outCount: number; // 销售出库数量
|
||||
fileUrl?: string; // 附件地址
|
||||
inCount?: number; // 采购入库数量
|
||||
returnCount: number; // 销售退货数量
|
||||
totalProductPrice?: number; // 产品金额,单位:元
|
||||
discountPercent?: number; // 优惠率,百分比
|
||||
discountPrice?: number; // 优惠金额,单位:元
|
||||
depositPrice?: number; // 定金金额,单位:元
|
||||
items?: SaleOrderItem[]; // 销售订单产品明细列表
|
||||
}
|
||||
|
||||
/** 销售订单项 */
|
||||
export interface SaleOrderItem {
|
||||
id?: number; // 订单项编号
|
||||
orderId?: number; // 采购订单编号
|
||||
productId?: number; // 产品编号
|
||||
productName?: string; // 产品名称
|
||||
productBarCode?: string; // 产品条码
|
||||
productUnitId?: number; // 产品单位编号
|
||||
productUnitName?: string; // 产品单位名称
|
||||
productPrice?: number; // 产品单价,单位:元
|
||||
totalProductPrice?: number; // 产品总价,单位:元
|
||||
count?: number; // 数量
|
||||
totalPrice?: number; // 总价,单位:元
|
||||
taxPercent?: number; // 税率,百分比
|
||||
taxPrice?: number; // 税额,单位:元
|
||||
totalTaxPrice?: number; // 含税总价,单位:元
|
||||
remark?: string; // 备注
|
||||
stockCount?: number; // 库存数量(显示字段)
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询销售订单分页 */
|
||||
export function getSaleOrderPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<ErpSaleOrderApi.SaleOrder>>(
|
||||
'/erp/sale-order/page',
|
||||
{ params },
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询销售订单详情 */
|
||||
export function getSaleOrder(id: number) {
|
||||
return requestClient.get<ErpSaleOrderApi.SaleOrder>(
|
||||
`/erp/sale-order/get?id=${id}`,
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询销售订单项列表 */
|
||||
export function getSaleOrderItemListByOrderId(orderId: number) {
|
||||
return requestClient.get<ErpSaleOrderApi.SaleOrderItem[]>(
|
||||
`/erp/sale-order/item/list-by-order-id?orderId=${orderId}`,
|
||||
);
|
||||
}
|
||||
|
||||
/** 新增销售订单 */
|
||||
export function createSaleOrder(data: ErpSaleOrderApi.SaleOrder) {
|
||||
return requestClient.post('/erp/sale-order/create', data);
|
||||
}
|
||||
|
||||
/** 修改销售订单 */
|
||||
export function updateSaleOrder(data: ErpSaleOrderApi.SaleOrder) {
|
||||
return requestClient.put('/erp/sale-order/update', data);
|
||||
}
|
||||
|
||||
/** 更新销售订单的状态 */
|
||||
export function updateSaleOrderStatus(id: number, status: number) {
|
||||
return requestClient.put('/erp/sale-order/update-status', null, {
|
||||
params: { id, status },
|
||||
});
|
||||
}
|
||||
|
||||
/** 删除销售订单 */
|
||||
export function deleteSaleOrder(ids: number[]) {
|
||||
return requestClient.delete('/erp/sale-order/delete', {
|
||||
params: { ids: ids.join(',') },
|
||||
});
|
||||
}
|
||||
|
||||
/** 导出销售订单 Excel */
|
||||
export function exportSaleOrder(params: any) {
|
||||
return requestClient.download('/erp/sale-order/export-excel', { params });
|
||||
}
|
||||
95
apps/web-ele/src/api/erp/sale/out/index.ts
Normal file
95
apps/web-ele/src/api/erp/sale/out/index.ts
Normal file
@@ -0,0 +1,95 @@
|
||||
import type { PageParam, PageResult } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace ErpSaleOutApi {
|
||||
/** 销售出库信息 */
|
||||
export interface SaleOut {
|
||||
id?: number; // 销售出库编号
|
||||
no?: string; // 销售出库号
|
||||
customerId?: number; // 客户编号
|
||||
saleUserId?: number; // 客户编号
|
||||
outTime?: Date; // 出库时间
|
||||
totalCount?: number; // 合计数量
|
||||
totalPrice?: number; // 合计金额,单位:元
|
||||
status?: number; // 状态
|
||||
remark?: string; // 备注
|
||||
discountPercent?: number; // 折扣百分比
|
||||
discountPrice?: number; // 折扣金额
|
||||
otherPrice?: number; // 其他费用
|
||||
totalProductPrice?: number; // 合计商品金额
|
||||
taxPrice?: number; // 合计税额
|
||||
totalTaxPrice?: number; // 合计税额
|
||||
fileUrl?: string; // 附件地址
|
||||
items?: SaleOutItem[];
|
||||
}
|
||||
|
||||
/** 销售出库项 */
|
||||
export interface SaleOutItem {
|
||||
count?: number;
|
||||
id?: number;
|
||||
orderItemId?: number;
|
||||
productBarCode?: string;
|
||||
productId?: number;
|
||||
productName: string;
|
||||
productPrice: number;
|
||||
productUnitId?: number;
|
||||
productUnitName?: string;
|
||||
totalProductPrice?: number;
|
||||
remark: string;
|
||||
stockCount?: number;
|
||||
taxPercent?: number;
|
||||
taxPrice?: number;
|
||||
totalPrice?: number;
|
||||
warehouseId?: number;
|
||||
outCount?: number;
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询销售出库分页 */
|
||||
export function getSaleOutPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<ErpSaleOutApi.SaleOut>>(
|
||||
'/erp/sale-out/page',
|
||||
{
|
||||
params,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询销售出库详情 */
|
||||
export function getSaleOut(id: number) {
|
||||
return requestClient.get<ErpSaleOutApi.SaleOut>(`/erp/sale-out/get?id=${id}`);
|
||||
}
|
||||
|
||||
/** 新增销售出库 */
|
||||
export function createSaleOut(data: ErpSaleOutApi.SaleOut) {
|
||||
return requestClient.post('/erp/sale-out/create', data);
|
||||
}
|
||||
|
||||
/** 修改销售出库 */
|
||||
export function updateSaleOut(data: ErpSaleOutApi.SaleOut) {
|
||||
return requestClient.put('/erp/sale-out/update', data);
|
||||
}
|
||||
|
||||
/** 更新销售出库的状态 */
|
||||
export function updateSaleOutStatus(id: number, status: number) {
|
||||
return requestClient.put('/erp/sale-out/update-status', null, {
|
||||
params: { id, status },
|
||||
});
|
||||
}
|
||||
|
||||
/** 删除销售出库 */
|
||||
export function deleteSaleOut(ids: number[]) {
|
||||
return requestClient.delete('/erp/sale-out/delete', {
|
||||
params: {
|
||||
ids: ids.join(','),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/** 导出销售出库 Excel */
|
||||
export function exportSaleOut(params: any) {
|
||||
return requestClient.download('/erp/sale-out/export-excel', {
|
||||
params,
|
||||
});
|
||||
}
|
||||
96
apps/web-ele/src/api/erp/sale/return/index.ts
Normal file
96
apps/web-ele/src/api/erp/sale/return/index.ts
Normal file
@@ -0,0 +1,96 @@
|
||||
import type { PageParam, PageResult } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace ErpSaleReturnApi {
|
||||
/** 销售退货信息 */
|
||||
export interface SaleReturn {
|
||||
id?: number; // 销售退货编号
|
||||
no?: string; // 销售退货号
|
||||
customerId?: number; // 客户编号
|
||||
returnTime?: Date; // 退货时间
|
||||
totalCount?: number; // 合计数量
|
||||
totalPrice?: number; // 合计金额,单位:元
|
||||
status?: number; // 状态
|
||||
remark?: string; // 备注
|
||||
discountPercent?: number; // 折扣百分比
|
||||
discountPrice?: number; // 折扣金额
|
||||
otherPrice?: number; // 其他费用
|
||||
totalProductPrice?: number; // 合计商品金额
|
||||
taxPrice?: number; // 合计税额
|
||||
totalTaxPrice?: number; // 合计税额
|
||||
fileUrl?: string; // 附件地址
|
||||
items?: SaleReturnItem[];
|
||||
}
|
||||
|
||||
/** 销售退货项 */
|
||||
export interface SaleReturnItem {
|
||||
count?: number;
|
||||
id?: number;
|
||||
orderItemId?: number;
|
||||
productBarCode?: string;
|
||||
productId?: number;
|
||||
productName: string;
|
||||
productPrice: number;
|
||||
productUnitId?: number;
|
||||
productUnitName?: string;
|
||||
totalProductPrice?: number;
|
||||
remark: string;
|
||||
stockCount?: number;
|
||||
taxPercent?: number;
|
||||
taxPrice?: number;
|
||||
totalPrice?: number;
|
||||
warehouseId?: number;
|
||||
returnCount?: number;
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询销售退货分页 */
|
||||
export function getSaleReturnPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<ErpSaleReturnApi.SaleReturn>>(
|
||||
'/erp/sale-return/page',
|
||||
{
|
||||
params,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询销售退货详情 */
|
||||
export function getSaleReturn(id: number) {
|
||||
return requestClient.get<ErpSaleReturnApi.SaleReturn>(
|
||||
`/erp/sale-return/get?id=${id}`,
|
||||
);
|
||||
}
|
||||
|
||||
/** 新增销售退货 */
|
||||
export function createSaleReturn(data: ErpSaleReturnApi.SaleReturn) {
|
||||
return requestClient.post('/erp/sale-return/create', data);
|
||||
}
|
||||
|
||||
/** 修改销售退货 */
|
||||
export function updateSaleReturn(data: ErpSaleReturnApi.SaleReturn) {
|
||||
return requestClient.put('/erp/sale-return/update', data);
|
||||
}
|
||||
|
||||
/** 更新销售退货的状态 */
|
||||
export function updateSaleReturnStatus(id: number, status: number) {
|
||||
return requestClient.put('/erp/sale-return/update-status', null, {
|
||||
params: { id, status },
|
||||
});
|
||||
}
|
||||
|
||||
/** 删除销售退货 */
|
||||
export function deleteSaleReturn(ids: number[]) {
|
||||
return requestClient.delete('/erp/sale-return/delete', {
|
||||
params: {
|
||||
ids: ids.join(','),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/** 导出销售退货 Excel */
|
||||
export function exportSaleReturn(params: any) {
|
||||
return requestClient.download('/erp/sale-return/export-excel', {
|
||||
params,
|
||||
});
|
||||
}
|
||||
590
apps/web-ele/src/views/erp/finance/receipt/data.ts
Normal file
590
apps/web-ele/src/views/erp/finance/receipt/data.ts
Normal file
@@ -0,0 +1,590 @@
|
||||
import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
|
||||
import { DICT_TYPE } from '@vben/constants';
|
||||
import { getDictOptions } from '@vben/hooks';
|
||||
import { erpPriceInputFormatter } from '@vben/utils';
|
||||
|
||||
import { getAccountSimpleList } from '#/api/erp/finance/account';
|
||||
import { getCustomerSimpleList } from '#/api/erp/sale/customer';
|
||||
import { getSimpleUserList } from '#/api/system/user';
|
||||
import { getRangePickerDefaultProps } from '#/utils';
|
||||
|
||||
/** 表单的配置项 */
|
||||
export function useFormSchema(formType: string): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'id',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'no',
|
||||
label: '收款单号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '系统自动生成',
|
||||
disabled: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'receiptTime',
|
||||
label: '收款时间',
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
disabled: formType === 'detail',
|
||||
placeholder: '选择收款时间',
|
||||
type: 'datetime',
|
||||
format: 'YYYY-MM-DD HH:mm:ss',
|
||||
valueFormat: 'x',
|
||||
class: '!w-full',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'customerId',
|
||||
label: '客户',
|
||||
component: 'ApiSelect',
|
||||
componentProps: {
|
||||
disabled: formType === 'detail',
|
||||
placeholder: '请选择客户',
|
||||
allowClear: true,
|
||||
showSearch: true,
|
||||
api: getCustomerSimpleList,
|
||||
labelField: 'name',
|
||||
valueField: 'id',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'financeUserId',
|
||||
label: '财务人员',
|
||||
component: 'ApiSelect',
|
||||
componentProps: {
|
||||
placeholder: '请选择财务人员',
|
||||
allowClear: true,
|
||||
showSearch: true,
|
||||
api: getSimpleUserList,
|
||||
labelField: 'nickname',
|
||||
valueField: 'id',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'remark',
|
||||
label: '备注',
|
||||
component: 'Textarea',
|
||||
componentProps: {
|
||||
placeholder: '请输入备注',
|
||||
autoSize: { minRows: 1, maxRows: 1 },
|
||||
disabled: formType === 'detail',
|
||||
},
|
||||
formItemClass: 'col-span-2',
|
||||
},
|
||||
{
|
||||
fieldName: 'fileUrl',
|
||||
label: '附件',
|
||||
component: 'FileUpload',
|
||||
componentProps: {
|
||||
maxNumber: 1,
|
||||
maxSize: 10,
|
||||
accept: [
|
||||
'pdf',
|
||||
'doc',
|
||||
'docx',
|
||||
'xls',
|
||||
'xlsx',
|
||||
'txt',
|
||||
'jpg',
|
||||
'jpeg',
|
||||
'png',
|
||||
],
|
||||
showDescription: formType !== 'detail',
|
||||
disabled: formType === 'detail',
|
||||
},
|
||||
formItemClass: 'col-span-3',
|
||||
},
|
||||
{
|
||||
fieldName: 'items',
|
||||
label: '销售出库、退货单',
|
||||
component: 'Input',
|
||||
formItemClass: 'col-span-3',
|
||||
},
|
||||
{
|
||||
fieldName: 'accountId',
|
||||
label: '收款账户',
|
||||
component: 'ApiSelect',
|
||||
componentProps: {
|
||||
placeholder: '请选择收款账户',
|
||||
allowClear: true,
|
||||
showSearch: true,
|
||||
api: getAccountSimpleList,
|
||||
labelField: 'name',
|
||||
valueField: 'id',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'totalPrice',
|
||||
label: '合计收款',
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
placeholder: '合计收款',
|
||||
precision: 2,
|
||||
formatter: erpPriceInputFormatter,
|
||||
disabled: true,
|
||||
controlsPosition: 'right',
|
||||
class: '!w-full',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'discountPrice',
|
||||
label: '优惠金额',
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
disabled: formType === 'detail',
|
||||
placeholder: '请输入优惠金额',
|
||||
precision: 2,
|
||||
formatter: erpPriceInputFormatter,
|
||||
controlsPosition: 'right',
|
||||
class: '!w-full',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'receiptPrice',
|
||||
label: '实际收款',
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
placeholder: '实际收款',
|
||||
precision: 2,
|
||||
formatter: erpPriceInputFormatter,
|
||||
disabled: true,
|
||||
controlsPosition: 'right',
|
||||
class: '!w-full',
|
||||
},
|
||||
dependencies: {
|
||||
triggerFields: ['totalPrice', 'discountPrice'],
|
||||
componentProps: (values) => {
|
||||
const totalPrice = values.totalPrice || 0;
|
||||
const discountPrice = values.discountPrice || 0;
|
||||
values.receiptPrice = totalPrice - discountPrice;
|
||||
return {};
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 表单的明细表格列 */
|
||||
export function useFormItemColumns(): VxeTableGridOptions['columns'] {
|
||||
return [
|
||||
{ type: 'seq', title: '序号', minWidth: 50, fixed: 'left' },
|
||||
{
|
||||
field: 'bizNo',
|
||||
title: '销售单据编号',
|
||||
minWidth: 200,
|
||||
},
|
||||
{
|
||||
field: 'totalPrice',
|
||||
title: '应收金额',
|
||||
minWidth: 100,
|
||||
formatter: 'formatAmount2',
|
||||
},
|
||||
{
|
||||
field: 'receiptedPrice',
|
||||
title: '已收金额',
|
||||
minWidth: 100,
|
||||
formatter: 'formatAmount2',
|
||||
},
|
||||
{
|
||||
field: 'receiptPrice',
|
||||
title: '本次收款',
|
||||
minWidth: 115,
|
||||
fixed: 'right',
|
||||
slots: { default: 'receiptPrice' },
|
||||
},
|
||||
{
|
||||
field: 'remark',
|
||||
title: '备注',
|
||||
minWidth: 150,
|
||||
slots: { default: 'remark' },
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 50,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的搜索表单 */
|
||||
export function useGridFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'no',
|
||||
label: '收款单号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入收款单号',
|
||||
allowClear: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'receiptTime',
|
||||
label: '收款时间',
|
||||
component: 'RangePicker',
|
||||
componentProps: {
|
||||
...getRangePickerDefaultProps(),
|
||||
allowClear: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'customerId',
|
||||
label: '客户',
|
||||
component: 'ApiSelect',
|
||||
componentProps: {
|
||||
placeholder: '请选择客户',
|
||||
allowClear: true,
|
||||
showSearch: true,
|
||||
api: getCustomerSimpleList,
|
||||
labelField: 'name',
|
||||
valueField: 'id',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'creator',
|
||||
label: '创建人',
|
||||
component: 'ApiSelect',
|
||||
componentProps: {
|
||||
placeholder: '请选择创建人',
|
||||
allowClear: true,
|
||||
showSearch: true,
|
||||
api: getSimpleUserList,
|
||||
labelField: 'nickname',
|
||||
valueField: 'id',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'financeUserId',
|
||||
label: '财务人员',
|
||||
component: 'ApiSelect',
|
||||
componentProps: {
|
||||
placeholder: '请选择财务人员',
|
||||
allowClear: true,
|
||||
showSearch: true,
|
||||
api: getSimpleUserList,
|
||||
labelField: 'nickname',
|
||||
valueField: 'id',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'accountId',
|
||||
label: '收款账户',
|
||||
component: 'ApiSelect',
|
||||
componentProps: {
|
||||
placeholder: '请选择收款账户',
|
||||
allowClear: true,
|
||||
showSearch: true,
|
||||
api: getAccountSimpleList,
|
||||
labelField: 'name',
|
||||
valueField: 'id',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'status',
|
||||
label: '状态',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
options: getDictOptions(DICT_TYPE.ERP_AUDIT_STATUS, 'number'),
|
||||
placeholder: '请选择状态',
|
||||
allowClear: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'remark',
|
||||
label: '备注',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入备注',
|
||||
allowClear: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'bizNo',
|
||||
label: '销售单号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入销售单号',
|
||||
allowClear: true,
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的字段 */
|
||||
export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
return [
|
||||
{
|
||||
type: 'checkbox',
|
||||
width: 50,
|
||||
fixed: 'left',
|
||||
},
|
||||
{
|
||||
field: 'no',
|
||||
title: '收款单号',
|
||||
width: 180,
|
||||
fixed: 'left',
|
||||
},
|
||||
{
|
||||
field: 'customerName',
|
||||
title: '客户',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'receiptTime',
|
||||
title: '收款时间',
|
||||
width: 160,
|
||||
formatter: 'formatDate',
|
||||
},
|
||||
{
|
||||
field: 'creatorName',
|
||||
title: '创建人',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'financeUserName',
|
||||
title: '财务人员',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'accountName',
|
||||
title: '收款账户',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'totalPrice',
|
||||
title: '合计收款',
|
||||
formatter: 'formatAmount2',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'discountPrice',
|
||||
title: '优惠金额',
|
||||
formatter: 'formatAmount2',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'receiptPrice',
|
||||
title: '实际收款',
|
||||
formatter: 'formatAmount2',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'status',
|
||||
title: '状态',
|
||||
minWidth: 90,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.ERP_AUDIT_STATUS },
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 260,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 销售出库单选择表单的配置项 */
|
||||
export function useSaleOutGridFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'no',
|
||||
label: '出库单号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入出库单号',
|
||||
allowClear: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'customerId',
|
||||
label: '客户',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
placeholder: '已自动选择客户',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'receiptStatus',
|
||||
label: '收款状态',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
options: [
|
||||
{ label: '未收款', value: 0 },
|
||||
{ label: '部分收款', value: 1 },
|
||||
{ label: '全部收款', value: 2 },
|
||||
],
|
||||
placeholder: '请选择收款状态',
|
||||
allowClear: true,
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 销售出库单选择列表的字段 */
|
||||
export function useSaleOutGridColumns(): VxeTableGridOptions['columns'] {
|
||||
return [
|
||||
{
|
||||
type: 'checkbox',
|
||||
width: 50,
|
||||
fixed: 'left',
|
||||
},
|
||||
{
|
||||
field: 'no',
|
||||
title: '出库单号',
|
||||
width: 200,
|
||||
fixed: 'left',
|
||||
},
|
||||
{
|
||||
field: 'customerName',
|
||||
title: '客户',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'outTime',
|
||||
title: '出库时间',
|
||||
width: 160,
|
||||
formatter: 'formatDate',
|
||||
},
|
||||
{
|
||||
field: 'totalPrice',
|
||||
title: '应收金额',
|
||||
formatter: 'formatAmount2',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'receiptPrice',
|
||||
title: '已收金额',
|
||||
formatter: 'formatAmount2',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'unReceiptPrice',
|
||||
title: '未收金额',
|
||||
formatter: ({ row }) => {
|
||||
return erpPriceInputFormatter(row.totalPrice - row.receiptPrice || 0);
|
||||
},
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'status',
|
||||
title: '状态',
|
||||
minWidth: 100,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.ERP_AUDIT_STATUS },
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 销售退货单选择表单的配置项 */
|
||||
export function useSaleReturnGridFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'no',
|
||||
label: '退货单号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入退货单号',
|
||||
allowClear: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'customerId',
|
||||
label: '客户',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
placeholder: '已自动选择客户',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'refundStatus',
|
||||
label: '退款状态',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
options: [
|
||||
{ label: '未退款', value: 0 },
|
||||
{ label: '部分退款', value: 1 },
|
||||
{ label: '全部退款', value: 2 },
|
||||
],
|
||||
placeholder: '请选择退款状态',
|
||||
allowClear: true,
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 销售退货单选择列表的字段 */
|
||||
export function useSaleReturnGridColumns(): VxeTableGridOptions['columns'] {
|
||||
return [
|
||||
{
|
||||
type: 'checkbox',
|
||||
width: 50,
|
||||
fixed: 'left',
|
||||
},
|
||||
{
|
||||
field: 'no',
|
||||
title: '退货单号',
|
||||
width: 200,
|
||||
fixed: 'left',
|
||||
},
|
||||
{
|
||||
field: 'customerName',
|
||||
title: '客户',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'returnTime',
|
||||
title: '退货时间',
|
||||
width: 160,
|
||||
formatter: 'formatDate',
|
||||
},
|
||||
{
|
||||
field: 'totalPrice',
|
||||
title: '应退金额',
|
||||
formatter: 'formatAmount2',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'refundPrice',
|
||||
title: '已退金额',
|
||||
formatter: 'formatAmount2',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'unRefundPrice',
|
||||
title: '未退金额',
|
||||
formatter: ({ row }) => {
|
||||
return erpPriceInputFormatter(row.totalPrice - row.refundPrice || 0);
|
||||
},
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'status',
|
||||
title: '状态',
|
||||
minWidth: 100,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.ERP_AUDIT_STATUS },
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
226
apps/web-ele/src/views/erp/finance/receipt/index.vue
Normal file
226
apps/web-ele/src/views/erp/finance/receipt/index.vue
Normal file
@@ -0,0 +1,226 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { ErpFinanceReceiptApi } from '#/api/erp/finance/receipt';
|
||||
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { DocAlert, Page, useVbenModal } from '@vben/common-ui';
|
||||
import { downloadFileFromBlobPart, isEmpty } from '@vben/utils';
|
||||
|
||||
import { ElLoading, ElMessage } from 'element-plus';
|
||||
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import {
|
||||
deleteFinanceReceipt,
|
||||
exportFinanceReceipt,
|
||||
getFinanceReceiptPage,
|
||||
updateFinanceReceiptStatus,
|
||||
} from '#/api/erp/finance/receipt';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useGridColumns, useGridFormSchema } from './data';
|
||||
import Form from './modules/form.vue';
|
||||
|
||||
/** ERP 收款单列表 */
|
||||
defineOptions({ name: 'ErpFinanceReceipt' });
|
||||
|
||||
const [FormModal, formModalApi] = useVbenModal({
|
||||
connectedComponent: Form,
|
||||
destroyOnClose: true,
|
||||
});
|
||||
|
||||
/** 刷新表格 */
|
||||
function handleRefresh() {
|
||||
gridApi.query();
|
||||
}
|
||||
|
||||
/** 导出表格 */
|
||||
async function handleExport() {
|
||||
const data = await exportFinanceReceipt(await gridApi.formApi.getValues());
|
||||
downloadFileFromBlobPart({ fileName: '收款单.xls', source: data });
|
||||
}
|
||||
|
||||
/** 新增收款单 */
|
||||
function handleCreate() {
|
||||
formModalApi.setData({ type: 'create' }).open();
|
||||
}
|
||||
|
||||
/** 编辑收款单 */
|
||||
function handleEdit(row: ErpFinanceReceiptApi.FinanceReceipt) {
|
||||
formModalApi.setData({ type: 'edit', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 删除收款单 */
|
||||
async function handleDelete(ids: number[]) {
|
||||
const loadingInstance = ElLoading.service({
|
||||
text: $t('ui.actionMessage.deleting'),
|
||||
});
|
||||
try {
|
||||
await deleteFinanceReceipt(ids);
|
||||
ElMessage.success($t('ui.actionMessage.deleteSuccess'));
|
||||
handleRefresh();
|
||||
} finally {
|
||||
loadingInstance.close();
|
||||
}
|
||||
}
|
||||
|
||||
/** 审批/反审批操作 */
|
||||
async function handleUpdateStatus(
|
||||
row: ErpFinanceReceiptApi.FinanceReceipt,
|
||||
status: number,
|
||||
) {
|
||||
const loadingInstance = ElLoading.service({
|
||||
text: `确定${status === 20 ? '审批' : '反审批'}该收款单吗?`,
|
||||
});
|
||||
try {
|
||||
await updateFinanceReceiptStatus(row.id!, status);
|
||||
ElMessage.success(`${status === 20 ? '审批' : '反审批'}成功`);
|
||||
handleRefresh();
|
||||
} finally {
|
||||
loadingInstance.close();
|
||||
}
|
||||
}
|
||||
|
||||
const checkedIds = ref<number[]>([]);
|
||||
function handleRowCheckboxChange({
|
||||
records,
|
||||
}: {
|
||||
records: ErpFinanceReceiptApi.FinanceReceipt[];
|
||||
}) {
|
||||
checkedIds.value = records.map((item) => item.id!);
|
||||
}
|
||||
|
||||
/** 查看详情 */
|
||||
function handleDetail(row: ErpFinanceReceiptApi.FinanceReceipt) {
|
||||
formModalApi.setData({ type: 'detail', id: row.id }).open();
|
||||
}
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
formOptions: {
|
||||
schema: useGridFormSchema(),
|
||||
},
|
||||
gridOptions: {
|
||||
columns: useGridColumns(),
|
||||
height: 'auto',
|
||||
keepSource: true,
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }, formValues) => {
|
||||
return await getFinanceReceiptPage({
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
...formValues,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
isHover: true,
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: true,
|
||||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<ErpFinanceReceiptApi.FinanceReceipt>,
|
||||
gridEvents: {
|
||||
checkboxAll: handleRowCheckboxChange,
|
||||
checkboxChange: handleRowCheckboxChange,
|
||||
},
|
||||
});
|
||||
</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:finance-receipt:create'],
|
||||
onClick: handleCreate,
|
||||
},
|
||||
{
|
||||
label: $t('ui.actionTitle.export'),
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.DOWNLOAD,
|
||||
auth: ['erp:finance-receipt:export'],
|
||||
onClick: handleExport,
|
||||
},
|
||||
{
|
||||
label: '批量删除',
|
||||
type: 'danger',
|
||||
disabled: isEmpty(checkedIds),
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['erp:finance-receipt:delete'],
|
||||
popConfirm: {
|
||||
title: `是否删除所选中数据?`,
|
||||
confirm: handleDelete.bind(null, checkedIds),
|
||||
},
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: $t('common.detail'),
|
||||
type: 'primary',
|
||||
link: true,
|
||||
icon: ACTION_ICON.VIEW,
|
||||
auth: ['erp:finance-receipt:query'],
|
||||
onClick: handleDetail.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: $t('common.edit'),
|
||||
type: 'primary',
|
||||
link: true,
|
||||
icon: ACTION_ICON.EDIT,
|
||||
auth: ['erp:finance-receipt:update'],
|
||||
ifShow: () => row.status !== 20,
|
||||
onClick: handleEdit.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: row.status === 10 ? '审批' : '反审批',
|
||||
type: 'primary',
|
||||
link: true,
|
||||
icon: ACTION_ICON.AUDIT,
|
||||
auth: ['erp:finance-receipt:update-status'],
|
||||
popConfirm: {
|
||||
title: `确认${row.status === 10 ? '审批' : '反审批'}${row.no}吗?`,
|
||||
confirm: handleUpdateStatus.bind(
|
||||
null,
|
||||
row,
|
||||
row.status === 10 ? 20 : 10,
|
||||
),
|
||||
},
|
||||
},
|
||||
{
|
||||
label: $t('common.delete'),
|
||||
type: 'danger',
|
||||
link: true,
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['erp:finance-receipt:delete'],
|
||||
popConfirm: {
|
||||
title: $t('ui.actionMessage.deleteConfirm', [row.no]),
|
||||
confirm: handleDelete.bind(null, [row.id!]),
|
||||
},
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
</Page>
|
||||
</template>
|
||||
209
apps/web-ele/src/views/erp/finance/receipt/modules/form.vue
Normal file
209
apps/web-ele/src/views/erp/finance/receipt/modules/form.vue
Normal file
@@ -0,0 +1,209 @@
|
||||
<script lang="ts" setup>
|
||||
import type { ErpFinanceReceiptApi } from '#/api/erp/finance/receipt';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
import { $t } from '@vben/locales';
|
||||
|
||||
import { ElMessage } from 'element-plus';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { getAccountSimpleList } from '#/api/erp/finance/account';
|
||||
import {
|
||||
createFinanceReceipt,
|
||||
getFinanceReceipt,
|
||||
updateFinanceReceipt,
|
||||
} from '#/api/erp/finance/receipt';
|
||||
|
||||
import { useFormSchema } from '../data';
|
||||
import ItemForm from './item-form.vue';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formData = ref<
|
||||
ErpFinanceReceiptApi.FinanceReceipt & {
|
||||
fileUrl?: string;
|
||||
}
|
||||
>({
|
||||
id: undefined,
|
||||
no: '',
|
||||
customerId: 0,
|
||||
accountId: 0,
|
||||
financeUserId: 0,
|
||||
receiptTime: new Date(),
|
||||
remark: '',
|
||||
fileUrl: undefined,
|
||||
totalPrice: 0,
|
||||
discountPrice: 0,
|
||||
receiptPrice: 0,
|
||||
items: [],
|
||||
status: 0,
|
||||
});
|
||||
|
||||
const formType = ref(''); // 表单类型:'create' | 'edit' | 'detail'
|
||||
const itemFormRef = ref<InstanceType<typeof ItemForm>>();
|
||||
|
||||
const getTitle = computed(() => {
|
||||
if (formType.value === 'create') {
|
||||
return $t('ui.actionTitle.create', ['收款单']);
|
||||
} else if (formType.value === 'edit') {
|
||||
return $t('ui.actionTitle.edit', ['收款单']);
|
||||
} else {
|
||||
return '收款单详情';
|
||||
}
|
||||
});
|
||||
|
||||
const [Form, formApi] = useVbenForm({
|
||||
commonConfig: {
|
||||
componentProps: {
|
||||
class: 'w-full',
|
||||
},
|
||||
labelWidth: 120,
|
||||
},
|
||||
wrapperClass: 'grid-cols-3',
|
||||
layout: 'vertical',
|
||||
schema: useFormSchema(formType.value),
|
||||
showDefaultActions: false,
|
||||
handleValuesChange: (values, changedFields) => {
|
||||
if (formData.value) {
|
||||
if (changedFields.includes('customerId')) {
|
||||
formData.value.customerId = values.customerId;
|
||||
}
|
||||
// 目的:同步到 item-form 组件,触发整体的价格计算
|
||||
if (changedFields.includes('discountPrice')) {
|
||||
formData.value.discountPrice = values.discountPrice;
|
||||
formData.value.receiptPrice =
|
||||
formData.value.totalPrice - values.discountPrice;
|
||||
formApi.setValues({
|
||||
receiptPrice: formData.value.receiptPrice,
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
/** 更新收款项 */
|
||||
function handleUpdateItems(items: ErpFinanceReceiptApi.FinanceReceiptItem[]) {
|
||||
formData.value.items = items;
|
||||
formApi.setValues({
|
||||
items,
|
||||
});
|
||||
}
|
||||
|
||||
/** 更新总金额 */
|
||||
function handleUpdateTotalPrice(totalPrice: number) {
|
||||
formData.value.totalPrice = totalPrice;
|
||||
formApi.setValues({
|
||||
totalPrice: formData.value.totalPrice,
|
||||
});
|
||||
}
|
||||
|
||||
/** 更新收款金额 */
|
||||
function handleUpdateReceiptPrice(receiptPrice: number) {
|
||||
formData.value.receiptPrice = receiptPrice;
|
||||
formApi.setValues({
|
||||
receiptPrice: formData.value.receiptPrice,
|
||||
});
|
||||
}
|
||||
|
||||
/** 创建或更新收款单 */
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
async onConfirm() {
|
||||
const { valid } = await formApi.validate();
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
const itemFormInstance = Array.isArray(itemFormRef.value)
|
||||
? itemFormRef.value[0]
|
||||
: itemFormRef.value;
|
||||
try {
|
||||
itemFormInstance.validate();
|
||||
} catch (error: any) {
|
||||
ElMessage.error(error.message || '子表单验证失败');
|
||||
return;
|
||||
}
|
||||
|
||||
modalApi.lock();
|
||||
// 提交表单
|
||||
const data =
|
||||
(await formApi.getValues()) as ErpFinanceReceiptApi.FinanceReceipt;
|
||||
try {
|
||||
await (formType.value === 'create'
|
||||
? createFinanceReceipt(data)
|
||||
: updateFinanceReceipt(data));
|
||||
// 关闭并提示
|
||||
await modalApi.close();
|
||||
emit('success');
|
||||
ElMessage.success($t('ui.actionMessage.operationSuccess'));
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
async onOpenChange(isOpen: boolean) {
|
||||
if (!isOpen) {
|
||||
formData.value = {
|
||||
id: undefined,
|
||||
no: '',
|
||||
customerId: 0,
|
||||
accountId: 0,
|
||||
financeUserId: 0,
|
||||
receiptTime: new Date(),
|
||||
remark: '',
|
||||
totalPrice: 0,
|
||||
discountPrice: 0,
|
||||
receiptPrice: 0,
|
||||
status: 0,
|
||||
items: [],
|
||||
bizNo: '',
|
||||
};
|
||||
return;
|
||||
}
|
||||
// 加载数据
|
||||
const data = modalApi.getData<{ id?: number; type: string }>();
|
||||
formType.value = data.type;
|
||||
formApi.setDisabled(formType.value === 'detail');
|
||||
formApi.updateSchema(useFormSchema(formType.value));
|
||||
if (!data || !data.id) {
|
||||
// 新增时,默认选中账户
|
||||
const accountList = await getAccountSimpleList();
|
||||
const defaultAccount = accountList.find((item) => item.defaultStatus);
|
||||
if (defaultAccount) {
|
||||
await formApi.setValues({ accountId: defaultAccount.id });
|
||||
}
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
try {
|
||||
formData.value = await getFinanceReceipt(data.id);
|
||||
// 设置到 values
|
||||
await formApi.setValues(formData.value, false);
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal
|
||||
:title="getTitle"
|
||||
class="w-3/4"
|
||||
:show-confirm-button="formType !== 'detail'"
|
||||
>
|
||||
<Form class="mx-3">
|
||||
<template #items>
|
||||
<ItemForm
|
||||
ref="itemFormRef"
|
||||
:items="formData?.items ?? []"
|
||||
:customer-id="formData?.customerId"
|
||||
:disabled="formType === 'detail'"
|
||||
:discount-price="formData?.discountPrice ?? 0"
|
||||
@update:items="handleUpdateItems"
|
||||
@update:total-price="handleUpdateTotalPrice"
|
||||
@update:receipt-price="handleUpdateReceiptPrice"
|
||||
class="w-full"
|
||||
/>
|
||||
</template>
|
||||
</Form>
|
||||
</Modal>
|
||||
</template>
|
||||
299
apps/web-ele/src/views/erp/finance/receipt/modules/item-form.vue
Normal file
299
apps/web-ele/src/views/erp/finance/receipt/modules/item-form.vue
Normal file
@@ -0,0 +1,299 @@
|
||||
<script lang="ts" setup>
|
||||
import type { ErpFinanceReceiptApi } from '#/api/erp/finance/receipt';
|
||||
import type { ErpSaleOutApi } from '#/api/erp/sale/out';
|
||||
import type { ErpSaleReturnApi } from '#/api/erp/sale/return';
|
||||
|
||||
import { computed, nextTick, ref, watch } from 'vue';
|
||||
|
||||
import { ErpBizType } from '@vben/constants';
|
||||
import { erpPriceInputFormatter } from '@vben/utils';
|
||||
|
||||
import { ElInput, ElInputNumber, ElMessage } from 'element-plus';
|
||||
|
||||
import { TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
|
||||
import { useFormItemColumns } from '../data';
|
||||
import SaleOutSelect from './sale-out-select.vue';
|
||||
import SaleReturnSelect from './sale-return-select.vue';
|
||||
|
||||
interface Props {
|
||||
items?: ErpFinanceReceiptApi.FinanceReceiptItem[];
|
||||
customerId?: number;
|
||||
disabled?: boolean;
|
||||
discountPrice?: number;
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
items: () => [],
|
||||
customerId: undefined,
|
||||
disabled: false,
|
||||
discountPrice: 0,
|
||||
});
|
||||
|
||||
const emit = defineEmits([
|
||||
'update:items',
|
||||
'update:total-price',
|
||||
'update:receipt-price',
|
||||
]);
|
||||
|
||||
const tableData = ref<ErpFinanceReceiptApi.FinanceReceiptItem[]>([]); // 表格数据
|
||||
|
||||
/** 获取表格合计数据 */
|
||||
const summaries = computed(() => {
|
||||
return {
|
||||
totalPrice: tableData.value.reduce(
|
||||
(sum, item) => sum + (item.totalPrice || 0),
|
||||
0,
|
||||
),
|
||||
receiptedPrice: tableData.value.reduce(
|
||||
(sum, item) => sum + (item.receiptedPrice || 0),
|
||||
0,
|
||||
),
|
||||
receiptPrice: tableData.value.reduce(
|
||||
(sum, item) => sum + (item.receiptPrice || 0),
|
||||
0,
|
||||
),
|
||||
};
|
||||
});
|
||||
|
||||
/** 表格配置 */
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions: {
|
||||
columns: useFormItemColumns(),
|
||||
data: tableData.value,
|
||||
minHeight: 250,
|
||||
autoResize: true,
|
||||
border: true,
|
||||
rowConfig: {
|
||||
keyField: 'seq',
|
||||
isHover: true,
|
||||
},
|
||||
pagerConfig: {
|
||||
enabled: false,
|
||||
},
|
||||
toolbarConfig: {
|
||||
enabled: false,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
/** 监听外部传入的列数据 */
|
||||
watch(
|
||||
() => props.items,
|
||||
async (items) => {
|
||||
if (!items) {
|
||||
return;
|
||||
}
|
||||
tableData.value = [...items];
|
||||
await nextTick(); // 特殊:保证 gridApi 已经初始化
|
||||
await gridApi.grid.reloadData(tableData.value);
|
||||
},
|
||||
{
|
||||
immediate: true,
|
||||
},
|
||||
);
|
||||
|
||||
/** 计算 totalPrice、receiptPrice 价格 */
|
||||
watch(
|
||||
() => [tableData.value, props.discountPrice],
|
||||
() => {
|
||||
if (!tableData.value || tableData.value.length === 0) {
|
||||
return;
|
||||
}
|
||||
const totalPrice = tableData.value.reduce(
|
||||
(prev, curr) => prev + (curr.totalPrice || 0),
|
||||
0,
|
||||
);
|
||||
const receiptPrice = tableData.value.reduce(
|
||||
(prev, curr) => prev + (curr.receiptPrice || 0),
|
||||
0,
|
||||
);
|
||||
const finalReceiptPrice = receiptPrice - (props.discountPrice || 0);
|
||||
// 通知父组件更新
|
||||
emit('update:total-price', totalPrice);
|
||||
emit('update:receipt-price', finalReceiptPrice);
|
||||
},
|
||||
{ deep: true },
|
||||
);
|
||||
|
||||
/** 添加销售出库单 */
|
||||
const saleOutSelectRef = ref();
|
||||
function handleOpenSaleOut() {
|
||||
if (!props.customerId) {
|
||||
ElMessage.error('请选择客户');
|
||||
return;
|
||||
}
|
||||
saleOutSelectRef.value?.open(props.customerId);
|
||||
}
|
||||
|
||||
function handleAddSaleOut(rows: ErpSaleOutApi.SaleOut[]) {
|
||||
rows.forEach((row) => {
|
||||
const newItem: ErpFinanceReceiptApi.FinanceReceiptItem = {
|
||||
bizId: row.id,
|
||||
bizType: ErpBizType.SALE_OUT,
|
||||
bizNo: row.no,
|
||||
totalPrice: row.totalPrice,
|
||||
receiptedPrice: row.receiptPrice,
|
||||
receiptPrice: row.totalPrice - row.receiptPrice,
|
||||
remark: undefined,
|
||||
};
|
||||
tableData.value.push(newItem);
|
||||
});
|
||||
emit('update:items', [...tableData.value]);
|
||||
}
|
||||
|
||||
/** 添加销售退货单 */
|
||||
const saleReturnSelectRef = ref();
|
||||
function handleOpenSaleReturn() {
|
||||
if (!props.customerId) {
|
||||
ElMessage.error('请选择客户');
|
||||
return;
|
||||
}
|
||||
saleReturnSelectRef.value?.open(props.customerId);
|
||||
}
|
||||
|
||||
function handleAddSaleReturn(rows: ErpSaleReturnApi.SaleReturn[]) {
|
||||
rows.forEach((row) => {
|
||||
const newItem: ErpFinanceReceiptApi.FinanceReceiptItem = {
|
||||
bizId: row.id,
|
||||
bizType: ErpBizType.SALE_RETURN,
|
||||
bizNo: row.no,
|
||||
totalPrice: -row.totalPrice,
|
||||
receiptedPrice: -row.refundPrice,
|
||||
receiptPrice: -row.totalPrice + row.refundPrice,
|
||||
remark: undefined,
|
||||
};
|
||||
tableData.value.push(newItem);
|
||||
});
|
||||
emit('update:items', [...tableData.value]);
|
||||
}
|
||||
|
||||
/** 删除行 */
|
||||
function handleDelete(row: any) {
|
||||
const index = tableData.value.findIndex(
|
||||
(item) => item.bizId === row.bizId && item.bizType === row.bizType,
|
||||
);
|
||||
if (index !== -1) {
|
||||
tableData.value.splice(index, 1);
|
||||
}
|
||||
// 通知父组件更新
|
||||
emit('update:items', [...tableData.value]);
|
||||
}
|
||||
|
||||
/** 处理行数据变更 */
|
||||
function handleRowChange(row: any) {
|
||||
const index = tableData.value.findIndex(
|
||||
(item) => item.bizId === row.bizId && item.bizType === row.bizType,
|
||||
);
|
||||
if (index === -1) {
|
||||
tableData.value.push(row);
|
||||
} else {
|
||||
tableData.value[index] = row;
|
||||
}
|
||||
emit('update:items', [...tableData.value]);
|
||||
}
|
||||
|
||||
/** 表单校验 */
|
||||
function validate() {
|
||||
// 检查是否有明细
|
||||
if (tableData.value.length === 0) {
|
||||
throw new Error('请添加收款明细');
|
||||
}
|
||||
// 检查每行的收款金额
|
||||
for (let i = 0; i < tableData.value.length; i++) {
|
||||
const item = tableData.value[i];
|
||||
if (!item.receiptPrice || item.receiptPrice <= 0) {
|
||||
throw new Error(`第 ${i + 1} 行:本次收款必须大于0`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
defineExpose({ validate });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<Grid class="w-full">
|
||||
<template #receiptPrice="{ row }">
|
||||
<ElInputNumber
|
||||
v-model="row.receiptPrice"
|
||||
:precision="2"
|
||||
:disabled="disabled"
|
||||
:formatter="erpPriceInputFormatter"
|
||||
placeholder="请输入本次收款"
|
||||
controls-position="right"
|
||||
class="!w-full"
|
||||
@change="handleRowChange(row)"
|
||||
/>
|
||||
</template>
|
||||
<template #remark="{ row }">
|
||||
<ElInput
|
||||
v-model="row.remark"
|
||||
:disabled="disabled"
|
||||
placeholder="请输入备注"
|
||||
@change="handleRowChange(row)"
|
||||
/>
|
||||
</template>
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
v-if="!disabled"
|
||||
:actions="[
|
||||
{
|
||||
label: '删除',
|
||||
type: 'danger',
|
||||
link: true,
|
||||
popConfirm: {
|
||||
title: '确认删除该收款明细吗?',
|
||||
confirm: handleDelete.bind(null, row),
|
||||
},
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<template #bottom>
|
||||
<div class="border-border bg-muted mt-2 rounded border p-2">
|
||||
<div class="text-muted-foreground flex justify-between text-sm">
|
||||
<span class="text-foreground font-medium">合计:</span>
|
||||
<div class="flex space-x-4">
|
||||
<span>
|
||||
合计收款:{{ erpPriceInputFormatter(summaries.totalPrice) }}
|
||||
</span>
|
||||
<span>
|
||||
已收金额:{{ erpPriceInputFormatter(summaries.receiptedPrice) }}
|
||||
</span>
|
||||
<span>
|
||||
本次收款:
|
||||
{{ erpPriceInputFormatter(summaries.receiptPrice) }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<TableAction
|
||||
v-if="!disabled"
|
||||
class="mt-2 flex justify-center"
|
||||
:actions="[
|
||||
{
|
||||
label: '添加销售出库单',
|
||||
type: 'default',
|
||||
onClick: handleOpenSaleOut,
|
||||
},
|
||||
{
|
||||
label: '添加销售退货单',
|
||||
type: 'default',
|
||||
onClick: handleOpenSaleReturn,
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
|
||||
<!-- 销售出库单选择组件 -->
|
||||
<SaleOutSelect ref="saleOutSelectRef" @success="handleAddSaleOut" />
|
||||
<!-- 销售退货单选择组件 -->
|
||||
<SaleReturnSelect
|
||||
ref="saleReturnSelectRef"
|
||||
@success="handleAddSaleReturn"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,110 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { ErpSaleOutApi } from '#/api/erp/sale/out';
|
||||
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { ElButton, ElDialog, ElMessage } from 'element-plus';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { getSaleOutPage } from '#/api/erp/sale/out';
|
||||
|
||||
import { useSaleOutGridColumns, useSaleOutGridFormSchema } from '../data';
|
||||
|
||||
const emit = defineEmits<{
|
||||
success: [rows: ErpSaleOutApi.SaleOut[]];
|
||||
}>();
|
||||
|
||||
const customerId = ref<number>(); // 客户ID
|
||||
const open = ref<boolean>(false); // 弹窗是否打开
|
||||
const selectedRows = ref<ErpSaleOutApi.SaleOut[]>([]); // 选中的行
|
||||
|
||||
/** 表格配置 */
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
formOptions: {
|
||||
schema: useSaleOutGridFormSchema(),
|
||||
},
|
||||
gridOptions: {
|
||||
columns: useSaleOutGridColumns(),
|
||||
height: 'auto',
|
||||
keepSource: true,
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }, formValues) => {
|
||||
return await getSaleOutPage({
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
customerId: customerId.value,
|
||||
receiptEnable: true, // 只查询可收款的
|
||||
...formValues,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
isHover: true,
|
||||
},
|
||||
checkboxConfig: {
|
||||
highlight: true,
|
||||
range: true,
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: true,
|
||||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<ErpSaleOutApi.SaleOut>,
|
||||
gridEvents: {
|
||||
checkboxChange: ({ records }: { records: ErpSaleOutApi.SaleOut[] }) => {
|
||||
selectedRows.value = records;
|
||||
},
|
||||
checkboxAll: ({ records }: { records: ErpSaleOutApi.SaleOut[] }) => {
|
||||
selectedRows.value = records;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
/** 打开弹窗 */
|
||||
function openModal(id: number) {
|
||||
// 重置数据
|
||||
customerId.value = id;
|
||||
open.value = true;
|
||||
selectedRows.value = [];
|
||||
// 查询列表
|
||||
gridApi.formApi?.resetForm();
|
||||
gridApi.formApi?.setValues({ customerId: id });
|
||||
gridApi.query();
|
||||
}
|
||||
|
||||
/** 确认选择销售出库单 */
|
||||
function handleOk() {
|
||||
if (selectedRows.value.length === 0) {
|
||||
ElMessage.warning('请选择要添加的销售出库单');
|
||||
return;
|
||||
}
|
||||
emit('success', selectedRows.value);
|
||||
open.value = false;
|
||||
}
|
||||
|
||||
defineExpose({ open: openModal });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ElDialog
|
||||
v-model="open"
|
||||
class="!w-[50vw]"
|
||||
title="选择销售出库单"
|
||||
@confirm="handleOk"
|
||||
>
|
||||
<Grid
|
||||
class="max-h-[600px]"
|
||||
table-title="销售出库单列表(仅展示可收款的单据)"
|
||||
/>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<ElButton @click="open = false">取消</ElButton>
|
||||
<ElButton type="primary" @click="handleOk">确定</ElButton>
|
||||
</div>
|
||||
</template>
|
||||
</ElDialog>
|
||||
</template>
|
||||
@@ -0,0 +1,114 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { ErpSaleReturnApi } from '#/api/erp/sale/return';
|
||||
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { ElButton, ElDialog, ElMessage } from 'element-plus';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { getSaleReturnPage } from '#/api/erp/sale/return';
|
||||
|
||||
import { useSaleReturnGridColumns, useSaleReturnGridFormSchema } from '../data';
|
||||
|
||||
const emit = defineEmits<{
|
||||
success: [rows: ErpSaleReturnApi.SaleReturn[]];
|
||||
}>();
|
||||
|
||||
const customerId = ref<number>(); // 客户ID
|
||||
const open = ref<boolean>(false); // 弹窗是否打开
|
||||
const selectedRows = ref<ErpSaleReturnApi.SaleReturn[]>([]); // 选中的行
|
||||
|
||||
/** 表格配置 */
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
formOptions: {
|
||||
schema: useSaleReturnGridFormSchema(),
|
||||
},
|
||||
gridOptions: {
|
||||
columns: useSaleReturnGridColumns(),
|
||||
height: 'auto',
|
||||
keepSource: true,
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }, formValues) => {
|
||||
return await getSaleReturnPage({
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
customerId: customerId.value,
|
||||
refundEnable: true, // 只查询可退款的
|
||||
...formValues,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
isHover: true,
|
||||
},
|
||||
checkboxConfig: {
|
||||
highlight: true,
|
||||
range: true,
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: true,
|
||||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<ErpSaleReturnApi.SaleReturn>,
|
||||
gridEvents: {
|
||||
checkboxChange: ({
|
||||
records,
|
||||
}: {
|
||||
records: ErpSaleReturnApi.SaleReturn[];
|
||||
}) => {
|
||||
selectedRows.value = records;
|
||||
},
|
||||
checkboxAll: ({ records }: { records: ErpSaleReturnApi.SaleReturn[] }) => {
|
||||
selectedRows.value = records;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
/** 打开弹窗 */
|
||||
function openModal(id: number) {
|
||||
// 重置数据
|
||||
customerId.value = id;
|
||||
open.value = true;
|
||||
selectedRows.value = [];
|
||||
// 查询列表
|
||||
gridApi.formApi?.resetForm();
|
||||
gridApi.formApi?.setValues({ customerId: id });
|
||||
gridApi.query();
|
||||
}
|
||||
|
||||
/** 确认选择销售退货单 */
|
||||
function handleOk() {
|
||||
if (selectedRows.value.length === 0) {
|
||||
ElMessage.warning('请选择要添加的销售退货单');
|
||||
return;
|
||||
}
|
||||
emit('success', selectedRows.value);
|
||||
open.value = false;
|
||||
}
|
||||
|
||||
defineExpose({ open: openModal });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ElDialog
|
||||
v-model="open"
|
||||
class="!w-[50vw]"
|
||||
title="选择销售退货单"
|
||||
@confirm="handleOk"
|
||||
>
|
||||
<Grid
|
||||
class="max-h-[600px]"
|
||||
table-title="销售退货单列表(仅展示可退款的单据)"
|
||||
/>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<ElButton @click="open = false">取消</ElButton>
|
||||
<ElButton type="primary" @click="handleOk">确定</ElButton>
|
||||
</div>
|
||||
</template>
|
||||
</ElDialog>
|
||||
</template>
|
||||
Reference in New Issue
Block a user