feat(biz): 优化采购退料和入库明细功能

This commit is contained in:
zxy 2026-05-25 16:31:01 +08:00
parent 1820d623ce
commit 70c8bebf0e
23 changed files with 1327 additions and 457 deletions

View File

@ -75,8 +75,8 @@ public class PurReceiptDetailController {
@Operation(summary = "获得采购入库单子分页")
@PreAuthorize("@ss.hasPermission('tsc:pur-receipt-detail:query')")
public CommonResult<PageResult<PurReceiptDetailRespVO>> getPurReceiptDetailPage(@Valid PurReceiptDetailPageReqVO pageReqVO) {
PageResult<PurReceiptDetailDO> pageResult = purReceiptDetailService.getPurReceiptDetailPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, PurReceiptDetailRespVO.class));
PageResult<PurReceiptDetailRespVO> pageResult = purReceiptDetailService.getPurReceiptDetailPageWithMaster(pageReqVO);
return success(pageResult);
}
@GetMapping("/export-excel")
@ -86,10 +86,10 @@ public class PurReceiptDetailController {
public void exportPurReceiptDetailExcel(@Valid PurReceiptDetailPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<PurReceiptDetailDO> list = purReceiptDetailService.getPurReceiptDetailPage(pageReqVO).getList();
List<PurReceiptDetailRespVO> list = purReceiptDetailService.getPurReceiptDetailPageWithMaster(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "采购入库单子.xls", "数据", PurReceiptDetailRespVO.class,
BeanUtils.toBean(list, PurReceiptDetailRespVO.class));
list);
}
}

View File

@ -84,4 +84,24 @@ public class PurReceiptDetailPageReqVO extends PageParam {
@Schema(description = "已退料数量")
private BigDecimal returnQty;
// ==================== 关联主表查询条件 ====================
@Schema(description = "采购入库单号(SCR+年份+月份+3位流水号)")
private String purReceiptNo;
@Schema(description = "供应商名称", example = "王五")
private String supplierName;
@Schema(description = "单据状态(1 已创建 2 已确认 )", example = "2")
private String purStatus;
@Schema(description = "采购订单编号")
private String purOrdNo;
@Schema(description = "入库人名称", example = "王五")
private String receiptEmpName;
@Schema(description = "单据类型(1 标准采购 2设备采购 3 标准采购退料 4设备采购退料)", example = "2")
private String billType;
}

View File

@ -112,5 +112,47 @@ public class PurReceiptDetailRespVO {
@ExcelProperty("采购数量")
private BigDecimal purQty;
// ==================== 关联主表字段 ====================
@Schema(description = "采购入库单号(SCR+年份+月份+3位流水号)")
@ExcelProperty("采购入库单号(SCR+年份+月份+3位流水号)")
private String purReceiptNo;
@Schema(description = "单据日期")
@ExcelProperty("单据日期")
@JsonFormat(pattern = "yyyy-MM-dd")
private LocalDate receiptDate;
@Schema(description = "供应商id", example = "6653")
@ExcelProperty("供应商id")
private Integer supplierId;
@Schema(description = "供应商名称", example = "王五")
@ExcelProperty("供应商名称")
private String supplierName;
@Schema(description = "单据状态(1 已创建 2 已确认 )", example = "2")
@ExcelProperty("单据状态(1 已创建 2 已确认 )")
private String purStatus;
@Schema(description = "采购订单主表id", example = "3872")
@ExcelProperty("采购订单主表id")
private Integer purOrdId;
@Schema(description = "采购订单编号")
@ExcelProperty("采购订单编号")
private String purOrdNo;
@Schema(description = "入库人id", example = "2172")
@ExcelProperty("入库人id")
private Long receiptEmpId;
@Schema(description = "入库人名称", example = "王五")
@ExcelProperty("入库人名称")
private String receiptEmpName;
@Schema(description = "单据类型(1 标准采购 2设备采购 3 标准采购退料 4设备采购退料)", example = "2")
@ExcelProperty("单据类型(1 标准采购 2设备采购 3 标准采购退料 4设备采购退料)")
private String billType;
}

View File

@ -67,8 +67,8 @@ public class PurReturnController {
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('biz:pur-return:query')")
public CommonResult<PurReturnRespVO> getPurReturn(@RequestParam("id") Integer id) {
PurReturnDO purReturn = purReturnService.getPurReturn(id);
return success(BeanUtils.toBean(purReturn, PurReturnRespVO.class));
PurReturnRespVO purReturn = purReturnService.getPurReturnWithDetails(id);
return success(purReturn);
}
@GetMapping("/page")

View File

@ -9,7 +9,7 @@ import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDate;
import static com.ningxia.yunxi.chemmes.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
import static com.ningxia.yunxi.chemmes.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY;
@Schema(description = "管理后台 - 采购退料单主分页 Request VO")
@Data
@ -21,7 +21,7 @@ public class PurReturnPageReqVO extends PageParam {
private String purReturnNo;
@Schema(description = "单据日期")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY)
private LocalDate[] receiptDate;
@Schema(description = "供应商id", example = "6653")

View File

@ -2,11 +2,14 @@ package com.ningxia.yunxi.chemmes.module.biz.controller.admin.purreturn.vo;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.purreturndetail.vo.PurReturnDetailRespVO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
@Schema(description = "管理后台 - 采购退料单主 Response VO")
@Data
@ -27,6 +30,7 @@ public class PurReturnRespVO {
@Schema(description = "单据日期")
@ExcelProperty("单据日期")
@JsonFormat(pattern = "yyyy-MM-dd")
private LocalDate receiptDate;
@Schema(description = "供应商id", example = "6653")
@ -69,4 +73,7 @@ public class PurReturnRespVO {
@ExcelProperty("单据类型(1 标准采购 2设备采购 3 标准采购退料 4设备采购退料)")
private String billType;
@Schema(description = "采购退料单子表列表")
private List<PurReturnDetailRespVO> returnDetailList;
}

View File

@ -75,8 +75,8 @@ public class PurReturnDetailController {
@Operation(summary = "获得采购退料单子分页")
@PreAuthorize("@ss.hasPermission('tsc:pur-return-detail:query')")
public CommonResult<PageResult<PurReturnDetailRespVO>> getPurReturnDetailPage(@Valid PurReturnDetailPageReqVO pageReqVO) {
PageResult<PurReturnDetailDO> pageResult = purReturnDetailService.getPurReturnDetailPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, PurReturnDetailRespVO.class));
PageResult<PurReturnDetailRespVO> pageResult = purReturnDetailService.getPurReturnDetailPageWithMaster(pageReqVO);
return success(pageResult);
}
@GetMapping("/export-excel")
@ -86,10 +86,10 @@ public class PurReturnDetailController {
public void exportPurReturnDetailExcel(@Valid PurReturnDetailPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<PurReturnDetailDO> list = purReturnDetailService.getPurReturnDetailPage(pageReqVO).getList();
List<PurReturnDetailRespVO> list = purReturnDetailService.getPurReturnDetailPageWithMaster(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "采购退料单子.xls", "数据", PurReturnDetailRespVO.class,
BeanUtils.toBean(list, PurReturnDetailRespVO.class));
list);
}
}

View File

@ -80,4 +80,24 @@ public class PurReturnDetailPageReqVO extends PageParam {
@Schema(description = "仓储名称", example = "王五")
private String storeHouseName;
// ==================== 关联主表查询条件 ====================
@Schema(description = "采购退料单号(SCT+年份+月份+3位流水号)")
private String purReturnNo;
@Schema(description = "供应商名称", example = "王五")
private String supplierName;
@Schema(description = "单据状态(1 已创建 2 已确认 )", example = "2")
private String purStatus;
@Schema(description = "采购入库单号")
private String purReceiptNo;
@Schema(description = "退料人名称", example = "王五")
private String returnEmpName;
@Schema(description = "单据类型(1 标准采购 2设备采购 3 标准采购退料 4设备采购退料)", example = "2")
private String billType;
}

View File

@ -6,8 +6,10 @@ import java.util.*;
import java.util.*;
import java.math.BigDecimal;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
@Schema(description = "管理后台 - 采购退料单子 Response VO")
@Data
@ -102,4 +104,47 @@ public class PurReturnDetailRespVO {
@ExcelProperty("仓储名称")
private String storeHouseName;
// ==================== 关联主表字段 ====================
@Schema(description = "采购退料单号(SCT+年份+月份+3位流水号)")
@ExcelProperty("采购退料单号(SCT+年份+月份+3位流水号)")
private String purReturnNo;
@Schema(description = "单据日期")
@ExcelProperty("单据日期")
@JsonFormat(pattern = "yyyy-MM-dd")
private LocalDate receiptDate;
@Schema(description = "供应商id", example = "6653")
@ExcelProperty("供应商id")
private Integer supplierId;
@Schema(description = "供应商名称", example = "王五")
@ExcelProperty("供应商名称")
private String supplierName;
@Schema(description = "单据状态(1 已创建 2 已确认 )", example = "2")
@ExcelProperty("单据状态(1 已创建 2 已确认 )")
private String purStatus;
@Schema(description = "采购入库单主表id", example = "3872")
@ExcelProperty("采购入库单主表id")
private Integer purReceiptId;
@Schema(description = "采购入库单号")
@ExcelProperty("采购入库单号")
private String purReceiptNo;
@Schema(description = "退料人id", example = "2172")
@ExcelProperty("退料人id")
private Integer returnEmpId;
@Schema(description = "退料人名称", example = "王五")
@ExcelProperty("退料人名称")
private String returnEmpName;
@Schema(description = "单据类型(1 标准采购 2设备采购 3 标准采购退料 4设备采购退料)", example = "2")
@ExcelProperty("单据类型(1 标准采购 2设备采购 3 标准采购退料 4设备采购退料)")
private String billType;
}

View File

@ -1,11 +1,15 @@
package com.ningxia.yunxi.chemmes.module.biz.dal.mysql.purreceiptdetail;
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.ningxia.yunxi.chemmes.framework.common.pojo.PageResult;
import com.ningxia.yunxi.chemmes.framework.mybatis.core.mapper.BaseMapperX;
import com.ningxia.yunxi.chemmes.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.purreceiptdetail.vo.PurReceiptDetailPageReqVO;
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.purreceiptdetail.vo.PurReceiptDetailRespVO;
import com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.purreceipt.PurReceiptDO;
import com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.purreceiptdetail.PurReceiptDetailDO;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -62,4 +66,46 @@ public interface PurReceiptDetailMapper extends BaseMapperX<PurReceiptDetailDO>
@InterceptorIgnore(tenantLine = "true")
int physicalDeleteByPurReceiptId(@Param("purReceiptId") Integer purReceiptId);
/**
* 获得采购入库单子分页关联主表
*
* @param pageReqVO 分页查询
* @return 采购入库单子分页包含主表信息
*/
default PageResult<PurReceiptDetailRespVO> selectPurReceiptDetailPageWithMaster(PurReceiptDetailPageReqVO pageReqVO) {
MPJLambdaWrapper<PurReceiptDetailDO> wrapper = new MPJLambdaWrapper<PurReceiptDetailDO>()
// 选择子表字段
.selectAll(PurReceiptDetailDO.class)
// 选择主表字段
.selectAs(PurReceiptDO::getPurReceiptNo, PurReceiptDetailRespVO::getPurReceiptNo)
.selectAs(PurReceiptDO::getReceiptDate, PurReceiptDetailRespVO::getReceiptDate)
.selectAs(PurReceiptDO::getSupplierId, PurReceiptDetailRespVO::getSupplierId)
.selectAs(PurReceiptDO::getSupplierName, PurReceiptDetailRespVO::getSupplierName)
.selectAs(PurReceiptDO::getPurStatus, PurReceiptDetailRespVO::getPurStatus)
.selectAs(PurReceiptDO::getPurOrdId, PurReceiptDetailRespVO::getPurOrdId)
.selectAs(PurReceiptDO::getPurOrdNo, PurReceiptDetailRespVO::getPurOrdNo)
.selectAs(PurReceiptDO::getReceiptEmpId, PurReceiptDetailRespVO::getReceiptEmpId)
.selectAs(PurReceiptDO::getReceiptEmpName, PurReceiptDetailRespVO::getReceiptEmpName)
.selectAs(PurReceiptDO::getBillType, PurReceiptDetailRespVO::getBillType)
// LEFT JOIN 主表
.leftJoin(PurReceiptDO.class, PurReceiptDO::getId, PurReceiptDetailDO::getPurReceiptId)
// 查询条件 - 子表
.like(StringUtils.isNotBlank(pageReqVO.getStoreAreCd()), PurReceiptDetailDO::getStoreAreCd, pageReqVO.getStoreAreCd())
.like(StringUtils.isNotBlank(pageReqVO.getStoreAreaName()), PurReceiptDetailDO::getStoreAreaName, pageReqVO.getStoreAreaName())
.eq(pageReqVO.getInventBillNo() != null, PurReceiptDetailDO::getInventBillNo, pageReqVO.getInventBillNo())
.eq(pageReqVO.getMaterialId() != null, PurReceiptDetailDO::getMaterialId, pageReqVO.getMaterialId())
.like(pageReqVO.getMaterialCode() != null, PurReceiptDetailDO::getMaterialCode, pageReqVO.getMaterialCode())
.like(StringUtils.isNotBlank(pageReqVO.getMaterialName()), PurReceiptDetailDO::getMaterialName, pageReqVO.getMaterialName())
// 查询条件 - 主表
.like(StringUtils.isNotBlank(pageReqVO.getPurReceiptNo()), PurReceiptDO::getPurReceiptNo, pageReqVO.getPurReceiptNo())
.like(StringUtils.isNotBlank(pageReqVO.getSupplierName()), PurReceiptDO::getSupplierName, pageReqVO.getSupplierName())
.eq(pageReqVO.getPurStatus() != null, PurReceiptDO::getPurStatus, pageReqVO.getPurStatus())
.like(StringUtils.isNotBlank(pageReqVO.getPurOrdNo()), PurReceiptDO::getPurOrdNo, pageReqVO.getPurOrdNo())
.like(StringUtils.isNotBlank(pageReqVO.getReceiptEmpName()), PurReceiptDO::getReceiptEmpName, pageReqVO.getReceiptEmpName())
.eq(pageReqVO.getBillType() != null, PurReceiptDO::getBillType, pageReqVO.getBillType())
.orderByDesc(PurReceiptDetailDO::getId);
return selectJoinPage(pageReqVO, PurReceiptDetailRespVO.class, wrapper);
}
}

View File

@ -1,10 +1,14 @@
package com.ningxia.yunxi.chemmes.module.biz.dal.mysql.purreturndetail;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.ningxia.yunxi.chemmes.framework.common.pojo.PageResult;
import com.ningxia.yunxi.chemmes.framework.mybatis.core.mapper.BaseMapperX;
import com.ningxia.yunxi.chemmes.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.purreturndetail.vo.PurReturnDetailPageReqVO;
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.purreturndetail.vo.PurReturnDetailRespVO;
import com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.purreturn.PurReturnDO;
import com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.purreturndetail.PurReturnDetailDO;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Mapper;
/**
@ -41,4 +45,48 @@ public interface PurReturnDetailMapper extends BaseMapperX<PurReturnDetailDO> {
.orderByDesc(PurReturnDetailDO::getId));
}
/**
* 获得采购退料单子分页关联主表
*
* @param pageReqVO 分页查询
* @return 采购退料单子分页包含主表信息
*/
default PageResult<PurReturnDetailRespVO> selectPurReturnDetailPageWithMaster(PurReturnDetailPageReqVO pageReqVO) {
MPJLambdaWrapper<PurReturnDetailDO> wrapper = new MPJLambdaWrapper<PurReturnDetailDO>()
// 选择子表字段
.selectAll(PurReturnDetailDO.class)
// 选择主表字段
.selectAs(PurReturnDO::getPurReturnNo, PurReturnDetailRespVO::getPurReturnNo)
.selectAs(PurReturnDO::getReceiptDate, PurReturnDetailRespVO::getReceiptDate)
.selectAs(PurReturnDO::getSupplierId, PurReturnDetailRespVO::getSupplierId)
.selectAs(PurReturnDO::getSupplierName, PurReturnDetailRespVO::getSupplierName)
.selectAs(PurReturnDO::getPurStatus, PurReturnDetailRespVO::getPurStatus)
.selectAs(PurReturnDO::getPurReceiptId, PurReturnDetailRespVO::getPurReceiptId)
.selectAs(PurReturnDO::getPurReceiptNo, PurReturnDetailRespVO::getPurReceiptNo)
.selectAs(PurReturnDO::getReturnEmpId, PurReturnDetailRespVO::getReturnEmpId)
.selectAs(PurReturnDO::getReturnEmpName, PurReturnDetailRespVO::getReturnEmpName)
.selectAs(PurReturnDO::getBillType, PurReturnDetailRespVO::getBillType)
// LEFT JOIN 主表
.leftJoin(PurReturnDO.class, PurReturnDO::getId, PurReturnDetailDO::getPurReturnId)
// 查询条件 - 子表
.eq(StringUtils.isNotBlank(pageReqVO.getStoreAreCd()), PurReturnDetailDO::getStoreAreCd, pageReqVO.getStoreAreCd())
.like(StringUtils.isNotBlank(pageReqVO.getStoreAreaName()), PurReturnDetailDO::getStoreAreaName, pageReqVO.getStoreAreaName())
.eq(pageReqVO.getInventBillNo() != null, PurReturnDetailDO::getInventBillNo, pageReqVO.getInventBillNo())
.eq(pageReqVO.getMaterialId() != null, PurReturnDetailDO::getMaterialId, pageReqVO.getMaterialId())
.eq(pageReqVO.getMaterialCode() != null, PurReturnDetailDO::getMaterialCode, pageReqVO.getMaterialCode())
.like(StringUtils.isNotBlank(pageReqVO.getMaterialName()), PurReturnDetailDO::getMaterialName, pageReqVO.getMaterialName())
.eq(pageReqVO.getStoreHouseId() != null, PurReturnDetailDO::getStoreHouseId, pageReqVO.getStoreHouseId())
.like(StringUtils.isNotBlank(pageReqVO.getStoreHouseCd()), PurReturnDetailDO::getStoreHouseCd, pageReqVO.getStoreHouseCd())
.like(StringUtils.isNotBlank(pageReqVO.getStoreHouseName()), PurReturnDetailDO::getStoreHouseName, pageReqVO.getStoreHouseName())
// 查询条件 - 主表
.like(StringUtils.isNotBlank(pageReqVO.getSupplierName()), PurReturnDO::getSupplierName, pageReqVO.getSupplierName())
.eq(pageReqVO.getPurStatus() != null, PurReturnDO::getPurStatus, pageReqVO.getPurStatus())
.like(StringUtils.isNotBlank(pageReqVO.getPurReceiptNo()), PurReturnDO::getPurReceiptNo, pageReqVO.getPurReceiptNo())
.like(StringUtils.isNotBlank(pageReqVO.getReturnEmpName()), PurReturnDO::getReturnEmpName, pageReqVO.getReturnEmpName())
.eq(pageReqVO.getBillType() != null, PurReturnDO::getBillType, pageReqVO.getBillType())
.orderByDesc(PurReturnDetailDO::getId);
return selectJoinPage(pageReqVO, PurReturnDetailRespVO.class, wrapper);
}
}

View File

@ -2,6 +2,7 @@ package com.ningxia.yunxi.chemmes.module.biz.service.purreceiptdetail;
import com.ningxia.yunxi.chemmes.framework.common.pojo.PageResult;
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.purreceiptdetail.vo.PurReceiptDetailPageReqVO;
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.purreceiptdetail.vo.PurReceiptDetailRespVO;
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.purreceiptdetail.vo.PurReceiptDetailSaveReqVO;
import com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.purreceiptdetail.PurReceiptDetailDO;
@ -52,4 +53,12 @@ public interface PurReceiptDetailService {
*/
PageResult<PurReceiptDetailDO> getPurReceiptDetailPage(PurReceiptDetailPageReqVO pageReqVO);
/**
* 获得采购入库单子分页关联主表
*
* @param pageReqVO 分页查询
* @return 采购入库单子分页包含主表信息
*/
PageResult<PurReceiptDetailRespVO> getPurReceiptDetailPageWithMaster(PurReceiptDetailPageReqVO pageReqVO);
}

View File

@ -3,6 +3,7 @@ package com.ningxia.yunxi.chemmes.module.biz.service.purreceiptdetail;
import com.ningxia.yunxi.chemmes.framework.common.pojo.PageResult;
import com.ningxia.yunxi.chemmes.framework.common.util.object.BeanUtils;
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.purreceiptdetail.vo.PurReceiptDetailPageReqVO;
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.purreceiptdetail.vo.PurReceiptDetailRespVO;
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.purreceiptdetail.vo.PurReceiptDetailSaveReqVO;
import com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.purreceiptdetail.PurReceiptDetailDO;
import com.ningxia.yunxi.chemmes.module.biz.dal.mysql.purreceiptdetail.PurReceiptDetailMapper;
@ -67,4 +68,9 @@ public class PurReceiptDetailServiceImpl implements PurReceiptDetailService {
return purReceiptDetailMapper.selectPage(pageReqVO);
}
@Override
public PageResult<PurReceiptDetailRespVO> getPurReceiptDetailPageWithMaster(PurReceiptDetailPageReqVO pageReqVO) {
return purReceiptDetailMapper.selectPurReceiptDetailPageWithMaster(pageReqVO);
}
}

View File

@ -44,6 +44,14 @@ public interface PurReturnService {
*/
PurReturnDO getPurReturn(Integer id);
/**
* 获得采购退料单主包含子表数据
*
* @param id 编号
* @return 采购退料单主包含子表数据
*/
PurReturnRespVO getPurReturnWithDetails(Integer id);
/**
* 获得采购退料单主分页
*

View File

@ -3,13 +3,19 @@ package com.ningxia.yunxi.chemmes.module.biz.service.purreturn;
import com.ningxia.yunxi.chemmes.framework.common.pojo.PageResult;
import com.ningxia.yunxi.chemmes.framework.common.util.object.BeanUtils;
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.purreturn.vo.PurReturnPageReqVO;
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.purreturn.vo.PurReturnRespVO;
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.purreturn.vo.PurReturnSaveReqVO;
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.purreturndetail.vo.PurReturnDetailRespVO;
import com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.purreturn.PurReturnDO;
import com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.purreturndetail.PurReturnDetailDO;
import com.ningxia.yunxi.chemmes.module.biz.dal.mysql.purreturn.PurReturnMapper;
import com.ningxia.yunxi.chemmes.module.biz.dal.mysql.purreturndetail.PurReturnDetailMapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.List;
import static com.ningxia.yunxi.chemmes.framework.common.exception.util.ServiceExceptionUtil.exception;
@ -25,6 +31,9 @@ public class PurReturnServiceImpl implements PurReturnService {
@Resource
private PurReturnMapper purReturnMapper;
@Resource
private PurReturnDetailMapper purReturnDetailMapper;
@Override
public Integer createPurReturn(PurReturnSaveReqVO createReqVO) {
// 插入
@ -62,6 +71,30 @@ public class PurReturnServiceImpl implements PurReturnService {
return purReturnMapper.selectById(id);
}
@Override
public PurReturnRespVO getPurReturnWithDetails(Integer id) {
// 查询主表数据
PurReturnDO purReturn = purReturnMapper.selectById(id);
if (purReturn == null) {
throw exception("采购退料单主不存在");
}
// 转换为VO
PurReturnRespVO respVO = BeanUtils.toBean(purReturn, PurReturnRespVO.class);
// 查询子表数据
List<PurReturnDetailDO> detailList = purReturnDetailMapper.selectList(
new LambdaQueryWrapper<PurReturnDetailDO>()
.eq(PurReturnDetailDO::getPurReturnId, id)
);
// 转换子表数据
List<PurReturnDetailRespVO> detailRespVOList = BeanUtils.toBean(detailList, PurReturnDetailRespVO.class);
respVO.setReturnDetailList(detailRespVOList);
return respVO;
}
@Override
public PageResult<PurReturnDO> getPurReturnPage(PurReturnPageReqVO pageReqVO) {
return purReturnMapper.selectPage(pageReqVO);

View File

@ -2,6 +2,7 @@ package com.ningxia.yunxi.chemmes.module.biz.service.purreturndetail;
import com.ningxia.yunxi.chemmes.framework.common.pojo.PageResult;
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.purreturndetail.vo.PurReturnDetailPageReqVO;
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.purreturndetail.vo.PurReturnDetailRespVO;
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.purreturndetail.vo.PurReturnDetailSaveReqVO;
import com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.purreturndetail.PurReturnDetailDO;
@ -52,4 +53,12 @@ public interface PurReturnDetailService {
*/
PageResult<PurReturnDetailDO> getPurReturnDetailPage(PurReturnDetailPageReqVO pageReqVO);
/**
* 获得采购退料单子分页关联主表
*
* @param pageReqVO 分页查询
* @return 采购退料单子分页包含主表信息
*/
PageResult<PurReturnDetailRespVO> getPurReturnDetailPageWithMaster(PurReturnDetailPageReqVO pageReqVO);
}

View File

@ -3,6 +3,7 @@ package com.ningxia.yunxi.chemmes.module.biz.service.purreturndetail;
import com.ningxia.yunxi.chemmes.framework.common.pojo.PageResult;
import com.ningxia.yunxi.chemmes.framework.common.util.object.BeanUtils;
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.purreturndetail.vo.PurReturnDetailPageReqVO;
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.purreturndetail.vo.PurReturnDetailRespVO;
import com.ningxia.yunxi.chemmes.module.biz.controller.admin.purreturndetail.vo.PurReturnDetailSaveReqVO;
import com.ningxia.yunxi.chemmes.module.biz.dal.dataobject.purreturndetail.PurReturnDetailDO;
import com.ningxia.yunxi.chemmes.module.biz.dal.mysql.purreturndetail.PurReturnDetailMapper;
@ -67,4 +68,9 @@ public class PurReturnDetailServiceImpl implements PurReturnDetailService {
return purReturnDetailMapper.selectPage(pageReqVO);
}
@Override
public PageResult<PurReturnDetailRespVO> getPurReturnDetailPageWithMaster(PurReturnDetailPageReqVO pageReqVO) {
return purReturnDetailMapper.selectPurReturnDetailPageWithMaster(pageReqVO);
}
}

View File

@ -108,6 +108,8 @@ public class RawStorageServiceImpl implements RawStorageService {
purReceiptDetailMapper.updateById(detail);
updateOrderItem(detail);
//更新库存
}

View File

@ -245,6 +245,7 @@ public class SaleDeliveryServiceImpl implements SaleDeliveryService {
.inventBillNo(saleDeliveryDetailDO.getInventBillNo())
.build();
proStorageLogService.saveProStorageLog(proStorageLogDO);
}
@ -264,21 +265,21 @@ public class SaleDeliveryServiceImpl implements SaleDeliveryService {
// .build();
// proStorageMapper.insert(proStorage);
//
// for (SaleDeliveryDetailDO detail : detailList) {
// ProStorageInventoryDO inventory = proStorageInventoryMapper.selectById(detail.getTwmStorageDetailId());
// if (inventory == null) {
// throw exception("库存不存在:仓库[" + detail.getStoreHouseName() + "] 批次[" + detail.getLotNo() + "]");
// }
//
// BigDecimal deliveriedQty = detail.getDeliveriedQty() != null ? detail.getDeliveriedQty() : BigDecimal.ZERO;
// if (inventory.getUseQty().compareTo(deliveriedQty) < 0) {
// throw exception("库存不足:当前可用数量[" + inventory.getUseQty() + "] < 发货数量[" + deliveriedQty + "]");
// }
//
// inventory.setUseQty(inventory.getUseQty().subtract(deliveriedQty));
// inventory.setYardQty(inventory.getYardQty().subtract(deliveriedQty));
// inventory.setPackQty(inventory.getPackQty() - (detail.getDeliveriedBagQty()));
// proStorageInventoryMapper.updateById(inventory);
for (SaleDeliveryDetailDO detail : detailList) {
ProStorageInventoryDO inventory = proStorageInventoryMapper.selectById(detail.getTwmStorageDetailId());
if (inventory == null) {
throw exception("库存不存在:仓库[" + detail.getStoreHouseName() + "] 批次[" + detail.getLotNo() + "]");
}
BigDecimal deliveriedQty = detail.getDeliveriedQty() != null ? detail.getDeliveriedQty() : BigDecimal.ZERO;
if (inventory.getUseQty().compareTo(deliveriedQty) < 0) {
throw exception("库存不足:当前可用数量[" + inventory.getUseQty() + "] < 发货数量[" + deliveriedQty + "]");
}
inventory.setUseQty(inventory.getUseQty().subtract(deliveriedQty));
inventory.setYardQty(inventory.getYardQty().subtract(deliveriedQty));
inventory.setPackQty(inventory.getPackQty() - (detail.getDeliveriedBagQty()));
proStorageInventoryMapper.updateById(inventory);
// ProStorageMatDO storageMat = ProStorageMatDO.builder()
// .stockId(proStorage.getId().longValue())
// .storeHouseId(detail.getStoreHouseId())
@ -304,7 +305,7 @@ public class SaleDeliveryServiceImpl implements SaleDeliveryService {
// .inventBillNo(inventory.getInventBillNo())
// .build();
// proStorageMatMapper.insert(storageMat);
// }
}
if (saleDelivery.getSaleOrdId() != null && saleDelivery.getSaleOrdDetailId() != null) {

View File

@ -19,6 +19,7 @@ declare module 'vue' {
ContentDetailWrap: typeof import('./../components/ContentDetailWrap/src/ContentDetailWrap.vue')['default']
ContentWrap: typeof import('./../components/ContentWrap/src/ContentWrap.vue')['default']
CopperModal: typeof import('./../components/Cropper/src/CopperModal.vue')['default']
copy: typeof import('./../views/biz/purreceipt copy/index.vue')['default']
CountTo: typeof import('./../components/CountTo/src/CountTo.vue')['default']
Crontab: typeof import('./../components/Crontab/src/Crontab.vue')['default']
Cropper: typeof import('./../components/Cropper/src/Cropper.vue')['default']
@ -35,6 +36,8 @@ declare module 'vue' {
ElAvatar: typeof import('element-plus/es')['ElAvatar']
ElButton: typeof import('element-plus/es')['ElButton']
ElCard: typeof import('element-plus/es')['ElCard']
ElCheckbox: typeof import('element-plus/es')['ElCheckbox']
ElCheckboxGroup: typeof import('element-plus/es')['ElCheckboxGroup']
ElCol: typeof import('element-plus/es')['ElCol']
ElDatePicker: typeof import('element-plus/es')['ElDatePicker']
ElDialog: typeof import('element-plus/es')['ElDialog']
@ -53,12 +56,14 @@ declare module 'vue' {
ElForm: typeof import('element-plus/es')['ElForm']
ElFormItem: typeof import('element-plus/es')['ElFormItem']
ElIcon: typeof import('element-plus/es')['ElIcon']
ElImageViewer: typeof import('element-plus/es')['ElImageViewer']
ElInput: typeof import('element-plus/es')['ElInput']
ElInputNumber: typeof import('element-plus/es')['ElInputNumber']
ElOption: typeof import('element-plus/es')['ElOption']
ElPagination: typeof import('element-plus/es')['ElPagination']
ElPopover: typeof import('element-plus/es')['ElPopover']
ElRadio: typeof import('element-plus/es')['ElRadio']
ElRadioButton: typeof import('element-plus/es')['ElRadioButton']
ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup']
ElRow: typeof import('element-plus/es')['ElRow']
ElScrollbar: typeof import('element-plus/es')['ElScrollbar']
@ -91,6 +96,9 @@ declare module 'vue' {
ProcessPalette: typeof import('./../components/bpmnProcessDesigner/package/palette/ProcessPalette.vue')['default']
ProcessViewer: typeof import('./../components/bpmnProcessDesigner/package/designer/ProcessViewer.vue')['default']
PropertiesPanel: typeof import('./../components/bpmnProcessDesigner/package/penal/PropertiesPanel.vue')['default']
PurOrderSelectDialog: typeof import('./../views/biz/purreceipt copy/PurOrderSelectDialog.vue')['default']
PurReceiptForm: typeof import('./../views/biz/purreceipt copy/PurReceiptForm.vue')['default']
PurReceiptSelectDialog: typeof import('./../views/biz/purreturn/PurReceiptSelectDialog.vue')['default']
Qrcode: typeof import('./../components/Qrcode/src/Qrcode.vue')['default']
ReceiveTask: typeof import('./../components/bpmnProcessDesigner/package/penal/task/task-components/ReceiveTask.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink']

View File

@ -0,0 +1,218 @@
<template>
<Dialog :title="'选择采购入库单'" v-model="dialogVisible" width="1500px">
<!-- 搜索区域 -->
<el-form :model="queryParams" inline class="mb-4">
<el-form-item label="供应商">
<el-input
v-model="queryParams.supplierName"
disabled
@keyup.enter="handleQuery"
class="!w-300px"
/>
</el-form-item>
<el-form-item label="入库单号">
<el-input
v-model="queryParams.purReceiptNo"
placeholder="请输入"
clearable
@keyup.enter="handleQuery"
class="!w-200px"
/>
</el-form-item>
<el-form-item label="物料名称">
<el-input
v-model="queryParams.materialName"
placeholder="请输入"
clearable
@keyup.enter="handleQuery"
class="!w-200px"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="handleQuery">搜索</el-button>
<el-button @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<!-- 入库单列表 -->
<el-table
ref="receiptTableRef"
v-loading="loading"
:data="receiptList"
:show-overflow-tooltip="true"
row-key="id"
highlight-current-row
@row-click="handleRowClick"
@selection-change="handleSelectionChange"
style="width: 100%;"
:height="400"
border
>
<el-table-column type="selection" width="50px" align="center" />
<el-table-column label="序号" type="index" width="60px" align="center" fixed="left" />
<el-table-column label="入库单号" align="center" prop="purReceiptNo" width="150px" fixed="left" />
<el-table-column label="单据类型" align="center" prop="billType" width="125px">
<template #default="scope">
<span v-if="scope.row.billType === '1'">标准采购入库</span>
<span v-else-if="scope.row.billType === '2'">设备采购入库</span>
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column label="入库日期" align="center" prop="receiptDate" width="110px" />
<el-table-column label="供应商名称" align="center" prop="supplierName" width="250px" />
<el-table-column label="物料编码" align="center" prop="materialCode" width="120px" />
<el-table-column label="物料名称" align="center" prop="materialName" width="120px" />
<el-table-column label="采购数量" align="center" prop="ordQty" width="90px" />
<el-table-column label="收货数量" align="center" prop="receiptQty" width="90px" />
<el-table-column label="规格型号" align="center" prop="spec" width="110px" />
<el-table-column label="仓储名称" align="center" prop="storeHouseName" width="120px" />
<el-table-column label="库区名称" align="center" prop="storeAreaName" width="120px" />
</el-table>
<!-- 分页 -->
<div class="pagination-container">
<Pagination
:total="total"
v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize"
@pagination="getList"
class="mb-4 mt-4"
/>
</div>
<!-- 底部按钮 -->
<template #footer>
<div style="text-align: right; padding-right: 20px;">
<el-button @click="handleSave" type="primary" style="margin-right: 10px;">保存</el-button>
<el-button @click="dialogVisible = false">取消</el-button>
</div>
</template>
</Dialog>
</template>
<script setup lang="ts">
import { ref, reactive } from 'vue'
import * as PurReceiptApi from '@/api/biz/purreceipt'
import Dialog from '@/components/Dialog/src/Dialog.vue'
import Pagination from '@/components/Pagination/index.vue'
const dialogVisible = ref(false)
const loading = ref(false)
const receiptList = ref([])
const total = ref(0)
const receiptTableRef = ref(null)
const emit = defineEmits(['select', 'close'])
const message = useMessage()
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
supplierName: undefined,
purReceiptNo: undefined,
purStatus: '2', //
})
/** 获取入库单列表 */
const getList = async () => {
loading.value = true
try {
const data = await PurReceiptApi.getPurReceiptPage(queryParams)
receiptList.value = data.list || []
total.value = data.total || 0
} finally {
loading.value = false
}
}
/** 搜索 */
const handleQuery = () => {
queryParams.pageNo = 1
getList()
}
/** 重置 */
const resetQuery = () => {
queryParams.purReceiptNo = undefined
handleQuery()
}
/** 点击行 */
const handleRowClick = (row) => {
if (receiptTableRef.value) {
receiptTableRef.value.toggleRowSelection(row)
}
}
/** 选择变更事件处理 */
const handleSelectionChange = (selectedItems: any[]) => {
//
}
/** 保存按钮 */
const handleSave = () => {
if (!receiptTableRef.value) return
//
const selectedRows = receiptTableRef.value.getSelectionRows ? receiptTableRef.value.getSelectionRows() : []
if (selectedRows.length === 0) {
return
}
//
const uniqueReceiptNos = [...new Set(selectedRows.map(row => row.purReceiptNo))]
if (uniqueReceiptNos.length > 1) {
message.warning('只能选择一个入库单进行退料,请确认!')
return
}
//
const selectData = selectedRows.map(row => ({
id: row.id,
purReceiptNo: row.purReceiptNo,
billType: row.billType,
receiptDate: row.receiptDate,
supplierName: row.supplierName,
materialCode: row.materialCode,
materialName: row.materialName,
receiptQty: row.receiptQty,
returnedQty: row.returnedQty || 0,
spec: row.spec,
storeHouseName: row.storeHouseName,
storeAreaName: row.storeAreaName,
unit: row.unit,
supplierId: row.supplierId,
materialId: row.materialId,
purReceiptId: row.purReceiptId,
}))
emit('select', selectData)
dialogVisible.value = false
}
/** 打开弹窗 */
const open = (supplierName?: string) => {
dialogVisible.value = true
//
queryParams.supplierName = supplierName
queryParams.purReceiptNo = undefined
queryParams.pageNo = 1
handleQuery()
}
defineExpose({ open })
import { watch } from 'vue'
watch(dialogVisible, (val) => {
if (!val) {
emit('close')
}
})
</script>
<style scoped>
.pagination-container {
margin-bottom: 60px;
}
</style>

View File

@ -1,160 +1,430 @@
<template>
<Dialog :title="dialogTitle" v-model="dialogVisible" width="800px">
<el-form
ref="formRef"
:model="formData"
:rules="formRules"
label-width="110px"
v-loading="formLoading"
>
<el-form-item label="采购退料单号(SCT+年份+月份+3位流水号)" prop="purReturnNo">
<el-input v-model="formData.purReturnNo" placeholder="请输入采购退料单号(SCT+年份+月份+3位流水号)" />
</el-form-item>
<el-form-item label="单据日期" prop="receiptDate">
<el-date-picker
v-model="formData.receiptDate"
type="date"
value-format="x"
placeholder="选择单据日期"
/>
</el-form-item>
<el-form-item label="供应商id" prop="supplierId">
<el-input v-model="formData.supplierId" placeholder="请输入供应商id" />
</el-form-item>
<el-form-item label="供应商名称" prop="supplierName">
<el-input v-model="formData.supplierName" placeholder="请输入供应商名称" />
</el-form-item>
<el-form-item label="单据状态(1 已创建 2 已确认 )" prop="purStatus">
<el-radio-group v-model="formData.purStatus">
<el-radio label="1">请选择字典生成</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="formData.remark" placeholder="请输入备注" />
</el-form-item>
<el-form-item label="采购入库单主表id" prop="purReceiptId">
<el-input v-model="formData.purReceiptId" placeholder="请输入采购入库单主表id" />
</el-form-item>
<el-form-item label="采购入库单号" prop="purReceiptNo">
<el-input v-model="formData.purReceiptNo" placeholder="请输入采购入库单号" />
</el-form-item>
<el-form-item label="退料人id" prop="returnEmpId">
<el-input v-model="formData.returnEmpId" placeholder="请输入退料人id" />
</el-form-item>
<el-form-item label="退料人名称" prop="returnEmpName">
<el-input v-model="formData.returnEmpName" placeholder="请输入退料人名称" />
</el-form-item>
<el-form-item label="入出库主表id" prop="twmStorageId">
<el-input v-model="formData.twmStorageId" placeholder="请输入入出库主表id" />
</el-form-item>
<el-form-item label="单据类型(1 标准采购 2设备采购 3 标准采购退料 4设备采购退料)" prop="billType">
<el-select v-model="formData.billType" placeholder="请选择单据类型(1 标准采购 2设备采购 3 标准采购退料 4设备采购退料)">
<el-option label="请选择字典生成" value="" />
</el-select>
</el-form-item>
</el-form>
<template #footer>
<el-button @click="submitForm" type="primary" :disabled="formLoading"> </el-button>
<el-button @click="dialogVisible = false"> </el-button>
</template>
</Dialog>
</template>
<script setup lang="ts">
import * as PurReturnApi from '@/api/biz/purreturn'
import { watch } from 'vue'
const { t } = useI18n() //
const message = useMessage() //
const dialogVisible = ref(false) //
const dialogTitle = ref('') //
const formLoading = ref(false) // 12
const formType = ref('') // create - update -
const formData = ref({
id: undefined,
purReturnNo: undefined,
receiptDate: undefined,
supplierId: undefined,
supplierName: undefined,
purStatus: undefined,
remark: undefined,
purReceiptId: undefined,
purReceiptNo: undefined,
returnEmpId: undefined,
returnEmpName: undefined,
twmStorageId: undefined,
billType: undefined,
})
/** 弹窗关闭时通知父组件 */
watch(dialogVisible, (val) => {
if (!val) {
emit('close')
}
})
const formRules = reactive({
})
const formRef = ref() // Ref
/** 打开弹窗 */
const open = async (type: string, id?: number) => {
dialogVisible.value = true
dialogTitle.value = t('action.' + type)
formType.value = type
resetForm()
//
if (id) {
formLoading.value = true
try {
formData.value = await PurReturnApi.getPurReturn(id)
} finally {
formLoading.value = false
}
}
}
defineExpose({ open }) // open
/** 提交表单 */
const emit = defineEmits(['success', 'close']) // success
const submitForm = async () => {
//
await formRef.value.validate()
//
formLoading.value = true
try {
const data = formData.value as unknown as PurReturnApi.PurReturnVO
if (formType.value === 'create') {
await PurReturnApi.createPurReturn(data)
message.success(t('common.createSuccess'))
} else {
await PurReturnApi.updatePurReturn(data)
message.success(t('common.updateSuccess'))
}
dialogVisible.value = false
//
emit('success')
} finally {
formLoading.value = false
}
}
/** 重置表单 */
const resetForm = () => {
formData.value = {
id: undefined,
purReturnNo: undefined,
receiptDate: undefined,
supplierId: undefined,
supplierName: undefined,
purStatus: undefined,
remark: undefined,
purReceiptId: undefined,
purReceiptNo: undefined,
returnEmpId: undefined,
returnEmpName: undefined,
twmStorageId: undefined,
billType: undefined,
}
formRef.value?.resetFields()
}
</script>
<template>
<Dialog :title="dialogTitle" v-model="dialogVisible" width="90%">
<el-form
ref="formRef"
:model="formData"
:rules="formRules"
label-width="110px"
v-loading="formLoading"
>
<!-- 基本信息 -->
<div class="mb-6">
<div style="font-weight: bold; margin-bottom: 15px;">基本信息</div>
<el-row :gutter="20">
<el-col :span="8">
<el-form-item label="单据类型" prop="billType">
<el-select
v-model="formData.billType"
placeholder="请选择"
:disabled="formType === 'detail'"
class="!w-full"
>
<el-option label="标准采购退料" value="3" />
<el-option label="设备采购退料" value="4" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="退料单号" prop="purReturnNo">
<el-input
v-model="formData.purReturnNo"
placeholder="保存时自动生成"
disabled
class="!w-full"
/>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="退料日期" prop="receiptDate">
<el-date-picker
v-model="formData.receiptDate"
type="date"
value-format="YYYY-MM-DD"
placeholder="请选择日期"
:disabled="formType === 'detail'"
class="!w-full"
/>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="8">
<el-form-item label="单据状态" prop="purStatus">
<el-select v-model="formData.purStatus" disabled class="!w-full">
<el-option label="已创建" value="1" />
<el-option label="已确认" value="2" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="供应商" prop="supplierId">
<el-select
v-model="formData.supplierId"
placeholder="请选择"
:disabled="formType === 'detail'"
class="!w-full"
@change="handleSupplierChange"
>
<el-option
v-for="item in supplierOptions"
:key="item.id"
:label="item.supplierName"
:value="item.id"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="采购入库单" prop="purReceiptId">
<el-input
v-model="formData.purReceiptNo"
placeholder="弹出窗体"
class="!w-full"
:disabled="formType === 'detail'"
@click="openPurReceiptDialog"
style="cursor: pointer;"
/>
</el-form-item>
</el-col>
</el-row>
<el-form-item label="备注" prop="remark">
<el-input
v-model="formData.remark"
placeholder="请输入"
:disabled="formType === 'detail'"
class="!w-full"
/>
</el-form-item>
</div>
<!-- 明细信息 -->
<div>
<div style="font-weight: bold; margin-bottom: 15px;">明细信息</div>
<el-table
:data="detailList"
:stripe="true"
:show-overflow-tooltip="true"
border
style="width: 100%;"
>
<el-table-column label="序号" type="index" min-width="60px" align="center" />
<el-table-column label="物料编码" prop="materialCode" min-width="120px" align="center" />
<el-table-column label="物料名称" prop="materialName" min-width="150px" align="center" />
<el-table-column label="规格型号" prop="spec" min-width="100px" align="center" />
<el-table-column label="收货数量" prop="receiptQty" min-width="100px" align="center" />
<el-table-column label="已退料数量" prop="returnedQty" min-width="100px" align="center" />
<el-table-column label="*退料数量" prop="returnQty" min-width="100px" align="center">
<template #default="scope">
<el-input
v-model="scope.row.returnQty"
type="number"
placeholder="手动输入"
:disabled="formType === 'detail'"
class="!w-80px"
/>
</template>
</el-table-column>
<el-table-column label="批次号" prop="lotNo" min-width="100px" align="center">
<template #default="scope">
<el-input
v-model="scope.row.lotNo"
placeholder="请输入"
:disabled="formType === 'detail'"
class="!w-120px"
/>
</template>
</el-table-column>
<el-table-column label="仓储名称" prop="storeHouseName" min-width="120px" align="center" />
<el-table-column label="库区名称" prop="storeAreaName" min-width="120px" align="center" />
<el-table-column label="入库日期" prop="receiptDate" min-width="100px" align="center" />
<el-table-column label="单位" prop="unit" min-width="60px" align="center" :formatter="getUnitName" />
<el-table-column label="操作" min-width="80px" align="center">
<template #default="scope">
<el-button
link
type="danger"
@click="removeItem(scope.$index)"
v-if="formType !== 'detail'"
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
</div>
</el-form>
<template #footer>
<el-button @click="dialogVisible = false">取消</el-button>
<el-button
type="primary"
@click="handleSave"
:disabled="formLoading"
v-if="formType !== 'detail'"
>保存</el-button>
<el-button
type="primary"
@click="handleConfirm"
:disabled="formLoading || formData.purStatus === '2'"
v-if="formType !== 'detail'"
>确认</el-button>
</template>
</Dialog>
<!-- 采购入库单选择弹窗 -->
<PurReceiptSelectDialog ref="purReceiptDialogRef" @select="handlePurReceiptSelect" />
</template>
<script setup lang="ts">
import { ref, reactive, onMounted, watch } from 'vue'
import Dialog from '@/components/Dialog/src/Dialog.vue'
import PurReceiptSelectDialog from './PurReceiptSelectDialog.vue'
import * as PurReturnApi from '@/api/biz/purreturn'
import * as SupplierApi from '@/api/biz/supplier'
import * as PurReceiptApi from '@/api/biz/purreceipt'
import { getUnitName } from '@/utils/dict'
const { t } = useI18n()
const message = useMessage()
const dialogVisible = ref(false)
const dialogTitle = ref('')
const formLoading = ref(false)
const formType = ref('')
const formRef = ref()
const purReceiptDialogRef = ref()
//
const supplierOptions = ref([])
const formData = reactive({
id: undefined,
purReturnNo: '保存时自动生成',
receiptDate: new Date().toISOString().split('T')[0],
supplierId: undefined,
supplierName: undefined,
purStatus: '1',
remark: undefined,
purReceiptId: undefined,
purReceiptNo: undefined,
returnEmpId: undefined,
returnEmpName: undefined,
twmStorageId: undefined,
billType: '3',
})
const detailList = ref([])
const formRules = reactive({
billType: [{ required: true, message: '请选择单据类型', trigger: 'blur' }],
receiptDate: [{ required: true, message: '请选择退料日期', trigger: 'blur' }],
supplierId: [{ required: true, message: '请选择供应商', trigger: 'blur' }],
purReceiptId: [{ required: true, message: '请选择采购入库单', trigger: 'blur' }],
})
//
watch(dialogVisible, (val) => {
if (!val) {
emit('close')
}
})
/** 打开表单 */
const emit = defineEmits(['success', 'close'])
const open = async (type: string, id?: number) => {
dialogVisible.value = true
dialogTitle.value = type === 'create' ? '新增' : type === 'update' ? '编辑' : '详情'
formType.value = type
resetForm()
//
await loadSupplierList()
if (id) {
//
formLoading.value = true
try {
const data = await PurReturnApi.getPurReturn(id)
Object.assign(formData, data)
//
detailList.value = data?.items || data?.detailList || []
//
const supplier = supplierOptions.value.find(s => s.id === formData.supplierId)
if (supplier) {
formData.supplierName = supplier.supplierName
}
} finally {
formLoading.value = false
}
}
}
defineExpose({ open })
/** 加载供应商列表 */
const loadSupplierList = async () => {
try {
const suppliers = await SupplierApi.dropdown()
supplierOptions.value = suppliers || []
} catch (error) {
console.error('加载供应商列表失败:', error)
}
}
/** 供应商变更处理 */
const handleSupplierChange = (value: number) => {
const supplier = supplierOptions.value.find(s => s.id === value)
formData.supplierName = supplier ? supplier.supplierName : undefined
formData.purReceiptId = undefined
formData.purReceiptNo = undefined
detailList.value = []
}
/** 打开采购入库单选择弹窗 */
const openPurReceiptDialog = () => {
//
if (!formData.supplierId || !formData.supplierName) {
message.warning('请先输入供应商信息')
return
}
//
purReceiptDialogRef.value?.open(formData.supplierName)
}
/** 处理采购入库单选择 */
const handlePurReceiptSelect = async (selectedData: any[]) => {
if (selectedData && selectedData.length > 0) {
//
const firstItem = selectedData[0]
formData.purReceiptId = firstItem.purReceiptId || firstItem.id
formData.purReceiptNo = firstItem.purReceiptNo
//
detailList.value = selectedData.map(item => ({
...item,
receiptQty: item.receiptQty || item.purQty,
returnedQty: item.returnedQty || 0,
returnQty: (Number(item.receiptQty || item.purQty) || 0) - (Number(item.returnedQty) || 0) // 退 = - 退
}))
}
}
/** 删除明细项 */
const removeItem = (index: number) => {
detailList.value.splice(index, 1)
}
/** 保存 */
const handleSave = async () => {
try {
await formRef.value.validate()
//
if (detailList.value.length === 0) {
message.warning('请至少添加一条物料明细')
return
}
// 退
for (let i = 0; i < detailList.value.length; i++) {
const item = detailList.value[i]
if (!item.returnQty || Number(item.returnQty) <= 0) {
message.warning(`${i + 1}行物料的退料数量不能为空且必须大于0`)
return
}
}
formLoading.value = true
const data = {
...formData,
items: detailList.value,
}
if (formType.value === 'create') {
await PurReturnApi.createPurReturn(data)
message.success(t('common.createSuccess'))
} else {
await PurReturnApi.updatePurReturn(data)
message.success(t('common.updateSuccess'))
}
dialogVisible.value = false
emit('success')
} finally {
formLoading.value = false
}
}
/** 确认 */
const handleConfirm = async () => {
try {
await formRef.value.validate()
//
if (detailList.value.length === 0) {
message.warning('请至少添加一条物料明细')
return
}
// 退
for (let i = 0; i < detailList.value.length; i++) {
const item = detailList.value[i]
if (!item.returnQty || Number(item.returnQty) <= 0) {
message.warning(`${i + 1}行物料的退料数量不能为空且必须大于0`)
return
}
}
formLoading.value = true
formData.purStatus = '2'
const data = {
...formData,
items: detailList.value,
}
if (formType.value === 'create') {
await PurReturnApi.createPurReturn(data)
} else {
await PurReturnApi.updatePurReturn(data)
}
message.success('确认成功')
dialogVisible.value = false
emit('success')
} finally {
formLoading.value = false
}
}
/** 重置表单 */
const resetForm = () => {
Object.assign(formData, {
id: undefined,
purReturnNo: '保存时自动生成',
receiptDate: new Date().toISOString().split('T')[0],
supplierId: undefined,
supplierName: undefined,
purStatus: '1',
remark: undefined,
purReceiptId: undefined,
purReceiptNo: undefined,
returnEmpId: undefined,
returnEmpName: undefined,
twmStorageId: undefined,
billType: '3',
})
detailList.value = []
purReceiptOptions.value = []
formRef.value?.resetFields()
}
/** 初始化 */
onMounted(() => {
loadSupplierList()
})
</script>

View File

@ -1,269 +1,341 @@
<template>
<ContentWrap>
<!-- 搜索工作栏 -->
<el-form
class="-mb-15px"
:model="queryParams"
ref="queryFormRef"
:inline="true"
label-width="80px"
>
<el-form-item label="采购退料单号(SCT+年份+月份+3位流水号)" prop="purReturnNo">
<el-input
v-model="queryParams.purReturnNo"
placeholder="请输入采购退料单号(SCT+年份+月份+3位流水号)"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<el-form-item label="单据日期" prop="receiptDate">
<el-date-picker
v-model="queryParams.receiptDate"
value-format="YYYY-MM-DD HH:mm:ss"
type="daterange"
start-placeholder="开始日期"
end-placeholder="结束日期"
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
class="!w-240px"
/>
</el-form-item>
<el-form-item label="供应商id" prop="supplierId">
<el-input
v-model="queryParams.supplierId"
placeholder="请输入供应商id"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<el-form-item label="供应商名称" prop="supplierName">
<el-input
v-model="queryParams.supplierName"
placeholder="请输入供应商名称"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<el-form-item label="单据状态(1 已创建 2 已确认 )" prop="purStatus">
<el-select
v-model="queryParams.purStatus"
placeholder="请选择单据状态(1 已创建 2 已确认 )"
clearable
class="!w-240px"
>
<el-option label="请选择字典生成" value="" />
</el-select>
</el-form-item>
<el-form-item label="采购入库单主表id" prop="purReceiptId">
<el-input
v-model="queryParams.purReceiptId"
placeholder="请输入采购入库单主表id"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<el-form-item label="采购入库单号" prop="purReceiptNo">
<el-input
v-model="queryParams.purReceiptNo"
placeholder="请输入采购入库单号"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<el-form-item label="入出库主表id" prop="twmStorageId">
<el-input
v-model="queryParams.twmStorageId"
placeholder="请输入入出库主表id"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<el-form-item label="单据类型(1 标准采购 2设备采购 3 标准采购退料 4设备采购退料)" prop="billType">
<el-select
v-model="queryParams.billType"
placeholder="请选择单据类型(1 标准采购 2设备采购 3 标准采购退料 4设备采购退料)"
clearable
class="!w-240px"
>
<el-option label="请选择字典生成" value="" />
</el-select>
</el-form-item>
<el-form-item>
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
<el-button
type="primary"
plain
@click="openForm('create')"
v-hasPermi="['biz:pur-return:create']"
>
<Icon icon="ep:plus" class="mr-5px" /> 新增
</el-button>
<el-button
type="success"
plain
@click="handleExport"
:loading="exportLoading"
v-hasPermi="['biz:pur-return:export']"
>
<Icon icon="ep:download" class="mr-5px" /> 导出
</el-button>
</el-form-item>
</el-form>
</ContentWrap>
<!-- 列表 -->
<ContentWrap>
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
<el-table-column label="序号" align="center" type="index" width="60px"/>
<el-table-column
label="创建时间"
align="center"
prop="createTime"
:formatter="dateFormatter"
width="180px"
/>
<el-table-column label="采购退料单号(SCT+年份+月份+3位流水号)" align="center" prop="purReturnNo" />
<el-table-column label="单据日期" align="center" prop="receiptDate" />
<el-table-column label="供应商id" align="center" prop="supplierId" />
<el-table-column label="供应商名称" align="center" prop="supplierName" />
<el-table-column label="单据状态(1 已创建 2 已确认 )" align="center" prop="purStatus" />
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="采购入库单主表id" align="center" prop="purReceiptId" />
<el-table-column label="采购入库单号" align="center" prop="purReceiptNo" />
<el-table-column label="退料人id" align="center" prop="returnEmpId" />
<el-table-column label="退料人名称" align="center" prop="returnEmpName" />
<el-table-column label="入出库主表id" align="center" prop="twmStorageId" />
<el-table-column label="单据类型(1 标准采购 2设备采购 3 标准采购退料 4设备采购退料)" align="center" prop="billType" />
<el-table-column label="操作" align="center">
<template #default="scope">
<el-button
link
type="primary"
@click="openForm('update', scope.row.id)"
v-hasPermi="['biz:pur-return:update']"
>
编辑
</el-button>
<el-button
link
type="danger"
@click="handleDelete(scope.row.id)"
v-hasPermi="['biz:pur-return:delete']"
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<Pagination
:total="total"
v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize"
@pagination="getList"
/>
</ContentWrap>
<!-- 表单弹窗添加/修改 -->
<PurReturnForm ref="formRef" @success="getList" @close="handleQuery"/>
</template>
<script setup lang="ts">
import { dateFormatter } from '@/utils/formatTime'
import download from '@/utils/download'
import * as PurReturnApi from '@/api/biz/purreturn'
import PurReturnForm from './PurReturnForm.vue'
defineOptions({ name: 'PurReturn' })
const message = useMessage() //
const { t } = useI18n() //
const loading = ref(false) //
const list = ref([]) //
const total = ref(0) //
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
purReturnNo: undefined,
receiptDate: [],
supplierId: undefined,
supplierName: undefined,
purStatus: undefined,
purReceiptId: undefined,
purReceiptNo: undefined,
twmStorageId: undefined,
billType: undefined,
})
const queryFormRef = ref() //
const exportLoading = ref(false) //
/** 查询列表 */
const getList = async () => {
loading.value = true
try {
const data = await PurReturnApi.getPurReturnPage(queryParams)
list.value = data.list
total.value = data.total
} finally {
loading.value = false
}
}
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.pageNo = 1
getList()
}
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value.resetFields()
handleQuery()
}
/** 添加/修改操作 */
const formRef = ref()
const openForm = (type: string, id?: number) => {
formRef.value.open(type, id)
}
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
try {
//
await message.delConfirm()
//
await PurReturnApi.deletePurReturn(id)
message.success(t('common.delSuccess'))
//
await getList()
} catch {}
}
/** 导出按钮操作 */
const handleExport = async () => {
try {
//
await message.exportConfirm()
//
exportLoading.value = true
const data = await PurReturnApi.exportPurReturn(queryParams)
download.excel(data, '采购退料单主.xls')
} catch {
} finally {
exportLoading.value = false
}
}
/** 初始化 **/
onMounted(() => {
//
})
</script>
<template>
<ContentWrap>
<!-- 搜索工作栏 -->
<el-form
class="-mb-15px"
:model="queryParams"
ref="queryFormRef"
:inline="true"
label-width="80px"
>
<el-form-item label="退料日期" prop="receiptDate">
<el-date-picker
v-model="queryParams.receiptDate"
value-format="YYYY-MM-DD"
type="daterange"
start-placeholder="开始日期"
end-placeholder="结束日期"
class="!w-240px"
/>
</el-form-item>
<el-form-item label="单据类型" prop="billType">
<el-select
v-model="queryParams.billType"
placeholder="请选择单据类型"
clearable
class="!w-200px"
>
<el-option label="标准采购退料" value="3" />
<el-option label="设备采购退料" value="4" />
</el-select>
</el-form-item>
<el-form-item label="退料单号" prop="purReturnNo">
<el-input
v-model="queryParams.purReturnNo"
placeholder="请输入退料单号"
clearable
@keyup.enter="handleQuery"
class="!w-200px"
/>
</el-form-item>
<el-form-item label="供应商" prop="supplierName">
<el-input
v-model="queryParams.supplierName"
placeholder="请输入供应商名称"
clearable
@keyup.enter="handleQuery"
class="!w-200px"
/>
</el-form-item>
<el-form-item label="单据状态" prop="purStatus">
<el-select
v-model="queryParams.purStatus"
placeholder="请选择单据状态"
clearable
class="!w-150px"
>
<el-option label="已创建" value="1" />
<el-option label="已确认" value="2" />
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
<el-button
type="primary"
@click="openForm('create')"
v-hasPermi="['biz:pur-return:create']"
>
<Icon icon="ep:plus" class="mr-5px" /> 新增
</el-button>
</el-form-item>
</el-form>
</ContentWrap>
<!-- 退料单信息表格 -->
<ContentWrap class="!p-10px">
<div style="display: flex; flex-direction: column; height: calc(50vh - 180px);">
<div style="flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden;">
<div style="font-weight: bold; margin-bottom: 8px;">退料单信息</div>
<el-table
v-loading="loading"
:data="list"
:stripe="true"
:show-overflow-tooltip="true"
border
@row-click="handleRowClick"
:highlight-current-row="true"
style="flex: 1;"
max-height="100%"
>
<el-table-column label="序号" align="center" type="index" width="60px"/>
<el-table-column label="单据类型" align="center" prop="billType" >
<template #default="scope">
<span v-if="scope.row.billType === '3'">标准采购退料</span>
<span v-else-if="scope.row.billType === '4'">设备采购退料</span>
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column label="退料单号" align="center" prop="purReturnNo" />
<el-table-column label="供应商" align="center" prop="supplierName" width="300px" />
<el-table-column label="单据状态" align="center" prop="purStatus" >
<template #default="scope">
<span v-if="scope.row.purStatus === '1'" class="text-blue">已创建</span>
<span v-else-if="scope.row.purStatus === '2'" class="text-green">已确认</span>
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column label="退料日期" align="center" prop="receiptDate" />
<el-table-column label="退料人员" align="center" prop="returnEmpName" />
<el-table-column label="采购入库单号" align="center" prop="purReceiptNo" />
<el-table-column label="操作" align="center" >
<template #default="scope">
<el-button
link
type="primary"
@click="openForm('update', scope.row.id)"
v-hasPermi="['biz:pur-return:update']"
v-if="scope.row.purStatus === '1' "
>
编辑
</el-button>
<el-button
link
type="danger"
@click="handleDelete(scope.row.id)"
v-hasPermi="['biz:pur-return:delete']"
v-if="scope.row.purStatus === '1' "
>
删除
</el-button>
<el-button
link
type="info"
@click="openForm('detail', scope.row.id)"
>
详情
</el-button>
</template>
</el-table-column>
</el-table>
<div style="display: flex; justify-content: flex-end; margin-top: 1px; flex-shrink: 0;">
<Pagination
:total="total"
v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize"
@pagination="getList"
/>
</div>
</div>
</div>
</ContentWrap>
<!-- 退料明细信息表格 -->
<ContentWrap class="!p-15px" style="height: calc(50vh - 60px);">
<div style="font-weight: bold; margin-bottom: 8px;">退料明细信息</div>
<div style="height: calc(100% - 40px); overflow: auto;">
<el-table
v-loading="detailLoading"
:data="detailList"
:stripe="true"
:show-overflow-tooltip="true"
show-summary
border
:summary-method="getDetailSummary"
style="width: 100%;"
>
<el-table-column label="序号" align="center" type="index" width="60px"/>
<el-table-column label="物料编码" align="center" prop="materialCode" />
<el-table-column label="物料名称" align="center" prop="materialName" />
<el-table-column label="规格型号" align="center" prop="spec" />
<el-table-column label="收货数量" align="center" prop="receiptQty" />
<el-table-column label="已退料数量" align="center" prop="returnedQty" />
<el-table-column label="退料数量" align="center" prop="returnQty" />
<el-table-column label="批次号" align="center" prop="lotNo" />
<el-table-column label="仓储名称" align="center" prop="storeHouseName" />
<el-table-column label="库区名称" align="center" prop="storeAreaName" />
<el-table-column label="单位" align="center" prop="unit" :formatter="getUnitName" />
</el-table>
</div>
</ContentWrap>
<!-- 表单弹窗添加/修改/详情 -->
<PurReturnForm ref="formRef" @success="getList" @close="handleQuery"/>
</template>
<script setup lang="ts">
import { ref, reactive, onMounted } from 'vue'
import * as PurReturnApi from '@/api/biz/purreturn'
import PurReturnForm from './PurReturnForm.vue'
import { getUnitName } from '@/utils/dict'
import { getCurrentSimMonthRange } from '@/utils/formatTime'
defineOptions({ name: 'PurReturn' })
const message = useMessage() //
const { t } = useI18n() //
const loading = ref(false) //
const detailLoading = ref(false) //
const list = ref([]) //
const total = ref(0) //
const detailList = ref([]) // 退
const mainInfo = ref<any>({}) //
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
purReturnNo: undefined,
receiptDate: getCurrentSimMonthRange(),
supplierName: undefined,
purStatus: undefined,
billType: undefined,
})
const queryFormRef = ref() //
/** 查询列表 */
const getList = async () => {
loading.value = true
try {
const data = await PurReturnApi.getPurReturnPage(queryParams)
list.value = data.list
total.value = data.total
//
if (list.value.length > 0) {
handleRowClick(list.value[0])
}
} finally {
loading.value = false
}
}
/** 获取详情列表 */
const getDetailList = async (id: number) => {
detailLoading.value = true
try {
// 退ID
const data = await PurReturnApi.getPurReturn(id)
//
mainInfo.value = {
storeHouseName: data.storeHouseName
}
// items
detailList.value = data?.items || data || []
//
detailList.value.forEach(item => {
item.storeHouseName = mainInfo.value.storeHouseName
})
} catch (error) {
console.error('获取退料物料详情失败:', error)
detailList.value = []
mainInfo.value = {}
} finally {
detailLoading.value = false
}
}
/** 点击行加载详情 */
const handleRowClick = (row: any) => {
if (row.id) {
getDetailList(row.id)
}
}
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.pageNo = 1
getList()
}
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value.resetFields()
handleQuery()
}
/** 添加/修改/详情操作 */
const formRef = ref()
const openForm = (type: string, id?: number) => {
formRef.value.open(type, id)
}
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
try {
//
await message.delConfirm()
//
await PurReturnApi.deletePurReturn(id)
message.success(t('common.delSuccess'))
//
await getList()
} catch {}
}
/** 详情表格合计方法 */
const getDetailSummary = (param: any) => {
const { columns, data } = param
const sums: any = []
// columns
if (!columns || !Array.isArray(columns)) {
return sums
}
columns.forEach((column: any, index: number) => {
if (index === 0) {
sums[index] = '合计'
} else if (index === 4) {
// 5
const total = data.reduce((sum: number, item: any) => sum + (Number(item.receiptQty) || 0), 0)
sums[index] = total
} else if (index === 5) {
// 6退
const total = data.reduce((sum: number, item: any) => sum + (Number(item.returnedQty) || 0), 0)
sums[index] = total
} else if (index === 6) {
// 7退
const total = data.reduce((sum: number, item: any) => sum + (Number(item.returnQty) || 0), 0)
sums[index] = total
} else {
sums[index] = ''
}
})
return sums
}
/** 初始化 **/
onMounted(() => {
//
})
</script>
<style scoped>
.text-blue {
color: #409eff;
}
.text-green {
color: #67c23a;
}
</style>