feat:【ele】【erp】stock 的迁移(10%)
This commit is contained in:
@@ -18,6 +18,7 @@ export namespace ErpStockCheckApi {
|
|||||||
items?: StockCheckItem[]; // 盘点产品清单
|
items?: StockCheckItem[]; // 盘点产品清单
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 库存盘点项 */
|
||||||
export interface StockCheckItem {
|
export interface StockCheckItem {
|
||||||
id?: number; // 编号
|
id?: number; // 编号
|
||||||
warehouseId?: number; // 仓库编号
|
warehouseId?: number; // 仓库编号
|
||||||
@@ -33,20 +34,10 @@ export namespace ErpStockCheckApi {
|
|||||||
stockCount?: number; // 账面库存
|
stockCount?: number; // 账面库存
|
||||||
remark?: string; // 备注
|
remark?: string; // 备注
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 库存盘点单分页查询参数 */
|
|
||||||
export interface StockCheckPageParams extends PageParam {
|
|
||||||
no?: string;
|
|
||||||
status?: number;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 查询库存盘点单分页 */
|
||||||
* 查询库存盘点单分页
|
export function getStockCheckPage(params: PageParam) {
|
||||||
*/
|
|
||||||
export function getStockCheckPage(
|
|
||||||
params: ErpStockCheckApi.StockCheckPageParams,
|
|
||||||
) {
|
|
||||||
return requestClient.get<PageResult<ErpStockCheckApi.StockCheck>>(
|
return requestClient.get<PageResult<ErpStockCheckApi.StockCheck>>(
|
||||||
'/erp/stock-check/page',
|
'/erp/stock-check/page',
|
||||||
{
|
{
|
||||||
@@ -55,41 +46,31 @@ export function getStockCheckPage(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 查询库存盘点单详情 */
|
||||||
* 查询库存盘点单详情
|
|
||||||
*/
|
|
||||||
export function getStockCheck(id: number) {
|
export function getStockCheck(id: number) {
|
||||||
return requestClient.get<ErpStockCheckApi.StockCheck>(
|
return requestClient.get<ErpStockCheckApi.StockCheck>(
|
||||||
`/erp/stock-check/get?id=${id}`,
|
`/erp/stock-check/get?id=${id}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 新增库存盘点单 */
|
||||||
* 新增库存盘点单
|
|
||||||
*/
|
|
||||||
export function createStockCheck(data: ErpStockCheckApi.StockCheck) {
|
export function createStockCheck(data: ErpStockCheckApi.StockCheck) {
|
||||||
return requestClient.post('/erp/stock-check/create', data);
|
return requestClient.post('/erp/stock-check/create', data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 修改库存盘点单 */
|
||||||
* 修改库存盘点单
|
|
||||||
*/
|
|
||||||
export function updateStockCheck(data: ErpStockCheckApi.StockCheck) {
|
export function updateStockCheck(data: ErpStockCheckApi.StockCheck) {
|
||||||
return requestClient.put('/erp/stock-check/update', data);
|
return requestClient.put('/erp/stock-check/update', data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 更新库存盘点单的状态 */
|
||||||
* 更新库存盘点单的状态
|
|
||||||
*/
|
|
||||||
export function updateStockCheckStatus(id: number, status: number) {
|
export function updateStockCheckStatus(id: number, status: number) {
|
||||||
return requestClient.put('/erp/stock-check/update-status', null, {
|
return requestClient.put('/erp/stock-check/update-status', null, {
|
||||||
params: { id, status },
|
params: { id, status },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 删除库存盘点 */
|
||||||
* 删除库存盘点单
|
|
||||||
*/
|
|
||||||
export function deleteStockCheck(ids: number[]) {
|
export function deleteStockCheck(ids: number[]) {
|
||||||
return requestClient.delete('/erp/stock-check/delete', {
|
return requestClient.delete('/erp/stock-check/delete', {
|
||||||
params: {
|
params: {
|
||||||
@@ -98,12 +79,8 @@ export function deleteStockCheck(ids: number[]) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 导出库存盘点单 Excel */
|
||||||
* 导出库存盘点单 Excel
|
export function exportStockCheck(params: any) {
|
||||||
*/
|
|
||||||
export function exportStockCheck(
|
|
||||||
params: ErpStockCheckApi.StockCheckPageParams,
|
|
||||||
) {
|
|
||||||
return requestClient.download('/erp/stock-check/export-excel', {
|
return requestClient.download('/erp/stock-check/export-excel', {
|
||||||
params,
|
params,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -35,19 +35,10 @@ export namespace ErpStockInApi {
|
|||||||
stockCount?: number; // 库存数量
|
stockCount?: number; // 库存数量
|
||||||
remark?: string; // 备注
|
remark?: string; // 备注
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 其它入库单分页查询参数 */
|
|
||||||
export interface StockInPageParams extends PageParam {
|
|
||||||
no?: string;
|
|
||||||
supplierId?: number;
|
|
||||||
status?: number;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 查询其它入库单分页 */
|
||||||
* 查询其它入库单分页
|
export function getStockInPage(params: PageParam) {
|
||||||
*/
|
|
||||||
export function getStockInPage(params: ErpStockInApi.StockInPageParams) {
|
|
||||||
return requestClient.get<PageResult<ErpStockInApi.StockIn>>(
|
return requestClient.get<PageResult<ErpStockInApi.StockIn>>(
|
||||||
'/erp/stock-in/page',
|
'/erp/stock-in/page',
|
||||||
{
|
{
|
||||||
@@ -56,39 +47,29 @@ export function getStockInPage(params: ErpStockInApi.StockInPageParams) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 查询其它入库单详情 */
|
||||||
* 查询其它入库单详情
|
|
||||||
*/
|
|
||||||
export function getStockIn(id: number) {
|
export function getStockIn(id: number) {
|
||||||
return requestClient.get<ErpStockInApi.StockIn>(`/erp/stock-in/get?id=${id}`);
|
return requestClient.get<ErpStockInApi.StockIn>(`/erp/stock-in/get?id=${id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 新增其它入库单 */
|
||||||
* 新增其它入库单
|
|
||||||
*/
|
|
||||||
export function createStockIn(data: ErpStockInApi.StockIn) {
|
export function createStockIn(data: ErpStockInApi.StockIn) {
|
||||||
return requestClient.post('/erp/stock-in/create', data);
|
return requestClient.post('/erp/stock-in/create', data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 修改其它入库单 */
|
||||||
* 修改其它入库单
|
|
||||||
*/
|
|
||||||
export function updateStockIn(data: ErpStockInApi.StockIn) {
|
export function updateStockIn(data: ErpStockInApi.StockIn) {
|
||||||
return requestClient.put('/erp/stock-in/update', data);
|
return requestClient.put('/erp/stock-in/update', data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 更新其它入库单的状态 */
|
||||||
* 更新其它入库单的状态
|
|
||||||
*/
|
|
||||||
export function updateStockInStatus(id: number, status: number) {
|
export function updateStockInStatus(id: number, status: number) {
|
||||||
return requestClient.put('/erp/stock-in/update-status', null, {
|
return requestClient.put('/erp/stock-in/update-status', null, {
|
||||||
params: { id, status },
|
params: { id, status },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 删除其它入库单 */
|
||||||
* 删除其它入库单
|
|
||||||
*/
|
|
||||||
export function deleteStockIn(ids: number[]) {
|
export function deleteStockIn(ids: number[]) {
|
||||||
return requestClient.delete('/erp/stock-in/delete', {
|
return requestClient.delete('/erp/stock-in/delete', {
|
||||||
params: {
|
params: {
|
||||||
@@ -97,10 +78,8 @@ export function deleteStockIn(ids: number[]) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 导出其它入库单 Excel */
|
||||||
* 导出其它入库单 Excel
|
export function exportStockIn(params: any) {
|
||||||
*/
|
|
||||||
export function exportStockIn(params: ErpStockInApi.StockInPageParams) {
|
|
||||||
return requestClient.download('/erp/stock-in/export-excel', {
|
return requestClient.download('/erp/stock-in/export-excel', {
|
||||||
params,
|
params,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -36,18 +36,10 @@ export namespace ErpStockMoveApi {
|
|||||||
toWarehouseId?: number; // 目标仓库ID
|
toWarehouseId?: number; // 目标仓库ID
|
||||||
totalPrice?: number; // 总价
|
totalPrice?: number; // 总价
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 库存调拨单分页查询参数 */
|
|
||||||
export interface StockMovePageParams extends PageParam {
|
|
||||||
no?: string;
|
|
||||||
status?: number;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 查询库存调拨单分页 */
|
||||||
* 查询库存调拨单分页
|
export function getStockMovePage(params: PageParam) {
|
||||||
*/
|
|
||||||
export function getStockMovePage(params: ErpStockMoveApi.StockMovePageParams) {
|
|
||||||
return requestClient.get<PageResult<ErpStockMoveApi.StockMove>>(
|
return requestClient.get<PageResult<ErpStockMoveApi.StockMove>>(
|
||||||
'/erp/stock-move/page',
|
'/erp/stock-move/page',
|
||||||
{
|
{
|
||||||
@@ -56,41 +48,31 @@ export function getStockMovePage(params: ErpStockMoveApi.StockMovePageParams) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 查询库存调拨单详情 */
|
||||||
* 查询库存调拨单详情
|
|
||||||
*/
|
|
||||||
export function getStockMove(id: number) {
|
export function getStockMove(id: number) {
|
||||||
return requestClient.get<ErpStockMoveApi.StockMove>(
|
return requestClient.get<ErpStockMoveApi.StockMove>(
|
||||||
`/erp/stock-move/get?id=${id}`,
|
`/erp/stock-move/get?id=${id}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 新增库存调拨单 */
|
||||||
* 新增库存调拨单
|
|
||||||
*/
|
|
||||||
export function createStockMove(data: ErpStockMoveApi.StockMove) {
|
export function createStockMove(data: ErpStockMoveApi.StockMove) {
|
||||||
return requestClient.post('/erp/stock-move/create', data);
|
return requestClient.post('/erp/stock-move/create', data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 修改库存调拨单 */
|
||||||
* 修改库存调拨单
|
|
||||||
*/
|
|
||||||
export function updateStockMove(data: ErpStockMoveApi.StockMove) {
|
export function updateStockMove(data: ErpStockMoveApi.StockMove) {
|
||||||
return requestClient.put('/erp/stock-move/update', data);
|
return requestClient.put('/erp/stock-move/update', data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 更新库存调拨单的状态 */
|
||||||
* 更新库存调拨单的状态
|
|
||||||
*/
|
|
||||||
export function updateStockMoveStatus(id: number, status: number) {
|
export function updateStockMoveStatus(id: number, status: number) {
|
||||||
return requestClient.put('/erp/stock-move/update-status', null, {
|
return requestClient.put('/erp/stock-move/update-status', null, {
|
||||||
params: { id, status },
|
params: { id, status },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 删除库存调拨单 */
|
||||||
* 删除库存调拨单
|
|
||||||
*/
|
|
||||||
export function deleteStockMove(ids: number[]) {
|
export function deleteStockMove(ids: number[]) {
|
||||||
return requestClient.delete('/erp/stock-move/delete', {
|
return requestClient.delete('/erp/stock-move/delete', {
|
||||||
params: {
|
params: {
|
||||||
@@ -99,9 +81,7 @@ export function deleteStockMove(ids: number[]) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 导出库存调拨单 Excel */
|
||||||
* 导出库存调拨单 Excel
|
export function exportStockMove(params: any) {
|
||||||
*/
|
|
||||||
export function exportStockMove(params: ErpStockMoveApi.StockMovePageParams) {
|
|
||||||
return requestClient.download('/erp/stock-move/export-excel', { params });
|
return requestClient.download('/erp/stock-move/export-excel', { params });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,19 +32,10 @@ export namespace ErpStockOutApi {
|
|||||||
stockCount?: number; // 库存数量
|
stockCount?: number; // 库存数量
|
||||||
remark?: string; // 备注
|
remark?: string; // 备注
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 其它出库单分页查询参数 */
|
|
||||||
export interface StockOutPageParams extends PageParam {
|
|
||||||
no?: string;
|
|
||||||
customerId?: number;
|
|
||||||
status?: number;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 查询其它出库单分页 */
|
||||||
* 查询其它出库单分页
|
export function getStockOutPage(params: PageParam) {
|
||||||
*/
|
|
||||||
export function getStockOutPage(params: ErpStockOutApi.StockOutPageParams) {
|
|
||||||
return requestClient.get<PageResult<ErpStockOutApi.StockOut>>(
|
return requestClient.get<PageResult<ErpStockOutApi.StockOut>>(
|
||||||
'/erp/stock-out/page',
|
'/erp/stock-out/page',
|
||||||
{
|
{
|
||||||
@@ -53,41 +44,31 @@ export function getStockOutPage(params: ErpStockOutApi.StockOutPageParams) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 查询其它出库单详情 */
|
||||||
* 查询其它出库单详情
|
|
||||||
*/
|
|
||||||
export function getStockOut(id: number) {
|
export function getStockOut(id: number) {
|
||||||
return requestClient.get<ErpStockOutApi.StockOut>(
|
return requestClient.get<ErpStockOutApi.StockOut>(
|
||||||
`/erp/stock-out/get?id=${id}`,
|
`/erp/stock-out/get?id=${id}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 新增其它出库单 */
|
||||||
* 新增其它出库单
|
|
||||||
*/
|
|
||||||
export function createStockOut(data: ErpStockOutApi.StockOut) {
|
export function createStockOut(data: ErpStockOutApi.StockOut) {
|
||||||
return requestClient.post('/erp/stock-out/create', data);
|
return requestClient.post('/erp/stock-out/create', data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 修改其它出库单 */
|
||||||
* 修改其它出库单
|
|
||||||
*/
|
|
||||||
export function updateStockOut(data: ErpStockOutApi.StockOut) {
|
export function updateStockOut(data: ErpStockOutApi.StockOut) {
|
||||||
return requestClient.put('/erp/stock-out/update', data);
|
return requestClient.put('/erp/stock-out/update', data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 更新其它出库单的状态 */
|
||||||
* 更新其它出库单的状态
|
|
||||||
*/
|
|
||||||
export function updateStockOutStatus(id: number, status: number) {
|
export function updateStockOutStatus(id: number, status: number) {
|
||||||
return requestClient.put('/erp/stock-out/update-status', null, {
|
return requestClient.put('/erp/stock-out/update-status', null, {
|
||||||
params: { id, status },
|
params: { id, status },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 删除其它出库单 */
|
||||||
* 删除其它出库单
|
|
||||||
*/
|
|
||||||
export function deleteStockOut(ids: number[]) {
|
export function deleteStockOut(ids: number[]) {
|
||||||
return requestClient.delete('/erp/stock-out/delete', {
|
return requestClient.delete('/erp/stock-out/delete', {
|
||||||
params: {
|
params: {
|
||||||
@@ -96,10 +77,8 @@ export function deleteStockOut(ids: number[]) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 导出其它出库单 Excel */
|
||||||
* 导出其它出库单 Excel
|
export function exportStockOut(params: any) {
|
||||||
*/
|
|
||||||
export function exportStockOut(params: ErpStockOutApi.StockOutPageParams) {
|
|
||||||
return requestClient.download('/erp/stock-out/export-excel', {
|
return requestClient.download('/erp/stock-out/export-excel', {
|
||||||
params,
|
params,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import type { PageParam, PageResult } from '@vben/request';
|
|||||||
import { requestClient } from '#/api/request';
|
import { requestClient } from '#/api/request';
|
||||||
|
|
||||||
export namespace ErpStockRecordApi {
|
export namespace ErpStockRecordApi {
|
||||||
/** ERP 产品库存明细 */
|
/** 产品库存明细 */
|
||||||
export interface StockRecord {
|
export interface StockRecord {
|
||||||
id?: number; // 编号
|
id?: number; // 编号
|
||||||
productId: number; // 产品编号
|
productId: number; // 产品编号
|
||||||
@@ -15,32 +15,16 @@ export namespace ErpStockRecordApi {
|
|||||||
bizItemId: number; // 业务项编号
|
bizItemId: number; // 业务项编号
|
||||||
bizNo: string; // 业务单号
|
bizNo: string; // 业务单号
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 库存记录分页查询参数 */
|
|
||||||
export interface StockRecordPageParam extends PageParam {
|
|
||||||
productId?: number;
|
|
||||||
warehouseId?: number;
|
|
||||||
bizType?: number;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 查询产品库存明细分页 */
|
/** 查询产品库存明细分页 */
|
||||||
export function getStockRecordPage(
|
export function getStockRecordPage(params: PageParam) {
|
||||||
params: ErpStockRecordApi.StockRecordPageParam,
|
|
||||||
) {
|
|
||||||
return requestClient.get<PageResult<ErpStockRecordApi.StockRecord>>(
|
return requestClient.get<PageResult<ErpStockRecordApi.StockRecord>>(
|
||||||
'/erp/stock-record/page',
|
'/erp/stock-record/page',
|
||||||
{ params },
|
{ params },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 查询产品库存明细详情 */
|
|
||||||
export function getStockRecord(id: number) {
|
|
||||||
return requestClient.get<ErpStockRecordApi.StockRecord>(
|
|
||||||
`/erp/stock-record/get?id=${id}`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 导出产品库存明细 Excel */
|
/** 导出产品库存明细 Excel */
|
||||||
export function exportStockRecord(params: any) {
|
export function exportStockRecord(params: any) {
|
||||||
return requestClient.download('/erp/stock-record/export-excel', { params });
|
return requestClient.download('/erp/stock-record/export-excel', { params });
|
||||||
|
|||||||
@@ -11,49 +11,21 @@ export namespace ErpStockApi {
|
|||||||
count: number; // 库存数量
|
count: number; // 库存数量
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 产品库存分页查询参数 */
|
|
||||||
export interface StockPageParams extends PageParam {
|
|
||||||
productId?: number;
|
|
||||||
warehouseId?: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 产品库存查询参数 */
|
/** 产品库存查询参数 */
|
||||||
export interface StockQueryParams {
|
export interface StockQueryReqVO {
|
||||||
productId: number;
|
productId: number;
|
||||||
warehouseId: number;
|
warehouseId: number;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 查询产品库存分页 */
|
||||||
* 查询产品库存分页
|
export function getStockPage(params: PageParam) {
|
||||||
*/
|
|
||||||
export function getStockPage(params: ErpStockApi.StockPageParams) {
|
|
||||||
return requestClient.get<PageResult<ErpStockApi.Stock>>('/erp/stock/page', {
|
return requestClient.get<PageResult<ErpStockApi.Stock>>('/erp/stock/page', {
|
||||||
params,
|
params,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 获得产品库存数量 */
|
||||||
* 查询产品库存详情
|
|
||||||
*/
|
|
||||||
export function getStock(id: number) {
|
|
||||||
return requestClient.get<ErpStockApi.Stock>(`/erp/stock/get?id=${id}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据产品和仓库查询库存详情
|
|
||||||
*/
|
|
||||||
export function getStockByProductAndWarehouse(
|
|
||||||
params: ErpStockApi.StockQueryParams,
|
|
||||||
) {
|
|
||||||
return requestClient.get<ErpStockApi.Stock>('/erp/stock/get', {
|
|
||||||
params,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获得产品库存数量
|
|
||||||
*/
|
|
||||||
export function getStockCount(productId: number, warehouseId?: number) {
|
export function getStockCount(productId: number, warehouseId?: number) {
|
||||||
const params: any = { productId };
|
const params: any = { productId };
|
||||||
if (warehouseId !== undefined) {
|
if (warehouseId !== undefined) {
|
||||||
@@ -64,19 +36,15 @@ export function getStockCount(productId: number, warehouseId?: number) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 导出产品库存 Excel */
|
||||||
* 导出产品库存 Excel
|
export function exportStock(params: any) {
|
||||||
*/
|
|
||||||
export function exportStock(params: ErpStockApi.StockPageParams) {
|
|
||||||
return requestClient.download('/erp/stock/export-excel', {
|
return requestClient.download('/erp/stock/export-excel', {
|
||||||
params,
|
params,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** 获取库存数量 */
|
||||||
* 获取库存数量
|
export function getWarehouseStockCount(params: ErpStockApi.StockQueryReqVO) {
|
||||||
*/
|
|
||||||
export function getWarehouseStockCount(params: ErpStockApi.StockQueryParams) {
|
|
||||||
return requestClient.get<number>('/erp/stock/get-count', {
|
return requestClient.get<number>('/erp/stock/get-count', {
|
||||||
params,
|
params,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import type { PageParam, PageResult } from '@vben/request';
|
|||||||
import { requestClient } from '#/api/request';
|
import { requestClient } from '#/api/request';
|
||||||
|
|
||||||
export namespace ErpWarehouseApi {
|
export namespace ErpWarehouseApi {
|
||||||
/** ERP 仓库信息 */
|
/** 仓库信息 */
|
||||||
export interface Warehouse {
|
export interface Warehouse {
|
||||||
id?: number; // 仓库编号
|
id?: number; // 仓库编号
|
||||||
name: string; // 仓库名称
|
name: string; // 仓库名称
|
||||||
@@ -16,16 +16,10 @@ export namespace ErpWarehouseApi {
|
|||||||
status: number; // 开启状态
|
status: number; // 开启状态
|
||||||
defaultStatus: boolean; // 是否默认
|
defaultStatus: boolean; // 是否默认
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 仓库分页查询参数 */
|
|
||||||
export interface WarehousePageParam extends PageParam {
|
|
||||||
name?: string;
|
|
||||||
status?: number;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 查询仓库分页 */
|
/** 查询仓库分页 */
|
||||||
export function getWarehousePage(params: ErpWarehouseApi.WarehousePageParam) {
|
export function getWarehousePage(params: PageParam) {
|
||||||
return requestClient.get<PageResult<ErpWarehouseApi.Warehouse>>(
|
return requestClient.get<PageResult<ErpWarehouseApi.Warehouse>>(
|
||||||
'/erp/warehouse/page',
|
'/erp/warehouse/page',
|
||||||
{ params },
|
{ params },
|
||||||
|
|||||||
87
apps/web-ele/src/api/erp/stock/check/index.ts
Normal file
87
apps/web-ele/src/api/erp/stock/check/index.ts
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
import type { PageParam, PageResult } from '@vben/request';
|
||||||
|
|
||||||
|
import { requestClient } from '#/api/request';
|
||||||
|
|
||||||
|
export namespace ErpStockCheckApi {
|
||||||
|
/** 库存盘点单信息 */
|
||||||
|
export interface StockCheck {
|
||||||
|
id?: number; // 盘点编号
|
||||||
|
no: string; // 盘点单号
|
||||||
|
checkTime: Date; // 盘点时间
|
||||||
|
totalCount: number; // 合计数量
|
||||||
|
totalPrice: number; // 合计金额,单位:元
|
||||||
|
status: number; // 状态
|
||||||
|
remark: string; // 备注
|
||||||
|
fileUrl?: string; // 附件
|
||||||
|
productNames?: string; // 产品信息
|
||||||
|
creatorName?: string; // 创建人
|
||||||
|
items?: StockCheckItem[]; // 盘点产品清单
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 库存盘点项 */
|
||||||
|
export interface StockCheckItem {
|
||||||
|
id?: number; // 编号
|
||||||
|
warehouseId?: number; // 仓库编号
|
||||||
|
productId?: number; // 产品编号
|
||||||
|
productName?: string; // 产品名称
|
||||||
|
productUnitId?: number; // 产品单位编号
|
||||||
|
productUnitName?: string; // 产品单位名称
|
||||||
|
productBarCode?: string; // 产品条码
|
||||||
|
count?: number; // 盈亏数量
|
||||||
|
actualCount?: number; // 实际库存
|
||||||
|
productPrice?: number; // 产品单价
|
||||||
|
totalPrice?: number; // 总价
|
||||||
|
stockCount?: number; // 账面库存
|
||||||
|
remark?: string; // 备注
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询库存盘点单分页 */
|
||||||
|
export function getStockCheckPage(params: PageParam) {
|
||||||
|
return requestClient.get<PageResult<ErpStockCheckApi.StockCheck>>(
|
||||||
|
'/erp/stock-check/page',
|
||||||
|
{
|
||||||
|
params,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询库存盘点单详情 */
|
||||||
|
export function getStockCheck(id: number) {
|
||||||
|
return requestClient.get<ErpStockCheckApi.StockCheck>(
|
||||||
|
`/erp/stock-check/get?id=${id}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 新增库存盘点单 */
|
||||||
|
export function createStockCheck(data: ErpStockCheckApi.StockCheck) {
|
||||||
|
return requestClient.post('/erp/stock-check/create', data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 修改库存盘点单 */
|
||||||
|
export function updateStockCheck(data: ErpStockCheckApi.StockCheck) {
|
||||||
|
return requestClient.put('/erp/stock-check/update', data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 更新库存盘点单的状态 */
|
||||||
|
export function updateStockCheckStatus(id: number, status: number) {
|
||||||
|
return requestClient.put('/erp/stock-check/update-status', null, {
|
||||||
|
params: { id, status },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除库存盘点 */
|
||||||
|
export function deleteStockCheck(ids: number[]) {
|
||||||
|
return requestClient.delete('/erp/stock-check/delete', {
|
||||||
|
params: {
|
||||||
|
ids: ids.join(','),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 导出库存盘点单 Excel */
|
||||||
|
export function exportStockCheck(params: any) {
|
||||||
|
return requestClient.download('/erp/stock-check/export-excel', {
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
}
|
||||||
86
apps/web-ele/src/api/erp/stock/in/index.ts
Normal file
86
apps/web-ele/src/api/erp/stock/in/index.ts
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
import type { PageParam, PageResult } from '@vben/request';
|
||||||
|
|
||||||
|
import { requestClient } from '#/api/request';
|
||||||
|
|
||||||
|
export namespace ErpStockInApi {
|
||||||
|
/** 其它入库单信息 */
|
||||||
|
export interface StockIn {
|
||||||
|
id?: number; // 入库编号
|
||||||
|
no: string; // 入库单号
|
||||||
|
supplierId: number; // 供应商编号
|
||||||
|
supplierName?: string; // 供应商名称
|
||||||
|
inTime: Date; // 入库时间
|
||||||
|
totalCount: number; // 合计数量
|
||||||
|
totalPrice: number; // 合计金额,单位:元
|
||||||
|
status: number; // 状态
|
||||||
|
remark: string; // 备注
|
||||||
|
fileUrl?: string; // 附件
|
||||||
|
productNames?: string; // 产品信息
|
||||||
|
creatorName?: string; // 创建人
|
||||||
|
items?: StockInItem[]; // 入库产品清单
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 其它入库单产品信息 */
|
||||||
|
export interface StockInItem {
|
||||||
|
id?: number; // 编号
|
||||||
|
warehouseId: number; // 仓库编号
|
||||||
|
productId: number; // 产品编号
|
||||||
|
productName?: string; // 产品名称
|
||||||
|
productUnitId?: number; // 产品单位编号
|
||||||
|
productUnitName?: string; // 产品单位名称
|
||||||
|
productBarCode?: string; // 产品条码
|
||||||
|
count: number; // 数量
|
||||||
|
productPrice: number; // 产品单价
|
||||||
|
totalPrice: number; // 总价
|
||||||
|
stockCount?: number; // 库存数量
|
||||||
|
remark?: string; // 备注
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询其它入库单分页 */
|
||||||
|
export function getStockInPage(params: PageParam) {
|
||||||
|
return requestClient.get<PageResult<ErpStockInApi.StockIn>>(
|
||||||
|
'/erp/stock-in/page',
|
||||||
|
{
|
||||||
|
params,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询其它入库单详情 */
|
||||||
|
export function getStockIn(id: number) {
|
||||||
|
return requestClient.get<ErpStockInApi.StockIn>(`/erp/stock-in/get?id=${id}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 新增其它入库单 */
|
||||||
|
export function createStockIn(data: ErpStockInApi.StockIn) {
|
||||||
|
return requestClient.post('/erp/stock-in/create', data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 修改其它入库单 */
|
||||||
|
export function updateStockIn(data: ErpStockInApi.StockIn) {
|
||||||
|
return requestClient.put('/erp/stock-in/update', data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 更新其它入库单的状态 */
|
||||||
|
export function updateStockInStatus(id: number, status: number) {
|
||||||
|
return requestClient.put('/erp/stock-in/update-status', null, {
|
||||||
|
params: { id, status },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除其它入库单 */
|
||||||
|
export function deleteStockIn(ids: number[]) {
|
||||||
|
return requestClient.delete('/erp/stock-in/delete', {
|
||||||
|
params: {
|
||||||
|
ids: ids.join(','),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 导出其它入库单 Excel */
|
||||||
|
export function exportStockIn(params: any) {
|
||||||
|
return requestClient.download('/erp/stock-in/export-excel', {
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
}
|
||||||
87
apps/web-ele/src/api/erp/stock/move/index.ts
Normal file
87
apps/web-ele/src/api/erp/stock/move/index.ts
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
import type { PageParam, PageResult } from '@vben/request';
|
||||||
|
|
||||||
|
import { requestClient } from '#/api/request';
|
||||||
|
|
||||||
|
export namespace ErpStockMoveApi {
|
||||||
|
/** 库存调拨单信息 */
|
||||||
|
export interface StockMove {
|
||||||
|
id?: number; // 调拨编号
|
||||||
|
no: string; // 调拨单号
|
||||||
|
outTime: Date; // 调拨时间
|
||||||
|
totalCount: number; // 合计数量
|
||||||
|
totalPrice: number; // 合计金额,单位:元
|
||||||
|
status: number; // 状态
|
||||||
|
remark: string; // 备注
|
||||||
|
fileUrl?: string; // 附件
|
||||||
|
fromWarehouseId?: number; // 来源仓库编号
|
||||||
|
createTime: Date; // 创建时间
|
||||||
|
creator: string; // 创建人
|
||||||
|
creatorName: string; // 创建人名称
|
||||||
|
productNames: string; // 产品名称
|
||||||
|
items?: StockMoveItem[]; // 子表信息
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 库存调拨单子表信息 */
|
||||||
|
export interface StockMoveItem {
|
||||||
|
count: number; // 数量
|
||||||
|
fromWarehouseId?: number; // 来源仓库ID
|
||||||
|
id?: number; // ID
|
||||||
|
productBarCode: string; // 产品条形码
|
||||||
|
productId?: number; // 产品ID
|
||||||
|
productName?: string; // 产品名称
|
||||||
|
productPrice: number; // 产品单价
|
||||||
|
productUnitName?: string; // 产品单位
|
||||||
|
remark?: string; // 备注
|
||||||
|
stockCount: number; // 库存数量
|
||||||
|
toWarehouseId?: number; // 目标仓库ID
|
||||||
|
totalPrice?: number; // 总价
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询库存调拨单分页 */
|
||||||
|
export function getStockMovePage(params: PageParam) {
|
||||||
|
return requestClient.get<PageResult<ErpStockMoveApi.StockMove>>(
|
||||||
|
'/erp/stock-move/page',
|
||||||
|
{
|
||||||
|
params,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询库存调拨单详情 */
|
||||||
|
export function getStockMove(id: number) {
|
||||||
|
return requestClient.get<ErpStockMoveApi.StockMove>(
|
||||||
|
`/erp/stock-move/get?id=${id}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 新增库存调拨单 */
|
||||||
|
export function createStockMove(data: ErpStockMoveApi.StockMove) {
|
||||||
|
return requestClient.post('/erp/stock-move/create', data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 修改库存调拨单 */
|
||||||
|
export function updateStockMove(data: ErpStockMoveApi.StockMove) {
|
||||||
|
return requestClient.put('/erp/stock-move/update', data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 更新库存调拨单的状态 */
|
||||||
|
export function updateStockMoveStatus(id: number, status: number) {
|
||||||
|
return requestClient.put('/erp/stock-move/update-status', null, {
|
||||||
|
params: { id, status },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除库存调拨单 */
|
||||||
|
export function deleteStockMove(ids: number[]) {
|
||||||
|
return requestClient.delete('/erp/stock-move/delete', {
|
||||||
|
params: {
|
||||||
|
ids: ids.join(','),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 导出库存调拨单 Excel */
|
||||||
|
export function exportStockMove(params: any) {
|
||||||
|
return requestClient.download('/erp/stock-move/export-excel', { params });
|
||||||
|
}
|
||||||
85
apps/web-ele/src/api/erp/stock/out/index.ts
Normal file
85
apps/web-ele/src/api/erp/stock/out/index.ts
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
import type { PageParam, PageResult } from '@vben/request';
|
||||||
|
|
||||||
|
import { requestClient } from '#/api/request';
|
||||||
|
|
||||||
|
export namespace ErpStockOutApi {
|
||||||
|
/** 其它出库单信息 */
|
||||||
|
export interface StockOut {
|
||||||
|
id?: number; // 出库编号
|
||||||
|
no: string; // 出库单号
|
||||||
|
customerId: number; // 客户编号
|
||||||
|
outTime: Date; // 出库时间
|
||||||
|
totalCount: number; // 合计数量
|
||||||
|
totalPrice: number; // 合计金额,单位:元
|
||||||
|
status: number; // 状态
|
||||||
|
remark: string; // 备注
|
||||||
|
fileUrl?: string; // 附件
|
||||||
|
items?: StockOutItem[]; // 出库产品清单
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 其它出库单产品信息 */
|
||||||
|
export interface StockOutItem {
|
||||||
|
id?: number; // 编号
|
||||||
|
warehouseId?: number; // 仓库编号
|
||||||
|
productId?: number; // 产品编号
|
||||||
|
productName?: string; // 产品名称
|
||||||
|
productUnitId?: number; // 产品单位编号
|
||||||
|
productUnitName?: string; // 产品单位名称
|
||||||
|
productBarCode?: string; // 产品条码
|
||||||
|
count: number; // 数量
|
||||||
|
productPrice: number; // 产品单价
|
||||||
|
totalPrice: number; // 总价
|
||||||
|
stockCount?: number; // 库存数量
|
||||||
|
remark?: string; // 备注
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询其它出库单分页 */
|
||||||
|
export function getStockOutPage(params: PageParam) {
|
||||||
|
return requestClient.get<PageResult<ErpStockOutApi.StockOut>>(
|
||||||
|
'/erp/stock-out/page',
|
||||||
|
{
|
||||||
|
params,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询其它出库单详情 */
|
||||||
|
export function getStockOut(id: number) {
|
||||||
|
return requestClient.get<ErpStockOutApi.StockOut>(
|
||||||
|
`/erp/stock-out/get?id=${id}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 新增其它出库单 */
|
||||||
|
export function createStockOut(data: ErpStockOutApi.StockOut) {
|
||||||
|
return requestClient.post('/erp/stock-out/create', data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 修改其它出库单 */
|
||||||
|
export function updateStockOut(data: ErpStockOutApi.StockOut) {
|
||||||
|
return requestClient.put('/erp/stock-out/update', data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 更新其它出库单的状态 */
|
||||||
|
export function updateStockOutStatus(id: number, status: number) {
|
||||||
|
return requestClient.put('/erp/stock-out/update-status', null, {
|
||||||
|
params: { id, status },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除其它出库单 */
|
||||||
|
export function deleteStockOut(ids: number[]) {
|
||||||
|
return requestClient.delete('/erp/stock-out/delete', {
|
||||||
|
params: {
|
||||||
|
ids: ids.join(','),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 导出其它出库单 Excel */
|
||||||
|
export function exportStockOut(params: any) {
|
||||||
|
return requestClient.download('/erp/stock-out/export-excel', {
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
}
|
||||||
31
apps/web-ele/src/api/erp/stock/record/index.ts
Normal file
31
apps/web-ele/src/api/erp/stock/record/index.ts
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
import type { PageParam, PageResult } from '@vben/request';
|
||||||
|
|
||||||
|
import { requestClient } from '#/api/request';
|
||||||
|
|
||||||
|
export namespace ErpStockRecordApi {
|
||||||
|
/** 产品库存明细 */
|
||||||
|
export interface StockRecord {
|
||||||
|
id?: number; // 编号
|
||||||
|
productId: number; // 产品编号
|
||||||
|
warehouseId: number; // 仓库编号
|
||||||
|
count: number; // 出入库数量
|
||||||
|
totalCount: number; // 总库存量
|
||||||
|
bizType: number; // 业务类型
|
||||||
|
bizId: number; // 业务编号
|
||||||
|
bizItemId: number; // 业务项编号
|
||||||
|
bizNo: string; // 业务单号
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询产品库存明细分页 */
|
||||||
|
export function getStockRecordPage(params: PageParam) {
|
||||||
|
return requestClient.get<PageResult<ErpStockRecordApi.StockRecord>>(
|
||||||
|
'/erp/stock-record/page',
|
||||||
|
{ params },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 导出产品库存明细 Excel */
|
||||||
|
export function exportStockRecord(params: any) {
|
||||||
|
return requestClient.download('/erp/stock-record/export-excel', { params });
|
||||||
|
}
|
||||||
51
apps/web-ele/src/api/erp/stock/stock/index.ts
Normal file
51
apps/web-ele/src/api/erp/stock/stock/index.ts
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
import type { PageParam, PageResult } from '@vben/request';
|
||||||
|
|
||||||
|
import { requestClient } from '#/api/request';
|
||||||
|
|
||||||
|
export namespace ErpStockApi {
|
||||||
|
/** 产品库存信息 */
|
||||||
|
export interface Stock {
|
||||||
|
id?: number; // 编号
|
||||||
|
productId: number; // 产品编号
|
||||||
|
warehouseId: number; // 仓库编号
|
||||||
|
count: number; // 库存数量
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 产品库存查询参数 */
|
||||||
|
export interface StockQueryReqVO {
|
||||||
|
productId: number;
|
||||||
|
warehouseId: number;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询产品库存分页 */
|
||||||
|
export function getStockPage(params: PageParam) {
|
||||||
|
return requestClient.get<PageResult<ErpStockApi.Stock>>('/erp/stock/page', {
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 获得产品库存数量 */
|
||||||
|
export function getStockCount(productId: number, warehouseId?: number) {
|
||||||
|
const params: any = { productId };
|
||||||
|
if (warehouseId !== undefined) {
|
||||||
|
params.warehouseId = warehouseId;
|
||||||
|
}
|
||||||
|
return requestClient.get<number>('/erp/stock/get-count', {
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 导出产品库存 Excel */
|
||||||
|
export function exportStock(params: any) {
|
||||||
|
return requestClient.download('/erp/stock/export-excel', {
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 获取库存数量 */
|
||||||
|
export function getWarehouseStockCount(params: ErpStockApi.StockQueryReqVO) {
|
||||||
|
return requestClient.get<number>('/erp/stock/get-count', {
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
}
|
||||||
71
apps/web-ele/src/api/erp/stock/warehouse/index.ts
Normal file
71
apps/web-ele/src/api/erp/stock/warehouse/index.ts
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
import type { PageParam, PageResult } from '@vben/request';
|
||||||
|
|
||||||
|
import { requestClient } from '#/api/request';
|
||||||
|
|
||||||
|
export namespace ErpWarehouseApi {
|
||||||
|
/** 仓库信息 */
|
||||||
|
export interface Warehouse {
|
||||||
|
id?: number; // 仓库编号
|
||||||
|
name: string; // 仓库名称
|
||||||
|
address: string; // 仓库地址
|
||||||
|
sort: number; // 排序
|
||||||
|
remark: string; // 备注
|
||||||
|
principal: string; // 负责人
|
||||||
|
warehousePrice: number; // 仓储费,单位:元
|
||||||
|
truckagePrice: number; // 搬运费,单位:元
|
||||||
|
status: number; // 开启状态
|
||||||
|
defaultStatus: boolean; // 是否默认
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询仓库分页 */
|
||||||
|
export function getWarehousePage(params: PageParam) {
|
||||||
|
return requestClient.get<PageResult<ErpWarehouseApi.Warehouse>>(
|
||||||
|
'/erp/warehouse/page',
|
||||||
|
{ params },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询仓库精简列表 */
|
||||||
|
export function getWarehouseSimpleList() {
|
||||||
|
return requestClient.get<ErpWarehouseApi.Warehouse[]>(
|
||||||
|
'/erp/warehouse/simple-list',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询仓库详情 */
|
||||||
|
export function getWarehouse(id: number) {
|
||||||
|
return requestClient.get<ErpWarehouseApi.Warehouse>(
|
||||||
|
`/erp/warehouse/get?id=${id}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 新增仓库 */
|
||||||
|
export function createWarehouse(data: ErpWarehouseApi.Warehouse) {
|
||||||
|
return requestClient.post('/erp/warehouse/create', data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 修改仓库 */
|
||||||
|
export function updateWarehouse(data: ErpWarehouseApi.Warehouse) {
|
||||||
|
return requestClient.put('/erp/warehouse/update', data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 修改仓库默认状态 */
|
||||||
|
export function updateWarehouseDefaultStatus(
|
||||||
|
id: number,
|
||||||
|
defaultStatus: boolean,
|
||||||
|
) {
|
||||||
|
return requestClient.put('/erp/warehouse/update-default-status', null, {
|
||||||
|
params: { id, defaultStatus },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除仓库 */
|
||||||
|
export function deleteWarehouse(id: number) {
|
||||||
|
return requestClient.delete(`/erp/warehouse/delete?id=${id}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 导出仓库 Excel */
|
||||||
|
export function exportWarehouse(params: any) {
|
||||||
|
return requestClient.download('/erp/warehouse/export-excel', { params });
|
||||||
|
}
|
||||||
305
apps/web-ele/src/views/erp/stock/check/data.ts
Normal file
305
apps/web-ele/src/views/erp/stock/check/data.ts
Normal file
@@ -0,0 +1,305 @@
|
|||||||
|
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 { getProductSimpleList } from '#/api/erp/product/product';
|
||||||
|
import { getWarehouseSimpleList } from '#/api/erp/stock/warehouse';
|
||||||
|
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: 'checkTime',
|
||||||
|
label: '盘点时间',
|
||||||
|
component: 'DatePicker',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '选择盘点时间',
|
||||||
|
showTime: true,
|
||||||
|
format: 'YYYY-MM-DD HH:mm:ss',
|
||||||
|
valueFormat: 'x',
|
||||||
|
class: '!w-full',
|
||||||
|
},
|
||||||
|
rules: 'required',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
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',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 表单的明细表格列 */
|
||||||
|
export function useFormItemColumns(): VxeTableGridOptions['columns'] {
|
||||||
|
return [
|
||||||
|
{ type: 'seq', title: '序号', minWidth: 50, fixed: 'left' },
|
||||||
|
{
|
||||||
|
field: 'warehouseId',
|
||||||
|
title: '仓库名称',
|
||||||
|
minWidth: 150,
|
||||||
|
slots: { default: 'warehouseId' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'productId',
|
||||||
|
title: '产品名称',
|
||||||
|
minWidth: 200,
|
||||||
|
slots: { default: 'productId' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'stockCount',
|
||||||
|
title: '账面库存',
|
||||||
|
minWidth: 80,
|
||||||
|
formatter: 'formatAmount3',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'productBarCode',
|
||||||
|
title: '条码',
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'productUnitName',
|
||||||
|
title: '单位',
|
||||||
|
minWidth: 80,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'remark',
|
||||||
|
title: '备注',
|
||||||
|
minWidth: 150,
|
||||||
|
slots: { default: 'remark' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'actualCount',
|
||||||
|
title: '实际库存',
|
||||||
|
minWidth: 120,
|
||||||
|
fixed: 'right',
|
||||||
|
slots: { default: 'actualCount' },
|
||||||
|
formatter: 'formatAmount3',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'count',
|
||||||
|
title: '盈亏数量',
|
||||||
|
minWidth: 120,
|
||||||
|
fixed: 'right',
|
||||||
|
formatter: 'formatAmount3',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'productPrice',
|
||||||
|
title: '产品单价',
|
||||||
|
minWidth: 120,
|
||||||
|
fixed: 'right',
|
||||||
|
slots: { default: 'productPrice' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'totalPrice',
|
||||||
|
title: '金额',
|
||||||
|
minWidth: 120,
|
||||||
|
fixed: 'right',
|
||||||
|
formatter: 'formatAmount2',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
width: 50,
|
||||||
|
fixed: 'right',
|
||||||
|
slots: { default: 'actions' },
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 列表的搜索表单 */
|
||||||
|
export function useGridFormSchema(): VbenFormSchema[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
fieldName: 'no',
|
||||||
|
label: '盘点单号',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入盘点单号',
|
||||||
|
allowClear: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'productId',
|
||||||
|
label: '产品',
|
||||||
|
component: 'ApiSelect',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请选择产品',
|
||||||
|
allowClear: true,
|
||||||
|
showSearch: true,
|
||||||
|
api: getProductSimpleList,
|
||||||
|
labelField: 'name',
|
||||||
|
valueField: 'id',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'checkTime',
|
||||||
|
label: '盘点时间',
|
||||||
|
component: 'RangePicker',
|
||||||
|
componentProps: {
|
||||||
|
...getRangePickerDefaultProps(),
|
||||||
|
allowClear: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'warehouseId',
|
||||||
|
label: '仓库',
|
||||||
|
component: 'ApiSelect',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请选择仓库',
|
||||||
|
allowClear: true,
|
||||||
|
showSearch: true,
|
||||||
|
api: getWarehouseSimpleList,
|
||||||
|
labelField: 'name',
|
||||||
|
valueField: 'id',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'creator',
|
||||||
|
label: '创建人',
|
||||||
|
component: 'ApiSelect',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请选择创建人',
|
||||||
|
allowClear: true,
|
||||||
|
showSearch: true,
|
||||||
|
api: getSimpleUserList,
|
||||||
|
labelField: 'nickname',
|
||||||
|
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,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 列表的字段 */
|
||||||
|
export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
type: 'checkbox',
|
||||||
|
width: 50,
|
||||||
|
fixed: 'left',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'no',
|
||||||
|
title: '盘点单号',
|
||||||
|
width: 200,
|
||||||
|
fixed: 'left',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'productNames',
|
||||||
|
title: '产品信息',
|
||||||
|
showOverflow: 'tooltip',
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'checkTime',
|
||||||
|
title: '盘点时间',
|
||||||
|
width: 160,
|
||||||
|
formatter: 'formatDate',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'creatorName',
|
||||||
|
title: '创建人',
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'totalCount',
|
||||||
|
title: '总数量',
|
||||||
|
formatter: 'formatAmount3',
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'totalPrice',
|
||||||
|
title: '总金额',
|
||||||
|
formatter: 'formatAmount2',
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'status',
|
||||||
|
title: '状态',
|
||||||
|
minWidth: 120,
|
||||||
|
cellRender: {
|
||||||
|
name: 'CellDict',
|
||||||
|
props: { type: DICT_TYPE.ERP_AUDIT_STATUS },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
width: 260,
|
||||||
|
fixed: 'right',
|
||||||
|
slots: { default: 'actions' },
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
215
apps/web-ele/src/views/erp/stock/check/index.vue
Normal file
215
apps/web-ele/src/views/erp/stock/check/index.vue
Normal file
@@ -0,0 +1,215 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
import type { ErpStockCheckApi } from '#/api/erp/stock/check';
|
||||||
|
|
||||||
|
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 {
|
||||||
|
deleteStockCheck,
|
||||||
|
exportStockCheck,
|
||||||
|
getStockCheckPage,
|
||||||
|
updateStockCheckStatus,
|
||||||
|
} from '#/api/erp/stock/check';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
|
import { useGridColumns, useGridFormSchema } from './data';
|
||||||
|
import Form from './modules/form.vue';
|
||||||
|
|
||||||
|
/** ERP 库存盘点单列表 */
|
||||||
|
defineOptions({ name: 'ErpStockCheck' });
|
||||||
|
|
||||||
|
const [FormModal, formModalApi] = useVbenModal({
|
||||||
|
connectedComponent: Form,
|
||||||
|
destroyOnClose: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 刷新表格 */
|
||||||
|
function handleRefresh() {
|
||||||
|
gridApi.query();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 导出表格 */
|
||||||
|
async function handleExport() {
|
||||||
|
const data = await exportStockCheck(await gridApi.formApi.getValues());
|
||||||
|
downloadFileFromBlobPart({ fileName: '库存盘点单.xls', source: data });
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 新增库存盘点单 */
|
||||||
|
function handleCreate() {
|
||||||
|
formModalApi.setData({ type: 'create' }).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 编辑库存盘点单 */
|
||||||
|
function handleEdit(row: ErpStockCheckApi.StockCheck) {
|
||||||
|
formModalApi.setData({ type: 'edit', id: row.id }).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除库存盘点单 */
|
||||||
|
async function handleDelete(ids: number[]) {
|
||||||
|
const loadingInstance = ElLoading.service({
|
||||||
|
text: $t('ui.actionMessage.deleting'),
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await deleteStockCheck(ids);
|
||||||
|
ElMessage.success($t('ui.actionMessage.deleteSuccess'));
|
||||||
|
handleRefresh();
|
||||||
|
} finally {
|
||||||
|
loadingInstance.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 审批/反审批操作 */
|
||||||
|
async function handleUpdateStatus(
|
||||||
|
row: ErpStockCheckApi.StockCheck,
|
||||||
|
status: number,
|
||||||
|
) {
|
||||||
|
const loadingInstance = ElLoading.service({
|
||||||
|
text: `确定${status === 20 ? '审批' : '反审批'}该盘点单吗?`,
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await updateStockCheckStatus(row.id!, status);
|
||||||
|
ElMessage.success(`${status === 20 ? '审批' : '反审批'}成功`);
|
||||||
|
handleRefresh();
|
||||||
|
} finally {
|
||||||
|
loadingInstance.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const checkedIds = ref<number[]>([]);
|
||||||
|
function handleRowCheckboxChange({
|
||||||
|
records,
|
||||||
|
}: {
|
||||||
|
records: ErpStockCheckApi.StockCheck[];
|
||||||
|
}) {
|
||||||
|
checkedIds.value = records.map((item) => item.id!);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查看详情 */
|
||||||
|
function handleDetail(row: ErpStockCheckApi.StockCheck) {
|
||||||
|
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 getStockCheckPage({
|
||||||
|
pageNo: page.currentPage,
|
||||||
|
pageSize: page.pageSize,
|
||||||
|
...formValues,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rowConfig: {
|
||||||
|
keyField: 'id',
|
||||||
|
isHover: true,
|
||||||
|
},
|
||||||
|
toolbarConfig: {
|
||||||
|
refresh: true,
|
||||||
|
search: true,
|
||||||
|
},
|
||||||
|
} as VxeTableGridOptions<ErpStockCheckApi.StockCheck>,
|
||||||
|
gridEvents: {
|
||||||
|
checkboxAll: handleRowCheckboxChange,
|
||||||
|
checkboxChange: handleRowCheckboxChange,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Page auto-content-height>
|
||||||
|
<template #doc>
|
||||||
|
<DocAlert
|
||||||
|
title="【库存】库存调拨、库存盘点"
|
||||||
|
url="https://doc.iocoder.cn/erp/stock-move-check/"
|
||||||
|
/>
|
||||||
|
</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:stock-check:create'],
|
||||||
|
onClick: handleCreate,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: $t('ui.actionTitle.export'),
|
||||||
|
type: 'primary',
|
||||||
|
icon: ACTION_ICON.DOWNLOAD,
|
||||||
|
auth: ['erp:stock-check:export'],
|
||||||
|
onClick: handleExport,
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<template #actions="{ row }">
|
||||||
|
<TableAction
|
||||||
|
:actions="[
|
||||||
|
{
|
||||||
|
label: $t('common.detail'),
|
||||||
|
type: 'primary',
|
||||||
|
link: true,
|
||||||
|
icon: ACTION_ICON.VIEW,
|
||||||
|
auth: ['erp:stock-check:query'],
|
||||||
|
onClick: handleDetail.bind(null, row),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: $t('common.edit'),
|
||||||
|
type: 'primary',
|
||||||
|
link: true,
|
||||||
|
icon: ACTION_ICON.EDIT,
|
||||||
|
auth: ['erp:stock-check:update'],
|
||||||
|
ifShow: () => row.status !== 20,
|
||||||
|
onClick: handleEdit.bind(null, row),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: row.status === 10 ? '审批' : '反审批',
|
||||||
|
type: 'primary',
|
||||||
|
link: true,
|
||||||
|
icon: row.status === 10 ? ACTION_ICON.AUDIT : ACTION_ICON.REJECT,
|
||||||
|
auth: ['erp:stock-check: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:stock-check:delete'],
|
||||||
|
popConfirm: {
|
||||||
|
title: $t('ui.actionMessage.deleteConfirm', [row.no]),
|
||||||
|
confirm: handleDelete.bind(null, [row.id!]),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</Grid>
|
||||||
|
</Page>
|
||||||
|
</template>
|
||||||
132
apps/web-ele/src/views/erp/stock/check/modules/form.vue
Normal file
132
apps/web-ele/src/views/erp/stock/check/modules/form.vue
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
import type { ErpStockCheckApi } from '#/api/erp/stock/check';
|
||||||
|
|
||||||
|
import { computed, ref } from 'vue';
|
||||||
|
|
||||||
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
|
|
||||||
|
import { ElMessage } from 'element-plus';
|
||||||
|
|
||||||
|
import { useVbenForm } from '#/adapter/form';
|
||||||
|
import {
|
||||||
|
createStockCheck,
|
||||||
|
getStockCheck,
|
||||||
|
updateStockCheck,
|
||||||
|
} from '#/api/erp/stock/check';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
|
import { useFormSchema } from '../data';
|
||||||
|
import ItemForm from './item-form.vue';
|
||||||
|
|
||||||
|
const emit = defineEmits(['success']);
|
||||||
|
const formData = ref<ErpStockCheckApi.StockCheck>();
|
||||||
|
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,
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 更新盘点单项 */
|
||||||
|
function handleUpdateItems(items: ErpStockCheckApi.StockCheckItem[]) {
|
||||||
|
formData.value = modalApi.getData<ErpStockCheckApi.StockCheck>();
|
||||||
|
formData.value.items = items;
|
||||||
|
formApi.setValues({
|
||||||
|
items,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 创建或更新库存盘点单 */
|
||||||
|
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 ErpStockCheckApi.StockCheck;
|
||||||
|
try {
|
||||||
|
await (formType.value === 'create'
|
||||||
|
? createStockCheck(data)
|
||||||
|
: updateStockCheck(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<{ id?: number; type: string }>();
|
||||||
|
formType.value = data.type;
|
||||||
|
formApi.setDisabled(formType.value === 'detail');
|
||||||
|
formApi.updateSchema(useFormSchema(formType.value));
|
||||||
|
if (!data || !data.id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
modalApi.lock();
|
||||||
|
try {
|
||||||
|
formData.value = await getStockCheck(data.id);
|
||||||
|
// 设置到 values
|
||||||
|
await formApi.setValues(formData.value);
|
||||||
|
} 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 ?? []"
|
||||||
|
:disabled="formType === 'detail'"
|
||||||
|
@update:items="handleUpdateItems"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</Form>
|
||||||
|
</Modal>
|
||||||
|
</template>
|
||||||
313
apps/web-ele/src/views/erp/stock/check/modules/item-form.vue
Normal file
313
apps/web-ele/src/views/erp/stock/check/modules/item-form.vue
Normal file
@@ -0,0 +1,313 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
import type { ErpProductApi } from '#/api/erp/product/product';
|
||||||
|
import type { ErpStockCheckApi } from '#/api/erp/stock/check';
|
||||||
|
|
||||||
|
import { computed, nextTick, onMounted, ref, watch } from 'vue';
|
||||||
|
|
||||||
|
import {
|
||||||
|
erpCountInputFormatter,
|
||||||
|
erpPriceInputFormatter,
|
||||||
|
erpPriceMultiply,
|
||||||
|
} from '@vben/utils';
|
||||||
|
|
||||||
|
import { ElInput, ElInputNumber, ElSelect } from 'element-plus';
|
||||||
|
|
||||||
|
import { TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
|
import { getProductSimpleList } from '#/api/erp/product/product';
|
||||||
|
import { getStockCount } from '#/api/erp/stock/stock';
|
||||||
|
import { getWarehouseSimpleList } from '#/api/erp/stock/warehouse';
|
||||||
|
|
||||||
|
import { useFormItemColumns } from '../data';
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
items?: ErpStockCheckApi.StockCheckItem[];
|
||||||
|
disabled?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
const props = withDefaults(defineProps<Props>(), {
|
||||||
|
items: () => [],
|
||||||
|
disabled: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
const emit = defineEmits(['update:items']);
|
||||||
|
|
||||||
|
const tableData = ref<ErpStockCheckApi.StockCheckItem[]>([]); // 表格数据
|
||||||
|
const productOptions = ref<ErpProductApi.Product[]>([]); // 产品下拉选项
|
||||||
|
const warehouseOptions = ref<any[]>([]); // 仓库下拉选项
|
||||||
|
|
||||||
|
/** 获取表格合计数据 */
|
||||||
|
const summaries = computed(() => {
|
||||||
|
return {
|
||||||
|
count: tableData.value.reduce((sum, item) => sum + (item.count || 0), 0),
|
||||||
|
totalPrice: tableData.value.reduce(
|
||||||
|
(sum, item) => sum + (item.totalPrice || 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;
|
||||||
|
}
|
||||||
|
items.forEach((item) => initRow(item));
|
||||||
|
tableData.value = [...items];
|
||||||
|
await nextTick(); // 特殊:保证 gridApi 已经初始化
|
||||||
|
await gridApi.grid.reloadData(tableData.value);
|
||||||
|
},
|
||||||
|
{
|
||||||
|
immediate: true,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
/** 处理新增 */
|
||||||
|
function handleAdd() {
|
||||||
|
const newRow = {
|
||||||
|
id: undefined,
|
||||||
|
warehouseId: undefined,
|
||||||
|
productId: undefined,
|
||||||
|
productUnitName: undefined, // 产品单位
|
||||||
|
productBarCode: undefined, // 产品条码
|
||||||
|
productPrice: undefined,
|
||||||
|
stockCount: undefined,
|
||||||
|
actualCount: undefined,
|
||||||
|
count: undefined,
|
||||||
|
totalPrice: undefined,
|
||||||
|
remark: undefined,
|
||||||
|
};
|
||||||
|
tableData.value.push(newRow);
|
||||||
|
// 通知父组件更新
|
||||||
|
emit('update:items', [...tableData.value]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 处理删除 */
|
||||||
|
function handleDelete(row: ErpStockCheckApi.StockCheckItem) {
|
||||||
|
const index = tableData.value.findIndex((item) => item.seq === row.seq);
|
||||||
|
if (index !== -1) {
|
||||||
|
tableData.value.splice(index, 1);
|
||||||
|
}
|
||||||
|
// 通知父组件更新
|
||||||
|
emit('update:items', [...tableData.value]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 处理仓库变更 */
|
||||||
|
async function handleWarehouseChange(warehouseId: any, row: any) {
|
||||||
|
const warehouse = warehouseOptions.value.find((w) => w.id === warehouseId);
|
||||||
|
if (!warehouse) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
row.warehouseId = warehouseId;
|
||||||
|
|
||||||
|
// 如果已选择产品,重新获取库存
|
||||||
|
if (row.productId) {
|
||||||
|
row.stockCount = (await getStockCount(row.productId, warehouseId)) || 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
handleRowChange(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 处理产品变更 */
|
||||||
|
async function handleProductChange(productId: any, row: any) {
|
||||||
|
const product = productOptions.value.find((p) => p.id === productId);
|
||||||
|
if (!product) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
row.productId = productId;
|
||||||
|
row.productUnitId = product.unitId;
|
||||||
|
row.productBarCode = product.barCode;
|
||||||
|
row.productUnitName = product.unitName;
|
||||||
|
row.productName = product.name;
|
||||||
|
row.stockCount = row.warehouseId
|
||||||
|
? (await getStockCount(productId, row.warehouseId)) || 0
|
||||||
|
: (await getStockCount(productId)) || 0;
|
||||||
|
row.actualCount = row.stockCount || 0;
|
||||||
|
row.productPrice = product.purchasePrice || 0;
|
||||||
|
row.count = row.actualCount - row.stockCount || 0;
|
||||||
|
handleRowChange(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 处理实际库存变更 */
|
||||||
|
function handleActualCountChange(actualCount: any, row: any) {
|
||||||
|
row.actualCount = actualCount;
|
||||||
|
if (row.stockCount !== undefined && row.actualCount !== undefined) {
|
||||||
|
row.count = row.actualCount - row.stockCount;
|
||||||
|
if (row.productPrice && row.count) {
|
||||||
|
row.totalPrice = erpPriceMultiply(row.productPrice, row.count) ?? 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
handleRowChange(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 处理行数据变更 */
|
||||||
|
function handleRowChange(row: any) {
|
||||||
|
const index = tableData.value.findIndex((item) => item.seq === row.seq);
|
||||||
|
if (index === -1) {
|
||||||
|
tableData.value.push(row);
|
||||||
|
} else {
|
||||||
|
tableData.value[index] = row;
|
||||||
|
}
|
||||||
|
emit('update:items', [...tableData.value]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 初始化行数据 */
|
||||||
|
function initRow(row: ErpStockCheckApi.StockCheckItem) {
|
||||||
|
if (row.productPrice && row.count) {
|
||||||
|
row.totalPrice = erpPriceMultiply(row.productPrice, row.count) ?? 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 表单校验 */
|
||||||
|
function validate() {
|
||||||
|
for (let i = 0; i < tableData.value.length; i++) {
|
||||||
|
const item = tableData.value[i];
|
||||||
|
if (item) {
|
||||||
|
if (!item.warehouseId) {
|
||||||
|
throw new Error(`第 ${i + 1} 行:仓库不能为空`);
|
||||||
|
}
|
||||||
|
if (!item.productId) {
|
||||||
|
throw new Error(`第 ${i + 1} 行:产品不能为空`);
|
||||||
|
}
|
||||||
|
if (!item.actualCount || item.actualCount <= 0) {
|
||||||
|
throw new Error(`第 ${i + 1} 行:实际库存不能为空`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
validate,
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 初始化 */
|
||||||
|
onMounted(async () => {
|
||||||
|
productOptions.value = await getProductSimpleList();
|
||||||
|
warehouseOptions.value = await getWarehouseSimpleList();
|
||||||
|
// 目的:新增时,默认添加一行
|
||||||
|
if (tableData.value.length === 0) {
|
||||||
|
handleAdd();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Grid class="w-full">
|
||||||
|
<template #warehouseId="{ row }">
|
||||||
|
<ElSelect
|
||||||
|
v-model="row.warehouseId"
|
||||||
|
:options="warehouseOptions"
|
||||||
|
:props="{ label: 'name', value: 'id' }"
|
||||||
|
class="w-full"
|
||||||
|
placeholder="请选择仓库"
|
||||||
|
filterable
|
||||||
|
:disabled="disabled"
|
||||||
|
@change="handleWarehouseChange($event, row)"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<template #productId="{ row }">
|
||||||
|
<ElSelect
|
||||||
|
v-model="row.productId"
|
||||||
|
:options="productOptions"
|
||||||
|
:props="{ label: 'name', value: 'id' }"
|
||||||
|
class="w-full"
|
||||||
|
placeholder="请选择产品"
|
||||||
|
filterable
|
||||||
|
:disabled="disabled"
|
||||||
|
@change="handleProductChange($event, row)"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<template #actualCount="{ row }">
|
||||||
|
<ElInputNumber
|
||||||
|
v-if="!disabled"
|
||||||
|
v-model="row.actualCount"
|
||||||
|
:min="0"
|
||||||
|
:precision="3"
|
||||||
|
controls-position="right"
|
||||||
|
class="!w-full"
|
||||||
|
@change="handleActualCountChange($event, row)"
|
||||||
|
/>
|
||||||
|
<span v-else>{{ erpCountInputFormatter(row.actualCount) || '-' }}</span>
|
||||||
|
</template>
|
||||||
|
<template #productPrice="{ row }">
|
||||||
|
<ElInputNumber
|
||||||
|
v-if="!disabled"
|
||||||
|
v-model="row.productPrice"
|
||||||
|
:min="0"
|
||||||
|
:precision="2"
|
||||||
|
controls-position="right"
|
||||||
|
class="!w-full"
|
||||||
|
@change="handleRowChange(row)"
|
||||||
|
/>
|
||||||
|
<span v-else>{{ erpPriceInputFormatter(row.productPrice) || '-' }}</span>
|
||||||
|
</template>
|
||||||
|
<template #remark="{ row }">
|
||||||
|
<ElInput v-if="!disabled" v-model="row.remark" class="w-full" />
|
||||||
|
<span v-else>{{ row.remark || '-' }}</span>
|
||||||
|
</template>
|
||||||
|
<template #actions="{ row }">
|
||||||
|
<TableAction
|
||||||
|
v-if="!disabled"
|
||||||
|
:actions="[
|
||||||
|
{
|
||||||
|
label: '删除',
|
||||||
|
type: 'danger',
|
||||||
|
link: true,
|
||||||
|
icon: 'ant-design:delete-outlined',
|
||||||
|
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>数量:{{ erpCountInputFormatter(summaries.count) }}</span>
|
||||||
|
<span>
|
||||||
|
金额:{{ erpPriceInputFormatter(summaries.totalPrice) }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<TableAction
|
||||||
|
v-if="!disabled"
|
||||||
|
class="mt-2 flex justify-center"
|
||||||
|
:actions="[
|
||||||
|
{
|
||||||
|
label: '添加盘点产品',
|
||||||
|
type: 'default',
|
||||||
|
onClick: handleAdd,
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</Grid>
|
||||||
|
</template>
|
||||||
330
apps/web-ele/src/views/erp/stock/in/data.ts
Normal file
330
apps/web-ele/src/views/erp/stock/in/data.ts
Normal file
@@ -0,0 +1,330 @@
|
|||||||
|
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 { getProductSimpleList } from '#/api/erp/product/product';
|
||||||
|
import { getSupplierSimpleList } from '#/api/erp/purchase/supplier';
|
||||||
|
import { getWarehouseSimpleList } from '#/api/erp/stock/warehouse';
|
||||||
|
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: 'inTime',
|
||||||
|
label: '入库时间',
|
||||||
|
component: 'DatePicker',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '选择入库时间',
|
||||||
|
showTime: true,
|
||||||
|
format: 'YYYY-MM-DD HH:mm:ss',
|
||||||
|
valueFormat: 'x',
|
||||||
|
class: '!w-full',
|
||||||
|
},
|
||||||
|
rules: 'required',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '供应商',
|
||||||
|
fieldName: 'supplierId',
|
||||||
|
component: 'ApiSelect',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请选择供应商',
|
||||||
|
allowClear: true,
|
||||||
|
showSearch: true,
|
||||||
|
api: getSupplierSimpleList,
|
||||||
|
labelField: 'name',
|
||||||
|
valueField: 'id',
|
||||||
|
},
|
||||||
|
rules: 'required',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
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',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 表单的明细表格列 */
|
||||||
|
export function useFormItemColumns(): VxeTableGridOptions['columns'] {
|
||||||
|
return [
|
||||||
|
{ type: 'seq', title: '序号', minWidth: 50, fixed: 'left' },
|
||||||
|
{
|
||||||
|
field: 'warehouseId',
|
||||||
|
title: '仓库名称',
|
||||||
|
minWidth: 150,
|
||||||
|
slots: { default: 'warehouseId' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'productId',
|
||||||
|
title: '产品名称',
|
||||||
|
minWidth: 200,
|
||||||
|
slots: { default: 'productId' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'stockCount',
|
||||||
|
title: '库存',
|
||||||
|
minWidth: 80,
|
||||||
|
formatter: 'formatAmount3',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'productBarCode',
|
||||||
|
title: '条码',
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'productUnitName',
|
||||||
|
title: '单位',
|
||||||
|
minWidth: 80,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'remark',
|
||||||
|
title: '备注',
|
||||||
|
minWidth: 150,
|
||||||
|
slots: { default: 'remark' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'count',
|
||||||
|
title: '数量',
|
||||||
|
minWidth: 120,
|
||||||
|
fixed: 'right',
|
||||||
|
slots: { default: 'count' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'productPrice',
|
||||||
|
title: '产品单价',
|
||||||
|
minWidth: 120,
|
||||||
|
fixed: 'right',
|
||||||
|
slots: { default: 'productPrice' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'totalPrice',
|
||||||
|
title: '金额',
|
||||||
|
minWidth: 120,
|
||||||
|
fixed: 'right',
|
||||||
|
formatter: 'formatAmount2',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
width: 50,
|
||||||
|
fixed: 'right',
|
||||||
|
slots: { default: 'actions' },
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 列表的搜索表单 */
|
||||||
|
export function useGridFormSchema(): VbenFormSchema[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
fieldName: 'no',
|
||||||
|
label: '入库单号',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入入库单号',
|
||||||
|
allowClear: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'productId',
|
||||||
|
label: '产品',
|
||||||
|
component: 'ApiSelect',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请选择产品',
|
||||||
|
allowClear: true,
|
||||||
|
showSearch: true,
|
||||||
|
api: getProductSimpleList,
|
||||||
|
labelField: 'name',
|
||||||
|
valueField: 'id',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'inTime',
|
||||||
|
label: '入库时间',
|
||||||
|
component: 'RangePicker',
|
||||||
|
componentProps: {
|
||||||
|
...getRangePickerDefaultProps(),
|
||||||
|
allowClear: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'supplierId',
|
||||||
|
label: '供应商',
|
||||||
|
component: 'ApiSelect',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请选择供应商',
|
||||||
|
allowClear: true,
|
||||||
|
showSearch: true,
|
||||||
|
api: getSupplierSimpleList,
|
||||||
|
labelField: 'name',
|
||||||
|
valueField: 'id',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'warehouseId',
|
||||||
|
label: '仓库',
|
||||||
|
component: 'ApiSelect',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请选择仓库',
|
||||||
|
allowClear: true,
|
||||||
|
showSearch: true,
|
||||||
|
api: getWarehouseSimpleList,
|
||||||
|
labelField: 'name',
|
||||||
|
valueField: 'id',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'creator',
|
||||||
|
label: '创建人',
|
||||||
|
component: 'ApiSelect',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请选择创建人',
|
||||||
|
allowClear: true,
|
||||||
|
showSearch: true,
|
||||||
|
api: getSimpleUserList,
|
||||||
|
labelField: 'nickname',
|
||||||
|
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,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 列表的字段 */
|
||||||
|
export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
type: 'checkbox',
|
||||||
|
width: 50,
|
||||||
|
fixed: 'left',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'no',
|
||||||
|
title: '入库单号',
|
||||||
|
width: 200,
|
||||||
|
fixed: 'left',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'productNames',
|
||||||
|
title: '产品信息',
|
||||||
|
showOverflow: 'tooltip',
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'supplierName',
|
||||||
|
title: '供应商',
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'inTime',
|
||||||
|
title: '入库时间',
|
||||||
|
width: 160,
|
||||||
|
formatter: 'formatDate',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'creatorName',
|
||||||
|
title: '创建人',
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'totalCount',
|
||||||
|
title: '总数量',
|
||||||
|
formatter: 'formatAmount3',
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'totalPrice',
|
||||||
|
title: '总金额',
|
||||||
|
formatter: 'formatAmount2',
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'status',
|
||||||
|
title: '状态',
|
||||||
|
minWidth: 120,
|
||||||
|
cellRender: {
|
||||||
|
name: 'CellDict',
|
||||||
|
props: { type: DICT_TYPE.ERP_AUDIT_STATUS },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
width: 260,
|
||||||
|
fixed: 'right',
|
||||||
|
slots: { default: 'actions' },
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
212
apps/web-ele/src/views/erp/stock/in/index.vue
Normal file
212
apps/web-ele/src/views/erp/stock/in/index.vue
Normal file
@@ -0,0 +1,212 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
import type { ErpStockInApi } from '#/api/erp/stock/in';
|
||||||
|
|
||||||
|
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 {
|
||||||
|
deleteStockIn,
|
||||||
|
exportStockIn,
|
||||||
|
getStockInPage,
|
||||||
|
updateStockInStatus,
|
||||||
|
} from '#/api/erp/stock/in';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
|
import { useGridColumns, useGridFormSchema } from './data';
|
||||||
|
import Form from './modules/form.vue';
|
||||||
|
|
||||||
|
/** ERP 其它入库单列表 */
|
||||||
|
defineOptions({ name: 'ErpStockIn' });
|
||||||
|
|
||||||
|
const [FormModal, formModalApi] = useVbenModal({
|
||||||
|
connectedComponent: Form,
|
||||||
|
destroyOnClose: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 刷新表格 */
|
||||||
|
function handleRefresh() {
|
||||||
|
gridApi.query();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 导出表格 */
|
||||||
|
async function handleExport() {
|
||||||
|
const data = await exportStockIn(await gridApi.formApi.getValues());
|
||||||
|
downloadFileFromBlobPart({ fileName: '其它入库单.xls', source: data });
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 新增其它入库单 */
|
||||||
|
function handleCreate() {
|
||||||
|
formModalApi.setData({ type: 'create' }).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 编辑其它入库单 */
|
||||||
|
function handleEdit(row: ErpStockInApi.StockIn) {
|
||||||
|
formModalApi.setData({ type: 'edit', id: row.id }).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除其它入库单 */
|
||||||
|
async function handleDelete(ids: number[]) {
|
||||||
|
const loadingInstance = ElLoading.service({
|
||||||
|
text: $t('ui.actionMessage.deleting'),
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await deleteStockIn(ids);
|
||||||
|
ElMessage.success($t('ui.actionMessage.deleteSuccess'));
|
||||||
|
handleRefresh();
|
||||||
|
} finally {
|
||||||
|
loadingInstance.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 审批/反审批操作 */
|
||||||
|
async function handleUpdateStatus(row: ErpStockInApi.StockIn, status: number) {
|
||||||
|
const loadingInstance = ElLoading.service({
|
||||||
|
text: `确定${status === 20 ? '审批' : '反审批'}该入库单吗?`,
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await updateStockInStatus(row.id!, status);
|
||||||
|
ElMessage.success(`${status === 20 ? '审批' : '反审批'}成功`);
|
||||||
|
handleRefresh();
|
||||||
|
} finally {
|
||||||
|
loadingInstance.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const checkedIds = ref<number[]>([]);
|
||||||
|
function handleRowCheckboxChange({
|
||||||
|
records,
|
||||||
|
}: {
|
||||||
|
records: ErpStockInApi.StockIn[];
|
||||||
|
}) {
|
||||||
|
checkedIds.value = records.map((item) => item.id!);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查看详情 */
|
||||||
|
function handleDetail(row: ErpStockInApi.StockIn) {
|
||||||
|
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 getStockInPage({
|
||||||
|
pageNo: page.currentPage,
|
||||||
|
pageSize: page.pageSize,
|
||||||
|
...formValues,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rowConfig: {
|
||||||
|
keyField: 'id',
|
||||||
|
isHover: true,
|
||||||
|
},
|
||||||
|
toolbarConfig: {
|
||||||
|
refresh: true,
|
||||||
|
search: true,
|
||||||
|
},
|
||||||
|
} as VxeTableGridOptions<ErpStockInApi.StockIn>,
|
||||||
|
gridEvents: {
|
||||||
|
checkboxAll: handleRowCheckboxChange,
|
||||||
|
checkboxChange: handleRowCheckboxChange,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Page auto-content-height>
|
||||||
|
<template #doc>
|
||||||
|
<DocAlert
|
||||||
|
title="【库存】其它入库、其它出库"
|
||||||
|
url="https://doc.iocoder.cn/erp/stock-in-out/"
|
||||||
|
/>
|
||||||
|
</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:stock-in:create'],
|
||||||
|
onClick: handleCreate,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: $t('ui.actionTitle.export'),
|
||||||
|
type: 'primary',
|
||||||
|
icon: ACTION_ICON.DOWNLOAD,
|
||||||
|
auth: ['erp:stock-in:export'],
|
||||||
|
onClick: handleExport,
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<template #actions="{ row }">
|
||||||
|
<TableAction
|
||||||
|
:actions="[
|
||||||
|
{
|
||||||
|
label: $t('common.detail'),
|
||||||
|
type: 'primary',
|
||||||
|
link: true,
|
||||||
|
icon: ACTION_ICON.VIEW,
|
||||||
|
auth: ['erp:stock-in:query'],
|
||||||
|
onClick: handleDetail.bind(null, row),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: $t('common.edit'),
|
||||||
|
type: 'primary',
|
||||||
|
link: true,
|
||||||
|
icon: ACTION_ICON.EDIT,
|
||||||
|
auth: ['erp:stock-in:update'],
|
||||||
|
ifShow: () => row.status !== 20,
|
||||||
|
onClick: handleEdit.bind(null, row),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: row.status === 10 ? '审批' : '反审批',
|
||||||
|
type: 'primary',
|
||||||
|
link: true,
|
||||||
|
icon: row.status === 10 ? ACTION_ICON.AUDIT : ACTION_ICON.REJECT,
|
||||||
|
auth: ['erp:stock-in: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:stock-in:delete'],
|
||||||
|
popConfirm: {
|
||||||
|
title: $t('ui.actionMessage.deleteConfirm', [row.no]),
|
||||||
|
confirm: handleDelete.bind(null, [row.id!]),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</Grid>
|
||||||
|
</Page>
|
||||||
|
</template>
|
||||||
128
apps/web-ele/src/views/erp/stock/in/modules/form.vue
Normal file
128
apps/web-ele/src/views/erp/stock/in/modules/form.vue
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
import type { ErpStockInApi } from '#/api/erp/stock/in';
|
||||||
|
|
||||||
|
import { computed, ref } from 'vue';
|
||||||
|
|
||||||
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
|
|
||||||
|
import { ElMessage } from 'element-plus';
|
||||||
|
|
||||||
|
import { useVbenForm } from '#/adapter/form';
|
||||||
|
import { createStockIn, getStockIn, updateStockIn } from '#/api/erp/stock/in';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
|
import { useFormSchema } from '../data';
|
||||||
|
import ItemForm from './item-form.vue';
|
||||||
|
|
||||||
|
const emit = defineEmits(['success']);
|
||||||
|
const formData = ref<ErpStockInApi.StockIn>();
|
||||||
|
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,
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 更新入库单项 */
|
||||||
|
function handleUpdateItems(items: ErpStockInApi.StockInItem[]) {
|
||||||
|
formData.value = modalApi.getData<ErpStockInApi.StockIn>();
|
||||||
|
formData.value.items = items;
|
||||||
|
formApi.setValues({
|
||||||
|
items,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 创建或更新其它入库单 */
|
||||||
|
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 ErpStockInApi.StockIn;
|
||||||
|
try {
|
||||||
|
await (formType.value === 'create'
|
||||||
|
? createStockIn(data)
|
||||||
|
: updateStockIn(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<{ id?: number; type: string }>();
|
||||||
|
formType.value = data.type;
|
||||||
|
formApi.setDisabled(formType.value === 'detail');
|
||||||
|
formApi.updateSchema(useFormSchema(formType.value));
|
||||||
|
if (!data || !data.id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
modalApi.lock();
|
||||||
|
try {
|
||||||
|
formData.value = await getStockIn(data.id);
|
||||||
|
// 设置到 values
|
||||||
|
await formApi.setValues(formData.value);
|
||||||
|
} 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 ?? []"
|
||||||
|
:disabled="formType === 'detail'"
|
||||||
|
@update:items="handleUpdateItems"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</Form>
|
||||||
|
</Modal>
|
||||||
|
</template>
|
||||||
302
apps/web-ele/src/views/erp/stock/in/modules/item-form.vue
Normal file
302
apps/web-ele/src/views/erp/stock/in/modules/item-form.vue
Normal file
@@ -0,0 +1,302 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
import type { ErpProductApi } from '#/api/erp/product/product';
|
||||||
|
import type { ErpStockInApi } from '#/api/erp/stock/in';
|
||||||
|
|
||||||
|
import { computed, nextTick, onMounted, ref, watch } from 'vue';
|
||||||
|
|
||||||
|
import {
|
||||||
|
erpCountInputFormatter,
|
||||||
|
erpPriceInputFormatter,
|
||||||
|
erpPriceMultiply,
|
||||||
|
} from '@vben/utils';
|
||||||
|
|
||||||
|
import { ElInput, ElInputNumber, ElSelect } from 'element-plus';
|
||||||
|
|
||||||
|
import { TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
|
import { getProductSimpleList } from '#/api/erp/product/product';
|
||||||
|
import { getStockCount } from '#/api/erp/stock/stock';
|
||||||
|
import { getWarehouseSimpleList } from '#/api/erp/stock/warehouse';
|
||||||
|
|
||||||
|
import { useFormItemColumns } from '../data';
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
items?: ErpStockInApi.StockInItem[];
|
||||||
|
disabled?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
const props = withDefaults(defineProps<Props>(), {
|
||||||
|
items: () => [],
|
||||||
|
disabled: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
const emit = defineEmits(['update:items']);
|
||||||
|
|
||||||
|
const tableData = ref<ErpStockInApi.StockInItem[]>([]); // 表格数据
|
||||||
|
const productOptions = ref<ErpProductApi.Product[]>([]); // 产品下拉选项
|
||||||
|
const warehouseOptions = ref<any[]>([]); // 仓库下拉选项
|
||||||
|
|
||||||
|
/** 获取表格合计数据 */
|
||||||
|
const summaries = computed(() => {
|
||||||
|
return {
|
||||||
|
count: tableData.value.reduce((sum, item) => sum + (item.count || 0), 0),
|
||||||
|
totalPrice: tableData.value.reduce(
|
||||||
|
(sum, item) => sum + (item.totalPrice || 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;
|
||||||
|
}
|
||||||
|
items.forEach((item) => initRow(item));
|
||||||
|
tableData.value = [...items];
|
||||||
|
await nextTick(); // 特殊:保证 gridApi 已经初始化
|
||||||
|
await gridApi.grid.reloadData(tableData.value);
|
||||||
|
},
|
||||||
|
{
|
||||||
|
immediate: true,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
/** 处理新增 */
|
||||||
|
function handleAdd() {
|
||||||
|
const newRow = {
|
||||||
|
id: undefined,
|
||||||
|
warehouseId: undefined,
|
||||||
|
productId: undefined,
|
||||||
|
productUnitName: undefined, // 产品单位
|
||||||
|
productBarCode: undefined, // 产品条码
|
||||||
|
productPrice: undefined,
|
||||||
|
stockCount: undefined,
|
||||||
|
count: 1,
|
||||||
|
totalPrice: undefined,
|
||||||
|
remark: undefined,
|
||||||
|
};
|
||||||
|
tableData.value.push(newRow);
|
||||||
|
// 通知父组件更新
|
||||||
|
emit('update:items', [...tableData.value]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 处理删除 */
|
||||||
|
function handleDelete(row: ErpStockInApi.StockInItem) {
|
||||||
|
const index = tableData.value.findIndex((item) => item.seq === row.seq);
|
||||||
|
if (index !== -1) {
|
||||||
|
tableData.value.splice(index, 1);
|
||||||
|
}
|
||||||
|
// 通知父组件更新
|
||||||
|
emit('update:items', [...tableData.value]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 处理仓库变更 */
|
||||||
|
async function handleWarehouseChange(warehouseId: any, row: any) {
|
||||||
|
const warehouse = warehouseOptions.value.find((w) => w.id === warehouseId);
|
||||||
|
if (!warehouse) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
row.warehouseId = warehouseId;
|
||||||
|
|
||||||
|
// 如果已选择产品,重新获取库存
|
||||||
|
if (row.productId) {
|
||||||
|
row.stockCount = (await getStockCount(row.productId, warehouseId)) || 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
handleRowChange(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 处理产品变更 */
|
||||||
|
async function handleProductChange(productId: any, row: any) {
|
||||||
|
const product = productOptions.value.find((p) => p.id === productId);
|
||||||
|
if (!product) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
row.productId = productId;
|
||||||
|
row.productUnitId = product.unitId;
|
||||||
|
row.productBarCode = product.barCode;
|
||||||
|
row.productUnitName = product.unitName;
|
||||||
|
row.productName = product.name;
|
||||||
|
row.stockCount = row.warehouseId
|
||||||
|
? (await getStockCount(productId, row.warehouseId)) || 0
|
||||||
|
: (await getStockCount(productId)) || 0;
|
||||||
|
row.productPrice = product.purchasePrice || 0;
|
||||||
|
row.count = row.count || 1;
|
||||||
|
handleRowChange(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 处理行数据变更 */
|
||||||
|
function handleRowChange(row: any) {
|
||||||
|
const index = tableData.value.findIndex((item) => item.seq === row.seq);
|
||||||
|
if (index === -1) {
|
||||||
|
tableData.value.push(row);
|
||||||
|
} else {
|
||||||
|
tableData.value[index] = row;
|
||||||
|
}
|
||||||
|
emit('update:items', [...tableData.value]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 初始化行数据 */
|
||||||
|
function initRow(row: ErpStockInApi.StockInItem) {
|
||||||
|
if (row.productPrice && row.count) {
|
||||||
|
row.totalPrice = erpPriceMultiply(row.productPrice, row.count) ?? 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 表单校验 */
|
||||||
|
function validate() {
|
||||||
|
for (let i = 0; i < tableData.value.length; i++) {
|
||||||
|
const item = tableData.value[i];
|
||||||
|
if (item) {
|
||||||
|
if (!item.warehouseId) {
|
||||||
|
throw new Error(`第 ${i + 1} 行:仓库不能为空`);
|
||||||
|
}
|
||||||
|
if (!item.productId) {
|
||||||
|
throw new Error(`第 ${i + 1} 行:产品不能为空`);
|
||||||
|
}
|
||||||
|
if (!item.count || item.count <= 0) {
|
||||||
|
throw new Error(`第 ${i + 1} 行:产品数量不能为空`);
|
||||||
|
}
|
||||||
|
if (!item.productPrice || item.productPrice <= 0) {
|
||||||
|
throw new Error(`第 ${i + 1} 行:产品单价不能为空`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
validate,
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 初始化 */
|
||||||
|
onMounted(async () => {
|
||||||
|
productOptions.value = await getProductSimpleList();
|
||||||
|
warehouseOptions.value = await getWarehouseSimpleList();
|
||||||
|
// 目的:新增时,默认添加一行
|
||||||
|
if (tableData.value.length === 0) {
|
||||||
|
handleAdd();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Grid class="w-full">
|
||||||
|
<template #warehouseId="{ row }">
|
||||||
|
<ElSelect
|
||||||
|
v-model="row.warehouseId"
|
||||||
|
:options="warehouseOptions"
|
||||||
|
:props="{ label: 'name', value: 'id' }"
|
||||||
|
class="w-full"
|
||||||
|
placeholder="请选择仓库"
|
||||||
|
filterable
|
||||||
|
:disabled="disabled"
|
||||||
|
@change="handleWarehouseChange($event, row)"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<template #productId="{ row }">
|
||||||
|
<ElSelect
|
||||||
|
v-model="row.productId"
|
||||||
|
:options="productOptions"
|
||||||
|
:props="{ label: 'name', value: 'id' }"
|
||||||
|
class="w-full"
|
||||||
|
placeholder="请选择产品"
|
||||||
|
filterable
|
||||||
|
:disabled="disabled"
|
||||||
|
@change="handleProductChange($event, row)"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<template #count="{ row }">
|
||||||
|
<ElInputNumber
|
||||||
|
v-if="!disabled"
|
||||||
|
v-model="row.count"
|
||||||
|
:min="0"
|
||||||
|
:precision="3"
|
||||||
|
controls-position="right"
|
||||||
|
class="!w-full"
|
||||||
|
@change="handleRowChange(row)"
|
||||||
|
/>
|
||||||
|
<span v-else>{{ erpCountInputFormatter(row.count) || '-' }}</span>
|
||||||
|
</template>
|
||||||
|
<template #productPrice="{ row }">
|
||||||
|
<ElInputNumber
|
||||||
|
v-if="!disabled"
|
||||||
|
v-model="row.productPrice"
|
||||||
|
:min="0"
|
||||||
|
:precision="2"
|
||||||
|
controls-position="right"
|
||||||
|
class="!w-full"
|
||||||
|
@change="handleRowChange(row)"
|
||||||
|
/>
|
||||||
|
<span v-else>{{ erpPriceInputFormatter(row.productPrice) || '-' }}</span>
|
||||||
|
</template>
|
||||||
|
<template #remark="{ row }">
|
||||||
|
<ElInput v-if="!disabled" v-model="row.remark" class="w-full" />
|
||||||
|
<span v-else>{{ row.remark || '-' }}</span>
|
||||||
|
</template>
|
||||||
|
<template #actions="{ row }">
|
||||||
|
<TableAction
|
||||||
|
v-if="!disabled"
|
||||||
|
:actions="[
|
||||||
|
{
|
||||||
|
label: '删除',
|
||||||
|
type: 'danger',
|
||||||
|
link: true,
|
||||||
|
icon: 'ant-design:delete-outlined',
|
||||||
|
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>数量:{{ erpCountInputFormatter(summaries.count) }}</span>
|
||||||
|
<span>
|
||||||
|
金额:{{ erpPriceInputFormatter(summaries.totalPrice) }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<TableAction
|
||||||
|
v-if="!disabled"
|
||||||
|
class="mt-2 flex justify-center"
|
||||||
|
:actions="[
|
||||||
|
{
|
||||||
|
label: '添加入库产品',
|
||||||
|
type: 'default',
|
||||||
|
onClick: handleAdd,
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</Grid>
|
||||||
|
</template>
|
||||||
316
apps/web-ele/src/views/erp/stock/move/data.ts
Normal file
316
apps/web-ele/src/views/erp/stock/move/data.ts
Normal file
@@ -0,0 +1,316 @@
|
|||||||
|
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 { getProductSimpleList } from '#/api/erp/product/product';
|
||||||
|
import { getWarehouseSimpleList } from '#/api/erp/stock/warehouse';
|
||||||
|
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: 'moveTime',
|
||||||
|
label: '调度时间',
|
||||||
|
component: 'DatePicker',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '选择调度时间',
|
||||||
|
showTime: true,
|
||||||
|
format: 'YYYY-MM-DD HH:mm:ss',
|
||||||
|
valueFormat: 'x',
|
||||||
|
class: '!w-full',
|
||||||
|
},
|
||||||
|
rules: 'required',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
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',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 表单的明细表格列 */
|
||||||
|
export function useFormItemColumns(): VxeTableGridOptions['columns'] {
|
||||||
|
return [
|
||||||
|
{ type: 'seq', title: '序号', minWidth: 50, fixed: 'left' },
|
||||||
|
{
|
||||||
|
field: 'fromWarehouseId',
|
||||||
|
title: '调出仓库',
|
||||||
|
minWidth: 150,
|
||||||
|
slots: { default: 'fromWarehouseId' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'toWarehouseId',
|
||||||
|
title: '调入仓库',
|
||||||
|
minWidth: 150,
|
||||||
|
slots: { default: 'toWarehouseId' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'productId',
|
||||||
|
title: '产品名称',
|
||||||
|
minWidth: 200,
|
||||||
|
slots: { default: 'productId' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'stockCount',
|
||||||
|
title: '库存',
|
||||||
|
minWidth: 80,
|
||||||
|
formatter: 'formatAmount3',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'productBarCode',
|
||||||
|
title: '条码',
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'productUnitName',
|
||||||
|
title: '单位',
|
||||||
|
minWidth: 80,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'remark',
|
||||||
|
title: '备注',
|
||||||
|
minWidth: 150,
|
||||||
|
slots: { default: 'remark' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'count',
|
||||||
|
title: '数量',
|
||||||
|
minWidth: 120,
|
||||||
|
fixed: 'right',
|
||||||
|
slots: { default: 'count' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'productPrice',
|
||||||
|
title: '产品单价',
|
||||||
|
minWidth: 120,
|
||||||
|
fixed: 'right',
|
||||||
|
slots: { default: 'productPrice' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'totalPrice',
|
||||||
|
title: '金额',
|
||||||
|
minWidth: 120,
|
||||||
|
fixed: 'right',
|
||||||
|
formatter: 'formatAmount2',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
width: 50,
|
||||||
|
fixed: 'right',
|
||||||
|
slots: { default: 'actions' },
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 列表的搜索表单 */
|
||||||
|
export function useGridFormSchema(): VbenFormSchema[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
fieldName: 'no',
|
||||||
|
label: '调度单号',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入调度单号',
|
||||||
|
allowClear: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'productId',
|
||||||
|
label: '产品',
|
||||||
|
component: 'ApiSelect',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请选择产品',
|
||||||
|
allowClear: true,
|
||||||
|
showSearch: true,
|
||||||
|
api: getProductSimpleList,
|
||||||
|
labelField: 'name',
|
||||||
|
valueField: 'id',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'moveTime',
|
||||||
|
label: '调度时间',
|
||||||
|
component: 'RangePicker',
|
||||||
|
componentProps: {
|
||||||
|
...getRangePickerDefaultProps(),
|
||||||
|
allowClear: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'fromWarehouseId',
|
||||||
|
label: '调出仓库',
|
||||||
|
component: 'ApiSelect',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请选择调出仓库',
|
||||||
|
allowClear: true,
|
||||||
|
showSearch: true,
|
||||||
|
api: getWarehouseSimpleList,
|
||||||
|
labelField: 'name',
|
||||||
|
valueField: 'id',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'toWarehouseId',
|
||||||
|
label: '调入仓库',
|
||||||
|
component: 'ApiSelect',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请选择调入仓库',
|
||||||
|
allowClear: true,
|
||||||
|
showSearch: true,
|
||||||
|
api: getWarehouseSimpleList,
|
||||||
|
labelField: 'name',
|
||||||
|
valueField: 'id',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'creator',
|
||||||
|
label: '创建人',
|
||||||
|
component: 'ApiSelect',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请选择创建人',
|
||||||
|
allowClear: true,
|
||||||
|
showSearch: true,
|
||||||
|
api: getSimpleUserList,
|
||||||
|
labelField: 'nickname',
|
||||||
|
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,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 列表的字段 */
|
||||||
|
export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
type: 'checkbox',
|
||||||
|
width: 50,
|
||||||
|
fixed: 'left',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'no',
|
||||||
|
title: '调度单号',
|
||||||
|
width: 200,
|
||||||
|
fixed: 'left',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'productNames',
|
||||||
|
title: '产品信息',
|
||||||
|
showOverflow: 'tooltip',
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'moveTime',
|
||||||
|
title: '调度时间',
|
||||||
|
width: 160,
|
||||||
|
formatter: 'formatDate',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'creatorName',
|
||||||
|
title: '创建人',
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'totalCount',
|
||||||
|
title: '总数量',
|
||||||
|
formatter: 'formatAmount3',
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'totalPrice',
|
||||||
|
title: '总金额',
|
||||||
|
formatter: 'formatAmount2',
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'status',
|
||||||
|
title: '状态',
|
||||||
|
minWidth: 120,
|
||||||
|
cellRender: {
|
||||||
|
name: 'CellDict',
|
||||||
|
props: { type: DICT_TYPE.ERP_AUDIT_STATUS },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
width: 260,
|
||||||
|
fixed: 'right',
|
||||||
|
slots: { default: 'actions' },
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
215
apps/web-ele/src/views/erp/stock/move/index.vue
Normal file
215
apps/web-ele/src/views/erp/stock/move/index.vue
Normal file
@@ -0,0 +1,215 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
import type { ErpStockMoveApi } from '#/api/erp/stock/move';
|
||||||
|
|
||||||
|
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 {
|
||||||
|
deleteStockMove,
|
||||||
|
exportStockMove,
|
||||||
|
getStockMovePage,
|
||||||
|
updateStockMoveStatus,
|
||||||
|
} from '#/api/erp/stock/move';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
|
import { useGridColumns, useGridFormSchema } from './data';
|
||||||
|
import Form from './modules/form.vue';
|
||||||
|
|
||||||
|
/** ERP 库存调拨单列表 */
|
||||||
|
defineOptions({ name: 'ErpStockMove' });
|
||||||
|
|
||||||
|
const [FormModal, formModalApi] = useVbenModal({
|
||||||
|
connectedComponent: Form,
|
||||||
|
destroyOnClose: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 刷新表格 */
|
||||||
|
function handleRefresh() {
|
||||||
|
gridApi.query();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 导出表格 */
|
||||||
|
async function handleExport() {
|
||||||
|
const data = await exportStockMove(await gridApi.formApi.getValues());
|
||||||
|
downloadFileFromBlobPart({ fileName: '库存调拨单.xls', source: data });
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 新增库存调拨单 */
|
||||||
|
function handleCreate() {
|
||||||
|
formModalApi.setData({ type: 'create' }).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 编辑库存调拨单 */
|
||||||
|
function handleEdit(row: ErpStockMoveApi.StockMove) {
|
||||||
|
formModalApi.setData({ type: 'edit', id: row.id }).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除库存调拨单 */
|
||||||
|
async function handleDelete(ids: number[]) {
|
||||||
|
const loadingInstance = ElLoading.service({
|
||||||
|
text: $t('ui.actionMessage.deleting'),
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await deleteStockMove(ids);
|
||||||
|
ElMessage.success($t('ui.actionMessage.deleteSuccess'));
|
||||||
|
handleRefresh();
|
||||||
|
} finally {
|
||||||
|
loadingInstance.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 审批/反审批操作 */
|
||||||
|
async function handleUpdateStatus(
|
||||||
|
row: ErpStockMoveApi.StockMove,
|
||||||
|
status: number,
|
||||||
|
) {
|
||||||
|
const loadingInstance = ElLoading.service({
|
||||||
|
text: `确定${status === 20 ? '审批' : '反审批'}该调拨单吗?`,
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await updateStockMoveStatus(row.id!, status);
|
||||||
|
ElMessage.success(`${status === 20 ? '审批' : '反审批'}成功`);
|
||||||
|
handleRefresh();
|
||||||
|
} finally {
|
||||||
|
loadingInstance.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const checkedIds = ref<number[]>([]);
|
||||||
|
function handleRowCheckboxChange({
|
||||||
|
records,
|
||||||
|
}: {
|
||||||
|
records: ErpStockMoveApi.StockMove[];
|
||||||
|
}) {
|
||||||
|
checkedIds.value = records.map((item) => item.id!);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查看详情 */
|
||||||
|
function handleDetail(row: ErpStockMoveApi.StockMove) {
|
||||||
|
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 getStockMovePage({
|
||||||
|
pageNo: page.currentPage,
|
||||||
|
pageSize: page.pageSize,
|
||||||
|
...formValues,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rowConfig: {
|
||||||
|
keyField: 'id',
|
||||||
|
isHover: true,
|
||||||
|
},
|
||||||
|
toolbarConfig: {
|
||||||
|
refresh: true,
|
||||||
|
search: true,
|
||||||
|
},
|
||||||
|
} as VxeTableGridOptions<ErpStockMoveApi.StockMove>,
|
||||||
|
gridEvents: {
|
||||||
|
checkboxAll: handleRowCheckboxChange,
|
||||||
|
checkboxChange: handleRowCheckboxChange,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Page auto-content-height>
|
||||||
|
<template #doc>
|
||||||
|
<DocAlert
|
||||||
|
title="【库存】库存调拨、库存盘点"
|
||||||
|
url="https://doc.iocoder.cn/erp/stock-move-check/"
|
||||||
|
/>
|
||||||
|
</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:stock-move:create'],
|
||||||
|
onClick: handleCreate,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: $t('ui.actionTitle.export'),
|
||||||
|
type: 'primary',
|
||||||
|
icon: ACTION_ICON.DOWNLOAD,
|
||||||
|
auth: ['erp:stock-move:export'],
|
||||||
|
onClick: handleExport,
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<template #actions="{ row }">
|
||||||
|
<TableAction
|
||||||
|
:actions="[
|
||||||
|
{
|
||||||
|
label: $t('common.detail'),
|
||||||
|
type: 'primary',
|
||||||
|
link: true,
|
||||||
|
icon: ACTION_ICON.VIEW,
|
||||||
|
auth: ['erp:stock-move:query'],
|
||||||
|
onClick: handleDetail.bind(null, row),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: $t('common.edit'),
|
||||||
|
type: 'primary',
|
||||||
|
link: true,
|
||||||
|
icon: ACTION_ICON.EDIT,
|
||||||
|
auth: ['erp:stock-move:update'],
|
||||||
|
ifShow: () => row.status !== 20,
|
||||||
|
onClick: handleEdit.bind(null, row),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: row.status === 10 ? '审批' : '反审批',
|
||||||
|
type: 'primary',
|
||||||
|
link: true,
|
||||||
|
icon: row.status === 10 ? ACTION_ICON.AUDIT : ACTION_ICON.REJECT,
|
||||||
|
auth: ['erp:stock-move: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:stock-move:delete'],
|
||||||
|
popConfirm: {
|
||||||
|
title: $t('ui.actionMessage.deleteConfirm', [row.no]),
|
||||||
|
confirm: handleDelete.bind(null, [row.id!]),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</Grid>
|
||||||
|
</Page>
|
||||||
|
</template>
|
||||||
132
apps/web-ele/src/views/erp/stock/move/modules/form.vue
Normal file
132
apps/web-ele/src/views/erp/stock/move/modules/form.vue
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
import type { ErpStockMoveApi } from '#/api/erp/stock/move';
|
||||||
|
|
||||||
|
import { computed, ref } from 'vue';
|
||||||
|
|
||||||
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
|
|
||||||
|
import { ElMessage } from 'element-plus';
|
||||||
|
|
||||||
|
import { useVbenForm } from '#/adapter/form';
|
||||||
|
import {
|
||||||
|
createStockMove,
|
||||||
|
getStockMove,
|
||||||
|
updateStockMove,
|
||||||
|
} from '#/api/erp/stock/move';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
|
import { useFormSchema } from '../data';
|
||||||
|
import ItemForm from './item-form.vue';
|
||||||
|
|
||||||
|
const emit = defineEmits(['success']);
|
||||||
|
const formData = ref<ErpStockMoveApi.StockMove>();
|
||||||
|
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,
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 更新调拨单项 */
|
||||||
|
function handleUpdateItems(items: ErpStockMoveApi.StockMoveItem[]) {
|
||||||
|
formData.value = modalApi.getData<ErpStockMoveApi.StockMove>();
|
||||||
|
formData.value.items = items;
|
||||||
|
formApi.setValues({
|
||||||
|
items,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 创建或更新库存调拨单 */
|
||||||
|
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 ErpStockMoveApi.StockMove;
|
||||||
|
try {
|
||||||
|
await (formType.value === 'create'
|
||||||
|
? createStockMove(data)
|
||||||
|
: updateStockMove(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<{ id?: number; type: string }>();
|
||||||
|
formType.value = data.type;
|
||||||
|
formApi.setDisabled(formType.value === 'detail');
|
||||||
|
formApi.updateSchema(useFormSchema(formType.value));
|
||||||
|
if (!data || !data.id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
modalApi.lock();
|
||||||
|
try {
|
||||||
|
formData.value = await getStockMove(data.id);
|
||||||
|
// 设置到 values
|
||||||
|
await formApi.setValues(formData.value);
|
||||||
|
} 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 ?? []"
|
||||||
|
:disabled="formType === 'detail'"
|
||||||
|
@update:items="handleUpdateItems"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</Form>
|
||||||
|
</Modal>
|
||||||
|
</template>
|
||||||
323
apps/web-ele/src/views/erp/stock/move/modules/item-form.vue
Normal file
323
apps/web-ele/src/views/erp/stock/move/modules/item-form.vue
Normal file
@@ -0,0 +1,323 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
import type { ErpProductApi } from '#/api/erp/product/product';
|
||||||
|
import type { ErpStockMoveApi } from '#/api/erp/stock/move';
|
||||||
|
|
||||||
|
import { computed, nextTick, onMounted, ref, watch } from 'vue';
|
||||||
|
|
||||||
|
import {
|
||||||
|
erpCountInputFormatter,
|
||||||
|
erpPriceInputFormatter,
|
||||||
|
erpPriceMultiply,
|
||||||
|
} from '@vben/utils';
|
||||||
|
|
||||||
|
import { ElInput, ElInputNumber, ElSelect } from 'element-plus';
|
||||||
|
|
||||||
|
import { TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
|
import { getProductSimpleList } from '#/api/erp/product/product';
|
||||||
|
import { getStockCount } from '#/api/erp/stock/stock';
|
||||||
|
import { getWarehouseSimpleList } from '#/api/erp/stock/warehouse';
|
||||||
|
|
||||||
|
import { useFormItemColumns } from '../data';
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
items?: ErpStockMoveApi.StockMoveItem[];
|
||||||
|
disabled?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
const props = withDefaults(defineProps<Props>(), {
|
||||||
|
items: () => [],
|
||||||
|
disabled: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
const emit = defineEmits(['update:items']);
|
||||||
|
|
||||||
|
const tableData = ref<ErpStockMoveApi.StockMoveItem[]>([]); // 表格数据
|
||||||
|
const productOptions = ref<ErpProductApi.Product[]>([]); // 产品下拉选项
|
||||||
|
const warehouseOptions = ref<any[]>([]); // 仓库下拉选项
|
||||||
|
|
||||||
|
/** 获取表格合计数据 */
|
||||||
|
const summaries = computed(() => {
|
||||||
|
return {
|
||||||
|
count: tableData.value.reduce((sum, item) => sum + (item.count || 0), 0),
|
||||||
|
totalPrice: tableData.value.reduce(
|
||||||
|
(sum, item) => sum + (item.totalPrice || 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;
|
||||||
|
}
|
||||||
|
items.forEach((item) => initRow(item));
|
||||||
|
tableData.value = [...items];
|
||||||
|
await nextTick(); // 特殊:保证 gridApi 已经初始化
|
||||||
|
await gridApi.grid.reloadData(tableData.value);
|
||||||
|
},
|
||||||
|
{
|
||||||
|
immediate: true,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
/** 处理新增 */
|
||||||
|
function handleAdd() {
|
||||||
|
const newRow = {
|
||||||
|
id: undefined,
|
||||||
|
fromWarehouseId: undefined,
|
||||||
|
toWarehouseId: undefined,
|
||||||
|
productId: undefined,
|
||||||
|
productUnitName: undefined, // 产品单位
|
||||||
|
productBarCode: undefined, // 产品条码
|
||||||
|
productPrice: undefined,
|
||||||
|
stockCount: undefined,
|
||||||
|
count: 1,
|
||||||
|
totalPrice: undefined,
|
||||||
|
remark: undefined,
|
||||||
|
};
|
||||||
|
tableData.value.push(newRow as any);
|
||||||
|
// 通知父组件更新
|
||||||
|
emit('update:items', [...tableData.value]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 处理删除 */
|
||||||
|
function handleDelete(row: ErpStockMoveApi.StockMoveItem) {
|
||||||
|
const index = tableData.value.findIndex((item) => item.seq === row.seq);
|
||||||
|
if (index !== -1) {
|
||||||
|
tableData.value.splice(index, 1);
|
||||||
|
}
|
||||||
|
// 通知父组件更新
|
||||||
|
emit('update:items', [...tableData.value]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 处理调出仓库变更 */
|
||||||
|
async function handleFromWarehouseChange(warehouseId: any, row: any) {
|
||||||
|
const warehouse = warehouseOptions.value.find((w) => w.id === warehouseId);
|
||||||
|
if (!warehouse) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
row.fromWarehouseId = warehouseId;
|
||||||
|
// 如果已选择产品,重新获取库存
|
||||||
|
if (row.productId) {
|
||||||
|
row.stockCount = (await getStockCount(row.productId, warehouseId)) || 0;
|
||||||
|
}
|
||||||
|
handleRowChange(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 处理调入仓库变更 */
|
||||||
|
async function handleToWarehouseChange(warehouseId: any, row: any) {
|
||||||
|
const warehouse = warehouseOptions.value.find((w) => w.id === warehouseId);
|
||||||
|
if (!warehouse) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
row.toWarehouseId = warehouseId;
|
||||||
|
handleRowChange(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 处理产品变更 */
|
||||||
|
async function handleProductChange(productId: any, row: any) {
|
||||||
|
const product = productOptions.value.find((p) => p.id === productId);
|
||||||
|
if (!product) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
row.productId = productId;
|
||||||
|
row.productUnitId = product.unitId;
|
||||||
|
row.productBarCode = product.barCode;
|
||||||
|
row.productUnitName = product.unitName;
|
||||||
|
row.productName = product.name;
|
||||||
|
row.stockCount = row.fromWarehouseId
|
||||||
|
? (await getStockCount(productId, row.fromWarehouseId)) || 0
|
||||||
|
: (await getStockCount(productId)) || 0;
|
||||||
|
row.productPrice = product.purchasePrice || 0;
|
||||||
|
row.count = row.count || 1;
|
||||||
|
handleRowChange(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 处理行数据变更 */
|
||||||
|
function handleRowChange(row: any) {
|
||||||
|
const index = tableData.value.findIndex((item) => item.seq === row.seq);
|
||||||
|
if (index === -1) {
|
||||||
|
tableData.value.push(row);
|
||||||
|
} else {
|
||||||
|
tableData.value[index] = row;
|
||||||
|
}
|
||||||
|
emit('update:items', [...tableData.value]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 初始化行数据 */
|
||||||
|
function initRow(row: ErpStockMoveApi.StockMoveItem) {
|
||||||
|
if (row.productPrice && row.count) {
|
||||||
|
row.totalPrice = erpPriceMultiply(row.productPrice, row.count) ?? 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 表单校验 */
|
||||||
|
function validate() {
|
||||||
|
for (let i = 0; i < tableData.value.length; i++) {
|
||||||
|
const item = tableData.value[i];
|
||||||
|
if (item) {
|
||||||
|
if (!item.fromWarehouseId) {
|
||||||
|
throw new Error(`第 ${i + 1} 行:调出仓库不能为空`);
|
||||||
|
}
|
||||||
|
if (!item.toWarehouseId) {
|
||||||
|
throw new Error(`第 ${i + 1} 行:调入仓库不能为空`);
|
||||||
|
}
|
||||||
|
if (!item.productId) {
|
||||||
|
throw new Error(`第 ${i + 1} 行:产品不能为空`);
|
||||||
|
}
|
||||||
|
if (!item.count || item.count <= 0) {
|
||||||
|
throw new Error(`第 ${i + 1} 行:产品数量不能为空`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
validate,
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 初始化 */
|
||||||
|
onMounted(async () => {
|
||||||
|
productOptions.value = await getProductSimpleList();
|
||||||
|
warehouseOptions.value = await getWarehouseSimpleList();
|
||||||
|
// 目的:新增时,默认添加一行
|
||||||
|
if (tableData.value.length === 0) {
|
||||||
|
handleAdd();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Grid class="w-full">
|
||||||
|
<template #fromWarehouseId="{ row }">
|
||||||
|
<ElSelect
|
||||||
|
v-model="row.fromWarehouseId"
|
||||||
|
:options="warehouseOptions"
|
||||||
|
:props="{ label: 'name', value: 'id' }"
|
||||||
|
class="w-full"
|
||||||
|
placeholder="请选择调出仓库"
|
||||||
|
filterable
|
||||||
|
:disabled="disabled"
|
||||||
|
@change="handleFromWarehouseChange($event, row)"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<template #toWarehouseId="{ row }">
|
||||||
|
<ElSelect
|
||||||
|
v-model="row.toWarehouseId"
|
||||||
|
:options="warehouseOptions"
|
||||||
|
:props="{ label: 'name', value: 'id' }"
|
||||||
|
class="w-full"
|
||||||
|
placeholder="请选择调入仓库"
|
||||||
|
filterable
|
||||||
|
:disabled="disabled"
|
||||||
|
@change="handleToWarehouseChange($event, row)"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<template #productId="{ row }">
|
||||||
|
<ElSelect
|
||||||
|
v-model="row.productId"
|
||||||
|
:options="productOptions"
|
||||||
|
:props="{ label: 'name', value: 'id' }"
|
||||||
|
class="w-full"
|
||||||
|
placeholder="请选择产品"
|
||||||
|
filterable
|
||||||
|
:disabled="disabled"
|
||||||
|
@change="handleProductChange($event, row)"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<template #count="{ row }">
|
||||||
|
<ElInputNumber
|
||||||
|
v-if="!disabled"
|
||||||
|
v-model="row.count"
|
||||||
|
:min="0"
|
||||||
|
:precision="3"
|
||||||
|
controls-position="right"
|
||||||
|
class="!w-full"
|
||||||
|
@change="handleRowChange(row)"
|
||||||
|
/>
|
||||||
|
<span v-else>{{ erpCountInputFormatter(row.count) || '-' }}</span>
|
||||||
|
</template>
|
||||||
|
<template #productPrice="{ row }">
|
||||||
|
<ElInputNumber
|
||||||
|
v-if="!disabled"
|
||||||
|
v-model="row.productPrice"
|
||||||
|
:min="0"
|
||||||
|
:precision="2"
|
||||||
|
controls-position="right"
|
||||||
|
class="!w-full"
|
||||||
|
@change="handleRowChange(row)"
|
||||||
|
/>
|
||||||
|
<span v-else>{{ erpPriceInputFormatter(row.productPrice) || '-' }}</span>
|
||||||
|
</template>
|
||||||
|
<template #remark="{ row }">
|
||||||
|
<ElInput v-if="!disabled" v-model="row.remark" class="w-full" />
|
||||||
|
<span v-else>{{ row.remark || '-' }}</span>
|
||||||
|
</template>
|
||||||
|
<template #actions="{ row }">
|
||||||
|
<TableAction
|
||||||
|
v-if="!disabled"
|
||||||
|
:actions="[
|
||||||
|
{
|
||||||
|
label: '删除',
|
||||||
|
type: 'danger',
|
||||||
|
link: true,
|
||||||
|
icon: 'ant-design:delete-outlined',
|
||||||
|
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>数量:{{ erpCountInputFormatter(summaries.count) }}</span>
|
||||||
|
<span>
|
||||||
|
金额:{{ erpPriceInputFormatter(summaries.totalPrice) }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<TableAction
|
||||||
|
v-if="!disabled"
|
||||||
|
class="mt-2 flex justify-center"
|
||||||
|
:actions="[
|
||||||
|
{
|
||||||
|
label: '添加调拨产品',
|
||||||
|
type: 'default',
|
||||||
|
onClick: handleAdd,
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</Grid>
|
||||||
|
</template>
|
||||||
330
apps/web-ele/src/views/erp/stock/out/data.ts
Normal file
330
apps/web-ele/src/views/erp/stock/out/data.ts
Normal file
@@ -0,0 +1,330 @@
|
|||||||
|
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 { getProductSimpleList } from '#/api/erp/product/product';
|
||||||
|
import { getCustomerSimpleList } from '#/api/erp/sale/customer';
|
||||||
|
import { getWarehouseSimpleList } from '#/api/erp/stock/warehouse';
|
||||||
|
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: 'outTime',
|
||||||
|
label: '出库时间',
|
||||||
|
component: 'DatePicker',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '选择出库时间',
|
||||||
|
showTime: true,
|
||||||
|
format: 'YYYY-MM-DD HH:mm:ss',
|
||||||
|
valueFormat: 'x',
|
||||||
|
class: '!w-full',
|
||||||
|
},
|
||||||
|
rules: 'required',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '客户',
|
||||||
|
fieldName: 'customerId',
|
||||||
|
component: 'ApiSelect',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请选择客户',
|
||||||
|
allowClear: true,
|
||||||
|
showSearch: true,
|
||||||
|
api: getCustomerSimpleList,
|
||||||
|
labelField: 'name',
|
||||||
|
valueField: 'id',
|
||||||
|
},
|
||||||
|
rules: 'required',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
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',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 表单的明细表格列 */
|
||||||
|
export function useFormItemColumns(): VxeTableGridOptions['columns'] {
|
||||||
|
return [
|
||||||
|
{ type: 'seq', title: '序号', minWidth: 50, fixed: 'left' },
|
||||||
|
{
|
||||||
|
field: 'warehouseId',
|
||||||
|
title: '仓库名称',
|
||||||
|
minWidth: 150,
|
||||||
|
slots: { default: 'warehouseId' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'productId',
|
||||||
|
title: '产品名称',
|
||||||
|
minWidth: 200,
|
||||||
|
slots: { default: 'productId' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'stockCount',
|
||||||
|
title: '库存',
|
||||||
|
minWidth: 80,
|
||||||
|
formatter: 'formatAmount3',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'productBarCode',
|
||||||
|
title: '条码',
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'productUnitName',
|
||||||
|
title: '单位',
|
||||||
|
minWidth: 80,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'remark',
|
||||||
|
title: '备注',
|
||||||
|
minWidth: 150,
|
||||||
|
slots: { default: 'remark' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'count',
|
||||||
|
title: '数量',
|
||||||
|
minWidth: 120,
|
||||||
|
fixed: 'right',
|
||||||
|
slots: { default: 'count' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'productPrice',
|
||||||
|
title: '产品单价',
|
||||||
|
minWidth: 120,
|
||||||
|
fixed: 'right',
|
||||||
|
slots: { default: 'productPrice' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'totalPrice',
|
||||||
|
title: '金额',
|
||||||
|
minWidth: 120,
|
||||||
|
fixed: 'right',
|
||||||
|
formatter: 'formatAmount2',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
width: 50,
|
||||||
|
fixed: 'right',
|
||||||
|
slots: { default: 'actions' },
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 列表的搜索表单 */
|
||||||
|
export function useGridFormSchema(): VbenFormSchema[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
fieldName: 'no',
|
||||||
|
label: '出库单号',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入出库单号',
|
||||||
|
allowClear: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'productId',
|
||||||
|
label: '产品',
|
||||||
|
component: 'ApiSelect',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请选择产品',
|
||||||
|
allowClear: true,
|
||||||
|
showSearch: true,
|
||||||
|
api: getProductSimpleList,
|
||||||
|
labelField: 'name',
|
||||||
|
valueField: 'id',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'outTime',
|
||||||
|
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: 'warehouseId',
|
||||||
|
label: '仓库',
|
||||||
|
component: 'ApiSelect',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请选择仓库',
|
||||||
|
allowClear: true,
|
||||||
|
showSearch: true,
|
||||||
|
api: getWarehouseSimpleList,
|
||||||
|
labelField: 'name',
|
||||||
|
valueField: 'id',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'creator',
|
||||||
|
label: '创建人',
|
||||||
|
component: 'ApiSelect',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请选择创建人',
|
||||||
|
allowClear: true,
|
||||||
|
showSearch: true,
|
||||||
|
api: getSimpleUserList,
|
||||||
|
labelField: 'nickname',
|
||||||
|
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,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 列表的字段 */
|
||||||
|
export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
type: 'checkbox',
|
||||||
|
width: 50,
|
||||||
|
fixed: 'left',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'no',
|
||||||
|
title: '出库单号',
|
||||||
|
width: 200,
|
||||||
|
fixed: 'left',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'productNames',
|
||||||
|
title: '产品信息',
|
||||||
|
showOverflow: 'tooltip',
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'customerName',
|
||||||
|
title: '客户',
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'outTime',
|
||||||
|
title: '出库时间',
|
||||||
|
width: 160,
|
||||||
|
formatter: 'formatDate',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'creatorName',
|
||||||
|
title: '创建人',
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'totalCount',
|
||||||
|
title: '总数量',
|
||||||
|
formatter: 'formatAmount3',
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'totalPrice',
|
||||||
|
title: '总金额',
|
||||||
|
formatter: 'formatAmount2',
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'status',
|
||||||
|
title: '状态',
|
||||||
|
minWidth: 120,
|
||||||
|
cellRender: {
|
||||||
|
name: 'CellDict',
|
||||||
|
props: { type: DICT_TYPE.ERP_AUDIT_STATUS },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
width: 260,
|
||||||
|
fixed: 'right',
|
||||||
|
slots: { default: 'actions' },
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
215
apps/web-ele/src/views/erp/stock/out/index.vue
Normal file
215
apps/web-ele/src/views/erp/stock/out/index.vue
Normal file
@@ -0,0 +1,215 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
import type { ErpStockOutApi } from '#/api/erp/stock/out';
|
||||||
|
|
||||||
|
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 {
|
||||||
|
deleteStockOut,
|
||||||
|
exportStockOut,
|
||||||
|
getStockOutPage,
|
||||||
|
updateStockOutStatus,
|
||||||
|
} from '#/api/erp/stock/out';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
|
import { useGridColumns, useGridFormSchema } from './data';
|
||||||
|
import Form from './modules/form.vue';
|
||||||
|
|
||||||
|
/** ERP 其它出库单列表 */
|
||||||
|
defineOptions({ name: 'ErpStockOut' });
|
||||||
|
|
||||||
|
const [FormModal, formModalApi] = useVbenModal({
|
||||||
|
connectedComponent: Form,
|
||||||
|
destroyOnClose: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 刷新表格 */
|
||||||
|
function handleRefresh() {
|
||||||
|
gridApi.query();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 导出表格 */
|
||||||
|
async function handleExport() {
|
||||||
|
const data = await exportStockOut(await gridApi.formApi.getValues());
|
||||||
|
downloadFileFromBlobPart({ fileName: '其它出库单.xls', source: data });
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 新增其它出库单 */
|
||||||
|
function handleCreate() {
|
||||||
|
formModalApi.setData({ type: 'create' }).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 编辑其它出库单 */
|
||||||
|
function handleEdit(row: ErpStockOutApi.StockOut) {
|
||||||
|
formModalApi.setData({ type: 'edit', id: row.id }).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除其它出库单 */
|
||||||
|
async function handleDelete(ids: number[]) {
|
||||||
|
const loadingInstance = ElLoading.service({
|
||||||
|
text: $t('ui.actionMessage.deleting'),
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await deleteStockOut(ids);
|
||||||
|
ElMessage.success($t('ui.actionMessage.deleteSuccess'));
|
||||||
|
handleRefresh();
|
||||||
|
} finally {
|
||||||
|
loadingInstance.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 审批/反审批操作 */
|
||||||
|
async function handleUpdateStatus(
|
||||||
|
row: ErpStockOutApi.StockOut,
|
||||||
|
status: number,
|
||||||
|
) {
|
||||||
|
const loadingInstance = ElLoading.service({
|
||||||
|
text: `确定${status === 20 ? '审批' : '反审批'}该出库单吗?`,
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await updateStockOutStatus(row.id!, status);
|
||||||
|
ElMessage.success(`${status === 20 ? '审批' : '反审批'}成功`);
|
||||||
|
handleRefresh();
|
||||||
|
} finally {
|
||||||
|
loadingInstance.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const checkedIds = ref<number[]>([]);
|
||||||
|
function handleRowCheckboxChange({
|
||||||
|
records,
|
||||||
|
}: {
|
||||||
|
records: ErpStockOutApi.StockOut[];
|
||||||
|
}) {
|
||||||
|
checkedIds.value = records.map((item) => item.id!);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查看详情 */
|
||||||
|
function handleDetail(row: ErpStockOutApi.StockOut) {
|
||||||
|
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 getStockOutPage({
|
||||||
|
pageNo: page.currentPage,
|
||||||
|
pageSize: page.pageSize,
|
||||||
|
...formValues,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rowConfig: {
|
||||||
|
keyField: 'id',
|
||||||
|
isHover: true,
|
||||||
|
},
|
||||||
|
toolbarConfig: {
|
||||||
|
refresh: true,
|
||||||
|
search: true,
|
||||||
|
},
|
||||||
|
} as VxeTableGridOptions<ErpStockOutApi.StockOut>,
|
||||||
|
gridEvents: {
|
||||||
|
checkboxAll: handleRowCheckboxChange,
|
||||||
|
checkboxChange: handleRowCheckboxChange,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Page auto-content-height>
|
||||||
|
<template #doc>
|
||||||
|
<DocAlert
|
||||||
|
title="【库存】其它入库、其它出库"
|
||||||
|
url="https://doc.iocoder.cn/erp/stock-in-out/"
|
||||||
|
/>
|
||||||
|
</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:stock-out:create'],
|
||||||
|
onClick: handleCreate,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: $t('ui.actionTitle.export'),
|
||||||
|
type: 'primary',
|
||||||
|
icon: ACTION_ICON.DOWNLOAD,
|
||||||
|
auth: ['erp:stock-out:export'],
|
||||||
|
onClick: handleExport,
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<template #actions="{ row }">
|
||||||
|
<TableAction
|
||||||
|
:actions="[
|
||||||
|
{
|
||||||
|
label: $t('common.detail'),
|
||||||
|
type: 'primary',
|
||||||
|
link: true,
|
||||||
|
icon: ACTION_ICON.VIEW,
|
||||||
|
auth: ['erp:stock-out:query'],
|
||||||
|
onClick: handleDetail.bind(null, row),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: $t('common.edit'),
|
||||||
|
type: 'primary',
|
||||||
|
link: true,
|
||||||
|
icon: ACTION_ICON.EDIT,
|
||||||
|
auth: ['erp:stock-out:update'],
|
||||||
|
ifShow: () => row.status !== 20,
|
||||||
|
onClick: handleEdit.bind(null, row),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: row.status === 10 ? '审批' : '反审批',
|
||||||
|
type: 'primary',
|
||||||
|
link: true,
|
||||||
|
icon: row.status === 10 ? ACTION_ICON.AUDIT : ACTION_ICON.REJECT,
|
||||||
|
auth: ['erp:stock-out: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:stock-out:delete'],
|
||||||
|
popConfirm: {
|
||||||
|
title: $t('ui.actionMessage.deleteConfirm', [row.no]),
|
||||||
|
confirm: handleDelete.bind(null, [row.id!]),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</Grid>
|
||||||
|
</Page>
|
||||||
|
</template>
|
||||||
132
apps/web-ele/src/views/erp/stock/out/modules/form.vue
Normal file
132
apps/web-ele/src/views/erp/stock/out/modules/form.vue
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
import type { ErpStockOutApi } from '#/api/erp/stock/out';
|
||||||
|
|
||||||
|
import { computed, ref } from 'vue';
|
||||||
|
|
||||||
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
|
|
||||||
|
import { ElMessage } from 'element-plus';
|
||||||
|
|
||||||
|
import { useVbenForm } from '#/adapter/form';
|
||||||
|
import {
|
||||||
|
createStockOut,
|
||||||
|
getStockOut,
|
||||||
|
updateStockOut,
|
||||||
|
} from '#/api/erp/stock/out';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
|
import { useFormSchema } from '../data';
|
||||||
|
import ItemForm from './item-form.vue';
|
||||||
|
|
||||||
|
const emit = defineEmits(['success']);
|
||||||
|
const formData = ref<ErpStockOutApi.StockOut>();
|
||||||
|
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,
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 更新出库单项 */
|
||||||
|
function handleUpdateItems(items: ErpStockOutApi.StockOutItem[]) {
|
||||||
|
formData.value = modalApi.getData<ErpStockOutApi.StockOut>();
|
||||||
|
formData.value.items = items;
|
||||||
|
formApi.setValues({
|
||||||
|
items,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 创建或更新其它出库单 */
|
||||||
|
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 ErpStockOutApi.StockOut;
|
||||||
|
try {
|
||||||
|
await (formType.value === 'create'
|
||||||
|
? createStockOut(data)
|
||||||
|
: updateStockOut(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<{ id?: number; type: string }>();
|
||||||
|
formType.value = data.type;
|
||||||
|
formApi.setDisabled(formType.value === 'detail');
|
||||||
|
formApi.updateSchema(useFormSchema(formType.value));
|
||||||
|
if (!data || !data.id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
modalApi.lock();
|
||||||
|
try {
|
||||||
|
formData.value = await getStockOut(data.id);
|
||||||
|
// 设置到 values
|
||||||
|
await formApi.setValues(formData.value);
|
||||||
|
} 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 ?? []"
|
||||||
|
:disabled="formType === 'detail'"
|
||||||
|
@update:items="handleUpdateItems"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</Form>
|
||||||
|
</Modal>
|
||||||
|
</template>
|
||||||
300
apps/web-ele/src/views/erp/stock/out/modules/item-form.vue
Normal file
300
apps/web-ele/src/views/erp/stock/out/modules/item-form.vue
Normal file
@@ -0,0 +1,300 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
import type { ErpProductApi } from '#/api/erp/product/product';
|
||||||
|
import type { ErpStockOutApi } from '#/api/erp/stock/out';
|
||||||
|
|
||||||
|
import { computed, nextTick, onMounted, ref, watch } from 'vue';
|
||||||
|
|
||||||
|
import {
|
||||||
|
erpCountInputFormatter,
|
||||||
|
erpPriceInputFormatter,
|
||||||
|
erpPriceMultiply,
|
||||||
|
} from '@vben/utils';
|
||||||
|
|
||||||
|
import { ElInput, ElInputNumber, ElSelect } from 'element-plus';
|
||||||
|
|
||||||
|
import { TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
|
import { getProductSimpleList } from '#/api/erp/product/product';
|
||||||
|
import { getStockCount } from '#/api/erp/stock/stock';
|
||||||
|
import { getWarehouseSimpleList } from '#/api/erp/stock/warehouse';
|
||||||
|
|
||||||
|
import { useFormItemColumns } from '../data';
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
items?: ErpStockOutApi.StockOutItem[];
|
||||||
|
disabled?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
const props = withDefaults(defineProps<Props>(), {
|
||||||
|
items: () => [],
|
||||||
|
disabled: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
const emit = defineEmits(['update:items']);
|
||||||
|
|
||||||
|
const tableData = ref<ErpStockOutApi.StockOutItem[]>([]); // 表格数据
|
||||||
|
const productOptions = ref<ErpProductApi.Product[]>([]); // 产品下拉选项
|
||||||
|
const warehouseOptions = ref<any[]>([]); // 仓库下拉选项
|
||||||
|
|
||||||
|
/** 获取表格合计数据 */
|
||||||
|
const summaries = computed(() => {
|
||||||
|
return {
|
||||||
|
count: tableData.value.reduce((sum, item) => sum + (item.count || 0), 0),
|
||||||
|
totalPrice: tableData.value.reduce(
|
||||||
|
(sum, item) => sum + (item.totalPrice || 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;
|
||||||
|
}
|
||||||
|
items.forEach((item) => initRow(item));
|
||||||
|
tableData.value = [...items];
|
||||||
|
await nextTick(); // 特殊:保证 gridApi 已经初始化
|
||||||
|
await gridApi.grid.reloadData(tableData.value);
|
||||||
|
},
|
||||||
|
{
|
||||||
|
immediate: true,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
/** 处理新增 */
|
||||||
|
function handleAdd() {
|
||||||
|
const newRow = {
|
||||||
|
id: undefined,
|
||||||
|
warehouseId: undefined,
|
||||||
|
productId: undefined,
|
||||||
|
productUnitName: undefined, // 产品单位
|
||||||
|
productBarCode: undefined, // 产品条码
|
||||||
|
productPrice: undefined,
|
||||||
|
stockCount: undefined,
|
||||||
|
count: 1,
|
||||||
|
totalPrice: undefined,
|
||||||
|
remark: undefined,
|
||||||
|
};
|
||||||
|
tableData.value.push(newRow as any);
|
||||||
|
// 通知父组件更新
|
||||||
|
emit('update:items', [...tableData.value]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 处理删除 */
|
||||||
|
function handleDelete(row: ErpStockOutApi.StockOutItem) {
|
||||||
|
const index = tableData.value.findIndex((item) => item.seq === row.seq);
|
||||||
|
if (index !== -1) {
|
||||||
|
tableData.value.splice(index, 1);
|
||||||
|
}
|
||||||
|
// 通知父组件更新
|
||||||
|
emit('update:items', [...tableData.value]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 处理仓库变更 */
|
||||||
|
async function handleWarehouseChange(warehouseId: any, row: any) {
|
||||||
|
const warehouse = warehouseOptions.value.find((w) => w.id === warehouseId);
|
||||||
|
if (!warehouse) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
row.warehouseId = warehouseId;
|
||||||
|
// 如果已选择产品,重新获取库存
|
||||||
|
if (row.productId) {
|
||||||
|
row.stockCount = (await getStockCount(row.productId, warehouseId)) || 0;
|
||||||
|
}
|
||||||
|
handleRowChange(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 处理产品变更 */
|
||||||
|
async function handleProductChange(productId: any, row: any) {
|
||||||
|
const product = productOptions.value.find((p) => p.id === productId);
|
||||||
|
if (!product) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
row.productId = productId;
|
||||||
|
row.productUnitId = product.unitId;
|
||||||
|
row.productBarCode = product.barCode;
|
||||||
|
row.productUnitName = product.unitName;
|
||||||
|
row.productName = product.name;
|
||||||
|
row.stockCount = row.warehouseId
|
||||||
|
? (await getStockCount(productId, row.warehouseId)) || 0
|
||||||
|
: (await getStockCount(productId)) || 0;
|
||||||
|
row.productPrice = product.purchasePrice || 0;
|
||||||
|
row.count = row.count || 1;
|
||||||
|
handleRowChange(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 处理行数据变更 */
|
||||||
|
function handleRowChange(row: any) {
|
||||||
|
const index = tableData.value.findIndex((item) => item.seq === row.seq);
|
||||||
|
if (index === -1) {
|
||||||
|
tableData.value.push(row);
|
||||||
|
} else {
|
||||||
|
tableData.value[index] = row;
|
||||||
|
}
|
||||||
|
emit('update:items', [...tableData.value]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 初始化行数据 */
|
||||||
|
function initRow(row: ErpStockOutApi.StockOutItem) {
|
||||||
|
if (row.productPrice && row.count) {
|
||||||
|
row.totalPrice = erpPriceMultiply(row.productPrice, row.count) ?? 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 表单校验 */
|
||||||
|
function validate() {
|
||||||
|
for (let i = 0; i < tableData.value.length; i++) {
|
||||||
|
const item = tableData.value[i];
|
||||||
|
if (item) {
|
||||||
|
if (!item.warehouseId) {
|
||||||
|
throw new Error(`第 ${i + 1} 行:仓库不能为空`);
|
||||||
|
}
|
||||||
|
if (!item.productId) {
|
||||||
|
throw new Error(`第 ${i + 1} 行:产品不能为空`);
|
||||||
|
}
|
||||||
|
if (!item.count || item.count <= 0) {
|
||||||
|
throw new Error(`第 ${i + 1} 行:产品数量不能为空`);
|
||||||
|
}
|
||||||
|
if (!item.productPrice || item.productPrice <= 0) {
|
||||||
|
throw new Error(`第 ${i + 1} 行:产品单价不能为空`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
validate,
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 初始化 */
|
||||||
|
onMounted(async () => {
|
||||||
|
productOptions.value = await getProductSimpleList();
|
||||||
|
warehouseOptions.value = await getWarehouseSimpleList();
|
||||||
|
// 目的:新增时,默认添加一行
|
||||||
|
if (tableData.value.length === 0) {
|
||||||
|
handleAdd();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Grid class="w-full">
|
||||||
|
<template #warehouseId="{ row }">
|
||||||
|
<ElSelect
|
||||||
|
v-model="row.warehouseId"
|
||||||
|
:options="warehouseOptions"
|
||||||
|
:props="{ label: 'name', value: 'id' }"
|
||||||
|
class="w-full"
|
||||||
|
placeholder="请选择仓库"
|
||||||
|
filterable
|
||||||
|
:disabled="disabled"
|
||||||
|
@change="handleWarehouseChange($event, row)"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<template #productId="{ row }">
|
||||||
|
<ElSelect
|
||||||
|
v-model="row.productId"
|
||||||
|
:options="productOptions"
|
||||||
|
:props="{ label: 'name', value: 'id' }"
|
||||||
|
class="w-full"
|
||||||
|
placeholder="请选择产品"
|
||||||
|
filterable
|
||||||
|
:disabled="disabled"
|
||||||
|
@change="handleProductChange($event, row)"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<template #count="{ row }">
|
||||||
|
<ElInputNumber
|
||||||
|
v-if="!disabled"
|
||||||
|
v-model="row.count"
|
||||||
|
:min="0"
|
||||||
|
:precision="3"
|
||||||
|
controls-position="right"
|
||||||
|
class="!w-full"
|
||||||
|
@change="handleRowChange(row)"
|
||||||
|
/>
|
||||||
|
<span v-else>{{ erpCountInputFormatter(row.count) || '-' }}</span>
|
||||||
|
</template>
|
||||||
|
<template #productPrice="{ row }">
|
||||||
|
<ElInputNumber
|
||||||
|
v-if="!disabled"
|
||||||
|
v-model="row.productPrice"
|
||||||
|
:min="0"
|
||||||
|
:precision="2"
|
||||||
|
controls-position="right"
|
||||||
|
class="!w-full"
|
||||||
|
@change="handleRowChange(row)"
|
||||||
|
/>
|
||||||
|
<span v-else>{{ erpPriceInputFormatter(row.productPrice) || '-' }}</span>
|
||||||
|
</template>
|
||||||
|
<template #remark="{ row }">
|
||||||
|
<ElInput v-if="!disabled" v-model="row.remark" class="w-full" />
|
||||||
|
<span v-else>{{ row.remark || '-' }}</span>
|
||||||
|
</template>
|
||||||
|
<template #actions="{ row }">
|
||||||
|
<TableAction
|
||||||
|
v-if="!disabled"
|
||||||
|
:actions="[
|
||||||
|
{
|
||||||
|
label: '删除',
|
||||||
|
type: 'danger',
|
||||||
|
link: true,
|
||||||
|
icon: 'ant-design:delete-outlined',
|
||||||
|
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>数量:{{ erpCountInputFormatter(summaries.count) }}</span>
|
||||||
|
<span>
|
||||||
|
金额:{{ erpPriceInputFormatter(summaries.totalPrice) }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<TableAction
|
||||||
|
v-if="!disabled"
|
||||||
|
class="mt-2 flex justify-center"
|
||||||
|
:actions="[
|
||||||
|
{
|
||||||
|
label: '添加出库产品',
|
||||||
|
type: 'default',
|
||||||
|
onClick: handleAdd,
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</Grid>
|
||||||
|
</template>
|
||||||
133
apps/web-ele/src/views/erp/stock/record/data.ts
Normal file
133
apps/web-ele/src/views/erp/stock/record/data.ts
Normal file
@@ -0,0 +1,133 @@
|
|||||||
|
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 { getProductSimpleList } from '#/api/erp/product/product';
|
||||||
|
import { getWarehouseSimpleList } from '#/api/erp/stock/warehouse';
|
||||||
|
import { getRangePickerDefaultProps } from '#/utils';
|
||||||
|
|
||||||
|
/** 搜索表单 */
|
||||||
|
export function useGridFormSchema(): VbenFormSchema[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
fieldName: 'productId',
|
||||||
|
label: '产品',
|
||||||
|
component: 'ApiSelect',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请选择产品',
|
||||||
|
allowClear: true,
|
||||||
|
showSearch: true,
|
||||||
|
api: getProductSimpleList,
|
||||||
|
labelField: 'name',
|
||||||
|
valueField: 'id',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'warehouseId',
|
||||||
|
label: '仓库',
|
||||||
|
component: 'ApiSelect',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请选择仓库',
|
||||||
|
allowClear: true,
|
||||||
|
showSearch: true,
|
||||||
|
api: getWarehouseSimpleList,
|
||||||
|
labelField: 'name',
|
||||||
|
valueField: 'id',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'bizType',
|
||||||
|
label: '类型',
|
||||||
|
component: 'Select',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请选择类型',
|
||||||
|
allowClear: true,
|
||||||
|
options: getDictOptions(DICT_TYPE.ERP_STOCK_RECORD_BIZ_TYPE, 'number'),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'bizNo',
|
||||||
|
label: '业务单号',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入业务单号',
|
||||||
|
allowClear: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'createTime',
|
||||||
|
label: '创建时间',
|
||||||
|
component: 'RangePicker',
|
||||||
|
componentProps: {
|
||||||
|
...getRangePickerDefaultProps(),
|
||||||
|
allowClear: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 列表的字段 */
|
||||||
|
export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
field: 'productName',
|
||||||
|
title: '产品名称',
|
||||||
|
minWidth: 150,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'categoryName',
|
||||||
|
title: '产品分类',
|
||||||
|
width: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'unitName',
|
||||||
|
title: '产品单位',
|
||||||
|
width: 100,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'warehouseName',
|
||||||
|
title: '仓库',
|
||||||
|
width: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'bizType',
|
||||||
|
title: '类型',
|
||||||
|
width: 100,
|
||||||
|
cellRender: {
|
||||||
|
name: 'CellDict',
|
||||||
|
props: { type: DICT_TYPE.ERP_STOCK_RECORD_BIZ_TYPE },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'bizNo',
|
||||||
|
title: '出入库单号',
|
||||||
|
width: 200,
|
||||||
|
showOverflow: 'tooltip',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'createTime',
|
||||||
|
title: '出入库日期',
|
||||||
|
width: 180,
|
||||||
|
formatter: 'formatDateTime',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'count',
|
||||||
|
title: '出入库数量',
|
||||||
|
width: 120,
|
||||||
|
formatter: 'formatAmount3',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'totalCount',
|
||||||
|
title: '库存量',
|
||||||
|
width: 100,
|
||||||
|
formatter: 'formatAmount3',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'creatorName',
|
||||||
|
title: '操作人',
|
||||||
|
width: 100,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
79
apps/web-ele/src/views/erp/stock/record/index.vue
Normal file
79
apps/web-ele/src/views/erp/stock/record/index.vue
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
import type { ErpStockRecordApi } from '#/api/erp/stock/record';
|
||||||
|
|
||||||
|
import { DocAlert, Page } from '@vben/common-ui';
|
||||||
|
import { downloadFileFromBlobPart } from '@vben/utils';
|
||||||
|
|
||||||
|
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
|
import { exportStockRecord, getStockRecordPage } from '#/api/erp/stock/record';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
|
import { useGridColumns, useGridFormSchema } from './data';
|
||||||
|
|
||||||
|
/** 产品库存明细管理 */
|
||||||
|
defineOptions({ name: 'ErpStockRecord' });
|
||||||
|
|
||||||
|
/** 导出库存明细 */
|
||||||
|
async function handleExport() {
|
||||||
|
const data = await exportStockRecord(await gridApi.formApi.getValues());
|
||||||
|
downloadFileFromBlobPart({ fileName: '产品库存明细.xls', source: data });
|
||||||
|
}
|
||||||
|
|
||||||
|
const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
|
formOptions: {
|
||||||
|
schema: useGridFormSchema(),
|
||||||
|
},
|
||||||
|
gridOptions: {
|
||||||
|
columns: useGridColumns(),
|
||||||
|
height: 'auto',
|
||||||
|
keepSource: true,
|
||||||
|
proxyConfig: {
|
||||||
|
ajax: {
|
||||||
|
query: async ({ page }, formValues) => {
|
||||||
|
return await getStockRecordPage({
|
||||||
|
pageNo: page.currentPage,
|
||||||
|
pageSize: page.pageSize,
|
||||||
|
...formValues,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rowConfig: {
|
||||||
|
keyField: 'id',
|
||||||
|
isHover: true,
|
||||||
|
},
|
||||||
|
toolbarConfig: {
|
||||||
|
refresh: true,
|
||||||
|
search: true,
|
||||||
|
},
|
||||||
|
} as VxeTableGridOptions<ErpStockRecordApi.StockRecord>,
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Page auto-content-height>
|
||||||
|
<template #doc>
|
||||||
|
<DocAlert
|
||||||
|
title="【库存】产品库存、库存明细"
|
||||||
|
url="https://doc.iocoder.cn/erp/stock/"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<Grid table-title="产品库存明细列表">
|
||||||
|
<template #toolbar-tools>
|
||||||
|
<TableAction
|
||||||
|
:actions="[
|
||||||
|
{
|
||||||
|
label: $t('ui.actionTitle.export'),
|
||||||
|
type: 'primary',
|
||||||
|
icon: ACTION_ICON.DOWNLOAD,
|
||||||
|
auth: ['erp:stock-record:export'],
|
||||||
|
onClick: handleExport,
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</Grid>
|
||||||
|
</Page>
|
||||||
|
</template>
|
||||||
69
apps/web-ele/src/views/erp/stock/stock/data.ts
Normal file
69
apps/web-ele/src/views/erp/stock/stock/data.ts
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
import type { VbenFormSchema } from '#/adapter/form';
|
||||||
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
|
||||||
|
import { getProductSimpleList } from '#/api/erp/product/product';
|
||||||
|
import { getWarehouseSimpleList } from '#/api/erp/stock/warehouse';
|
||||||
|
|
||||||
|
/** 搜索表单 */
|
||||||
|
export function useGridFormSchema(): VbenFormSchema[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
fieldName: 'productId',
|
||||||
|
label: '产品',
|
||||||
|
component: 'ApiSelect',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请选择产品',
|
||||||
|
allowClear: true,
|
||||||
|
showSearch: true,
|
||||||
|
api: getProductSimpleList,
|
||||||
|
labelField: 'name',
|
||||||
|
valueField: 'id',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'warehouseId',
|
||||||
|
label: '仓库',
|
||||||
|
component: 'ApiSelect',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请选择仓库',
|
||||||
|
allowClear: true,
|
||||||
|
showSearch: true,
|
||||||
|
api: getWarehouseSimpleList,
|
||||||
|
labelField: 'name',
|
||||||
|
valueField: 'id',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 列表的字段 */
|
||||||
|
export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
field: 'productName',
|
||||||
|
title: '产品名称',
|
||||||
|
minWidth: 150,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'unitName',
|
||||||
|
title: '产品单位',
|
||||||
|
minWidth: 100,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'categoryName',
|
||||||
|
title: '产品分类',
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'count',
|
||||||
|
title: '库存量',
|
||||||
|
minWidth: 100,
|
||||||
|
formatter: 'formatAmount3',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'warehouseName',
|
||||||
|
title: '仓库',
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
79
apps/web-ele/src/views/erp/stock/stock/index.vue
Normal file
79
apps/web-ele/src/views/erp/stock/stock/index.vue
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
import type { ErpStockApi } from '#/api/erp/stock/stock';
|
||||||
|
|
||||||
|
import { DocAlert, Page } from '@vben/common-ui';
|
||||||
|
import { downloadFileFromBlobPart } from '@vben/utils';
|
||||||
|
|
||||||
|
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
|
import { exportStock, getStockPage } from '#/api/erp/stock/stock';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
|
import { useGridColumns, useGridFormSchema } from './data';
|
||||||
|
|
||||||
|
/** 产品库存管理 */
|
||||||
|
defineOptions({ name: 'ErpStock' });
|
||||||
|
|
||||||
|
/** 导出库存 */
|
||||||
|
async function handleExport() {
|
||||||
|
const data = await exportStock(await gridApi.formApi.getValues());
|
||||||
|
downloadFileFromBlobPart({ fileName: '产品库存.xls', source: data });
|
||||||
|
}
|
||||||
|
|
||||||
|
const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
|
formOptions: {
|
||||||
|
schema: useGridFormSchema(),
|
||||||
|
},
|
||||||
|
gridOptions: {
|
||||||
|
columns: useGridColumns(),
|
||||||
|
height: 'auto',
|
||||||
|
keepSource: true,
|
||||||
|
proxyConfig: {
|
||||||
|
ajax: {
|
||||||
|
query: async ({ page }, formValues) => {
|
||||||
|
return await getStockPage({
|
||||||
|
pageNo: page.currentPage,
|
||||||
|
pageSize: page.pageSize,
|
||||||
|
...formValues,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rowConfig: {
|
||||||
|
keyField: 'id',
|
||||||
|
isHover: true,
|
||||||
|
},
|
||||||
|
toolbarConfig: {
|
||||||
|
refresh: true,
|
||||||
|
search: true,
|
||||||
|
},
|
||||||
|
} as VxeTableGridOptions<ErpStockApi.Stock>,
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Page auto-content-height>
|
||||||
|
<template #doc>
|
||||||
|
<DocAlert
|
||||||
|
title="【库存】产品库存、库存明细"
|
||||||
|
url="https://doc.iocoder.cn/erp/stock/"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<Grid table-title="产品库存列表">
|
||||||
|
<template #toolbar-tools>
|
||||||
|
<TableAction
|
||||||
|
:actions="[
|
||||||
|
{
|
||||||
|
label: $t('ui.actionTitle.export'),
|
||||||
|
type: 'primary',
|
||||||
|
icon: ACTION_ICON.DOWNLOAD,
|
||||||
|
auth: ['erp:stock:export'],
|
||||||
|
onClick: handleExport,
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</Grid>
|
||||||
|
</Page>
|
||||||
|
</template>
|
||||||
209
apps/web-ele/src/views/erp/stock/warehouse/data.ts
Normal file
209
apps/web-ele/src/views/erp/stock/warehouse/data.ts
Normal file
@@ -0,0 +1,209 @@
|
|||||||
|
import type { VbenFormSchema } from '#/adapter/form';
|
||||||
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
import type { ErpWarehouseApi } from '#/api/erp/stock/warehouse';
|
||||||
|
|
||||||
|
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,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'name',
|
||||||
|
label: '仓库名称',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入仓库名称',
|
||||||
|
},
|
||||||
|
rules: 'required',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'address',
|
||||||
|
label: '仓库地址',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入仓库地址',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'status',
|
||||||
|
label: '开启状态',
|
||||||
|
component: 'RadioGroup',
|
||||||
|
componentProps: {
|
||||||
|
options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
|
||||||
|
},
|
||||||
|
rules: z.number().default(CommonStatusEnum.ENABLE),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'warehousePrice',
|
||||||
|
label: '仓储费(元)',
|
||||||
|
component: 'InputNumber',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入仓储费,单位:元/天/KG',
|
||||||
|
min: 0,
|
||||||
|
precision: 2,
|
||||||
|
controlsPosition: 'right',
|
||||||
|
class: '!w-full',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'truckagePrice',
|
||||||
|
label: '搬运费(元)',
|
||||||
|
component: 'InputNumber',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入搬运费,单位:元',
|
||||||
|
min: 0,
|
||||||
|
precision: 2,
|
||||||
|
controlsPosition: 'right',
|
||||||
|
class: '!w-full',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'principal',
|
||||||
|
label: '负责人',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入负责人',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'sort',
|
||||||
|
label: '排序',
|
||||||
|
component: 'InputNumber',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入排序',
|
||||||
|
precision: 0,
|
||||||
|
controlsPosition: 'right',
|
||||||
|
class: '!w-full',
|
||||||
|
},
|
||||||
|
rules: 'required',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'remark',
|
||||||
|
label: '备注',
|
||||||
|
component: 'Textarea',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入备注',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 搜索表单 */
|
||||||
|
export function useGridFormSchema(): VbenFormSchema[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
fieldName: 'name',
|
||||||
|
label: '仓库名称',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入仓库名称',
|
||||||
|
allowClear: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'status',
|
||||||
|
label: '仓库状态',
|
||||||
|
component: 'Select',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请选择仓库状态',
|
||||||
|
allowClear: true,
|
||||||
|
options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 列表的字段 */
|
||||||
|
export function useGridColumns(
|
||||||
|
onDefaultStatusChange?: (
|
||||||
|
newStatus: boolean,
|
||||||
|
row: ErpWarehouseApi.Warehouse,
|
||||||
|
) => PromiseLike<boolean | undefined>,
|
||||||
|
): VxeTableGridOptions['columns'] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
field: 'name',
|
||||||
|
title: '仓库名称',
|
||||||
|
minWidth: 150,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'address',
|
||||||
|
title: '仓库地址',
|
||||||
|
minWidth: 200,
|
||||||
|
showOverflow: 'tooltip',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'warehousePrice',
|
||||||
|
title: '仓储费',
|
||||||
|
minWidth: 120,
|
||||||
|
formatter: 'formatAmount2',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'truckagePrice',
|
||||||
|
title: '搬运费',
|
||||||
|
minWidth: 120,
|
||||||
|
formatter: 'formatAmount2',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'principal',
|
||||||
|
title: '负责人',
|
||||||
|
minWidth: 100,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
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: 'remark',
|
||||||
|
title: '备注',
|
||||||
|
minWidth: 150,
|
||||||
|
showOverflow: 'tooltip',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'createTime',
|
||||||
|
title: '创建时间',
|
||||||
|
minWidth: 180,
|
||||||
|
formatter: 'formatDateTime',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
width: 130,
|
||||||
|
fixed: 'right',
|
||||||
|
slots: { default: 'actions' },
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
178
apps/web-ele/src/views/erp/stock/warehouse/index.vue
Normal file
178
apps/web-ele/src/views/erp/stock/warehouse/index.vue
Normal file
@@ -0,0 +1,178 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
import type { ErpWarehouseApi } from '#/api/erp/stock/warehouse';
|
||||||
|
|
||||||
|
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 {
|
||||||
|
deleteWarehouse,
|
||||||
|
exportWarehouse,
|
||||||
|
getWarehousePage,
|
||||||
|
updateWarehouseDefaultStatus,
|
||||||
|
} from '#/api/erp/stock/warehouse';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
|
import { useGridColumns, useGridFormSchema } from './data';
|
||||||
|
import WarehouseForm from './modules/form.vue';
|
||||||
|
|
||||||
|
/** 仓库管理 */
|
||||||
|
defineOptions({ name: 'ErpWarehouse' });
|
||||||
|
|
||||||
|
/** 刷新表格 */
|
||||||
|
function handleRefresh() {
|
||||||
|
gridApi.query();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 导出仓库 */
|
||||||
|
async function handleExport() {
|
||||||
|
const data = await exportWarehouse(await gridApi.formApi.getValues());
|
||||||
|
downloadFileFromBlobPart({ fileName: '仓库.xls', source: data });
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 创建仓库 */
|
||||||
|
function handleCreate() {
|
||||||
|
formModalApi.setData(null).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 编辑仓库 */
|
||||||
|
function handleEdit(row: ErpWarehouseApi.Warehouse) {
|
||||||
|
formModalApi.setData(row).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除仓库 */
|
||||||
|
async function handleDelete(row: ErpWarehouseApi.Warehouse) {
|
||||||
|
const loadingInstance = ElLoading.service({
|
||||||
|
text: $t('ui.actionMessage.deleting', [row.name]),
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await deleteWarehouse(row.id!);
|
||||||
|
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.name]));
|
||||||
|
handleRefresh();
|
||||||
|
} finally {
|
||||||
|
loadingInstance.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 修改默认状态 */
|
||||||
|
async function handleDefaultStatusChange(
|
||||||
|
newStatus: boolean,
|
||||||
|
row: ErpWarehouseApi.Warehouse,
|
||||||
|
): Promise<boolean | undefined> {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const text = newStatus ? '设置' : '取消';
|
||||||
|
confirm({
|
||||||
|
content: `确认要${text}"${row.name}"默认吗?`,
|
||||||
|
})
|
||||||
|
.then(async () => {
|
||||||
|
// 更新默认状态
|
||||||
|
await updateWarehouseDefaultStatus(row.id!, newStatus);
|
||||||
|
// 提示并返回成功
|
||||||
|
ElMessage.success(`${text}默认成功`);
|
||||||
|
resolve(true);
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
reject(new Error('取消操作'));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const [FormModal, formModalApi] = useVbenModal({
|
||||||
|
connectedComponent: WarehouseForm,
|
||||||
|
destroyOnClose: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
|
formOptions: {
|
||||||
|
schema: useGridFormSchema(),
|
||||||
|
},
|
||||||
|
gridOptions: {
|
||||||
|
columns: useGridColumns(handleDefaultStatusChange),
|
||||||
|
height: 'auto',
|
||||||
|
keepSource: true,
|
||||||
|
proxyConfig: {
|
||||||
|
ajax: {
|
||||||
|
query: async ({ page }, formValues) => {
|
||||||
|
return await getWarehousePage({
|
||||||
|
pageNo: page.currentPage,
|
||||||
|
pageSize: page.pageSize,
|
||||||
|
...formValues,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rowConfig: {
|
||||||
|
keyField: 'id',
|
||||||
|
isHover: true,
|
||||||
|
},
|
||||||
|
toolbarConfig: {
|
||||||
|
refresh: true,
|
||||||
|
search: true,
|
||||||
|
},
|
||||||
|
} as VxeTableGridOptions<ErpWarehouseApi.Warehouse>,
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Page auto-content-height>
|
||||||
|
<template #doc>
|
||||||
|
<DocAlert
|
||||||
|
title="【库存】产品库存、库存明细"
|
||||||
|
url="https://doc.iocoder.cn/erp/stock/"
|
||||||
|
/>
|
||||||
|
</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:warehouse:create'],
|
||||||
|
onClick: handleCreate,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: $t('ui.actionTitle.export'),
|
||||||
|
type: 'primary',
|
||||||
|
icon: ACTION_ICON.DOWNLOAD,
|
||||||
|
auth: ['erp:warehouse:export'],
|
||||||
|
onClick: handleExport,
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template #actions="{ row }">
|
||||||
|
<TableAction
|
||||||
|
:actions="[
|
||||||
|
{
|
||||||
|
label: $t('common.edit'),
|
||||||
|
type: 'primary',
|
||||||
|
link: true,
|
||||||
|
icon: ACTION_ICON.EDIT,
|
||||||
|
auth: ['erp:warehouse:update'],
|
||||||
|
onClick: handleEdit.bind(null, row),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: $t('common.delete'),
|
||||||
|
type: 'danger',
|
||||||
|
link: true,
|
||||||
|
icon: ACTION_ICON.DELETE,
|
||||||
|
auth: ['erp:warehouse:delete'],
|
||||||
|
popConfirm: {
|
||||||
|
title: $t('ui.actionMessage.deleteConfirm', [row.name]),
|
||||||
|
confirm: handleDelete.bind(null, row),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</Grid>
|
||||||
|
</Page>
|
||||||
|
</template>
|
||||||
88
apps/web-ele/src/views/erp/stock/warehouse/modules/form.vue
Normal file
88
apps/web-ele/src/views/erp/stock/warehouse/modules/form.vue
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
import type { ErpWarehouseApi } from '#/api/erp/stock/warehouse';
|
||||||
|
|
||||||
|
import { computed, ref } from 'vue';
|
||||||
|
|
||||||
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
|
|
||||||
|
import { ElMessage } from 'element-plus';
|
||||||
|
|
||||||
|
import { useVbenForm } from '#/adapter/form';
|
||||||
|
import {
|
||||||
|
createWarehouse,
|
||||||
|
getWarehouse,
|
||||||
|
updateWarehouse,
|
||||||
|
} from '#/api/erp/stock/warehouse';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
|
import { useFormSchema } from '../data';
|
||||||
|
|
||||||
|
const emit = defineEmits(['success']);
|
||||||
|
const formData = ref<ErpWarehouseApi.Warehouse>();
|
||||||
|
const getTitle = computed(() => {
|
||||||
|
return formData.value?.id
|
||||||
|
? $t('ui.actionTitle.edit', ['仓库'])
|
||||||
|
: $t('ui.actionTitle.create', ['仓库']);
|
||||||
|
});
|
||||||
|
|
||||||
|
const [Form, formApi] = useVbenForm({
|
||||||
|
commonConfig: {
|
||||||
|
componentProps: {
|
||||||
|
class: 'w-full',
|
||||||
|
},
|
||||||
|
labelWidth: 100,
|
||||||
|
},
|
||||||
|
wrapperClass: 'grid-cols-2',
|
||||||
|
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 ErpWarehouseApi.Warehouse;
|
||||||
|
try {
|
||||||
|
await (formData.value?.id
|
||||||
|
? updateWarehouse(data)
|
||||||
|
: createWarehouse(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<ErpWarehouseApi.Warehouse>();
|
||||||
|
if (!data || !data.id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
modalApi.lock();
|
||||||
|
try {
|
||||||
|
formData.value = await getWarehouse(data.id);
|
||||||
|
// 设置到 values
|
||||||
|
await formApi.setValues(formData.value);
|
||||||
|
} finally {
|
||||||
|
modalApi.unlock();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Modal :title="getTitle" class="w-1/2">
|
||||||
|
<Form class="mx-4" />
|
||||||
|
</Modal>
|
||||||
|
</template>
|
||||||
Reference in New Issue
Block a user