Browse Source

[feat]修改采购单编辑功能,替换采购订单数据表,修改采购订单页面中采购数据字段信息。在采购单子表添加关联采购计划编号,以便可以根据采购计划划分采购单物料信息数据。添加采购订单物料信息,物料合计,数量合计。

dev
zhangsiqi 5 months ago
parent
commit
c0f46d8a1f
  1. 1
      ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseOrderChildController.java
  2. 110
      ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseOrderController.java
  3. 58
      ruoyi-admin/src/main/java/com/ruoyi/purchase/domain/PurchaseOrderChild.java
  4. 75
      ruoyi-admin/src/main/resources/mapper/purchase/PurchaseOrderChildMapper.xml
  5. 135
      ruoyi-admin/src/main/resources/mapper/purchase/PurchaseOrderMapper.xml
  6. 2
      ruoyi-admin/src/main/resources/templates/erp/material/material.html
  7. 59
      ruoyi-admin/src/main/resources/templates/purchase/purchaseOrder/purchaseOrder.html
  8. 293
      ruoyi-admin/src/main/resources/templates/purchase/purchasePlan/addPurchaseOrder.html
  9. 2
      ruoyi-admin/src/main/resources/templates/purchase/purchasePlan/purchasePlan.html
  10. 17
      ruoyi-admin/src/main/resources/templates/system/customerQuote/taskYwzgVerify.html

1
ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseOrderChildController.java

@ -114,7 +114,6 @@ public class PurchaseOrderChildController extends BaseController
{ {
return toAjax(purchaseOrderChildService.updatePurchaseOrderChild(purchaseOrderChild)); return toAjax(purchaseOrderChildService.updatePurchaseOrderChild(purchaseOrderChild));
} }
/** /**
* 删除采购订单子表 * 删除采购订单子表
*/ */

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

@ -33,9 +33,11 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap; import org.springframework.ui.ModelMap;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException; import java.io.IOException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.*; import java.util.*;
@ -114,45 +116,83 @@ public class PurchaseOrderController extends BaseController
@Log(title = "采购订单", businessType = BusinessType.INSERT) @Log(title = "采购订单", businessType = BusinessType.INSERT)
@PostMapping("/add") @PostMapping("/add")
@ResponseBody @ResponseBody
public AjaxResult addSave(@RequestBody PurchaseOrder purchaseOrder) throws Exception{ public AjaxResult addSave(@Valid @RequestBody PurchaseOrder purchaseOrder) {
//获取采购订单子表中的供应商,核算供应商数量和采购物料合计以及采购数量合计,采购不含税报价合计,采购含税报价合计 // 数据校验,确保前端传入数据格式正确
validatePurchaseOrder(purchaseOrder);
// 生成采购订单编号
purchaseOrder.setPurchaseOrderCode(redisCache.generateBillNo("CG")); purchaseOrder.setPurchaseOrderCode(redisCache.generateBillNo("CG"));
BigDecimal materialNoRmb = BigDecimal.valueOf(0.0); // 初始化累加变量
BigDecimal materialRmb = BigDecimal.valueOf(0.0); BigDecimal materialNoRmb = BigDecimal.ZERO;
BigDecimal materialNoRmbSum = BigDecimal.valueOf(0.0); BigDecimal materialRmb = BigDecimal.ZERO;
BigDecimal materialRmbSum = BigDecimal.valueOf(0.0); BigDecimal materialNoRmbSum = BigDecimal.ZERO;
BigDecimal materialSum = BigDecimal.valueOf(0.0); BigDecimal materialRmbSum = BigDecimal.ZERO;
List<PurchaseOrderChild> purchaseMaterials = new ArrayList<>();
Long materialNum = 0L; Long materialNum = 0L;
int supplierNum = 0; int supplierNum = 0;
int purOdersize = purchaseOrder.getPurchaseOrderChildList().size(); // 遍历处理采购订单子表
if(purOdersize > 1){ for (PurchaseOrderChild child : purchaseOrder.getPurchaseOrderChildList()) {
purchaseMaterials = purchaseOrder.getPurchaseOrderChildList(); child.setPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode());
for (PurchaseOrderChild purchaseOrderChild : purchaseMaterials) { // 累加物料数量和金额
purchaseOrderChild.setPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode()); for (PurchaseQuoteChild quote : child.getPurchaseQuoteChildList()) {
for (PurchaseQuoteChild purchaseSupplierQuote : purchaseOrderChild.getPurchaseQuoteChildList()){ //获取物料供应商采购价格
BigDecimal suplierMaterialNoRmb = purchaseSupplierQuote.getMaterialNoRmb(); BigDecimal suplierMaterialNoRmb = quote.getMaterialNoRmb();
BigDecimal suplierMaterialRmb = purchaseSupplierQuote.getMaterialRmb(); // 获取物料供应商采购价格
Long suplierMaterialNum = purchaseSupplierQuote.getMaterialNum(); BigDecimal suplierMaterialRmb = quote.getMaterialRmb();
BigDecimal suplierMaterialNoRmbSum = suplierMaterialNoRmb.multiply(BigDecimal.valueOf(suplierMaterialNum)); // 获取物料数量
BigDecimal suplierMaterialRmbSum = suplierMaterialRmb.multiply(BigDecimal.valueOf(suplierMaterialNum)); Long suplierMaterialNum = quote.getMaterialNum();
materialNum = materialNum + suplierMaterialNum; // 累加物料数量
materialNoRmb = materialNoRmb.add(purchaseSupplierQuote.getMaterialNoRmb()); materialNum += suplierMaterialNum;
materialRmb = materialRmb.add(purchaseSupplierQuote.getMaterialRmb()); // 累加不含税物料价格
materialRmbSum = materialRmbSum.add(suplierMaterialRmbSum); materialNoRmb = materialNoRmb.add(suplierMaterialNoRmb);
materialNoRmbSum = materialNoRmbSum.add(suplierMaterialNoRmbSum); // 累加含税物料价格
purchaseSupplierQuote.setPurchaseQuoteCode(purchaseOrder.getPurchaseOrderCode()); materialRmb = materialRmb.add(suplierMaterialRmb);
if (purchaseSupplierQuote.getSupplierCode() != null){
supplierNum ++; child.setPurchasePlanCode(quote.getPurchasePlanCode());
} // 计算不含税物料总价
} BigDecimal suplierMaterialNoRmbSumLocal = suplierMaterialNoRmb.multiply(BigDecimal.valueOf(suplierMaterialNum));
purchaseOrderChild.setMaterialNormb(materialNoRmb); // 计算物料含税总价
purchaseOrderChild.setMaterialRmb(materialRmb); BigDecimal suplierMaterialRmbSumLocal = suplierMaterialRmb.multiply(BigDecimal.valueOf(suplierMaterialNum));
purchaseOrderChild.setMaterialNum(materialNum); // 累加物料总价
} materialNoRmbSum = materialNoRmbSum.add(suplierMaterialNoRmbSumLocal);
purchaseOrder.setSupplierNum(supplierNum); // 累加物料含税总价
materialRmbSum = materialRmbSum.add(suplierMaterialRmbSumLocal);
// 设置采购报价单编号和供应商信息到QuoteChild
quote.setPurchaseQuoteCode(purchaseOrder.getPurchaseOrderCode());
child.setSupplierCode(quote.getSupplierCode());
child.setSupplierName(quote.getSupplierName());
// 确保供应商数量统计准确
if (quote.getSupplierCode() != null) {
supplierNum++;
}
}
// 设置累加的物料信息到子表
child.setMaterialNoRmb(materialNoRmb);
child.setMaterialRmb(materialRmb);
child.setMaterialNum(materialNum);
// 执行子表插入操作
purchaseOrderChildService.insertPurchaseOrderChild(child);
}
// 设置主表的供应商数量
purchaseOrder.setSupplierNum(supplierNum);
// 执行主表插入操作
return toAjax(purchaseOrderService.insertPurchaseOrder(purchaseOrder)); // 假设toAjax方法处理成功逻辑
}
// 数据校验逻辑
private void validatePurchaseOrder(PurchaseOrder purchaseOrder) {
if (CollectionUtils.isEmpty(purchaseOrder.getPurchaseOrderChildList())) {
try {
throw new Exception("采购订单子项不能为空");
} catch (Exception e) {
throw new RuntimeException(e);
}
} }
return toAjax(purchaseOrderService.insertPurchaseOrder(purchaseOrder)); // 可以添加更多校验逻辑
} }
/** /**

58
ruoyi-admin/src/main/java/com/ruoyi/purchase/domain/PurchaseOrderChild.java

@ -26,6 +26,8 @@ public class PurchaseOrderChild extends BaseEntity
@Excel(name = "关联采购订单号") @Excel(name = "关联采购订单号")
private String purchaseOrderCode; private String purchaseOrderCode;
private String purchasePlanCode;
/** 供应商代码 */ /** 供应商代码 */
@Excel(name = "供应商代码") @Excel(name = "供应商代码")
private String supplierCode; private String supplierCode;
@ -44,7 +46,7 @@ public class PurchaseOrderChild extends BaseEntity
/** 物料不含税单价 */ /** 物料不含税单价 */
@Excel(name = "物料不含税单价") @Excel(name = "物料不含税单价")
private BigDecimal materialNormb; private BigDecimal materialNoRmb;
/** 物料含税单价 */ /** 物料含税单价 */
@Excel(name = "物料含税单价") @Excel(name = "物料含税单价")
@ -64,11 +66,11 @@ public class PurchaseOrderChild extends BaseEntity
/** 不含税总价(RMB) */ /** 不含税总价(RMB) */
@Excel(name = "不含税总价(RMB)") @Excel(name = "不含税总价(RMB)")
private BigDecimal materialNormbsum; private BigDecimal materialNoRmbSum;
/** 含税总价(RMB) */ /** 含税总价(RMB) */
@Excel(name = "含税总价(RMB)") @Excel(name = "含税总价(RMB)")
private BigDecimal materialRmbsum; private BigDecimal materialRmbSum;
/** 交货时间 */ /** 交货时间 */
@JsonFormat(pattern = "yyyy-MM-dd") @JsonFormat(pattern = "yyyy-MM-dd")
@ -130,6 +132,14 @@ public class PurchaseOrderChild extends BaseEntity
this.supplierCode = supplierCode; this.supplierCode = supplierCode;
} }
public String getPurchasePlanCode() {
return purchasePlanCode;
}
public void setPurchasePlanCode(String purchasePlanCode) {
this.purchasePlanCode = purchasePlanCode;
}
public String getSupplierCode() public String getSupplierCode()
{ {
return supplierCode; return supplierCode;
@ -161,15 +171,15 @@ public class PurchaseOrderChild extends BaseEntity
{ {
return materialName; return materialName;
} }
public void setMaterialNormb(BigDecimal materialNormb)
{ public BigDecimal getMaterialNoRmb() {
this.materialNormb = materialNormb; return materialNoRmb;
} }
public BigDecimal getMaterialNormb() public void setMaterialNoRmb(BigDecimal materialNoRmb) {
{ this.materialNoRmb = materialNoRmb;
return materialNormb;
} }
public void setMaterialRmb(BigDecimal materialRmb) public void setMaterialRmb(BigDecimal materialRmb)
{ {
this.materialRmb = materialRmb; this.materialRmb = materialRmb;
@ -206,24 +216,23 @@ public class PurchaseOrderChild extends BaseEntity
{ {
return materialSum; return materialSum;
} }
public void setMaterialNormbsum(BigDecimal materialNormbsum)
{ public BigDecimal getMaterialNoRmbSum() {
this.materialNormbsum = materialNormbsum; return materialNoRmbSum;
} }
public BigDecimal getMaterialNormbsum() public void setMaterialNoRmbSum(BigDecimal materialNoRmbSum) {
{ this.materialNoRmbSum = materialNoRmbSum;
return materialNormbsum;
} }
public void setMaterialRmbsum(BigDecimal materialRmbsum)
{ public BigDecimal getMaterialRmbSum() {
this.materialRmbsum = materialRmbsum; return materialRmbSum;
} }
public BigDecimal getMaterialRmbsum() public void setMaterialRmbSum(BigDecimal materialRmbSum) {
{ this.materialRmbSum = materialRmbSum;
return materialRmbsum;
} }
public void setDeliveryTime(Date deliveryTime) public void setDeliveryTime(Date deliveryTime)
{ {
this.deliveryTime = deliveryTime; this.deliveryTime = deliveryTime;
@ -293,17 +302,18 @@ public class PurchaseOrderChild extends BaseEntity
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("purchaseOrderChildId", getPurchaseOrderChildId()) .append("purchaseOrderChildId", getPurchaseOrderChildId())
.append("purchaseOrderCode", getPurchaseOrderCode()) .append("purchaseOrderCode", getPurchaseOrderCode())
.append("purchasePlanCode", getPurchasePlanCode())
.append("supplierCode", getSupplierCode()) .append("supplierCode", getSupplierCode())
.append("supplierName", getSupplierName()) .append("supplierName", getSupplierName())
.append("materialCode", getMaterialCode()) .append("materialCode", getMaterialCode())
.append("materialName", getMaterialName()) .append("materialName", getMaterialName())
.append("materialNormb", getMaterialNormb()) .append("materialNoRmb", getMaterialNoRmb())
.append("materialRmb", getMaterialRmb()) .append("materialRmb", getMaterialRmb())
.append("materialNum", getMaterialNum()) .append("materialNum", getMaterialNum())
.append("materialAmount", getMaterialAmount()) .append("materialAmount", getMaterialAmount())
.append("materialSum", getMaterialSum()) .append("materialSum", getMaterialSum())
.append("materialNormbsum", getMaterialNormbsum()) .append("materialNoRmbSum", getMaterialNoRmbSum())
.append("materialRmbsum", getMaterialRmbsum()) .append("materialRmbSum", getMaterialRmbSum())
.append("deliveryTime", getDeliveryTime()) .append("deliveryTime", getDeliveryTime())
.append("eceiptStatus", getEceiptStatus()) .append("eceiptStatus", getEceiptStatus())
.append("paymentStatus", getPaymentStatus()) .append("paymentStatus", getPaymentStatus())

75
ruoyi-admin/src/main/resources/mapper/purchase/PurchaseOrderChildMapper.xml

@ -5,40 +5,45 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<mapper namespace="com.ruoyi.purchase.mapper.PurchaseOrderChildMapper"> <mapper namespace="com.ruoyi.purchase.mapper.PurchaseOrderChildMapper">
<resultMap type="PurchaseOrderChild" id="PurchaseOrderChildResult"> <resultMap type="PurchaseOrderChild" id="PurchaseOrderChildResult">
<result property="purchaseOrderChildId" column="purchase_order_child_id" /> <result property="purchaseOrderChildId" column="purchase_order_child_id" />
<result property="purchaseOrderCode" column="purchase_order_code" /> <result property="purchaseOrderCode" column="purchase_order_code" />
<result property="supplierCode" column="supplier_code" /> <result property="purchasePlanCode" column="purchase_plan_code" />
<result property="supplierName" column="supplier_name" /> <result property="supplierCode" column="supplier_code" />
<result property="materialCode" column="material_code" /> <result property="supplierName" column="supplier_name" />
<result property="materialName" column="material_name" /> <result property="materialCode" column="material_code" />
<result property="materialNormb" column="material_noRmb" /> <result property="materialName" column="material_name" />
<result property="materialRmb" column="material_rmb" /> <result property="materialNoRmb" column="material_no_rmb" />
<result property="materialNum" column="material_num" /> <result property="materialRmb" column="material_rmb" />
<result property="materialAmount" column="material_amount" /> <result property="materialNum" column="material_num" />
<result property="materialSum" column="material_sum" /> <result property="materialAmount" column="material_amount" />
<result property="materialNormbsum" column="material_noRmbSum" /> <result property="materialSum" column="material_sum" />
<result property="materialRmbsum" column="material_rmbSum" /> <result property="materialNoRmbSum" column="material_no_rmb_sum" />
<result property="deliveryTime" column="delivery_time" /> <result property="materialRmbSum" column="material_rmb_sum" />
<result property="eceiptStatus" column="eceipt_status" /> <result property="deliveryTime" column="delivery_time" />
<result property="paymentStatus" column="payment_status" /> <result property="eceiptStatus" column="eceipt_status" />
<result property="taxRate" column="tax_rate" /> <result property="paymentStatus" column="payment_status" />
<result property="createBy" column="create_by" /> <result property="taxRate" column="tax_rate" />
<result property="createTime" column="create_time" /> <result property="createBy" column="create_by" />
<result property="updateBy" column="update_by" /> <result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" /> <result property="updateBy" column="update_by" />
<result property="delFlag" column="del_flag" /> <result property="updateTime" column="update_time" />
<result property="standbyOne" column="standby_one" /> <result property="delFlag" column="del_flag" />
<result property="standbyTwo" column="standby_two" /> <result property="standbyOne" column="standby_one" />
<result property="standbyTwo" column="standby_two" />
</resultMap> </resultMap>
<sql id="selectPurchaseOrderChildVo"> <sql id="selectPurchaseOrderChildVo">
select purchase_order_child_id, purchase_order_code, supplier_code, supplier_name, material_code, material_name, material_noRmb, material_rmb, material_num, material_amount, material_sum, material_noRmbSum, material_rmbSum, delivery_time, eceipt_status, payment_status, tax_rate, create_by, create_time, update_by, update_time, del_flag, standby_one, standby_two from purchase_order_child select purchase_order_child_id, purchase_order_code, supplier_code, supplier_name,
material_code, material_name, material_no_rmb, material_rmb, material_num,
material_amount, material_sum, material_no_rmb_sum, material_rmb_sum, delivery_time,
eceipt_status, payment_status, tax_rate, create_by, create_time, update_by, update_time,
del_flag, standby_one, standby_two from purchase_order_child
</sql> </sql>
<select id="selectPurchaseOrderChildList" parameterType="PurchaseOrderChild" resultMap="PurchaseOrderChildResult"> <select id="selectPurchaseOrderChildList" parameterType="PurchaseOrderChild" resultMap="PurchaseOrderChildResult">
<include refid="selectPurchaseOrderChildVo"/> <include refid="selectPurchaseOrderChildVo"/>
<where> <where>
<if test="purchaseOrderCode != null and purchaseOrderCode != ''"> and purchase_order_code = #{purchaseOrderCode}</if> <if test="purchaseOrderCode != null and purchaseOrderCode != ''"> and purchase_order_code = #{purchaseOrderCode}</if>
<if test="supplierCode != null and supplierCode != ''"> and supplier_code = #{supplierCode}</if> <if test="supplierCode != null and supplierCode != ''"> and supplier_code = #{supplierCode}</if>
<if test="supplierName != null and supplierName != ''"> and supplier_name like concat('%', #{supplierName}, '%')</if> <if test="supplierName != null and supplierName != ''"> and supplier_name like concat('%', #{supplierName}, '%')</if>
<if test="materialCode != null and materialCode != ''"> and material_code = #{materialCode}</if> <if test="materialCode != null and materialCode != ''"> and material_code = #{materialCode}</if>
@ -63,13 +68,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="supplierName != null">supplier_name,</if> <if test="supplierName != null">supplier_name,</if>
<if test="materialCode != null">material_code,</if> <if test="materialCode != null">material_code,</if>
<if test="materialName != null">material_name,</if> <if test="materialName != null">material_name,</if>
<if test="materialNormb != null">material_noRmb,</if> <if test="materialNormb != null">material_no_rmb,</if>
<if test="materialRmb != null">material_rmb,</if> <if test="materialRmb != null">material_rmb,</if>
<if test="materialNum != null">material_num,</if> <if test="materialNum != null">material_num,</if>
<if test="materialAmount != null">material_amount,</if> <if test="materialAmount != null">material_amount,</if>
<if test="materialSum != null">material_sum,</if> <if test="materialSum != null">material_sum,</if>
<if test="materialNormbsum != null">material_noRmbSum,</if> <if test="materialNoRmbSum != null">material_no_rmb_sum,</if>
<if test="materialRmbsum != null">material_rmbSum,</if> <if test="materialRmbSum != null">material_rmb_sum,</if>
<if test="deliveryTime != null">delivery_time,</if> <if test="deliveryTime != null">delivery_time,</if>
<if test="eceiptStatus != null">eceipt_status,</if> <if test="eceiptStatus != null">eceipt_status,</if>
<if test="paymentStatus != null">payment_status,</if> <if test="paymentStatus != null">payment_status,</if>
@ -88,13 +93,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="supplierName != null">#{supplierName},</if> <if test="supplierName != null">#{supplierName},</if>
<if test="materialCode != null">#{materialCode},</if> <if test="materialCode != null">#{materialCode},</if>
<if test="materialName != null">#{materialName},</if> <if test="materialName != null">#{materialName},</if>
<if test="materialNormb != null">#{materialNormb},</if> <if test="materialNoRmb != null">#{materialNormb},</if>
<if test="materialRmb != null">#{materialRmb},</if> <if test="materialRmb != null">#{materialRmb},</if>
<if test="materialNum != null">#{materialNum},</if> <if test="materialNum != null">#{materialNum},</if>
<if test="materialAmount != null">#{materialAmount},</if> <if test="materialAmount != null">#{materialAmount},</if>
<if test="materialSum != null">#{materialSum},</if> <if test="materialSum != null">#{materialSum},</if>
<if test="materialNormbsum != null">#{materialNormbsum},</if> <if test="materialNoRmbSum != null">#{materialNormbsum},</if>
<if test="materialRmbsum != null">#{materialRmbsum},</if> <if test="materialRmbSum != null">#{materialRmbsum},</if>
<if test="deliveryTime != null">#{deliveryTime},</if> <if test="deliveryTime != null">#{deliveryTime},</if>
<if test="eceiptStatus != null">#{eceiptStatus},</if> <if test="eceiptStatus != null">#{eceiptStatus},</if>
<if test="paymentStatus != null">#{paymentStatus},</if> <if test="paymentStatus != null">#{paymentStatus},</if>
@ -117,13 +122,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="supplierName != null">supplier_name = #{supplierName},</if> <if test="supplierName != null">supplier_name = #{supplierName},</if>
<if test="materialCode != null">material_code = #{materialCode},</if> <if test="materialCode != null">material_code = #{materialCode},</if>
<if test="materialName != null">material_name = #{materialName},</if> <if test="materialName != null">material_name = #{materialName},</if>
<if test="materialNormb != null">material_noRmb = #{materialNormb},</if> <if test="materialNoRmb != null">material_no_rmb = #{materialNoRmb},</if>
<if test="materialRmb != null">material_rmb = #{materialRmb},</if> <if test="materialRmb != null">material_rmb = #{materialRmb},</if>
<if test="materialNum != null">material_num = #{materialNum},</if> <if test="materialNum != null">material_num = #{materialNum},</if>
<if test="materialAmount != null">material_amount = #{materialAmount},</if> <if test="materialAmount != null">material_amount = #{materialAmount},</if>
<if test="materialSum != null">material_sum = #{materialSum},</if> <if test="materialSum != null">material_sum = #{materialSum},</if>
<if test="materialNormbsum != null">material_noRmbSum = #{materialNormbsum},</if> <if test="materialNoRmbSum != null">material_no_rmb_sum = #{materialNoRmbSum},</if>
<if test="materialRmbsum != null">material_rmbSum = #{materialRmbsum},</if> <if test="materialRmbSum != null">material_rmb_sum = #{materialRmbsum},</if>
<if test="deliveryTime != null">delivery_time = #{deliveryTime},</if> <if test="deliveryTime != null">delivery_time = #{deliveryTime},</if>
<if test="eceiptStatus != null">eceipt_status = #{eceiptStatus},</if> <if test="eceiptStatus != null">eceipt_status = #{eceiptStatus},</if>
<if test="paymentStatus != null">payment_status = #{paymentStatus},</if> <if test="paymentStatus != null">payment_status = #{paymentStatus},</if>

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

@ -5,54 +5,60 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<mapper namespace="com.ruoyi.purchase.mapper.PurchaseOrderMapper"> <mapper namespace="com.ruoyi.purchase.mapper.PurchaseOrderMapper">
<resultMap type="PurchaseOrder" id="PurchaseOrderResult"> <resultMap type="PurchaseOrder" id="PurchaseOrderResult">
<result property="purchaseOrderId" column="purchase_order_id" /> <result property="purchaseOrderId" column="purchase_order_id" />
<result property="purchaseOrderCode" column="purchase_order_code" /> <result property="purchaseOrderCode" column="purchase_order_code" />
<result property="purchaseBuyer" column="purchase_buyer" /> <result property="purchaseBuyer" column="purchase_buyer" />
<result property="useStatus" column="use_status" /> <result property="useStatus" column="use_status" />
<result property="auditStatus" column="audit_status" /> <result property="auditStatus" column="audit_status" />
<result property="eceiptStatus" column="eceipt_status" /> <result property="eceiptStatus" column="eceipt_status" />
<result property="payment_status" column="payment_status" /> <result property="paymentStatus" column="payment_status" />
<result property="supplierNum" column="supplier_num" /> <result property="supplierNum" column="supplier_num" />
<result property="materialAmount" column="material_amount" /> <result property="materialAmount" column="material_amount" />
<result property="materialSum" column="material_sum" /> <result property="materialSum" column="material_sum" />
<result property="noRmbSum" column="noRmbSum" /> <result property="noRmbSum" column="noRmbSum" />
<result property="rmbSum" column="rmbSum" /> <result property="rmbSum" column="rmbSum" />
<result property="supplierCode" column="supplier_code" /> <result property="supplierCode" column="supplier_code" />
<result property="supplierName" column="supplier_name" /> <result property="supplierName" column="supplier_name" />
<result property="customerContact" column="customer_contact" /> <result property="customerContact" column="customer_contact" />
<result property="contactNumber" column="contact_number" /> <result property="contactNumber" column="contact_number" />
<result property="customerFax" column="customer_fax" /> <result property="customerFax" column="customer_fax" />
<result property="deliveryAddress" column="delivery_address" /> <result property="deliveryAddress" column="delivery_address" />
<result property="paymentTerms" column="payment_terms" /> <result property="paymentTerms" column="payment_terms" />
<result property="deliveryConditions" column="delivery_conditions" /> <result property="deliveryConditions" column="delivery_conditions" />
<result property="deliveryMethod" column="delivery_method" /> <result property="deliveryMethod" column="delivery_method" />
<result property="purchaseName" column="purchase_name" /> <result property="purchaseName" column="purchase_name" />
<result property="billingDate" column="billing_date" /> <result property="billingDate" column="billing_date" />
<result property="taxRate" column="tax_rate" /> <result property="taxRate" column="tax_rate" />
<result property="purchaseCategory" column="purchase_category" /> <result property="purchaseCategory" column="purchase_category" />
<result property="purchaseCommander" column="purchase_commander" /> <result property="purchaseCommander" column="purchase_commander" />
<result property="customerOrderNumber" column="customer_order_number" /> <result property="customerOrderNumber" column="customer_order_number" />
<result property="remarkContent" column="remark_content" /> <result property="remarkContent" column="remark_content" />
<result property="closeCaseNo" column="close_case_no" /> <result property="closeCaseNo" column="close_case_no" />
<result property="closeCaseName" column="close_case_name" /> <result property="closeCaseName" column="close_case_name" />
<result property="closeCaseTime" column="close_case_time" /> <result property="closeCaseTime" column="close_case_time" />
<result property="confirmNo" column="confirm_no" /> <result property="confirmNo" column="confirm_no" />
<result property="confirmName" column="confirm_name" /> <result property="confirmName" column="confirm_name" />
<result property="confirmTime" column="confirm_time" /> <result property="confirmTime" column="confirm_time" />
<result property="auditNo" column="audit_no" /> <result property="auditNo" column="audit_no" />
<result property="auditName" column="audit_name" /> <result property="auditName" column="audit_name" />
<result property="auditTime" column="audit_time" /> <result property="auditTime" column="audit_time" />
<result property="approveNo" column="approve_no" /> <result property="approveNo" column="approve_no" />
<result property="approveName" column="approve_name" /> <result property="approveName" column="approve_name" />
<result property="approveTime" column="approve_time" /> <result property="approveTime" column="approve_time" />
<result property="firstAddTime" column="first_add_time" /> <result property="firstAddTime" column="first_add_time" />
<result property="updateInfoTime" column="update_info_time" /> <result property="updateInfoTime" column="update_info_time" />
<result property="standbyOne" column="standby_one" /> <result property="standbyOne" column="standby_one" />
<result property="standbyTwo" column="standby_two" /> <result property="standbyTwo" column="standby_two" />
</resultMap> </resultMap>
<sql id="selectPurchaseOrderVo"> <sql id="selectPurchaseOrderVo">
select purchase_order_id, purchase_order_code, supplier_code, supplier_name, customer_contact, contact_number, customer_fax, delivery_address, payment_terms, delivery_conditions, delivery_method, purchase_name, billing_date, tax_rate, purchase_category, purchase_commander, customer_order_number, remark_content, close_case_no, close_case_name, close_case_time, confirm_no, confirm_name, confirm_time, audit_no, audit_name, audit_time, approve_no, approve_name, approve_time, first_add_time, update_info_time, standby_one, standby_two from purchase_order select purchase_order_id, purchase_order_code, supplier_code, supplier_name,
customer_contact, contact_number, customer_fax, delivery_address, payment_terms,
delivery_conditions, delivery_method, purchase_name, billing_date, tax_rate,
purchase_category, purchase_commander, customer_order_number, remark_content,
close_case_no, close_case_name, close_case_time, confirm_no, confirm_name,
confirm_time, audit_no, audit_name, audit_time, approve_no, approve_name,
approve_time, standby_one, standby_two from purchase_order
</sql> </sql>
<select id="selectPurchaseOrderList" parameterType="PurchaseOrder" resultMap="PurchaseOrderResult"> <select id="selectPurchaseOrderList" parameterType="PurchaseOrder" resultMap="PurchaseOrderResult">
@ -62,10 +68,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="supplierCode != null and supplierCode != ''"> and supplier_code like concat('%', #{supplierCode}, '%')</if> <if test="supplierCode != null and supplierCode != ''"> and supplier_code like concat('%', #{supplierCode}, '%')</if>
<if test="supplierName != null and supplierName != ''"> and supplier_name like concat('%', #{supplierName}, '%')</if> <if test="supplierName != null and supplierName != ''"> and supplier_name like concat('%', #{supplierName}, '%')</if>
<if test="params.beginBillingDate != null and params.beginBillingDate != '' and params.endBillingDate != null and params.endBillingDate != ''"> and billing_date between #{params.beginBillingDate} and #{params.endBillingDate}</if> <if test="params.beginBillingDate != null and params.beginBillingDate != '' and params.endBillingDate != null and params.endBillingDate != ''"> and billing_date between #{params.beginBillingDate} and #{params.endBillingDate}</if>
<if test="closeCaseNo != null and closeCaseNo != ''"> and close_case_no = #{closeCaseNo}</if>
<if test="confirmNo != null and confirmNo != ''"> and confirm_no = #{confirmNo}</if>
<if test="auditNo != null and auditNo != ''"> and audit_no = #{auditNo}</if>
<if test="approveNo != null and approveNo != ''"> and approve_no = #{approveNo}</if>
</where> </where>
</select> </select>
@ -93,22 +95,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="purchaseCategory != null">purchase_category,</if> <if test="purchaseCategory != null">purchase_category,</if>
<if test="purchaseCommander != null">purchase_commander,</if> <if test="purchaseCommander != null">purchase_commander,</if>
<if test="customerOrderNumber != null">customer_order_number,</if> <if test="customerOrderNumber != null">customer_order_number,</if>
<if test="remarkContent != null">remark_content,</if>
<if test="closeCaseNo != null">close_case_no,</if>
<if test="closeCaseName != null">close_case_name,</if>
<if test="closeCaseTime != null">close_case_time,</if>
<if test="confirmNo != null">confirm_no,</if>
<if test="confirmName != null">confirm_name,</if>
<if test="confirmTime != null">confirm_time,</if>
<if test="auditNo != null">audit_no,</if>
<if test="auditName != null">audit_name,</if>
<if test="auditTime != null">audit_time,</if>
<if test="approveNo != null">approve_no,</if>
<if test="approveName != null">approve_name,</if>
<if test="approveTime != null">approve_time,</if>
first_add_time,
<if test="standbyOne != null">standby_one,</if> <if test="standbyOne != null">standby_one,</if>
<if test="standbyTwo != null">standby_two,</if> <if test="standbyTwo != null">standby_two,</if>
<if test="createTime != null" >create_time,</if>
<if test="createBy != null" >create_by,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="purchaseOrderCode != null">#{purchaseOrderCode},</if> <if test="purchaseOrderCode != null">#{purchaseOrderCode},</if>
@ -128,21 +118,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="purchaseCommander != null">#{purchaseCommander},</if> <if test="purchaseCommander != null">#{purchaseCommander},</if>
<if test="customerOrderNumber != null">#{customerOrderNumber},</if> <if test="customerOrderNumber != null">#{customerOrderNumber},</if>
<if test="remarkContent != null">#{remarkContent},</if> <if test="remarkContent != null">#{remarkContent},</if>
<if test="closeCaseNo != null">#{closeCaseNo},</if>
<if test="closeCaseName != null">#{closeCaseName},</if>
<if test="closeCaseTime != null">#{closeCaseTime},</if>
<if test="confirmNo != null">#{confirmNo},</if>
<if test="confirmName != null">#{confirmName},</if>
<if test="confirmTime != null">#{confirmTime},</if>
<if test="auditNo != null">#{auditNo},</if>
<if test="auditName != null">#{auditName},</if>
<if test="auditTime != null">#{auditTime},</if>
<if test="approveNo != null">#{approveNo},</if>
<if test="approveName != null">#{approveName},</if>
<if test="approveTime != null">#{approveTime},</if>
now(),
<if test="standbyOne != null">#{standbyOne},</if> <if test="standbyOne != null">#{standbyOne},</if>
<if test="standbyTwo != null">#{standbyTwo},</if> <if test="standbyTwo != null">#{standbyTwo},</if>
<if test="createTime != null">#{createTime},</if>
<if test="createBy != null">#{createBy},</if>
</trim> </trim>
</insert> </insert>
@ -178,7 +157,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="approveNo != null">approve_no = #{approveNo},</if> <if test="approveNo != null">approve_no = #{approveNo},</if>
<if test="approveName != null">approve_name = #{approveName},</if> <if test="approveName != null">approve_name = #{approveName},</if>
<if test="approveTime != null">approve_time = #{approveTime},</if> <if test="approveTime != null">approve_time = #{approveTime},</if>
update_info_time = CONCAT_WS(',',NOW(),update_info_time),
<if test="standbyOne != null">standby_one = #{standbyOne},</if> <if test="standbyOne != null">standby_one = #{standbyOne},</if>
<if test="standbyTwo != null">standby_two = #{standbyTwo},</if> <if test="standbyTwo != null">standby_two = #{standbyTwo},</if>
</trim> </trim>
@ -201,7 +179,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<!-- </select>--> <!-- </select>-->
<select id="selectOrderByIdDesc" resultMap="PurchaseOrderResult"> <select id="selectOrderByIdDesc" resultMap="PurchaseOrderResult">
<include refid="selectPurchaseOrderVo"/> <include refid="selectPurchaseOrderVo"/>
WHERE purchase_order_code like '%PO%' WHERE purchase_order_code like '%PO%' ORDER BY purchase_order_id DESC
ORDER BY purchase_order_id DESC
</select> </select>
</mapper> </mapper>

2
ruoyi-admin/src/main/resources/templates/erp/material/material.html

@ -125,7 +125,7 @@
detailUrl: prefix + "/detail/{id}", detailUrl: prefix + "/detail/{id}",
pageList: [10, 25, 50], pageList: [10, 25, 50],
pageSize: 10, pageSize: 10,
showColumns: false, showColumns: true,
modalName: "物料信息", modalName: "物料信息",
fixedColumns: true, // 启用冻结列 fixedColumns: true, // 启用冻结列
fixedRightNumber: 1, // 冻结右列个数 fixedRightNumber: 1, // 冻结右列个数

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

@ -169,8 +169,13 @@
exportUrl: prefix + "/export", exportUrl: prefix + "/export",
clickToSelect: true, clickToSelect: true,
modalName: "采购订单", modalName: "采购订单",
detailView: true,
fixedColumns: true, // 启用冻结列 fixedColumns: true, // 启用冻结列
fixedRightNumber: 1, // 冻结右列个数 fixedRightNumber: 1, // 冻结右列个数
onExpandRow:function(index, row, $detail){
$detail.html('<table class="table-container" id="purchase_order_'+row.id+'"></table>');
initChildTable(row, index, $detail);
},
columns: [ columns: [
{checkbox: true}, {checkbox: true},
{title: '采购订单id',field: 'purchaseOrderId', visible: false}, {title: '采购订单id',field: 'purchaseOrderId', visible: false},
@ -187,22 +192,20 @@
$.table.selectDictLabel(paymentStatusDatas, value); $.table.selectDictLabel(paymentStatusDatas, value);
}}, }},
{title:'采购单号',field: 'purchaseOrderCode'}, {title:'采购单号',field: 'purchaseOrderCode'},
{ title: '供应商ID',field: 'supplierCode'},
{title: '供应商名称',field: 'supplierName'},
{title: '联系人',field: 'customerContact',visible: false}, {title: '联系人',field: 'customerContact',visible: false},
{title: '联系电话',field: 'contactNumber',visible: false}, {title: '联系电话',field: 'contactNumber',visible: false},
{title:'供应商数量',field: 'supplierNum'}, {title:'供应商数量',field: 'supplierNum'},
{title:'物料合计',field: 'materialAmount'}, {title:'物料合计',field: 'materialAmount'},
{title:'数量合计',field: 'materialSum'}, {title:'数量合计',field: 'materialSum'},
{title:'不含税总价(RMB)',field: 'noRmbSum'}, {title:'不含税总价(RMB)',field: 'noRmbSum'},
{title:'含税总价',field: 'rmbSum'}, {title:'含税总价(RMB)',field: 'rmbSum'},
{field: 'firstAddTime', title: '录入时间', {field: 'createTime', title: '录入时间',
formatter: function (value, row, index) { formatter: function (value, row, index) {
if (value == null) { return " ";} if (value == null) { return " ";}
else { var vArr = value.split(',');return vArr[0];} else { var vArr = value.split(',');return vArr[0];}
} }
}, },
{field: 'updateInfoTime',title: '上次更新时间', {field: 'updateTime',title: '上次更新时间',
formatter: function (value, row, index) { formatter: function (value, row, index) {
if (value == null) {return ""; } if (value == null) {return ""; }
else { var vArr = value.split(',');return vArr[0];} else { var vArr = value.split(',');return vArr[0];}
@ -219,25 +222,35 @@
}; };
$.table.init(options); $.table.init(options);
}); });
initChildTable = function(index, row, $detail) {
$("#"+"purchase_order_"+row.id).bootstrapTable({
url: ctx + "purchase/purchaseOrderChild/list",
method: 'post',
sidePagination: "server",
contentType: "application/x-www-form-urlencoded",
queryParams : {
purchaseOrderCode: row.purchaseOrderCode
},
columns: [
{title: '采购单子表编号',field: 'purchaseOrderChildId',visible: false},
{title: '关联采购订单号',field: 'purchaseOrderCode',visible: false},
{title: '供应商ID',field: 'supplierCode',},
{title: '供应商名称',field: 'supplierName',},
{title: '物料合计',field: 'materialAmount',},
{title: '数量合计',field: 'materialSum',},
{title: '不含税总价(RMB)',field: 'materialNoRmbSum',},
{title: '含税总价(RMB)',field: 'materialRmbSum',},
{title:'收货状态',field: 'eceiptStatus',formatter: function (value, row, index) {
$.table.selectDictLabel(eceiptStatusDatas, value);}
},
{title:'打款状态',field: 'paymentStatus',formatter: function (value, row, index) {
$.table.selectDictLabel(paymentStatusDatas, value);}
},
{title: '交货时间',field: 'deliveryTime',visible: false},
]
});
};
/*供应商列表*/
$.ajax({
url: ctx + 'system/supplier/list',
type: 'post',
success: function (res) {
console.log(res)
if (res.rows.length > 0) {
var suppliertData = res.rows;
//alert(JSON.stringify(data));
for (let i in suppliertData) {
// console.log(finishProductData[i].finishProductCode)
$("#formId select[name='supplierCode']").append("<option value='" + suppliertData[i].supplierCode + "'>" + suppliertData[i].supplierCode + "</option>");
}
} else {
$.modal.msgError(res.msg);
}
}
})
//导出 //导出

293
ruoyi-admin/src/main/resources/templates/purchase/purchasePlan/addPurchaseOrder.html

@ -5,7 +5,7 @@
</head> </head>
<body class="white-bg"> <body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content"> <div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-plan-add" th:object="${purchasePlanList}"> <form class="form-horizontal m" id="form-plan-purchaseOrder-add" th:object="${purchasePlanList}">
<div class="col-xs-12"> <div class="col-xs-12">
<label class="col-sm-4 control-label">已选择采购计划:</label> <label class="col-sm-4 control-label">已选择采购计划:</label>
<div class="col-sm-7"> <div class="col-sm-7">
@ -25,30 +25,57 @@
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="inputWarehouseName" class="col-sm-2 control-label">仓库名称:</label> <label for="inputWarehouseName" class="col-sm-2 col-form-label">仓库名称:</label>
<div class="col-sm-4"> <div class="col-sm-4">
<input type="text" class="form-control" id="inputWarehouseName" placeholder="请输入仓库名称"> <input type="text" class="form-control" id="inputWarehouseName" placeholder="请输入仓库名称">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="inputReceiver" class="col-sm-2 control-label">收货人:</label> <label for="inputReceiver" class="col-sm-2 col-form-label">收货人:</label>
<div class="col-sm-4"> <div class="col-sm-4">
<input type="text" class="form-control" id="inputReceiver" placeholder="请输入收货人"> <input type="text" class="form-control" id="inputReceiver" placeholder="请输入收货人">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="inputPhone" class="col-sm-2 control-label">收货电话:</label> <label for="inputPhone" class="col-sm-2 col-form-label">收货电话:</label>
<div class="col-sm-4"> <div class="col-sm-4">
<input type="text" class="form-control" id="inputPhone" placeholder="请输入收货电话"> <input type="text" class="form-control" id="inputPhone" placeholder="请输入收货电话">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="inputAddressDetails" class="col-sm-2 control-label">详细地址:</label> <label for="inputAddressDetails" class="col-sm-2 col-form-label">详细地址:</label>
<div class="col-sm-4"> <div class="col-sm-4">
<textarea class="form-control" id="inputAddressDetails"></textarea> <textarea class="form-control" id="inputAddressDetails"></textarea>
</div> </div>
</div> </div>
</div> </div>
<div class="container">
<div class="row"><h4 class="card-header">订单合计:</h4></div>
<div class="form-group">
<label for="purchaseMaterialSum" class="col-sm-2 col-form-label">物料合计:</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="purchaseMaterialSum">
</div>
</div>
<div class="form-group">
<label for="purchaseSum" class="col-sm-2 col-form-label">采购合计:</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="purchaseSum">
</div>
</div>
<div class="form-group">
<label for="purchaseNoRmbSum" class="col-sm-2 col-form-label">不含税采购总价:</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="purchaseNoRmbSum">
</div>
</div>
<div class="form-group">
<label for="purchaseRmbSum" class="col-sm-2 col-form-label">含税采购总价:</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="purchaseRmbSum">
</div>
</div>
</div>
</div> </div>
<th:block th:include="include :: footer" /> <th:block th:include="include :: footer" />
<th:block th:include="include :: bootstrap-table-editable-js" /> <th:block th:include="include :: bootstrap-table-editable-js" />
@ -59,10 +86,10 @@
var sysUnitClassDatas = [[${@dict.getType('sys_unit_class')}]]; var sysUnitClassDatas = [[${@dict.getType('sys_unit_class')}]];
var processMethodDatas = [[${@dict.getType('processMethod')}]]; var processMethodDatas = [[${@dict.getType('processMethod')}]];
var loginName = [[${@permission.getPrincipalProperty('loginName')}]]; var loginName = [[${@permission.getPrincipalProperty('loginName')}]];
$("#form-plan-add").validate({focusCleanup: true}); $("#form-plan-purchaseOrder-add").validate({focusCleanup: true});
var purchasePlanChildList = [[${purchasePlanChildList}]]; var purchasePlanChildList = [[${purchasePlanChildList}]];
var purchasePlanList = [[${purchasePlanList}]]; var purchasePlanList = [[${purchasePlanList}]];
var formId = $("#form-plan-add").attr("id"); var formId = "form-plan-purchaseOrder-add";
//根据物料物料数量添加物料分类表,自动生成类似的表单对象 //根据物料物料数量添加物料分类表,自动生成类似的表单对象
//初始根据采购计划单,涉及到物料做分类表 //初始根据采购计划单,涉及到物料做分类表
//根据采购计划单,获取物料信息,自动生成物料的供应商分类表 //根据采购计划单,获取物料信息,自动生成物料的供应商分类表
@ -134,6 +161,7 @@
// 将整个物料信息容器添加到页面 // 将整个物料信息容器添加到页面
$('#material').append($tableWrapper); $('#material').append($tableWrapper);
var materialObj = { var materialObj = {
purchasePlanCode: material.purchasePlanCode,
materialCode: material.materialCode, materialCode: material.materialCode,
photoUrl: material.photoUrl, photoUrl: material.photoUrl,
materialName: material.materialName, materialName: material.materialName,
@ -148,136 +176,177 @@
materialList.push(materialObj); materialList.push(materialObj);
tables(materialTable, materialData); tables(materialTable, materialData);
}); });
// 给实际采购数的输入框绑定事件处理器
$('.supplierMaterialNum').off('keyup').on('keyup', function() {
var tableId = $(this).closest('.table-materialCode').attr('id');
recalculateTotals(tableId); // 重新计算当前物料的合计
calculateGlobalTotals(); // 然后重新计算整个订单的合计
});
});
// 新增函数:重新计算某物料的采购数量合计、不含税采购总价和含税采购总价
function recalculateTotals(tableId) {
var actualPurchaseTotal = 0;
var materialNoRmbTotal = 0;
var materialRmbTotal = 0;
function tableSetup(element, tableId) { $('#' + 'supplier-' + tableId).find('.supplier-card').each(function(supplierIndex, supplierCard) {
var $totalSection = $( var purchaseNum = parseFloat($(supplierCard).find('.supplierMaterialNum').val()) || 0;
'<div class="card mt-8">' + var noRmbPrice = parseFloat($(supplierCard).find('.supplierMaterialNoRmb').text().trim());
'<div class="card-body" class="supplierTotal_' + tableId + '">' + var rmbPrice = parseFloat($(supplierCard).find('.supplierMaterialRmb').text().trim());
'<div class="form-row">' +
'<label for="actualPurchaseTotal" class="col-sm-3">实际采购数合计:</label>' +
'<div class="col-sm-8">' +
'<input type="number" name="materialAmountSum" class="form-control" id="materialNoRmbSum_' + tableId + '" readonly>' +
'</div>' +
'</div>' +
'<div class="form-row">' +
'<label for="actualPurchaseTotal" class="col-sm-3">不含税采购总价:</label>' +
'<div class="col-sm-8">' +
'<input type="number" name="materialNoRmbSum" class="form-control" id="materialNoRmbSum_' + tableId + '" readonly>' +
'</div>' +
'</div>' +
'<div class="form-row">' +
'<label for="actualPurchaseTotalTax" class="col-sm-3">含税采购总价:</label>' +
'<div class="col-sm-8">' +
'<input type="number" name="materialRmbSum" class="form-control" id="materialRmbSum_' + tableId + '" readonly>' +
'</div>' +
'</div>' +
'</div>'+
'</div>');
element.append($totalSection);
}
// 表格初始化函数保持不变 actualPurchaseTotal += purchaseNum;
function tables(tableId, data) { materialNoRmbTotal += purchaseNum * noRmbPrice;
$('#' + tableId).bootstrapTable({ materialRmbTotal += purchaseNum * rmbPrice;
showExport: false, });
showFooter: false, // 更新合计显示
showSearch: false, $('#materialNoRmbSum_' + tableId).val(materialNoRmbTotal.toFixed(2)); // 格式化为两位小数
showRefresh: false, $('#materialRmbSum_' + tableId).val(materialRmbTotal.toFixed(2));
showColumns: false, }
showToggle: false, function calculateGlobalTotals() {
data: data, var totalMaterialSum = 0;
height: 25, var totalPurchaseSum = 0;
columns: [ var totalNoRmbSum = 0;
{checkbox: false}, var totalRmbSum = 0;
{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', formatter: function (value, row, index) {
return $.table.selectDictLabel(sysUnitClassDatas, value);
}
},
{title: '计划采购数', field: 'planPurchaseNum'},
],
});
}
// 提交表单的处理函数 tableIdList.forEach(function(tableId) {
}); var materialNoRmbTotal = parseFloat($('#materialNoRmbSum_' + tableId).val()) || 0;
var materialRmbTotal = parseFloat($('#materialRmbSum_' + tableId).val()) || 0;
totalMaterialSum += materialNoRmbTotal; // 假设物料合计就是不含税采购总价
totalPurchaseSum += materialNoRmbTotal; // 假设采购合计也是不含税采购总价(如果逻辑不同,请相应调整)
totalNoRmbSum += materialNoRmbTotal;
totalRmbSum += materialRmbTotal;
});
// 设置合计值,确保处理NaN
$('#purchaseMaterialSum').val(isNaN(totalMaterialSum) ? '' : totalMaterialSum.toFixed(2));
$('#purchaseSum').val(isNaN(totalPurchaseSum) ? '' : totalPurchaseSum.toFixed(2));
$('#purchaseNoRmbSum').val(isNaN(totalNoRmbSum) ? '' : totalNoRmbSum.toFixed(2));
$('#purchaseRmbSum').val(isNaN(totalRmbSum) ? '' : totalRmbSum.toFixed(2));
}
function tableSetup(element, tableId) {
var $totalSection = $(
'<div class="card mt-8">' +
'<div class="card-body" class="supplierTotal_' + tableId + '">' +
'<div class="form-row">' +
'<label for="actualPurchaseTotal" class="col-sm-3">实际采购数合计:</label>' +
'<div class="col-sm-8">' +
'<input type="number" name="materialAmountSum" class="form-control" id="materialNoRmbSum_' + tableId + '" readonly>' +
'</div>' +
'</div>' +
'<div class="form-row">' +
'<label for="actualPurchaseTotal" class="col-sm-3">不含税采购总价:</label>' +
'<div class="col-sm-8">' +
'<input type="number" name="materialNoRmbSum" class="form-control" id="materialNoRmbSum_' + tableId + '" readonly>' +
'</div>' +
'</div>' +
'<div class="form-row">' +
'<label for="actualPurchaseTotalTax" class="col-sm-3">含税采购总价:</label>' +
'<div class="col-sm-8">' +
'<input type="number" name="materialRmbSum" class="form-control" id="materialRmbSum_' + tableId + '" readonly>' +
'</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: 25,
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', formatter: function (value, row, index) {
return $.table.selectDictLabel(sysUnitClassDatas, value);
}
},
{title: '计划采购数', field: 'planPurchaseNum'},
],
});
}
function submitHandler() { function submitHandler() {
if ($.validate.form()) { if ($.validate.form()) {
var purchaseOrder = { var purchaseOrder = {
purchaseOrderCode: "", // 这里可能需要生成一个临时的或预设的订单号,实际生产环境应由后端生成
supplierNum: 0, supplierNum: 0,
materialNum: 0, materialNum: 0,
materialNoRmbSum: 0, materialNoRmbSum: 0,
materialRmbSum: 0, materialRmbSum: 0,
purchaseOrderChildList: [] purchaseOrderChildList: []
}; };
// 遍历每个物料容器 // 遍历每个物料容器
$('.table-materialCode').each(function(index, tableElement) { $('.table-materialCode').each(function(index, tableElement) {
console.log(tableElement); var tableId = tableIdList[index];
var tableId = tableIdList[index]; // 从table ID中提取tableId let materialObj = materialList[index];
var materialTable = "bootstrap-table_" + tableId; if (typeof materialObj === 'undefined') return;
var data = $('#' + materialTable).bootstrapTable('getData');
var materialData = {
materialCode:'' , // 假设'materialCode'是你要获取的字段名}) , // 确保能正确获取物料编码
materialNum:10,
materialNoRmbSum: 0,
materialRmbSum: 0,
purchaseQuoteChildList: []
};
var materialActualNum = $('#' + 'actualPurchaseNum_' + tableId).val();
var materialNoRmbTotal = $('#' + 'materialNoRmbSum_' + tableId).val();
var materialRmbTotal = $('#' + 'materialRmbSum_' + tableId).val();
materialData.materialNum = parseInt(materialActualNum);
materialData.materialNoRmbSum = parseFloat(materialNoRmbTotal);
materialData.materialRmbSum = parseFloat(materialRmbTotal);
// 遍历该物料下的供应商信息
$('#' + 'material-' + tableId).find('.supplier-card').each(function(supplierIndex, supplierCard) { $('#' + 'material-' + tableId).find('.supplier-card').each(function(supplierIndex, supplierCard) {
var supplierQuote = { var materialData = {
supplierCode: $(supplierCard).find('.supplierCode').text().trim(), purchasePlanCode: materialObj.purchasePlanCode,
supplierName: $(supplierCard).find('.supplierName').text().trim(), materialCode: materialObj.materialCode,
materialNoRmb: parseFloat($(supplierCard).find('.supplierMaterialNoRmb').text().trim()), materialName: materialObj.materialName,
materialRmb: parseFloat($(supplierCard).find('.supplierMaterialRmb').text().trim()), materialType: materialObj.materialType,
materialNum: $(supplierCard).find('.supplierMaterialNum').val().trim(), materialBrand:materialObj.brand,
deliveryTime: $(supplierCard).find('.supplierDeliveryTime').val() describe: materialObj.describe,
}; processMethod:materialObj.processMethod,
materialData.purchaseQuoteChildList.push(supplierQuote); unit:materialObj.unit,
purchaseOrder.supplierNum += 1; // 累加供应商数量 supplierCode: $(supplierCard).find('.supplierCode').text().trim(),
supplierName: $(supplierCard).find('.supplierName').text().trim(),
materialNoRmb: parseFloat($(supplierCard).find('.supplierMaterialNoRmb').text().trim()),
materialRmb: parseFloat($(supplierCard).find('.supplierMaterialRmb').text().trim()),
materialNum: parseInt($(supplierCard).find('.supplierMaterialNum').val(), 10) || 0,
deliveryTime: $(supplierCard).find('.supplierDeliveryTime').val()
};
purchaseOrder.purchaseQuoteChildList.push(materialData);
}); });
purchaseOrder.materialNoRmbSum += parseFloat(materialNoRmbTotal) ;
purchaseOrder.materialRmbSum += parseFloat(materialRmbTotal); // 累加含税总价
purchaseOrder.purchaseOrderChildList.push(materialData);
}); });
// 计算整个订单的合计值,这部分应在遍历完所有物料后执行
let totalMaterialNum = purchaseOrder.materialNum;
let totalNoRmbSum = purchaseOrder.materialNoRmbSum;
let totalRmbSum = purchaseOrder.materialRmbSum;
let totalPurchaseSum = totalNoRmbSum; // 或者根据实际业务逻辑调整
// 将合计值附加到purchaseOrder对象
purchaseOrder.totalMaterialSum = totalMaterialNum;
purchaseOrder.totalPurchaseSum = totalPurchaseSum;
purchaseOrder.totalNoRmbSum = totalNoRmbSum.toFixed(2);
purchaseOrder.totalRmbSum = totalRmbSum.toFixed(2);
// 发送数据到后端API // 发送数据到后端API
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: prefix + "/add", // 这里的prefix应该是之前定义的context路径 url: prefix + "/add",
data: JSON.stringify(purchaseOrder), // 将构造好的对象转换为JSON字符串 data: JSON.stringify(purchaseOrder),
contentType: "application/json; charset=utf-8", contentType: "application/json; charset=utf-8",
dataType: "json", dataType: "json",
success: function (response) { success: function (response) {
if (response.code === 200) { if (response.code === 200) {
alert("采购订单添加成功!"); alert("采购订单添加成功!");
// 可以在这里添加更多成功的处理逻辑,如页面跳转等
} else { } else {
alert("采购订单添加失败:" + response.msg); alert("采购订单添加失败:" + response.msg);
} }
@ -287,6 +356,8 @@
alert("提交过程中发生错误,请重试。"); alert("提交过程中发生错误,请重试。");
} }
}); });
// 如果需要在页面加载时初始化合计或重新绑定事件处理器,这部分应放在更合适的位置,不在此函数内
} }
} }
</script> </script>

2
ruoyi-admin/src/main/resources/templates/purchase/purchasePlan/purchasePlan.html

@ -146,7 +146,7 @@
}, },
{field: 'describe',title: '描述',}, {field: 'describe',title: '描述',},
{field: 'brand',title: '品牌',}, {field: 'brand',title: '品牌',},
{field: 'processMethod',title: '半成品类型', {field: 'processMethod',title: '加工类型',
formatter: function(value, row, index) {return $.table.selectDictLabel(processMethodDatas, value);} formatter: function(value, row, index) {return $.table.selectDictLabel(processMethodDatas, value);}
}, },
{field: 'unit',title: '单位', {field: 'unit',title: '单位',

17
ruoyi-admin/src/main/resources/templates/system/customerQuote/taskYwgzVerify.html → ruoyi-admin/src/main/resources/templates/system/customerQuote/taskYwzgVerify.html

@ -6,7 +6,7 @@
</head> </head>
<body class="white-bg"> <body class="white-bg">
<div id="app" class="wrapper wrapper-content animated fadeInRight ibox-content"> <div id="app" class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-customerQuote-ywgz" th:object="${formData}"> <form class="form-horizontal m" id="form-customerQuote-ywzg" th:object="${formData}">
<input name="id" th:field="*{id}" type="hidden"> <input name="id" th:field="*{id}" type="hidden">
<input name="taskId" th:field="*{taskId}" type="hidden"> <input name="taskId" th:field="*{taskId}" type="hidden">
<input name="taskName" th:field="*{taskName}" type="hidden"> <input name="taskName" th:field="*{taskName}" type="hidden">
@ -179,7 +179,7 @@
<script th:src="@{/ajax/libs/element-ui/element-ui.js}"></script> <script th:src="@{/ajax/libs/element-ui/element-ui.js}"></script>
<script th:inline="javascript"> <script th:inline="javascript">
var prefix = ctx + "erp/bom"; var prefix = ctx + "erp/bom";
$("#form-customerQuote-ywgz").validate({focusCleanup: true}); $("#form-customerQuote-ywzg").validate({focusCleanup: true});
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')}]];
@ -188,7 +188,7 @@
var sysCustomerQuote = [[${formData}]]; var sysCustomerQuote = [[${formData}]];
var prefix = ctx + "system/customerQuote" var prefix = ctx + "system/customerQuote"
var commonCurrency = $("#commonCurrency_edit option:selected").val(); var commonCurrency = $("#commonCurrency_edit option:selected").val();
$("#form-customerQuote-ywgz").validate({ $("#form-customerQuote-ywzg").validate({
focusCleanup: true, focusCleanup: true,
}); });
$(function() { $(function() {
@ -201,9 +201,9 @@
if (res.rows.length > 0) { if (res.rows.length > 0) {
var usertData = res.rows; var usertData = res.rows;
for (let i in usertData) { for (let i in usertData) {
$("#form-customerQuote-ywgz select[name='businessMembers']").append("<option value='" + usertData[i].userName + "'>" + usertData[i].userName + "</option>"); $("#form-customerQuote-ywzg select[name='businessMembers']").append("<option value='" + usertData[i].userName + "'>" + usertData[i].userName + "</option>");
} }
$("#form-customerQuote-ywgz select[name='businessMembers']").val(sysCustomerQuote.businessMembers).trigger("change") $("#form-customerQuote-ywzg select[name='businessMembers']").val(sysCustomerQuote.businessMembers).trigger("change")
} else { } else {
$.modal.msgError(res.msg); $.modal.msgError(res.msg);
} }
@ -516,15 +516,14 @@
} }
function submitHandler() { function submitHandler() {
if ($.validate.form()) { if ($.validate.form()) {
var materialType = $('#selectMaterialType').select2('val');
$('#materialType').val(materialType);
if ($('textarea[name="comment"]').val()) { if ($('textarea[name="comment"]').val()) {
$('input[name="p_COM_comment"]').val($('textarea[name="comment"]').val()); $('input[name="p_COM_comment"]').val($('textarea[name="comment"]').val());
} }
var taskId = [[${taskId}]];
var tableData = $("#bootstrap-table-Quote-child3").bootstrapTable('getData'); var tableData = $("#bootstrap-table-Quote-child3").bootstrapTable('getData');
$("input[name='customerQuoteChildList']").val(JSON.stringify(tableData)); $("input[name='customerQuoteChildList']").val(JSON.stringify(tableData));
var taskId = [[${taskId}]];
$.operate.save(prefix + "/complete/" + taskId, $('#form-customerQuote-ywgz').serialize()); $.operate.save(prefix + "/complete/" + taskId, $('#form-customerQuote-ywzg').serialize());
} }
} }
Loading…
Cancel
Save