Browse Source

[feat]: 修改:新增采购订单查询添加审核状态条件查询,修改采购订单切割条件,新增采购订单关联生产单号切割,新增采购单显示按钮条件。新增采购订单,驳回申请修改采购单号是添加子表对象json数据。

dev
zhangsiqi 3 months ago
parent
commit
84e55eea6e
  1. 3
      ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseOrderController.java
  2. 2
      ruoyi-admin/src/main/java/com/ruoyi/purchase/service/IPurchaseOrderService.java
  3. 268
      ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchaseOrderServiceImpl.java
  4. 1
      ruoyi-admin/src/main/resources/mapper/purchase/PurchaseOrderMapper.xml
  5. 516
      ruoyi-admin/src/main/resources/templates/purchase/purchaseOrder/edit.html
  6. 12
      ruoyi-admin/src/main/resources/templates/purchase/purchaseOrder/purchaseOrder.html
  7. 99
      ruoyi-admin/src/main/resources/templates/purchase/purchaseOrder/taskModifyApply.html

3
ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseOrderController.java

@ -360,7 +360,6 @@ public class PurchaseOrderController extends BaseController
// 使用状态-是 // 使用状态-是
purchaseOrderVo.setUseStatus("1"); purchaseOrderVo.setUseStatus("1");
purchaseOrderService.addPurchaseOrderPayable(purchaseOrderVo); purchaseOrderService.addPurchaseOrderPayable(purchaseOrderVo);
} }
// 作废 // 作废
else if("cancel".equals(instanceType)){ else if("cancel".equals(instanceType)){
@ -376,7 +375,7 @@ public class PurchaseOrderController extends BaseController
purchaseOrderService.updatePurchaseOrder(purchaseOrderVo); purchaseOrderService.updatePurchaseOrder(purchaseOrderVo);
// 驳回申请后继续申请,可能修改表单 // 驳回申请后继续申请,可能修改表单
if (saveEntityBoolean) { if (saveEntityBoolean) {
purchaseOrderService.updatePurchaseOrder(purchaseOrderVo); purchaseOrderService.updatePurchaseOrderCode(purchaseOrderVo);
} }
return success("任务已完成"); return success("任务已完成");
} }

2
ruoyi-admin/src/main/java/com/ruoyi/purchase/service/IPurchaseOrderService.java

@ -51,6 +51,8 @@ public interface IPurchaseOrderService
*/ */
public int updatePurchaseOrder(PurchaseOrder purchaseOrder); public int updatePurchaseOrder(PurchaseOrder purchaseOrder);
int updatePurchaseOrderCode(PurchaseOrder purchaseOrder);
/** /**
* 批量删除采购订单 * 批量删除采购订单
* *

268
ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchaseOrderServiceImpl.java

@ -26,7 +26,6 @@ import com.ruoyi.erp.domain.ErpDevelopModifyorder;
import com.ruoyi.erp.mapper.ErpDevelopModifyorderMapper; import com.ruoyi.erp.mapper.ErpDevelopModifyorderMapper;
import com.ruoyi.financial.domain.FinancialAccountsPayable; import com.ruoyi.financial.domain.FinancialAccountsPayable;
import com.ruoyi.financial.mapper.FinancialAccountsPayableMapper; import com.ruoyi.financial.mapper.FinancialAccountsPayableMapper;
import com.ruoyi.financial.service.IFinancialAccountsPayableService;
import com.ruoyi.process.general.service.IProcessService; import com.ruoyi.process.general.service.IProcessService;
import com.ruoyi.process.todoitem.mapper.BizTodoItemMapper; import com.ruoyi.process.todoitem.mapper.BizTodoItemMapper;
import com.ruoyi.purchase.domain.PurchaseOrder; import com.ruoyi.purchase.domain.PurchaseOrder;
@ -40,7 +39,6 @@ import com.ruoyi.purchase.service.IPurchaseOrderService;
import com.ruoyi.system.domain.SysAttachFile; import com.ruoyi.system.domain.SysAttachFile;
import com.ruoyi.system.domain.SysCompanyInformation; import com.ruoyi.system.domain.SysCompanyInformation;
import com.ruoyi.system.domain.SysSupplier; import com.ruoyi.system.domain.SysSupplier;
import com.ruoyi.system.domain.Vo.SysSupplierVo;
import com.ruoyi.system.mapper.SysCompanyInformationMapper; import com.ruoyi.system.mapper.SysCompanyInformationMapper;
import com.ruoyi.system.mapper.SysUserMapper; import com.ruoyi.system.mapper.SysUserMapper;
import com.ruoyi.system.service.ISysAttachFileService; import com.ruoyi.system.service.ISysAttachFileService;
@ -57,7 +55,6 @@ import org.activiti.engine.impl.persistence.entity.TaskEntityImpl;
import org.activiti.engine.runtime.ProcessInstance; import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task; import org.activiti.engine.task.Task;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
@ -67,10 +64,8 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.ServletOutputStream; import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
@ -513,14 +508,28 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
//获取物料供应商的信息,采购订单的供应商数量 //获取物料供应商的信息,采购订单的供应商数量
return 0; return 0;
} }
/** /**
* 修改采购订单 * 修改采购订单
* *
* @param purchaseOrder 采购订单 * @param purchaseOrder 采购订单
* @return 结果 * @return 结果
*/ */
@Override @Override
public int updatePurchaseOrder(PurchaseOrder purchaseOrder) public int updatePurchaseOrder(PurchaseOrder purchaseOrder)
{
purchaseOrder.setCreateTime(DateUtils.getNowDate());
purchaseOrder.setCreateBy(ShiroUtils.getLoginName());
return purchaseOrderMapper.updatePurchaseOrder(purchaseOrder);
}
/**
* 修改采购订单
*
* @param purchaseOrder 采购订单
* @return 结果
*/
@Override
public int updatePurchaseOrderCode(PurchaseOrder purchaseOrder)
{ {
// 初始化累加变量 // 初始化累加变量
BigDecimal materialNoRmb = BigDecimal.ZERO; BigDecimal materialNoRmb = BigDecimal.ZERO;
@ -537,84 +546,167 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
List<PurchaseOrderChild> purchaseOrderChildList = purchaseOrder.getPurchaseOrderChildList(); List<PurchaseOrderChild> purchaseOrderChildList = purchaseOrder.getPurchaseOrderChildList();
//订单子表去除实际物料数量位null或者0的物料信息 //订单子表去除实际物料数量位null或者0的物料信息
purchaseOrderChildList = purchaseOrderChildList.stream().filter(child -> child.getMaterialRealNum() != null).collect(Collectors.toList()); purchaseOrderChildList = purchaseOrderChildList.stream().filter(child -> child.getMaterialRealNum() != null).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(purchaseOrderChildList)) { for (PurchaseOrderChild child : purchaseOrderChildList) {
purchaseOrderChildService.deletePurchaseOrderChildByPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode()); purchaseOrderChildService.deletePurchaseOrderChildByPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode());
for (PurchaseOrderChild child : purchaseOrderChildList) { if (child.getCorrelationCode().contains(","))
if (child.getCorrelationCode().contains(",")) { {
String[] correlationCodes = child.getCorrelationCode().split(",");
String[] planCodes = child.getPurchasePlanCode().split(",");
String[] purchaseQuoteCodes = child.getPurchaseQuoteCode().split(",");
for (int i = 0; i < planCodes.length - 1; i++) {
String planCode = planCodes[i];
PurchasePlan purchasePlan = purchasePlanService.selectPurchasePlanByPlanCode(planCode);
if (planCode != null) {
PurchaseOrderChild material = new PurchaseOrderChild();
child.setPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode());
//获取物料供应商不含税采购价格
BigDecimal suplierMaterialNoRmb = child.getMaterialRealNoRmb();
// 获取物料供应商含税采购价格
BigDecimal suplierMaterialRmb = child.getMaterialRealRmb();
// 获取物料数量
BigDecimal suplierMaterialNum = child.getMaterialRealNum();
if(suplierMaterialNoRmb == null){suplierMaterialNoRmb = BigDecimal.ZERO;}
if(suplierMaterialRmb == null){suplierMaterialRmb = BigDecimal.ZERO;}
if(suplierMaterialNum == null){suplierMaterialNum = new BigDecimal(0);}
//获取供应商不含税价格合计 = 物料数量 * 供应商采购不含税价格
BigDecimal suplierMaterialNoRmbSumLocal = suplierMaterialNoRmb.multiply(suplierMaterialNum);
//获取供应商含税价格合计 = 物料数量 * 供应商采购含税价格
BigDecimal suplierMaterialRmbSumLocal = suplierMaterialRmb.multiply(suplierMaterialNum);
// 累加物料数量
materialNum = materialNum.add(suplierMaterialNum);
// 累加物料总价
materialNoRmbSum = materialNoRmbSum.add(suplierMaterialNoRmbSumLocal);
// 累加物料含税总价
materialRmbSum = materialRmbSum.add(suplierMaterialRmbSumLocal);
// 设置采购报价单编号和供应商信息到QuoteChild
material.setPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode());
material.setPurchasePlanCorrelationCode(correlationCodes[i]);
material.setSupplierCode(child.getSupplierCode());
material.setMaterialUnit(child.getMaterialUnit());
material.setWarehouseDept(child.getWarehouseDept());
material.setSupplierName(child.getSupplierName());
material.setMaterialCode(child.getMaterialCode());
material.setMaterialName(child.getMaterialName());
material.setMaterialBrand(child.getMaterialBrand());
material.setMaterialDescribe(child.getMaterialDescribe());
material.setMaterialPhotoUrl(child.getMaterialPhotoUrl());
material.setMaterialProcessMethod(child.getMaterialProcessMethod());
material.setWarehouseDept(child.getWarehouseDept());
//计划采购数
material.setMaterialNum(child.getMaterialNum());
material.setMaterialNoRmb(child.getMaterialNoRmb());
material.setMaterialRmb(child.getMaterialRmb());
material.setMaterialNoRmbSum(child.getMaterialNoRmbSum());
material.setMaterialRmbSum(child.getMaterialRmbSum());
//实际采购数
material.setMaterialRealNum(child.getMaterialRealNum());
material.setMaterialRealNoRmb(child.getMaterialRealNoRmb());
material.setMaterialRealRmb(child.getMaterialRealRmb());
//实际采购单价合计
material.setMaterialRealRmbSum(suplierMaterialRmbSumLocal);
material.setMaterialRealNoRmbSum(suplierMaterialNoRmbSumLocal);
material.setCorrelationCode(correlationCodes[i]);
material.setDeliveryTime(child.getDeliveryTime());
material.setPurchasePlanCode(planCode);
material.setPurchaseQuoteCode(child.getPurchaseQuoteCode());
//收货状态,0:未收货,1:已收货 收款状态:0:待付款,1:已付款
material.setEceiptStatus("0");
material.setPaymentStatus("0");
// 执行子表插入操作
purchaseOrderChildService.insertPurchaseOrderChild(material);
PurchasePlan plan = new PurchasePlan();
plan.setPurchasePlanCode(planCode);
plan.setPurchasePlanStatus("1");
int result = purchasePlanService.updatePurchasePlan(plan);
}
}
}
else if ((child.getPurchasePlanCode().contains(",") && !child.getCorrelationCode().contains(",")
&& child.getCorrelationCode()!= null)) {
String[] planCodes = child.getPurchasePlanCode().split(",");
for (int i = 0; i < planCodes.length - 1; i++) {
String[] correlationCodes = child.getCorrelationCode().split(","); String[] correlationCodes = child.getCorrelationCode().split(",");
String[] planCodes = child.getPurchasePlanCode().split(","); String[] planCode2 = child.getPurchasePlanCode().split(",");
String[] purchaseQuoteCodes = child.getPurchaseQuoteCode().split(","); String[] purchaseQuoteCodes = child.getPurchaseQuoteCode().split(",");
for (int i = 0; i < planCodes.length - 1; i++) { String planCode = planCode2[i];
String planCode = planCodes[i]; PurchasePlan purchasePlan = purchasePlanService.selectPurchasePlanByPlanCode(planCode);
PurchasePlan purchasePlan = purchasePlanService.selectPurchasePlanByPlanCode(planCode); if (planCode != null) {
if (planCode != null) { PurchaseOrderChild material = new PurchaseOrderChild();
PurchaseOrderChild material = new PurchaseOrderChild(); child.setPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode());
child.setPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode()); //获取物料供应商不含税采购价格
//获取物料供应商不含税采购价格 BigDecimal suplierMaterialNoRmb = child.getMaterialRealNoRmb();
BigDecimal suplierMaterialNoRmb = child.getMaterialRealNoRmb(); // 获取物料供应商含税采购价格
// 获取物料供应商含税采购价格 BigDecimal suplierMaterialRmb = child.getMaterialRealRmb();
BigDecimal suplierMaterialRmb = child.getMaterialRealRmb(); // 获取物料数量
// 获取物料数量 BigDecimal suplierMaterialNum = child.getMaterialRealNum();
BigDecimal suplierMaterialNum = child.getMaterialRealNum(); if (suplierMaterialNoRmb == null) {
if(suplierMaterialNoRmb == null){suplierMaterialNoRmb = BigDecimal.ZERO;} suplierMaterialNoRmb = BigDecimal.ZERO;
if(suplierMaterialRmb == null){suplierMaterialRmb = BigDecimal.ZERO;} }
if(suplierMaterialNum == null){suplierMaterialNum = new BigDecimal(0);} if (suplierMaterialRmb == null) {
//获取供应商不含税价格合计 = 物料数量 * 供应商采购不含税价格 suplierMaterialRmb = BigDecimal.ZERO;
BigDecimal suplierMaterialNoRmbSumLocal = suplierMaterialNoRmb.multiply(suplierMaterialNum);
//获取供应商含税价格合计 = 物料数量 * 供应商采购含税价格
BigDecimal suplierMaterialRmbSumLocal = suplierMaterialRmb.multiply(suplierMaterialNum);
// 累加物料数量
materialNum = materialNum.add(suplierMaterialNum);
// 累加物料总价
materialNoRmbSum = materialNoRmbSum.add(suplierMaterialNoRmbSumLocal);
// 累加物料含税总价
materialRmbSum = materialRmbSum.add(suplierMaterialRmbSumLocal);
// 设置采购报价单编号和供应商信息到QuoteChild
material.setPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode());
material.setPurchasePlanCorrelationCode(child.getCorrelationCode());
material.setSupplierCode(child.getSupplierCode());
material.setMaterialUnit(child.getMaterialUnit());
material.setWarehouseDept(child.getWarehouseDept());
material.setSupplierName(child.getSupplierName());
material.setMaterialCode(child.getMaterialCode());
material.setMaterialName(child.getMaterialName());
material.setMaterialBrand(child.getMaterialBrand());
material.setMaterialDescribe(child.getMaterialDescribe());
material.setMaterialPhotoUrl(child.getMaterialPhotoUrl());
material.setMaterialProcessMethod(child.getMaterialProcessMethod());
material.setWarehouseDept(child.getWarehouseDept());
//计划采购数
material.setMaterialNum(child.getMaterialNum());
material.setMaterialNoRmb(child.getMaterialNoRmb());
material.setMaterialRmb(child.getMaterialRmb());
material.setMaterialNoRmbSum(child.getMaterialNoRmbSum());
material.setMaterialRmbSum(child.getMaterialRmbSum());
//实际采购数
material.setMaterialRealNum(child.getMaterialRealNum());
material.setMaterialRealNoRmb(child.getMaterialRealNoRmb());
material.setMaterialRealRmb(child.getMaterialRealRmb());
//实际采购单价合计
material.setMaterialRealRmbSum(suplierMaterialRmbSumLocal);
material.setMaterialRealNoRmbSum(suplierMaterialNoRmbSumLocal);
material.setCorrelationCode(child.getCorrelationCode());
material.setDeliveryTime(child.getDeliveryTime());
material.setPurchasePlanCode(child.getPurchasePlanCode());
material.setPurchaseQuoteCode(child.getPurchaseQuoteCode());
//收货状态,0:未收货,1:已收货 收款状态:0:待付款,1:已付款
material.setEceiptStatus("0");
material.setPaymentStatus("0");
// 执行子表插入操作
purchaseOrderChildService.insertPurchaseOrderChild(material);
PurchasePlan plan = new PurchasePlan();
plan.setPurchasePlanCode(child.getPurchasePlanCode());
plan.setPurchasePlanStatus("1");
int result = purchasePlanService.updatePurchasePlan(plan);
} }
if (suplierMaterialNum == null) {
suplierMaterialNum = new BigDecimal(0);
}
//获取供应商不含税价格合计 = 物料数量 * 供应商采购不含税价格
BigDecimal suplierMaterialNoRmbSumLocal = suplierMaterialNoRmb.multiply(suplierMaterialNum);
//获取供应商含税价格合计 = 物料数量 * 供应商采购含税价格
BigDecimal suplierMaterialRmbSumLocal = suplierMaterialRmb.multiply(suplierMaterialNum);
// 累加物料数量
materialNum = materialNum.add(suplierMaterialNum);
// 累加物料总价
materialNoRmbSum = materialNoRmbSum.add(suplierMaterialNoRmbSumLocal);
// 累加物料含税总价
materialRmbSum = materialRmbSum.add(suplierMaterialRmbSumLocal);
// 设置采购报价单编号和供应商信息到QuoteChild
material.setPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode());
material.setCorrelationCode(purchasePlan.getCorrelationCode());
material.setPurchasePlanCorrelationCode(correlationCodes[i]);
material.setSupplierCode(child.getSupplierCode());
material.setMaterialUnit(child.getMaterialUnit());
material.setWarehouseDept(child.getWarehouseDept());
material.setSupplierName(child.getSupplierName());
material.setMaterialCode(child.getMaterialCode());
material.setMaterialName(child.getMaterialName());
material.setMaterialBrand(child.getMaterialBrand());
material.setMaterialDescribe(child.getMaterialDescribe());
material.setMaterialPhotoUrl(child.getMaterialPhotoUrl());
material.setMaterialProcessMethod(child.getMaterialProcessMethod());
material.setWarehouseDept(child.getWarehouseDept());
//计划采购数
material.setMaterialNum(child.getMaterialNum());
material.setMaterialNoRmb(child.getMaterialNoRmb());
material.setMaterialRmb(child.getMaterialRmb());
material.setMaterialNoRmbSum(child.getMaterialNoRmbSum());
material.setMaterialRmbSum(child.getMaterialRmbSum());
//实际采购数
material.setMaterialRealNum(child.getMaterialRealNum());
material.setMaterialRealNoRmb(child.getMaterialRealNoRmb());
material.setMaterialRealRmb(child.getMaterialRealRmb());
material.setDeliveryTime(child.getDeliveryTime());
//实际采购单价合计
material.setMaterialRealRmbSum(suplierMaterialRmbSumLocal);
material.setMaterialRealNoRmbSum(suplierMaterialNoRmbSumLocal);
material.setCorrelationCode(child.getCorrelationCode());
material.setPurchasePlanCode(planCode);
material.setPurchaseQuoteCode(child.getPurchaseQuoteCode());
//收货状态,0:未收货,1:已收货 收款状态:0:待付款,1:已付款
material.setEceiptStatus("0");
material.setPaymentStatus("0");
// 执行子表插入操作
purchaseOrderChildService.insertPurchaseOrderChild(material);
PurchasePlan plan = new PurchasePlan();
plan.setPurchasePlanCode(planCode);
plan.setPurchasePlanStatus("1");
int result = purchasePlanService.updatePurchasePlan(plan);
} }
} }
else if ((!child.getCorrelationCode().contains(",")) }
&& child.getPurchasePlanCode() != null) { else if(child.getCorrelationCode().contains(",") && child.getCorrelationCode().contains(",") &&
PurchasePlan purchasePlan = purchasePlanService.selectPurchasePlanByPlanCode(child.getPurchasePlanCode()); child.getPurchasePlanCode()!=null && child.getCorrelationCode()!=null){
String planCode = child.getPurchasePlanCode();
PurchasePlan purchasePlan = purchasePlanService.selectPurchasePlanByPlanCode(planCode);
if (planCode != null) {
PurchaseOrderChild material = new PurchaseOrderChild(); PurchaseOrderChild material = new PurchaseOrderChild();
child.setPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode()); child.setPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode());
//获取物料供应商不含税采购价格 //获取物料供应商不含税采购价格
@ -623,15 +715,21 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
BigDecimal suplierMaterialRmb = child.getMaterialRealRmb(); BigDecimal suplierMaterialRmb = child.getMaterialRealRmb();
// 获取物料数量 // 获取物料数量
BigDecimal suplierMaterialNum = child.getMaterialRealNum(); BigDecimal suplierMaterialNum = child.getMaterialRealNum();
if(suplierMaterialNoRmb == null){suplierMaterialNoRmb = BigDecimal.ZERO;} if (suplierMaterialNoRmb == null) {
if(suplierMaterialRmb == null){suplierMaterialRmb = BigDecimal.ZERO;} suplierMaterialNoRmb = BigDecimal.ZERO;
if(suplierMaterialNum == null){suplierMaterialNum = new BigDecimal(0);} }
if (suplierMaterialRmb == null) {
suplierMaterialRmb = BigDecimal.ZERO;
}
if (suplierMaterialNum == null) {
suplierMaterialNum = new BigDecimal(0);
}
//获取供应商不含税价格合计 = 物料数量 * 供应商采购不含税价格 //获取供应商不含税价格合计 = 物料数量 * 供应商采购不含税价格
BigDecimal suplierMaterialNoRmbSumLocal = suplierMaterialNoRmb.multiply(suplierMaterialNum); BigDecimal suplierMaterialNoRmbSumLocal = suplierMaterialNoRmb.multiply(suplierMaterialNum);
//获取供应商含税价格合计 = 物料数量 * 供应商采购含税价格 //获取供应商含税价格合计 = 物料数量 * 供应商采购含税价格
BigDecimal suplierMaterialRmbSumLocal = suplierMaterialRmb.multiply(suplierMaterialNum); BigDecimal suplierMaterialRmbSumLocal = suplierMaterialRmb.multiply(suplierMaterialNum);
// 累加物料数量 // 累加物料数量
materialNum = materialNum.add(suplierMaterialNum); materialNum = materialNum.add(suplierMaterialNum);
// 累加物料总价 // 累加物料总价
materialNoRmbSum = materialNoRmbSum.add(suplierMaterialNoRmbSumLocal); materialNoRmbSum = materialNoRmbSum.add(suplierMaterialNoRmbSumLocal);
// 累加物料含税总价 // 累加物料含税总价
@ -681,7 +779,9 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
} }
} }
} }
// 遍历处理采购订单子表// 设置累加的物料信息到子表// 设置主表的供应商数量 // 遍历处理采购订单子表
// 设置累加的物料信息到子表
// 设置主表的供应商数量
purchaseOrder.setSupplierNum(supplierNum); purchaseOrder.setSupplierNum(supplierNum);
purchaseOrder.setNoRmbSum(materialNoRmbSum); purchaseOrder.setNoRmbSum(materialNoRmbSum);
purchaseOrder.setRmbSum(materialRmbSum); purchaseOrder.setRmbSum(materialRmbSum);
@ -694,8 +794,6 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
Set<String> amountSet = purchaseOrder.getPurchaseOrderChildList().stream().map(PurchaseOrderChild::getMaterialCode).collect(Collectors.toSet()); Set<String> amountSet = purchaseOrder.getPurchaseOrderChildList().stream().map(PurchaseOrderChild::getMaterialCode).collect(Collectors.toSet());
Integer amount = amountSet.size(); Integer amount = amountSet.size();
purchaseOrder.setMaterialAmount(amount); purchaseOrder.setMaterialAmount(amount);
purchaseOrder.setCreateTime(DateUtils.getNowDate());
purchaseOrder.setCreateBy(ShiroUtils.getLoginName());
return purchaseOrderMapper.updatePurchaseOrder(purchaseOrder); return purchaseOrderMapper.updatePurchaseOrder(purchaseOrder);
} }

1
ruoyi-admin/src/main/resources/mapper/purchase/PurchaseOrderMapper.xml

@ -103,6 +103,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="supplierName != null and supplierName != ''"> <if test="supplierName != null and supplierName != ''">
and pur.purchase_order_code in ( select purchase_order_code from purchase_order_child where supplier_name = #{supplierName}) and pur.purchase_order_code in ( select purchase_order_code from purchase_order_child where supplier_name = #{supplierName})
</if> </if>
<if test="auditStatus != null and auditStatus != ''">and pur.audit_status = #{auditStatus}</if>
<if test="useStatus != null and useStatus != ''">and pur.use_status = #{useStatus}</if> <if test="useStatus != null and useStatus != ''">and pur.use_status = #{useStatus}</if>
<if test="eceiptStatus != null and eceiptStatus !='' ">and pur.eceipt_status = #{eceiptStatus}</if> <if test="eceiptStatus != null and eceiptStatus !='' ">and pur.eceipt_status = #{eceiptStatus}</if>
<if test="paymentStatus != null and paymentStatus != '' ">and pur.payment_status = #{paymentStatus}</if> <if test="paymentStatus != null and paymentStatus != '' ">and pur.payment_status = #{paymentStatus}</if>

516
ruoyi-admin/src/main/resources/templates/purchase/purchaseOrder/edit.html

@ -69,19 +69,19 @@
<div class="form-group"> <div class="form-group">
<label for="purchaseMaterialSum" class="col-sm-2 col-form-label">物料合计:</label> <label for="purchaseMaterialSum" class="col-sm-2 col-form-label">物料合计:</label>
<div class="col-sm-4"> <div class="col-sm-4">
<input type="text" class="form-control" value="0" id="purchaseMaterialSum"> <input type="text" class="form-control" id="purchaseMaterialSum">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="purchaseSum" class="col-sm-2 col-form-label">采购合计:</label> <label for="purchaseSum" class="col-sm-2 col-form-label">采购合计:</label>
<div class="col-sm-4"> <div class="col-sm-4">
<input type="text" class="form-control" value="0" id="purchaseSum"> <input type="text" class="form-control" id="purchaseSum">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="purchaseNoRmbSum" class="col-sm-2 col-form-label">不含税采购总价:</label> <label for="purchaseNoRmbSum" class="col-sm-2 col-form-label">不含税采购总价:</label>
<div class="col-sm-4"> <div class="col-sm-4">
<input type="text" class="form-control" value="0" id="purchaseNoRmbSum"> <input type="text" class="form-control" id="purchaseNoRmbSum">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
@ -99,8 +99,8 @@
<th:block th:include="include :: bootstrap-table-editable-js" /> <th:block th:include="include :: bootstrap-table-editable-js" />
<script th:inline="javascript"> <script th:inline="javascript">
import JSOn from "./swagger-ui-bundle"; import JSOn from "./swagger-ui-bundle";
var prefix = ctx + "purchase/purchaseOrder"; var prefix = ctx + "purchase/purchaseOrder";
var purchaseOrder = [[${formData}]];
var materialTypeDatas = [[${@category.getChildByCode('materialType')}]]; var materialTypeDatas = [[${@category.getChildByCode('materialType')}]];
var auditStatusDatas = [[${@dict.getType('auditStatus')}]]; var auditStatusDatas = [[${@dict.getType('auditStatus')}]];
var sysUnitClassDatas = [[${@dict.getType('sys_unit_class')}]]; var sysUnitClassDatas = [[${@dict.getType('sys_unit_class')}]];
@ -108,18 +108,24 @@
var warehouseDeptDatas = [[${@dict.getType('warehouseDept')}]]; var warehouseDeptDatas = [[${@dict.getType('warehouseDept')}]];
var loginName = [[${@permission.getPrincipalProperty('loginName')}]]; var loginName = [[${@permission.getPrincipalProperty('loginName')}]];
$("#form-purchaseOrder-edit").validate({focusCleanup: true}); $("#form-purchaseOrder-edit").validate({focusCleanup: true});
// var purchasePlanChildList = [[${purchasePlanChildList}]]; var purchasePlanChildList = [];
// var purchasePlanList = [[${purchasePlanList}]]; var purchasePlanCodes = [];
var purchasePlanCodes = [[${purchasePlanCodes}]]; var formId = "form-purchaseOrder-edit";
var formId = "form-plan-purchaseOrder-add";
//根据物料物料数量添加物料分类表,自动生成类似的表单对象 //根据物料物料数量添加物料分类表,自动生成类似的表单对象
//初始根据采购计划单,涉及到物料做分类表 //初始根据采购计划单,涉及到物料做分类表
//根据采购计划单,获取物料信息,自动生成物料的供应商分类表 //根据采购计划单,获取物料信息,自动生成物料的供应商分类表
//获取表单的id; //获取表单的id;
var materialList = []; var materialList = [];
var tableIdList = []; var tableIdList = [];
var $supplierForm;
var tableDatas = [];
//获取采购计划单的物料信息
// 假设qualityOrderCode已经定义或者可以通过某种方式获取到
$(function() { $(function() {
$("#purchasePlanCodes").val(purchasePlanCodes); // 初始化时默认加载仓库ID列表
// 假设purchaseOrderCode已经定义或者可以通过某种方式获取到
var purchaseOrderCode = [[${formData.purchaseOrderCode}]]; // 这里需要实际赋值,比如从前端某个地方读取
var purchaseOrderId = [[${formData.purchaseOrderId}]];
loadWarehouseCodes(); loadWarehouseCodes();
//物料合计 = 物料实际采购数合计,不含税总价,含税采购总价不为null的情况可以合计物料,否则跳过 //物料合计 = 物料实际采购数合计,不含税总价,含税采购总价不为null的情况可以合计物料,否则跳过
$("#purchaseMaterialSum").val(purchaseOrder.materialSum); $("#purchaseMaterialSum").val(purchaseOrder.materialSum);
@ -129,103 +135,421 @@
$('#purchaseNoRmbSum').val(purchaseOrder.noRmbSum); $('#purchaseNoRmbSum').val(purchaseOrder.noRmbSum);
//采购含税总价 //采购含税总价
$('#purchaseRmbSum').val(purchaseOrder.rmbSum); $('#purchaseRmbSum').val(purchaseOrder.rmbSum);
// 假设qualityOrderCode已经定义或者可以通过某种方式获取到
var purchaseOrderCode = [[${purchaseOrder.purchaseOrderCode}]]; // 这里需要实际赋值,比如从前端某个地方读取
var purchaseOrderId = [[${purchaseOrder.purchaseOrderId}]];
// 初始化表格,假设purchasePlanChildList已定义并包含了需要处理的数据 // 初始化表格,假设purchasePlanChildList已定义并包含了需要处理的数据
$.getJSON(prefix + "/editPurchaserOrder/" + purchaseOrderId, function(data) { $.getJSON(prefix + "/editPurchaserOrder/" + purchaseOrderId, function(data) {
console.log("获取采购订单数据"); $("#purchasePlanCodes").val(data.data.purchasePlanCodes);
console.log(JSOn.stringify(data)); var datas = data.data.purchasePlanChildList;
for (var supplierCode in data) { purchasePlanChildList = datas;
if (data.hasOwnProperty(supplierCode)) { var supplierCodes = data.data.supplierCodes;
var supplierData = data[supplierCode]; var supplierMaterials = {};
datas.forEach(function(item) {
var supplierCode = item.supplierCode;
var materialCode = item.materialCode;
// 如果供应商还没有在对象中,就创建一个新的对象
if (!supplierMaterials[supplierCode]) {supplierMaterials[supplierCode] = {};}
// 如果该物料还没有在供应商的对象中,就添加它
if (!supplierMaterials[supplierCode][materialCode]) {
supplierMaterials[supplierCode][materialCode] = {
...item, materialNum: 0 // 初始化数量为0
};
}
supplierMaterials[supplierCode][materialCode].materialNum += item.materialNum;
});
for (var supplierCode in supplierMaterials) {
if (supplierMaterials.hasOwnProperty(supplierCode)) {
var supplierData = Object.values(supplierMaterials[supplierCode]);
createTableForSupplier(supplierCode, supplierData); createTableForSupplier(supplierCode, supplierData);
} }
} }
}); //按照物料的维度查看采购订单信息
// 初始化表格
// 假设purchasePlanChildList已定义并包含了需要处理的数据
//物料列表
purchasePlanChildList.forEach(function (material, index) {
var tableId = 'materialCode-' + index;
var materialTable = "bootstrap-table_" + tableId;
tableIdList.push(tableId);
// 创建物料信息的容器
var $tableWrapper = $('<div id="material-' + tableId + '""></div>');
// 将整个物料信息容器添加到页面
$('#purchasePlanMaterial').append($tableWrapper);
var uniqueSuppliers = [];
////如果物料相同,则添加供应商信息,并对比现在的关系采购计划关联单号是否有包含,没有添加。有则不添加
material.purchaseOrderChildSupplierList.forEach(supplier => {
const key = `${supplier.supplierCode}_${supplier.materialCode}`;
if (!uniqueSuppliers.map(s => `${s.supplierCode}_${s.materialCode}`).includes(key)) {
uniqueSuppliers.push(supplier);
}
});
// 添加关联销售订单号信息
// 创建表格的容器
var $headerDiv =
$('<div class="row">' +
'<div class="col-xs-12">' +
'<h3>' +
'<span><strong>物料 ' + (index + 1) + ': </strong><strong>关联订单号: </strong></span><span class="correlationCodes" id="correlateion-' + tableId + ' ">' + material.purchasePlanCorrelationCode + '</span>' +
'</h3>' +
'<div class="col-sm-12">' +
'<table class="table-materialCode" id="' + materialTable + '">' + '<table/>' +
'</div>' +
'</div>' +
'</div>');
$tableWrapper.append($headerDiv);
//创建物料库存容器
var $stockWrapper = $('<div class="row"><div class="inventory-count " id=" inventory-count-' + tableId + '">'+
'<span><strong>可用库存数:</strong></span>'+'<span id="stock-count-' + tableId + '">10 </span>'+'<span>注:含其他订单待领取的库存,仅供参考,请以实际为准.</span>'+
'</div></div>');
$tableWrapper.append($stockWrapper);
var materialObj = {
purchasePlanCode: material.purchasePlanCode, materialCode: material.materialCode,
photoUrl: material.materialPhotourl, materialName: material.materialName,
materialType: material.materialType, describe: material.materialDescribe,
brand: material.materiaBrand, processMethod: material.materialProcessMethod,
unit: material.materialUnit, warehouseDept:material.warehouseDept,
materialNum: material.materialNum,
};
var materialData = [materialObj];
materialList.push(material);
tables(materialTable, materialData);
var supplierCode = material.supplierCode;
if (supplierCodes.includes(supplierCode)) {
var supplierInfo = $('#supplierInfo_' + tableId);
if (supplierInfo.length === 0) {
var $supplierInfo = $('<div class="supplier-card " style="height: 20px;" id="supplierInfo_' + tableId + '"></div>');
$tableWrapper.append($supplierInfo);
}
var supplierData = material.purchaseOrderChildSupplierList;
supplierData.forEach(function (supplier) {
var supplierCode = supplier.supplierCode;
});
}
//如果物料下的供应商为空,则不需要添加供应商信息,并在容器中添加一个提示信息:暂无供应商信息,请先添加供应商信息。
if (material.purchaseOrderChildSupplierList.length <= 0) {
var $noSupplierDiv = $('<div class="no-supplier">暂无供应商信息,请先添加供应商信息。</div>');
$tableWrapper.append($noSupplierDiv);
}
else{
// 循环处理每个供应商的信息
uniqueSuppliers.forEach(function (supplier, supplierIndex) {
//如果供应商相同,则不需要再次添加供应商信息
// 卡片样式容器,用于包裹每个供应商的信息
// 构建供应商信息头部
var $headerContent =
$( '<div class="card-header supplier_card" id = "supplier-' + tableId + '_' + supplierIndex + '" xmlns="http://www.w3.org/1999/html">' +
'<div class="row">' +
'<div class="crad-text">'+
'<span><strong>供应商 ' + (supplierIndex + 1) + ': </strong></span>' + '<span class="supplierCode">' + supplier.supplierCode + '</span>' + '-' + '<span class="supplierName">' + supplier.supplierName + '</span>' +
'-最新不含税采购价: ' +'<span id="supplierMaterialNoRmb-' + tableId + '" class="supplierMaterialNoRmb"></strong>' + supplier.materialRealNoRmb +'</strong></span>'+
' RMB 最新含税采购价: ' +'<span class="supplierMaterialRmb"><strong>' + supplier.materialRealRmb + '</strong> RMB </span>' +
'<span class="supplierPurchasePlanCode" hidden="hidden" >' + material.planCodes + '</span>' +
'<span class="supplierCorrelationCode" hidden="hidden" >' + material.correlationCode + '</span>' +
'<span class="supplierPurchaseQuoteCode" hidden="hidden" >' + supplier.purchaseQuoteCode + '</span>' +
'</div>' +
'</div>' +
'<div class="row">' +
'<div class="col-xs-6 form-group">' +
'<label class="col-sm-4"> 实际采购数: </label>' +
'<div class ="col-sm-6">' +
'<input type="text" name="materialNum" value="' + supplier.materialRealNum + '" class="form-control supplierMaterialNum actualPurchaseNum" id="actualPurchaseNum_' + tableId + '" disabled>' +
'</div>' +
'</div>' +
'<div class="col-xs-6 form-group">' +
'<label class="col-sm-4">计划交付时间: </label>' +
'<div class ="col-sm-6">' +
'<div class="input-group date"> ' +
'<input type="text" name="deliveryTime" value="' + supplier.deliveryTime + '" text="' + supplier.deliveryTime + '" class="form-control supplierDeliveryTime" id="deliveryTime_' + tableId + '" disabled >' +
'<span class="input-group-addon"><i class="fa fa-calendar"></i></span>' +
'</div> ' +
'</div>' +
'</div>' +
'</div>' +
'</div>');
if (supplier.supplierCode != undefined && supplier.supplierCode != '' && supplier.supplierCode != null) {
$supplierInfo.append($headerContent);
// 构建供应商信息下的输入表单
$supplierForm = $('<div class="card-body" id="card_body_' + tableId + '"></div>');
// 实际采购数输入框
// 其他表单项可以根据需要类似添加
$supplierInfo.append($supplierForm);
}else{
var $noSupplierDiv = $('<div class="no-supplier">暂无供应商信息,请先添加供应商信息。</div>');
$supplierInfo.append($noSupplierDiv);
}
});
$tableWrapper.append($supplierInfo);
}
tableSetup($supplierInfo, tableId);
});
// 给实际采购数的输入框绑定事件处理器
$('.actualPurchaseNum').off('keyup').on('keyup', function(event) {
if (event.keyCode === 13) {
var $supplierInfo = $(this).closest('.supplier-card');
var $supplierCard = $(this).closest('.supplier_card');
var crad = $supplierInfo.attr('id');
var tableId = crad.split('_')[1];
var purchaseNum = parseFloat($(this).val()) || 0;
var noRmbPrice = parseFloat($(this).find('.supplierMaterialNoRmb').text().trim()) || 0;
var rmbPrice = parseFloat($(this).find('.supplierMaterialRmb').text().trim()) || 0;
var materialIndex = tableId.split('-')[1];
// 确保实际采购数不超过计划采购数
var maxPurchaseNum = parseFloat(materialList[materialIndex].materialNum);
// if (purchaseNum > maxPurchaseNum) {
// purchaseNum = maxPurchaseNum;
// $(this).val(maxPurchaseNum);
// }
//物料所有的供应商的采购数加起来超出了materialList[materialIndex].materialNum,就提示超出计划采购数
let actualPurchaseNum = 0;
$supplierCard.find('.actualPurchaseNum').each(function () {
actualPurchaseNum += parseInt($(this).val()) || 0;
});
if (actualPurchaseNum > maxPurchaseNum) {
actualPurchaseNum - maxPurchaseNum;
}
// 更新供应商采购总价
$supplierInfo.find('.supplierPurchaseTotal').val(parseFloat(Number(purchaseNum * noRmbPrice).toFixed(2)));
if (rmbPrice) {
$supplierInfo.find('.supplierPurchaseTotalRmb').val(parseFloat(Number(purchaseNum * rmbPrice).toFixed(2)));
}
// 如果采购数量大于0,则显示供应商采购总价
if (purchaseNum > 0) {
$supplierInfo.find('.supplierPurchaseTotal').removeClass('hidden');
$supplierInfo.find('.supplierPurchaseTotalRmb').removeClass('hidden');
} else {
// 否则隐藏供应商采购总价
$supplierInfo.find('.supplierPurchaseTotal').addClass('hidden');
$supplierInfo.find('.supplierPurchaseTotalRmb').addClass('hidden');
}
recalculateTotals(tableId); // 重新计算当前物料的合计
}
});
// 定义一个函数来重新计算当前物料的合计
// 初始化总计
purchasePlanChildList.forEach(function (material, index) {recalculateTotals('materialCode-' + index);});
});
}); });
function createTableForSupplier(supplierCode, supplierData) { function createTableForSupplier(supplierCode, supplierData) {
var tableId = 'bootstrap-table-' + supplierCode.replace(/[^a-z0-9]/gi, '_').toLowerCase(); var tableId = 'bootstrap-table-' + supplierCode.replace(/[^a-z0-9]/gi, '_').toLowerCase();
tableDatas.push(tableId); tableDatas.push(tableId);
var $tableWrapper = $('<div class="table-responsive"></div>'); var $tableWrapper = $('<div class="table-responsive"></div>');
// 确保supplierData至少有一条记录,并从中提取供应商详细信息 // 确保supplierData至少有一条记录,并从中提取供应商详细信息
var supplierInfo = supplierData.length > 0 ? supplierData[0] : {}; // 默认为空对象,以防数据不存在 var supplierInfo = supplierData.length > 0 ? supplierData[0] : {}; // 默认为空对象,以防数据不存在
// 构建含有额外供应商信息的标题字符串 // 构建含有额外供应商信息的标题字符串
var headerTitle ='供应商'+'</br>'+supplierCode + ' - ' + supplierInfo.supplierName ; var headerTitle = '供应商: ' + supplierCode + ' - ' + supplierInfo.supplierName;
var $header = $('<h4>' + headerTitle + '</h4>'); var $header = $('<h4>' + headerTitle + '</h4>');
var $table = $('<table id="' + tableId + '" class="table table-striped table-bordered"></table>'); var $table = $('<table id="' + tableId + '" class="table table-striped table-bordered"></table>');
$table.bootstrapTable({ $table.bootstrapTable({
data: supplierData, data: supplierData,
columns: [ columns: [
{checkbox: false,visible: false}, { checkbox: false, visible: false },
{title: '供应商ID',field: 'supplierCode',visible: false}, { title: '供应商ID', field: 'supplierCode', visible: false },
{title: '料号',field: 'materialCode'}, { title: '料号', field: 'materialCode' },
{title: '物料名称',field: 'materialName'}, { title: '图片', field: 'materialPhotoUrl',
{title: '物料类型',field: 'materialType', formatter: function(value, row, index) {return $.table.imageView(value);}
formatter: function (value,row, index) { },
$.table.selectCategoryLabel(materialTypeDatas, value) { title: '物料名称', field: 'materialName' },
} { title: '物料类型', field: 'materialType', align: 'center',
}, formatter: function(value, row, index) {return $.table.selectCategoryLabel(materialTypeDatas, value);}
{title: '物料图片地址',field: 'materialPhotourl', },
formatter: function (value, row, index) { { title: '物料描述', field: 'materialDescribe' },
$.table.imageView(value) { title: '品牌', field: 'materialBrand' },
} { title: '加工类型', field: 'materialProcessMethod', align: 'center',
}, formatter: function(value, row, index) {return $.table.selectDictLabel(processMethodDatas, value);}
{title: '物料描述',field: 'materialDescribe',}, },
{title: '物料品牌',field: 'materialBrand',}, { title: '单位', field: 'materialUnit', align: 'center' },
{title: '物料单位',field: 'materialUnit', { title: '入库部门', field: 'warehouseDept', align: 'center',
formatter:function (value) { formatter: function(value, row, index) {return $.table.selectDictLabel(warehouseDeptDatas, value);}
return $.table.selectDictLabel(materialUnitDatas, value); },
} { title: '计划采购数', field: 'materialNum' },
}, { title: '币种', field: '' },
{title: '物料加工方式',field: 'materialProcessMethod', { title: '不含税采购价', field: 'materialNoRmb' },
formatter:function (value) { { title: '含税采购价', field: 'materialRmb' },
return $.table.selectDictLabel(processMethodDatas, value); { title: '实际采购数', field: 'materialRealNum' },
} { title: '实际不含税采购金额', field: 'materialRealNoRmb' },
}, { title: '实际含税采购金额', field: 'materialRealRmb' },
{title: '入库部门',field: 'warehouseDept',visible: false, { title: '已入库数', field: 'actualHasArrivedNum' },
formatter:function (value) { ]
return $.table.selectDictLabel(warehouseDeptDatas, value); });
} $tableWrapper.append($header).append($table);
}, $('#supplierMaterial').append($tableWrapper);
{title: '计划采购数',field: 'materialNum',}, }
{title: '实际采购数',field: 'materialRealNum',}, // 新增函数:重新计算某物料的采购数量合计、不含税采购总价和含税采购总价
{title: '交付时间',field: 'deliveryTime',}, function recalculateTotals(tableId) {
{title: '通知已到货数',field: 'notifyHasArrivedNum', var $tableWrapper = $('#material-' + tableId);
formatter: function (value, row, index) { var totalNoRmb = 0;
if (value == null || value == '') { var totalRmb = 0;
value = 0; var totalActualPurchase = 0;
} var $suplierInfo = $tableWrapper.find('.supplier-card');
return value; //获取所有物料表中供应商列表数据,实际采购数合计,不含税总价,含税采购总价
} $suplierInfo.find('.supplier_card').each(function() {
}, let purchaseNum = parseFloat($(this).find('.actualPurchaseNum').val()) || 0;
{title: '已入库数',field: 'hasStorageNum', let noRmbPrice = parseFloat($(this).find('.supplierMaterialNoRmb').text().trim()) || 0;
formatter: function (value, row, index) { let rmbPrice = parseFloat($(this).find('.supplierMaterialRmb').text().trim()) || 0;
if (value == null || value == '') { totalNoRmb += purchaseNum * noRmbPrice;
value = 0; totalRmb += purchaseNum * rmbPrice;
} totalActualPurchase = totalActualPurchase + purchaseNum;
return value; });
} //物料的实际采购数合计
}, $('#materialAmountSum_' + tableId).val(parseFloat(totalActualPurchase.toFixed(2)));
{title: '通知到货数',field: 'notifyArriveNum',editable: { //物料的实际不含税采购总价:
type: 'text', $('#materialNoRmbSum_' + tableId).val(parseFloat(totalNoRmb.toFixed(2)));
title: '通知到货数', //物料的实际含税总价:
validate: function (value, row, index) { $('#materialRmbSum_' + tableId).val(parseFloat(totalRmb.toFixed(2)));
var num = parseInt(value); // 采购物料合计
if (isNaN(num)) { materialActualPurchaseSum();
return '请输入数字'; }
} else if (num < 0) { function materialActualPurchaseSum(){
return '不能小于0'; var totalNoRmb = 0;
} var totalRmb = 0;
} var totalActualPurchase = 0;
} var materialAmount = 0;
tableIdList.forEach(function (material, index) {
var tableId = tableIdList[index];
var $tableWrapper = $('#material-' + tableId);
//采购合计 = 所有物料的采购数量合计
//采购不含税总价 = 所有物料的不含税总价合计
//采购含税总价 = 所有物料的含税总价合计
//查询物料表下吗整合的物料的实际采购数合计,物料的实际不含税采购总价,物料的实际含税总价
var supplierInfo = $tableWrapper.find('#supplierInfo_' + tableId );
let purchaseNum = parseInt(supplierInfo.find('.actualPurchaseTotalSum').val()) || 0;
let noRmbPrice = parseFloat(supplierInfo.find('.actualPurchaseTotal').val()) || 0;
let rmbPrice = parseFloat(supplierInfo.find('.actualPurchaseTotalTax').val()) || 0;
if (purchaseNum > 0) {
materialAmount += 1;
}
totalActualPurchase += purchaseNum;
totalNoRmb += noRmbPrice;
totalRmb += rmbPrice;
});
//物料合计 = 物料实际采购数合计,不含税总价,含税采购总价不为null的情况可以合计物料,否则跳过
$("#purchaseMaterialSum").val(parseFloat(materialAmount.toFixed(2)));
//采购数量合计
$('#purchaseSum').val(parseFloat(totalActualPurchase.toFixed(2)));
//采购不含税总价
$('#purchaseNoRmbSum').val(parseFloat(totalNoRmb.toFixed(2)));
//采购含税总价
$('#purchaseRmbSum').val(parseFloat(totalRmb.toFixed(2)));
}
function tableSetup(element, tableId) {
var $totalSection = $(
'<div class="card">' +
'<div class="card-body" class="supplierTotal_' + tableId + '">' +
'<div class="col-xs-4">' +
'<label for="actualPurchaseTotal" class="col-sm-5">实际采购数合计:</label>' +
'<div class="col-sm-6">' +
'<input type="number" name="materialAmountSum" class="form-control actualPurchaseTotalSum" id="materialAmountSum_' + tableId + '" disabled>' +
'</div>' +
'</div>' +
'<div class="col-xs-4">' +
'<label for="actualPurchaseTotal" class="col-sm-5">不含税采购总价:</label>' +
'<div class="col-sm-6">' +
'<input type="number" name="materialNoRmbSum" class="form-control actualPurchaseTotal" id="materialNoRmbSum_' + tableId + '" disabled>' +
'</div>' +
'</div>' +
'<div class="col-xs-4">' +
'<label for="actualPurchaseTotalTax" class="col-sm-5">含税采购总价:</label>' +
'<div class="col-sm-6">' +
'<input type="number" name="materialRmbSum" class="form-control actualPurchaseTotalTax" id="materialRmbSum_' + tableId + '" disabled>' +
'</div>' +
'</div>' +
'</div>'+
'</div>');
element.append($totalSection);
}
// 创建表格并添加到页面
function tables(tableId, data) {
$('#' + tableId).bootstrapTable({
showExport: false,
showFooter: false,
showSearch: false,
showRefresh: false,
showColumns: false,
showToggle: false,
data: data,
height: 70,
columns: [
{checkbox: false},
{title: '料号', field: 'materialCode'},
{title: '图片', field: 'photoUrl', formatter: function (value, row, index) {
return $.table.imageView(value);
} }
] },
{title: '物料名称', field: 'materialName'},
{title: '物料类型', field: 'materialType', align: 'center', formatter: function (value, row, index) {
return $.table.selectCategoryLabel(materialTypeDatas, value);
}
},
{title: '物料描述', field: 'describe'},
{title: '品牌', field: 'brand'},
{title: '加工类型', field: 'processMethod', align: 'center', formatter: function (value, row, index) {
return $.table.selectDictLabel(processMethodDatas, value);
}
},
{title: '单位', field: 'unit', align: 'center', },
{title: '入库部门', field: 'warehouseDept', align: 'center', formatter: function (value, row, index) {
return $.table.selectDictLabel(warehouseDeptDatas, value);
}},
{title: '计划采购数', field: 'materialNum'},
],
});
}
// 加载仓库Id列表函数
$("#form-cgjl-edit").validate({focusCleanup: true});
//open打开时,模态框foot下新增审核通过和审核拒绝按钮
//获取仓库相关信息Select2,根据仓库ID查询仓库名称
function loadWarehouseCodes() {
var url = ctx + 'stock/stockInfo/getAllWarehouseCode';
$.ajax({
type: 'GET', // 请求类型
url: url, // 后端接口URL
dataType: 'json', // 预期服务器返回的数据类型
success: function(data) {
if (data && Array.isArray(data)) {
var selectElement = $('#stockNo'); // 获取仓库编号下拉框元素
selectElement.empty();// 清空下拉框现有选项
$.each(data, function(index, item) {
selectElement.append('<option value="' + item.stockNO + '">' + item.stockNO + '</option>');
}); // 遍历返回的数据,添加为下拉框的选项
//设备当前选择的值
selectElement.val(purchaseOrder.stockNo).trigger('change');
} else {
$.modal.errMsg("数据为空");
}
}
});
}
$('#stockNo').on('change', function() {
var selectedWarehouseCode = $(this).val(); // 获取选中的仓库ID
if (selectedWarehouseCode) {
// 发起Ajax请求获取仓库名称
$.ajax({
type: 'GET',
url: ctx +'stock/stockInfo/getStockNameByWarehouseCode/' + selectedWarehouseCode,
dataType: 'json', // 假设返回的数据格式是JSON
success: function(data) {
console.log(data);
// 将获取到的仓库名称填充到输入框
if(data.data == null){
// 如果返回的数据有问题,可以给出提示或处理
$.modal.alertWarning('未能获取到仓库名称!');
}
$('input[name="stockName"]').val(data.data.stockName);
$('input[name="stockAddress"]').val(data.data.stockAddr);
$('input[name="stockContact"]').val(data.data.stockManager);
$('input[name="stockPhone"]').val(data.data.stockManagerPhone);
},
error: function(jqXHR, textStatus, errorThrown) {
console.error('Error:', textStatus, errorThrown);
$.modal.alertWarning('查询仓库名称时发生错误!');
}
}); });
$tableWrapper.append($header).append($table);
$('#supplierMaterial').append($tableWrapper);
} }
});
//获取采购计划单的物料信息 //获取采购计划单的物料信息
//假设qualityOrderCode已经定义或者可以通过某种方式获取到 //假设qualityOrderCode已经定义或者可以通过某种方式获取到
function submitHandler() { function submitHandler() {
@ -306,7 +630,7 @@
purchaseOrder.supplierNum = supplierNumList.length; purchaseOrder.supplierNum = supplierNumList.length;
// 发送数据到后端API // 发送数据到后端API
$.operate.saveJson(prefix + "/addPurchaseOrder",JSON.stringify(purchaseOrder)); $.operate.saveJson(prefix + "/edit",JSON.stringify(purchaseOrder));
} }
} }

12
ruoyi-admin/src/main/resources/templates/purchase/purchaseOrder/purchaseOrder.html

@ -252,18 +252,20 @@
var actions = []; var actions = [];
// actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.purchaseOrderId + '\')"><i class="fa fa-edit"></i>编辑</a> '); // actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.purchaseOrderId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
// actions.push('<a class="btn btn-danger btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.detail(\'' + row.purchaseOrderId + '\')"><i class="fa fa-detail"></i>详情</a>') // actions.push('<a class="btn btn-danger btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.detail(\'' + row.purchaseOrderId + '\')"><i class="fa fa-detail"></i>详情</a>')
if(row.auditStatus=="1" && row.useStatus=="1" && !row.cancelInstanceId) { if(row.auditStatus=="1" && row.useStatus=="1") {
// 作废 // 作废
actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="$.operate.cancel(\'' + row.purchaseOrderId + '\')"><i class="fa fa-remove"></i> 作废</a>'); actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="$.operate.cancel(\'' + row.purchaseOrderId + '\')"><i class="fa fa-remove"></i> 作废</a>');
// 入库通知 // 入库通知
actions.push('<a class="btn btn-success btn-xs ' + addPurchaseOrderStorageFlag + '" href="javascript:void(0)" onclick="$.modal.open(\'添加入库通知检验单\',\'' + prefix+"/addPurchaseOrderStorage/"+row.purchaseOrderCode + '\')">入库通知</a> '); actions.push('<a class="btn btn-success btn-xs ' + addPurchaseOrderStorageFlag + '" href="javascript:void(0)" onclick="$.modal.open(\'添加入库通知检验单\',\'' + prefix+"/addPurchaseOrderStorage/"+row.purchaseOrderCode + '\')">入库通知</a> ');
}else if(row.auditStatus=="2" && row.cancelInstanceId){ }
// 编辑 //审核拒绝
actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.purchaseOrderId + '\')"><i class="fa fa-edit"></i> 编辑</a> '); if(row.auditStatus=="2" && row.applyUser == loginName){
//编辑
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.purchaseOrderId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
} }
//else{actions.push('<a class="btn btn-default btn-xs" href="javascript:void(0)" disabled><i class="fa fa-edit"></i> 编辑</a> ');} //else{actions.push('<a class="btn btn-default btn-xs" href="javascript:void(0)" disabled><i class="fa fa-edit"></i> 编辑</a> ');}
// 有流程实例id // 有流程实例id
if(row.useStatus=="2" && !row.restoreInstanceId){ if(row.useStatus=="2"){
// 恢复 // 恢复
actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="$.operate.restore(\'' + row.purchaseOrderId + '\')"><i class="fa fa-window-restore"></i> 恢复</a> '); actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="$.operate.restore(\'' + row.purchaseOrderId + '\')"><i class="fa fa-window-restore"></i> 恢复</a> ');
} }

99
ruoyi-admin/src/main/resources/templates/purchase/purchaseOrder/taskModifyApply.html

@ -138,6 +138,7 @@
</div> </div>
</div> </div>
</div> </div>
<input name="purchaseOrder" type="hidden"/>
</form> </form>
</div> </div>
@ -298,14 +299,14 @@
'<div class="col-xs-6 form-group">' + '<div class="col-xs-6 form-group">' +
'<label class="col-sm-4"> 实际采购数: </label>' + '<label class="col-sm-4"> 实际采购数: </label>' +
'<div class ="col-sm-6">' + '<div class ="col-sm-6">' +
'<input type="text" name="materialNum" value="' + supplier.materialRealNum + '" class="form-control supplierMaterialNum actualPurchaseNum" id="actualPurchaseNum_' + tableId + '" disabled>' + '<input type="text" name="materialNum" value="' + supplier.materialRealNum + '" class="form-control supplierMaterialNum actualPurchaseNum" id="actualPurchaseNum_' + tableId + '">' +
'</div>' + '</div>' +
'</div>' + '</div>' +
'<div class="col-xs-6 form-group">' + '<div class="col-xs-6 form-group">' +
'<label class="col-sm-4">计划交付时间: </label>' + '<label class="col-sm-4">计划交付时间: </label>' +
'<div class ="col-sm-6">' + '<div class ="col-sm-6">' +
'<div class="input-group date"> ' + '<div class="input-group date"> ' +
'<input type="text" name="deliveryTime" value="' + supplier.deliveryTime + '" text="' + supplier.deliveryTime + '" class="form-control supplierDeliveryTime" id="deliveryTime_' + tableId + '" disabled >' + '<input type="text" name="deliveryTime" value="' + supplier.deliveryTime + '" text="' + supplier.deliveryTime + '" class="form-control supplierDeliveryTime" id="deliveryTime_' + tableId + '" >' +
'<span class="input-group-addon"><i class="fa fa-calendar"></i></span>' + '<span class="input-group-addon"><i class="fa fa-calendar"></i></span>' +
'</div> ' + '</div> ' +
'</div>' + '</div>' +
@ -359,7 +360,6 @@
$supplierInfo.find('.supplierPurchaseTotalRmb').val(parseFloat(Number(purchaseNum * rmbPrice).toFixed(2))); $supplierInfo.find('.supplierPurchaseTotalRmb').val(parseFloat(Number(purchaseNum * rmbPrice).toFixed(2)));
} }
// 如果采购数量大于0,则显示供应商采购总价 // 如果采购数量大于0,则显示供应商采购总价
if (purchaseNum > 0) { if (purchaseNum > 0) {
$supplierInfo.find('.supplierPurchaseTotal').removeClass('hidden'); $supplierInfo.find('.supplierPurchaseTotal').removeClass('hidden');
@ -369,7 +369,6 @@
$supplierInfo.find('.supplierPurchaseTotal').addClass('hidden'); $supplierInfo.find('.supplierPurchaseTotal').addClass('hidden');
$supplierInfo.find('.supplierPurchaseTotalRmb').addClass('hidden'); $supplierInfo.find('.supplierPurchaseTotalRmb').addClass('hidden');
} }
recalculateTotals(tableId); // 重新计算当前物料的合计 recalculateTotals(tableId); // 重新计算当前物料的合计
} }
}); });
@ -612,6 +611,7 @@
function submitHandler() { function submitHandler() {
if ($.validate.form()) { if ($.validate.form()) {
$("#p_B_reApply").val($("#reApply").val()); $("#p_B_reApply").val($("#reApply").val());
var taskId = [[${taskId}]]; var taskId = [[${taskId}]];
var formData = $("#form-purchaseOrder-modify").serialize(); var formData = $("#form-purchaseOrder-modify").serialize();
@ -619,6 +619,97 @@
$.operate.save(prefix + "/complete/" + taskId, formData) $.operate.save(prefix + "/complete/" + taskId, formData)
} }
} }
function submitHandler() {
if ($.validate.form()) {
var materialSum = 0;
var materialRealSum = 0;
var materialNoRmbSum = 0;
var materialRmbSum = 0;
//添加去除供应商编号数组
var supplierNumList = [];
var purchaseOrder = {
supplierNum: 0,materialNum: 0,noRmbSum: 0,rmbSum: 0,
stockNo: $("#stockNo").val(),
stockName: $("#stockName").val(),
stockAddress: $("#stockAddress").val(),
stockContact: $("#stockContact").val(),
stockPhone: $("#stockPhone").val(),
purchaseOrderChildList: [],
};
// 遍历每个物料容器
$('.table-materialCode').each(function(index, tableElement) {
var tableId = tableIdList[index];
let materialObj = materialList[index];
var $tableWrapper = $('#material-' + tableId);
if (typeof materialObj === 'undefined') return;
var $suplierInfo = $tableWrapper.find('.supplier-card');
$suplierInfo.find('.supplier_card').each(function(supplierIndex, supplierCard) {
var supplierCode = $(this).find('.supplierCode').text().trim();
var supplierName = $(this).find('.supplierName').text().trim();
var materialRealNum = parseInt($(this).find('.actualPurchaseNum' ).val()) || 0;
var materialRealRmb = parseFloat($(this).find('.supplierMaterialRmb').text()) || 0;
var materialRealNoRmb = parseFloat($(this).find('.supplierMaterialNoRmb').text()) || 0;
var deliveryTime = $(this).find('.supplierDeliveryTime').val();
var purchasePlanCode = $(this).find('.supplierPurchasePlanCode').text().trim();
var correlationCode = $(this).find('.supplierCorrelationCode').text().trim();
var purchaseQuoteCode = $(this).find('.supplierPurchaseQuoteCode').text().trim();
var materialRealRmbSum = parseFloat(materialRealRmb * materialRealNum);
var materialRealNoRmbSum = parseFloat(materialRealNoRmb * materialRealNum);
materialRealSum += materialRealNum;
materialNoRmbSum += materialRealNoRmbSum;
materialRmbSum += materialRealRmbSum;
if (supplierNumList.indexOf(supplierCode) === -1) {
supplierNumList.push(supplierCode);
purchaseOrder.supplierNum += 1;
}
var materialData = {
materialCode: materialObj.materialCode,
materialName: materialObj.materialName,
materialType: materialObj.materialType,
materialBrand:materialObj.brand,
materialDescribe: materialObj.describe,
materialProcessMethod:materialObj.processMethod,
materialUnit:materialObj.unit,
materialPhotoUrl: materialObj.photoUrl,
warehouseDept: materialObj.warehouseDept,
materialNum: materialObj.materialNum,
supplierCode: supplierCode,
supplierName: supplierName,
materialNoRmb: materialObj.materialNoRmb,
materialRmb: materialObj.materialRmb,
materialRealNum: materialRealNum,
materialRealRmb: materialRealRmb,
materialRealNoRmb: materialRealNoRmb,
materialRealRmbSum: materialRealRmbSum,
materialRealNoRmbSum: materialRealNoRmbSum,
deliveryTime: deliveryTime,
purchasePlanCode:purchasePlanCode,
correlationCode:correlationCode,
purchaseQuoteCode: purchaseQuoteCode,
};
purchaseOrder.purchaseOrderChildList.push(materialData);
});
});
// 获取采购物料合计,采购物料实际合计,采购物料实际非人民币合计,采购物料实际人民币合计
var purchaseAmount = parseFloat($('#purchaseMaterialSum').val());
var purchaseSum = parseFloat($('#purchaseSum').val());
var purchaseNoRmbSum = parseFloat($('#purchaseNoRmbSum').val());
var purchaseRmbSum = parseFloat($('#purchaseRmbSum').val());
// 将合计值附加到purchaseOrder对象
purchaseOrder.materialAmount = purchaseAmount;
purchaseOrder.materialSum = purchaseSum;
purchaseOrder.materialNoRmbSum = purchaseNoRmbSum;
purchaseOrder.materialRmbSum = purchaseRmbSum;
purchaseOrder.supplierNum = supplierNumList.length;
$("#p_B_reApply").val($("#reApply").val());
var taskId = [[${taskId}]];
$("input[name='purchaserOrder']").val(JSON.stringify(purchaseOrder));
var formData = $("#form-purchaseOrder-modify").serialize()
// 发送请求
$.operate.save(prefix + "/complete/" + taskId, formData)
}
}
</script> </script>
</body> </body>
</html> </html>
Loading…
Cancel
Save