继续对销售出库单进行完善与处理
一、列表显示状态
目前先给出库表单两种状态,未审核与审核通过状态,前端通过下面调整
{
title:'状态',
align:"center",
dataIndex: 'status',
customRender:function (text) {
if(text==1){
return "未审核";
}else if(text==2){
return "审核通过";
}else{
return text;
}
}
},
二、对按钮显示进行处理,已经审核的表单只显示详情
详情
编辑
审核
handleDelete(record.id)">
删除
三、对批量删除进行处理,有审核的单据不能进行删除,对NbcioListMixin里的下面函数修改如下
batchDel: function () {
if(!this.url.deleteBatch){
this.$message.error("请设置url.deleteBatch属性!")
return
}
if (this.selectedRowKeys.length <= 0) {
this.$message.warning('请选择一条记录!');
return;
} else {
var ids = "";
for (var a = 0; a < this.selectedRowKeys.length; a++) {
ids += this.selectedRowKeys[a] + ",";
if(this.selectionRows[a].hasOwnProperty('status') && this.selectionRows[a].status === 2) {
this.$message.warning(`第${a+1}行单据已经审核,不能删除!`)
return
}
}
四、因为审核单据界面与编辑单据界面使用相同的窗口,所以需要做一些逻辑处理
1、首先ErpSaleOutModal文件进行调整如下
审核与编辑分开处理,同时增加两个变量okText和approve,增加一个handleApprove函数
2、在ErpSaleOutForm增加审核的url如下:
url: {
add: "/sale/erpSaleOut/add",
edit: "/sale/erpSaleOut/edit",
approvePass:"/sale/erpSaleOut/approvePass",
3、NbcioListMixin里的handleApprove加入下面代码
handleApprove:function(record){
if(record.status === 2) {
this.$message.warning("单据已经审核,不能再次审核!")
return
}
this.$refs.modalForm.approve=true;
this.$refs.modalForm.edit(record);
this.$refs.modalForm.title="审核详情";
this.$refs.modalForm.okText="审核通过"
this.$refs.modalForm.disableSubmit = true;
},
同时对增加,新建处理需要设置this.$refs.modalForm.approve=false;
4、同时在NbcioTableModelMixin下面增加下面代码
/** 审核通过按钮点击事件 */
handleApprove() {
let url = this.url.approvePass, method = 'post'
console.log("handleApprove this.model.id=",this.model.id)
this.confirmLoading = true
httpAction(url, this.model.id, method).then((res) => {
if (res.success) {
this.$message.success(res.message)
this.$emit('ok')
this.close()
} else {
this.$message.warning(res.message)
}
}).finally(() => {
this.confirmLoading = false
})
},
五、后端调用审核通过代码
/**
* 审核
*
* @param id
* @return
* @throws Exception
*/
@AutoLog(value = "销售出库单-审核通过")
@ApiOperation(value="销售出库单-审核通过", notes="销售出库单-审核通过")
@PostMapping(value = "/approvePass")
public Result> approvePass(@RequestBody String id) throws Exception {
return erpSaleOutService.approvePass(id);
}
@Override
@Transactional(rollbackFor = Exception.class)
public Result> approvePass(String id) throws Exception {
ErpSaleOut erpSaleOut = erpSaleOutMapper.selectById(id);
if (erpSaleOut == null) {
return Result.error("销售出库单不存在!");
}
if (erpSaleOut.getStatus() == 2 ) {
return Result.error("销售出库单已审核通过,不能再次审核!");
}
SysUser loginUser = iErpThirdService.getLoginUser();
LambdaUpdateWrapper updateOrderWrapper = Wrappers.lambdaUpdate(ErpSaleOut.class)
.set(ErpSaleOut::getApproveBy, loginUser.getUsername())
.set(ErpSaleOut::getApproveTime, LocalDateTime.now())
.eq(ErpSaleOut::getId, erpSaleOut.getId());
erpSaleOut.setStatus(2); //审核通过标志 2代表通过
if(erpSaleOutMapper.update(erpSaleOut, updateOrderWrapper) != 1) {
return Result.error("销售出库单信息已过期,请刷新重试!");
}
Wrapper queryDetailWrapper = Wrappers.lambdaQuery(ErpSaleOutDetail.class)
.eq(ErpSaleOutDetail::getSheetId, erpSaleOut.getId())
.orderByAsc(ErpSaleOutDetail::getOrderNo);
List details = erpSaleOutDetailService.list(queryDetailWrapper);
for (ErpSaleOutDetail detail : details) {
ErpGoodsStockVo erpGoodsStockVo = new ErpGoodsStockVo();
erpGoodsStockVo.setScId(erpSaleOut.getScId());
erpGoodsStockVo.setGoodsId(detail.getGoodsId());
erpGoodsStockVo.setStockNum(detail.getOrderNum());
erpGoodsStockVo.setTaxAmount(NumberUtil.mul(detail.getTaxPrice(), detail.getOrderNum()));
erpGoodsStockVo.setUnTaxAmount(NumberUtil.mul(NumberUtil.calcUnTaxPrice(detail.getTaxPrice(), detail.getTaxRate()), detail.getOrderNum()));
erpGoodsStockVo.setTaxPrice(detail.getTaxPrice());
erpGoodsStockVo.setUnTaxPrice(NumberUtil.calcUnTaxPrice(detail.getTaxPrice(), detail.getTaxRate()));
erpGoodsStockVo.setBizCode(erpSaleOut.getCode());
erpGoodsStockVo.setBizDetailId(detail.getId());
erpGoodsStockVo.setBizId(erpSaleOut.getId());
erpGoodsStockVo.setBizType(GoodsStockType.SALE.getCode());
erpGoodsStockService.outStock(erpGoodsStockVo);
}
return Result.OK("审核通过完成");
}
@Override
@Transactional(rollbackFor = Exception.class)
public void outStock(ErpGoodsStockVo erpGoodsStockVo) throws Exception {
Wrapper queryWrapper = Wrappers.lambdaQuery(ErpGoodsStock.class)
.eq(ErpGoodsStock::getGoodsId, erpGoodsStockVo.getGoodsId()).eq(ErpGoodsStock::getScId, erpGoodsStockVo.getScId());
ErpGoodsStock outerpGoodsStock = erpGoodsStockMapper.selectOne(queryWrapper);
ErpGoodsStockLog erpGoodsStockLog = new ErpGoodsStockLog();
if(outerpGoodsStock == null) {
//第一次出库,新增记录
outerpGoodsStock = new ErpGoodsStock();
outerpGoodsStock.setScId(erpGoodsStockVo.getScId());
outerpGoodsStock.setGoodsId(erpGoodsStockVo.getGoodsId());
outerpGoodsStock.setStockNum(0-erpGoodsStockVo.getStockNum());
outerpGoodsStock.setTaxPrice(erpGoodsStockVo.getTaxPrice());
outerpGoodsStock.setTaxAmount(NumberUtil.sub(BigDecimal.ZERO, erpGoodsStockVo.getTaxAmount()));
outerpGoodsStock.setUnTaxPrice(erpGoodsStockVo.getUnTaxPrice());
outerpGoodsStock.setUnTaxAmount(NumberUtil.sub(BigDecimal.ZERO, erpGoodsStockVo.getUnTaxAmount()));
erpGoodsStockMapper.insert(outerpGoodsStock);
erpGoodsStockLog.setOriStockNum(0);
erpGoodsStockLog.setOriUnTaxPrice(BigDecimal.ZERO);
erpGoodsStockLog.setOriTaxPrice(BigDecimal.ZERO);
}
else {//已有库存数量金额更新
LambdaUpdateWrapper updateWrapper = Wrappers.lambdaUpdate(ErpGoodsStock.class)
.eq(ErpGoodsStock::getScId, erpGoodsStockVo.getScId())
.eq(ErpGoodsStock::getGoodsId, erpGoodsStockVo.getGoodsId());
erpGoodsStockLog.setOriStockNum(outerpGoodsStock.getStockNum());
erpGoodsStockLog.setOriUnTaxPrice(outerpGoodsStock.getUnTaxPrice());
erpGoodsStockLog.setOriTaxPrice(outerpGoodsStock.getTaxPrice());
outerpGoodsStock.setScId(erpGoodsStockVo.getScId());
outerpGoodsStock.setGoodsId(erpGoodsStockVo.getGoodsId());
outerpGoodsStock.setStockNum(outerpGoodsStock.getStockNum() - erpGoodsStockVo.getStockNum());
if(outerpGoodsStock.getStockNum() == 0) {
outerpGoodsStock.setTaxPrice(NumberUtil.div(NumberUtil.add(erpGoodsStockVo.getTaxPrice(),outerpGoodsStock.getTaxPrice()),2));
outerpGoodsStock.setUnTaxPrice(NumberUtil.div(NumberUtil.add(erpGoodsStockVo.getUnTaxPrice(),outerpGoodsStock.getUnTaxPrice()),2));
outerpGoodsStock.setTaxAmount(BigDecimal.ZERO);
outerpGoodsStock.setUnTaxAmount(BigDecimal.ZERO);
}
else {
outerpGoodsStock.setTaxAmount(NumberUtil.sub(erpGoodsStockVo.getTaxAmount(),outerpGoodsStock.getTaxAmount()));
outerpGoodsStock.setUnTaxAmount(NumberUtil.sub(erpGoodsStockVo.getUnTaxAmount(),outerpGoodsStock.getUnTaxAmount()));
outerpGoodsStock.setTaxPrice(NumberUtil.div(outerpGoodsStock.getTaxAmount(), outerpGoodsStock.getStockNum()));
outerpGoodsStock.setUnTaxPrice(NumberUtil.div(outerpGoodsStock.getUnTaxAmount(), outerpGoodsStock.getStockNum()));
}
if(erpGoodsStockMapper.update(outerpGoodsStock, updateWrapper) != 1) {
throw new Exception("出库更新信息已过期,请刷新重试!");
}
}
erpGoodsStockLog.setGoodsId(erpGoodsStockVo.getGoodsId());
erpGoodsStockLog.setScId(erpGoodsStockVo.getScId());
erpGoodsStockLog.setStockNum(erpGoodsStockVo.getStockNum());
erpGoodsStockLog.setTaxAmount(erpGoodsStockVo.getTaxAmount());
erpGoodsStockLog.setUnTaxAmount(erpGoodsStockVo.getUnTaxAmount());
erpGoodsStockLog.setCurStockNum(outerpGoodsStock.getStockNum());
erpGoodsStockLog.setStockNum(outerpGoodsStock.getStockNum());
erpGoodsStockLog.setCurTaxPrice(outerpGoodsStock.getTaxPrice());
erpGoodsStockLog.setCurUnTaxPrice(outerpGoodsStock.getUnTaxPrice());
erpGoodsStockLog.setBizCode(erpGoodsStockVo.getBizCode());
erpGoodsStockLog.setBizDetailId(erpGoodsStockVo.getBizDetailId());
erpGoodsStockLog.setBizId(erpGoodsStockVo.getBizId());
erpGoodsStockLog.setBizType(erpGoodsStockVo.getBizType());
erpGoodsStockLogService.save(erpGoodsStockLog);
}
六、效果图: