Browse Source

修改:采购计划转采购订单,新增采购订单信息,审核修改采购订单样式

dev
zhangsiqi 3 months ago
parent
commit
11dde25f84
  1. 11
      ruoyi-admin/src/main/java/com/ruoyi/purchase/domain/PurchaseOrderChild.java
  2. 13
      ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchaseOrderServiceImpl.java
  3. 119
      ruoyi-admin/src/main/resources/mapper/purchase/PurchaseOrderChildMapper.xml
  4. 57
      ruoyi-admin/src/main/resources/mapper/purchase/PurchaseQuoteChildMapper.xml
  5. 325
      ruoyi-admin/src/main/resources/templates/purchase/purchaseOrder/detail.html
  6. 458
      ruoyi-admin/src/main/resources/templates/purchase/purchaseOrder/taskCgjlVerify.html
  7. 576
      ruoyi-admin/src/main/resources/templates/purchase/purchaseOrder/taskCgzgVerify.html
  8. 575
      ruoyi-admin/src/main/resources/templates/purchase/purchaseOrder/taskFzjlVerify.html
  9. 93
      ruoyi-admin/src/main/resources/templates/purchase/purchaseOrder/taskModifyApply.html
  10. 140
      ruoyi-admin/src/main/resources/templates/purchase/purchasePlan/addPurchaseOrder.html

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

@ -150,6 +150,8 @@ public class PurchaseOrderChild extends BaseEntity
@Excel(name = "实际已到货数量") @Excel(name = "实际已到货数量")
private Integer actualHasArrivedNum; private Integer actualHasArrivedNum;
private List<PurchaseOrderChildSupplier> supplierList;
public Integer getNotifyHasArrivedNum() { public Integer getNotifyHasArrivedNum() {
return notifyHasArrivedNum; return notifyHasArrivedNum;
} }
@ -169,6 +171,15 @@ public class PurchaseOrderChild extends BaseEntity
this.purchaseQuoteChildList = purchaseQuoteChildList; this.purchaseQuoteChildList = purchaseQuoteChildList;
} }
public List<PurchaseOrderChildSupplier> getPurchaseOrderChildSupplierList() {
return supplierList;
}
public void setPurchaseOrderChildSupplierList(List<PurchaseOrderChildSupplier> supplierList) {
this.supplierList = supplierList;
}
public String getWarehouseDept() { public String getWarehouseDept() {
return warehouseDept; return warehouseDept;
} }

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

@ -284,7 +284,7 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
materialRmbSum = materialRmbSum.add(suplierMaterialRmbSumLocal); materialRmbSum = materialRmbSum.add(suplierMaterialRmbSumLocal);
// 设置采购报价单编号和供应商信息到QuoteChild // 设置采购报价单编号和供应商信息到QuoteChild
material.setPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode()); material.setPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode());
material.setPurchasePlanCorrelationCode(purchasePlan.getCorrelationCode()); material.setPurchasePlanCorrelationCode(child.getCorrelationCode());
material.setSupplierCode(child.getSupplierCode()); material.setSupplierCode(child.getSupplierCode());
material.setMaterialUnit(child.getMaterialUnit()); material.setMaterialUnit(child.getMaterialUnit());
material.setWarehouseDept(child.getWarehouseDept()); material.setWarehouseDept(child.getWarehouseDept());
@ -316,7 +316,7 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
material.setEceiptStatus("0"); material.setEceiptStatus("0");
material.setPaymentStatus("0"); material.setPaymentStatus("0");
// 执行子表插入操作 // 执行子表插入操作
purchaseOrderChildService.insertPurchaseOrderChild(child); purchaseOrderChildService.insertPurchaseOrderChild(material);
PurchasePlan plan = new PurchasePlan(); PurchasePlan plan = new PurchasePlan();
plan.setPurchasePlanCode(child.getPurchasePlanCode()); plan.setPurchasePlanCode(child.getPurchasePlanCode());
plan.setPurchasePlanStatus("1"); plan.setPurchasePlanStatus("1");
@ -351,7 +351,7 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
// 设置采购报价单编号和供应商信息到QuoteChild // 设置采购报价单编号和供应商信息到QuoteChild
material.setPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode()); material.setPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode());
material.setCorrelationCode(purchasePlan.getCorrelationCode()); material.setCorrelationCode(purchasePlan.getCorrelationCode());
material.setPurchasePlanCorrelationCode(purchasePlan.getCorrelationCode()); material.setPurchasePlanCorrelationCode(child.getCorrelationCode());
material.setSupplierCode(child.getSupplierCode()); material.setSupplierCode(child.getSupplierCode());
material.setMaterialUnit(child.getMaterialUnit()); material.setMaterialUnit(child.getMaterialUnit());
material.setWarehouseDept(child.getWarehouseDept()); material.setWarehouseDept(child.getWarehouseDept());
@ -383,7 +383,7 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
material.setEceiptStatus("0"); material.setEceiptStatus("0");
material.setPaymentStatus("0"); material.setPaymentStatus("0");
// 执行子表插入操作 // 执行子表插入操作
purchaseOrderChildService.insertPurchaseOrderChild(child); purchaseOrderChildService.insertPurchaseOrderChild(material);
PurchasePlan plan = new PurchasePlan(); PurchasePlan plan = new PurchasePlan();
plan.setPurchasePlanCode(child.getPurchasePlanCode()); plan.setPurchasePlanCode(child.getPurchasePlanCode());
plan.setPurchasePlanStatus("1"); plan.setPurchasePlanStatus("1");
@ -411,9 +411,6 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
Integer amount = amountSet.size(); Integer amount = amountSet.size();
purchaseOrder.setMaterialAmount(amount); purchaseOrder.setMaterialAmount(amount);
return purchaseOrderMapper.insertPurchaseOrder(purchaseOrder); return purchaseOrderMapper.insertPurchaseOrder(purchaseOrder);
} }
//生成应付账款,根据物料的供应商划分应付供应商,供应商的物料价格合计。 //生成应付账款,根据物料的供应商划分应付供应商,供应商的物料价格合计。
public int purchaseOrderPayment(PurchaseOrder purchaseOrder) { public int purchaseOrderPayment(PurchaseOrder purchaseOrder) {
@ -586,7 +583,7 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
FinancialAccountsPayable financialAccountsPayable = new FinancialAccountsPayable(); FinancialAccountsPayable financialAccountsPayable = new FinancialAccountsPayable();
financialAccountsPayable.setAccountsPayableCode(redisCache.generateBillNo("YF")); financialAccountsPayable.setAccountsPayableCode(redisCache.generateBillNo("YF"));
financialAccountsPayable.setRelevanceCode(purchaseOrder.getPurchaseOrderCode()); financialAccountsPayable.setRelevanceCode(purchaseOrder.getPurchaseOrderCode());
for (PurchaseOrderChild purchaseOrderChild1 : purchaseOrderChildList) { for (PurchaseOrderChild purchaseOrderChild1 : children) {
//如果是如上述的供应商,则进行统计 //如果是如上述的供应商,则进行统计
if (purchaseOrderChild1.getSupplierCode().equals(purchaseOrderChild.getSupplierCode())) { if (purchaseOrderChild1.getSupplierCode().equals(purchaseOrderChild.getSupplierCode())) {
//供应商应付账款 不含税金额 //供应商应付账款 不含税金额

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

@ -5,47 +5,65 @@ 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="purchasePlanCode" column="purchase_plan_code" /> <result property="purchasePlanCode" column="purchase_plan_code" />
<result property="purchasePlanCorrelationCode" column="purchase_plan_correlation_code" /> <result property="purchasePlanCorrelationCode" column="purchase_plan_correlation_code" />
<result property="supplierCode" column="supplier_code" /> <result property="correlationCode" column="correlation_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="materialType" column="material_type" /> <result property="materialName" column="material_name" />
<result property="materialBrand" column="material_brand" /> <result property="materialType" column="material_type" />
<result property="materialDescribe" column="material_describe" /> <result property="materialBrand" column="material_brand" />
<result property="materialPhotourl" column="material_photoUrl" /> <result property="materialDescribe" column="material_describe" />
<result property="warehouseDept" column="warehouseDept" /> <result property="materialPhotourl" column="material_photoUrl" />
<result property="materialProcessMethod" column="material_process_method" /> <result property="warehouseDept" column="warehouseDept" />
<result property="materialUnit" column="material_unit" /> <result property="materialProcessMethod" column="material_process_method" />
<result property="hasStorageNum" column="has_storage_num" /> <result property="materialUnit" column="material_unit" />
<result property="notifyHasArrivedNum" column="notify_has_arrived_num" /> <result property="hasStorageNum" column="has_storage_num" />
<result property="materialNoRmb" column="material_no_rmb" /> <result property="notifyHasArrivedNum" column="notify_has_arrived_num" />
<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_no_rmb_sum" /> <result property="materialSum" column="material_sum" />
<result property="materialRmbSum" column="material_rmb_sum" /> <result property="materialNoRmbSum" column="material_no_rmb_sum" />
<result property="materialRealNum" column="material_real_num" /> <result property="materialRmbSum" column="material_rmb_sum" />
<result property="materialRealNoRmb" column="material_real_no_rmb" /> <result property="materialRealNum" column="material_real_num" />
<result property="materialRealRmb" column="material_real_rmb" /> <result property="materialRealNoRmb" column="material_real_no_rmb" />
<result property="materialRealNoRmbSum" column="material_real_no_rmb_sum" /> <result property="materialRealRmb" column="material_real_rmb" />
<result property="materialRealRmbSum" column="material_real_rmb_sum" /> <result property="materialRealNoRmbSum" column="material_real_no_rmb_sum" />
<result property="deliveryTime" column="delivery_time" /> <result property="materialRealRmbSum" column="material_real_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" />
<collection property="supplierList" ofType="com.ruoyi.purchase.domain.PurchaseOrderChildSupplier">
<id property="purchaseOrderCode" column="purchaseOrderCode" />
<result property="supplierCode" column="supplier_code" />
<result property="supplierName" column="supplier_name" />
<result property="materialCode" column="material_code" />
<result property="materialNum" column="material_num" />
<result property="materialNoRmbSum" column="material_no_rmb_sum" />
<result property="materialRmbSum" column="material_rmb_sum" />
<result property="materialRealNum" column="material_real_num" />
<result property="materialRealNoRmb" column="material_real_no_rmb" />
<result property="materialRealRmb" column="material_real_rmb" />
<result property="materialRealNoRmbSum" column="material_real_no_rmb_sum" />
<result property="materialRealRmbSum" column="material_real_rmb_sum" />
<result property="deliveryTime" column="delivery_time" />
<!-- 其他供应商字段映射 -->
</collection>
</resultMap> </resultMap>
<!-- 映射供应商列表 -->
<sql id="selectPurchaseOrderChildVo"> <sql id="selectPurchaseOrderChildVo">
select purchase_order_child_id, purchase_order_code, purchase_plan_code, purchase_plan_correlation_code, supplier_code, supplier_name, select purchase_order_child_id, purchase_order_code, purchase_plan_code, purchase_plan_correlation_code, supplier_code, supplier_name,
@ -58,7 +76,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</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>
@ -73,8 +91,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select> </select>
<select id="selectPurchaseOrderChildById" parameterType="Long" resultMap="PurchaseOrderChildResult"> <select id="selectPurchaseOrderChildById" parameterType="Long" resultMap="PurchaseOrderChildResult">
<include refid="selectPurchaseOrderChildVo"/> select p.purchase_order_code,p.purchase_plan_code,p.purchase_plan_correlation_code,
where purchase_order_child_id = #{purchaseOrderChildId} p.supplier_code,p.supplier_name,p.material_code,p.material_name,p.material_type,p.material_describe,
p.material_brand,p.material_photoUrl,p.material_process_method,p.material_unit,p.warehouseDept,p.material_no_rmb,
p.material_rmb,p.material_num,p.material_amount,p.material_sum,p.material_no_rmb_sum,p.material_rmb_sum,
p.material_real_num,p.material_real_no_rmb,p.material_real_rmb,p.material_real_no_rmb_sum,p.material_real_rmb_sum,
p.delivery_time,p.eceipt_status,p.payment_status,p.tax_rate,p.create_by,p.create_time,p.update_by,p.update_time,p.del_flag,
w.has_storage_num,sum(w.notify_arrive_num) as notify_has_arrived_num
from purchase_order_child as p left join warehouse_storage_order_detail as w
on p.purchase_order_code = w.related_order_code
and p.material_code = w.material_no and p.supplier_code = w.supplier_code
where p.purchase_order_child_id = #{purchaseOrderChildId}
</select> </select>
<select id="selectPurchaseOrderChildBySupplierCode" parameterType="String" resultMap="PurchaseOrderChildResult"> <select id="selectPurchaseOrderChildBySupplierCode" parameterType="String" resultMap="PurchaseOrderChildResult">
@ -260,5 +287,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and p.material_code = w.material_no and p.supplier_code = w.supplier_code and p.material_code = w.material_no and p.supplier_code = w.supplier_code
where p.purchase_order_code = #{purchaseOrderCode} GROUP BY supplier_code,material_code where p.purchase_order_code = #{purchaseOrderCode} GROUP BY supplier_code,material_code
</select> </select>
<select id="selectPurchaseOrderChldByPurchaseOrderCode" parameterType="String" resultMap="PurchaseOrderChildResult">
SELECT purchase_order_code,material_code,GROUP_CONCAT(DISTINCT purchase_plan_code SEPARATOR ',') AS correlation_codes
FROM purchase_order_child where purchase_order_code = #{purchaseOrderCode}
GROUP BY purchase_order_code,material_code
</select>
</mapper> </mapper>

57
ruoyi-admin/src/main/resources/mapper/purchase/PurchaseQuoteChildMapper.xml

@ -183,34 +183,47 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
update purchase_quote_child set del_flag = '0' where purchase_quote_child_id = #{purchaseQuoteChildId} update purchase_quote_child set del_flag = '0' where purchase_quote_child_id = #{purchaseQuoteChildId}
</update> </update>
<select id="selectQuoteChildByMaterialCode" parameterType="String" resultMap="PurchaseQuoteChildResult"> <select id="selectQuoteChildByMaterialCode" parameterType="String" resultMap="PurchaseQuoteChildResult">
select * from purchase_quote_child as quoteChild SELECT * FROM purchase_quote_child AS quoteChild
left JOIN purchase_quote as quote on quote.purchase_quote_code = quoteChild.purchase_quote_code LEFT JOIN purchase_quote AS quote
ON quote.purchase_quote_code = quoteChild.purchase_quote_code
LEFT JOIN
-- 子查询找出每个供应商和指定物料的最新通过报价的 purchase_quote_code
(SELECT supplier_quote_code, material_no,MAX(create_time) AS max_create_time
FROM purchase_quote where audit_status = '1' AND use_status = '1'
GROUP BY supplier_quote_code, material_no) AS latest_quotes
ON latest_quotes.supplier_quote_code = quote.supplier_quote_code
AND quote.create_time = latest_quotes.max_create_time
WHERE WHERE
quote.audit_status = '1' and quote.use_status = '1' and quoteChild.del_flag = '0'
quoteChild.material_code = #{material} and quoteChild.del_flag = '0'; and quote.audit_status = '1' AND quote.use_status = '1'
AND quoteChild.material_code = #{material}
AND quoteChild.material_rmb != ''
GROUP BY
quoteChild.supplier_code,quoteChild.material_code
</select> </select>
<select id="findLatestAuditPassedGroups" parameterType="String" resultMap="PurchaseQuoteChildResult"> <select id="findLatestAuditPassedGroups" parameterType="String" resultMap="PurchaseQuoteChildResult">
<!-- 子查询找出每个供应商分组的最大审计日期 --> <!-- 子查询找出每个供应商分组的最大审计日期 -->
WITH max_audit_dates AS ( SELECT
SELECT quoteChild.*,
purchase_quote_code, quote.*
MAX(audit_date) AS max_audit_date FROM
FROM purchase_quote purchase_quote_child AS quoteChild
WHERE audit_status = '1' AND use_status = '1' LEFT JOIN
GROUP BY purchase_quote_code purchase_quote AS quote ON quote.purchase_quote_code = quoteChild.purchase_quote_code
) LEFT JOIN
<!-- 主查询获取每个供应商分组最大审计日期的记录 --> (SELECT supplier_id,material_code,MAX(create_time) AS max_create_time
SELECT pc.*,pq.* FROM purchase_quote WHERE audit_status = '1' AND use_status = '1' GROUP BY
FROM purchase_quote_child AS pc supplier_id,material_code) AS latest_quotes
LEFT JOIN ON latest_quotes.supplier_id = quote.supplier_id AND
purchase_quote AS pq ON pq.purchase_quote_code = pc.purchase_quote_code latest_quotes.material_code = quote.material_code AND
LEFT JOIN quote.create_time = latest_quotes.max_create_time
max_audit_dates AS mad ON pq.purchase_quote_code = mad.purchase_quote_code AND pq.audit_date = mad.max_audit_date WHERE
WHERE quoteChild.material_code = #{material} AND
pq.audit_status = '1' AND pq.use_status = '1' AND quoteChild.del_flag = '0' AND
pc.material_code = #{material} AND pc.del_flag = '0' quote.audit_status = '1' AND
quote.use_status = '1';
</select> </select>
</mapper> </mapper>

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

@ -1,10 +1,16 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" > <html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head> <head>
<th:block th:include="include :: header('编辑采购订单')" /> <th:block th:include="include :: header('采购订单详情')" />
<th:block th:include="include :: select2-css" /> <th:block th:include="include :: select2-css" />
<th:block th:include="include :: datetimepicker-css" /> <th:block th:include="include :: datetimepicker-css" />
<th:block th:include="include :: bootstrap-editable-css" /> <th:block th:include="include :: bootstrap-editable-css" />
<style>
.fixed-table-container {
border: 0px solid #ddd;
min-height: 110px;
}
</style>
</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">
@ -12,17 +18,17 @@
<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">
<input id="purchasePlanCodes" name="purchasePlanCode" class="form-control" type="text"> <input id="purchasePlanCodes" name="purchasePlanCode" class="form-control" type="text" disabled/>
</div> </div>
</div> </div>
<div class="container"> <div class="container">
<ul class="nav nav-tabs" role="tablist"> <ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active"><a href="#supplierModel" aria-controls="supplierModel" role="tab" data-toggle="tab">按供应商展示</a></li> <li role="presentation" ><a href="#supplierModel" aria-controls="supplierModel" role="tab" data-toggle="tab">按供应商展示</a></li>
<li role="presentation"><a href="purchasePlanModel" aria-controls="purchasePlanModel" role="tab" data-toggle="tab">按采购计划展示</a></li> <li role="presentation" class="active"><a href="#purchasePlanModel" aria-controls="purchasePlanModel" role="tab" data-toggle="tab">按采购计划展示</a></li>
</ul> </ul>
<div class="tab-content"> <div class="tab-content">
<div role="tabpanel" class="tab-pane" id="supplierModel"> <div role="tabpanel" class="tab-pane " id="supplierModel">
<div class="container" id="supplierMaterial"> <div class="container" id="supplierMaterial">
</div> </div>
@ -37,57 +43,61 @@
</form> </form>
<div class="container"> <div class="container">
<div class="row"><h4 class="card-header">公司地址:</h4></div> <div class="row"><h4 class="card-header">公司地址:</h4></div>
<div class="row"> <div class="col-xs-6">
<label for="stockNo" class="col-sm-2 col-form-label">仓库ID:</label> <label for="stockNo" class="col-sm-6 col-form-label">仓库ID:</label>
<div class="col-sm-4"> <div class="col-sm-5">
<select class="form-control" name="stockNo" id="stockNo" ></select> <select class="form-control" name="stockNo" id="stockNo" disabled ></select>
</div> </div>
<label for="stockName" class="col-sm-2 col-form-label">仓库名称:</label> </div>
<div class="col-sm-4"> <div class="col-xs-6">
<input type="text" class="form-control" name="stockName" id="stockName"> <label for="stockName" class="col-sm-6 col-form-label">仓库名称:</label>
<div class="col-sm-5">
<input type="text" class="form-control" name="stockName" id="stockName" readonly/>
</div> </div>
</div> </div>
<div class="row"> <div class="col-xs-6">
<label for="stockContact" class="col-sm-2 col-form-label">收货人:</label> <label for="stockContact" class="col-sm-6 col-form-label">收货人:</label>
<div class="col-sm-4"> <div class="col-sm-5">
<input type="text" name="stockContact" class="form-control" id="stockContact" > <input type="text" name="stockContact" class="form-control" id="stockContact" readonly />
</div> </div>
<label for="stockPhone" class="col-sm-2 col-form-label">收货电话:</label> </div>
<div class="col-sm-4"> <div class="col-xs-6">
<input type="text" name="stockPhone" class="form-control" id="stockPhone" placeholder="请输入收货电话"> <label for="stockPhone" class="col-sm-6 col-form-label">收货电话:</label>
<div class="col-sm-5">
<input type="text" name="stockPhone" class="form-control" id="stockPhone" placeholder="请输入收货电话" readonly />
</div> </div>
</div> </div>
<div class="form-group"> <div class="col-xs-6">
<label for="stockAddress" class="col-sm-2 col-form-label">详细地址:</label> <label for="stockAddress" class="col-sm-6 col-form-label">详细地址:</label>
<div class="col-sm-4"> <div class="col-sm-5">
<textarea class="form-control" name="stockAddress" id="stockAddress"></textarea> <textarea class="form-control" name="stockAddress" id="stockAddress" readonly></textarea>
</div> </div>
</div> </div>
</div> </div>
<div class="container"> <div class="container">
<div class="row"><h4 class="card-header">订单合计:</h4></div> <div class="row"><h4 class="card-header">订单合计:</h4></div>
<div class="form-group"> <div class="col-xs-6">
<label for="purchaseMaterialSum" class="col-sm-2 col-form-label">物料合计:</label> <label for="purchaseMaterialSum" class="col-sm-6 col-form-label">物料合计:</label>
<div class="col-sm-4"> <div class="col-sm-5">
<input type="text" class="form-control" value="0" id="purchaseMaterialSum"> <input type="text" class="form-control" id="purchaseMaterialSum" readonly />
</div> </div>
</div> </div>
<div class="form-group"> <div class="col-xs-6">
<label for="purchaseSum" class="col-sm-2 col-form-label">采购合计:</label> <label for="purchaseSum" class="col-sm-6 col-form-label">采购合计:</label>
<div class="col-sm-4"> <div class="col-sm-5">
<input type="text" class="form-control" value="0" id="purchaseSum"> <input type="text" class="form-control" id="purchaseSum" readonly />
</div> </div>
</div> </div>
<div class="form-group"> <div class="col-xs-6">
<label for="purchaseNoRmbSum" class="col-sm-2 col-form-label">不含税采购总价:</label> <label for="purchaseNoRmbSum" class="col-sm-5 col-form-label">不含税采购总价:</label>
<div class="col-sm-4"> <div class="col-sm-6">
<input type="text" class="form-control" value="0" id="purchaseNoRmbSum"> <input type="text" class="form-control" id="purchaseNoRmbSum" readonly />
</div> </div>
</div> </div>
<div class="form-group"> <div class="col-xs-6">
<label for="purchaseRmbSum" class="col-sm-2 col-form-label">含税采购总价:</label> <label for="purchaseRmbSum" class="col-sm-5 col-form-label">含税采购总价:</label>
<div class="col-sm-4"> <div class="col-sm-6">
<input type="text" class="form-control" value="0" id="purchaseRmbSum"> <input type="text" class="form-control" id="purchaseRmbSum" readonly />
</div> </div>
</div> </div>
</div> </div>
@ -122,7 +132,6 @@
// 假设qualityOrderCode已经定义或者可以通过某种方式获取到 // 假设qualityOrderCode已经定义或者可以通过某种方式获取到
$(function() { $(function() {
// 初始化时默认加载仓库ID列表 // 初始化时默认加载仓库ID列表
loadWarehouseCodes();
// 假设purchaseOrderCode已经定义或者可以通过某种方式获取到 // 假设purchaseOrderCode已经定义或者可以通过某种方式获取到
var purchaseOrderCode = [[${purchaseOrder.purchaseOrderCode}]]; // 这里需要实际赋值,比如从前端某个地方读取 var purchaseOrderCode = [[${purchaseOrder.purchaseOrderCode}]]; // 这里需要实际赋值,比如从前端某个地方读取
var purchaseOrderId = [[${purchaseOrder.purchaseOrderId}]]; var purchaseOrderId = [[${purchaseOrder.purchaseOrderId}]];
@ -152,6 +161,16 @@
createTableForSupplier(supplierCode, supplierData); createTableForSupplier(supplierCode, supplierData);
} }
} }
loadWarehouseCodes();
//物料合计 = 物料实际采购数合计,不含税总价,含税采购总价不为null的情况可以合计物料,否则跳过
$("#purchaseMaterialSum").val(purchaseOrder.materialSum);
//采购数量合计
$('#purchaseSum').val(purchaseOrder.materialSum);
//采购不含税总价
$('#purchaseNoRmbSum').val(purchaseOrder.noRmbSum);
//采购含税总价
$('#purchaseRmbSum').val(purchaseOrder.rmbSum);
$('#stockNo').val(purchaseOrder.stockNo);
//按照物料的维度查看采购订单信息 //按照物料的维度查看采购订单信息
// 初始化表格 // 初始化表格
@ -165,14 +184,27 @@
var $tableWrapper = $('<div id="material-' + tableId + '""></div>'); var $tableWrapper = $('<div id="material-' + tableId + '""></div>');
// 将整个物料信息容器添加到页面 // 将整个物料信息容器添加到页面
$('#purchasePlanMaterial').append($tableWrapper); $('#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 = var $headerDiv =
$('<div class="row"><div class="col-xs-12"><h3>' + $('<div class="row">' +
'<span><strong>物料 ' + (index + 1) + ': </strong><strong>关联订单号: </strong></span><span class="correlationCodes" id="correlateion-' + tableId + ' ">' + material.purchasePlanCorrelationCode '<div class="col-xs-12">' +
+ '</span>' + '<h3>' +
'</h3><div class="col-sm-12"><table class="table-materialCode" id="' + materialTable + '">' + '<table/>' + '<span><strong>物料 ' + (index + 1) + ': </strong><strong>关联订单号: </strong></span><span class="correlationCodes" id="correlateion-' + tableId + ' ">' + material.purchasePlanCorrelationCode + '</span>' +
'</div></div></div>'); '</h3>' +
'<div class="col-sm-12">' +
'<table class="table-materialCode" id="' + materialTable + '">' + '<table/>' +
'</div>' +
'</div>' +
'</div>');
$tableWrapper.append($headerDiv); $tableWrapper.append($headerDiv);
//创建物料库存容器 //创建物料库存容器
var $stockWrapper = $('<div class="row"><div class="inventory-count " id=" inventory-count-' + tableId + '">'+ var $stockWrapper = $('<div class="row"><div class="inventory-count " id=" inventory-count-' + tableId + '">'+
@ -190,57 +222,60 @@
var materialData = [materialObj]; var materialData = [materialObj];
materialList.push(material); materialList.push(material);
tables(materialTable, materialData); tables(materialTable, materialData);
var $supplierInfo = $('<div class="supplier-card " style="height: 20px;" id="supplierInfo_' + tableId + '"></div>');
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;
});
}
//如果物料下的供应商为空,则不需要添加供应商信息,并在容器中添加一个提示信息:暂无供应商信息,请先添加供应商信息。 //如果物料下的供应商为空,则不需要添加供应商信息,并在容器中添加一个提示信息:暂无供应商信息,请先添加供应商信息。
const uniqueSuppliers = []; if (material.purchaseOrderChildSupplierList.length <= 0) {
if (material.purchaseSupplierList.length <= 0) {
var $noSupplierDiv = $('<div class="no-supplier">暂无供应商信息,请先添加供应商信息。</div>'); var $noSupplierDiv = $('<div class="no-supplier">暂无供应商信息,请先添加供应商信息。</div>');
$tableWrapper.append($noSupplierDiv); $tableWrapper.append($noSupplierDiv);
} }
else{ else{
material.purchaseSupplierList.forEach(supplier => {
const key = `${supplier.supplierCode}_${supplier.materialCode}`;
if (!uniqueSuppliers.map(s => `${s.supplierCode}_${s.materialCode}`).includes(key)) {
uniqueSuppliers.push(supplier);
}
});
// 循环处理每个供应商的信息 // 循环处理每个供应商的信息
uniqueSuppliers.forEach(function (supplier, supplierIndex) { uniqueSuppliers.forEach(function (supplier, supplierIndex) {
//如果供应商相同,则不需要再次添加供应商信息 //如果供应商相同,则不需要再次添加供应商信息
// 卡片样式容器,用于包裹每个供应商的信息 // 卡片样式容器,用于包裹每个供应商的信息
// 构建供应商信息头部 // 构建供应商信息头部
var $headerContent = var $headerContent =
$('<div class="card-header supplier_card" id = "supplier-' + tableId + '_' + supplierIndex + '">' + $( '<div class="card-header supplier_card" id = "supplier-' + tableId + '_' + supplierIndex + '" xmlns="http://www.w3.org/1999/html">' +
'<div class="row">' + '<div class="row">' +
'<div class="crad-text">'+ '<div class="crad-text">'+
'<h4>供应商 ' + (supplierIndex + 1) + ':' + '</h4>' + '<span><strong>供应商 ' + (supplierIndex + 1) + ': </strong></span>' + '<span class="supplierCode">' + supplier.supplierCode + '</span>' + '-' + '<span class="supplierName">' + supplier.supplierName + '</span>' +
'<span class="supplierCode">' + supplier.supplierCode + '</span>' + '-' + '-最新不含税采购价: ' +'<span id="supplierMaterialNoRmb-' + tableId + '" class="supplierMaterialNoRmb"></strong>' + supplier.materialRealNoRmb +'</strong></span>'+
'<span class="supplierName">' + supplier.supplierName + '</span>' + ' RMB 最新含税采购价: ' +'<span class="supplierMaterialRmb"><strong>' + supplier.materialRealRmb + '</strong> RMB </span>' +
'-最新不含税采购价: ' +'<span id="supplierMaterialNoRmb-' + tableId + '" class="supplierMaterialNoRmb">' + supplier.materialNoRmb +'</span>'+ '<span class="supplierPurchasePlanCode" hidden="hidden" >' + material.planCodes + '</span>' +
' RMB 最新含税采购价: ' +'<span class="supplierMaterialRmb">' + supplier.materialRmb + '</span> RMB ' + '<span class="supplierCorrelationCode" hidden="hidden" >' + material.correlationCode + '</span>' +
'<span class="supplierPurchasePlanCode" hidden="hidden" >' + material.planCodes + '</span>' + '<span class="supplierPurchaseQuoteCode" hidden="hidden" >' + supplier.purchaseQuoteCode + '</span>' +
'<span class="supplierCorrelationCode" hidden="hidden" >' + material.correlationCodes + '</span>' + '</div>' +
'<span class="supplierPurchaseQuoteCode" hidden="hidden" >' + supplier.purchaseQuoteCode + '</span>' + '</div>' +
'</div>' + '<div class="row">' +
'</div>' + '<div class="col-xs-6 form-group">' +
'<div class="row">' + '<label class="col-sm-4"> 实际采购数: </label>' +
'<div class="col-xs-6 form-group">' + '<div class ="col-sm-6">' +
'<label class="col-sm-4"> 实际采购数: </label>' + '<input type="text" name="materialNum" value="' + supplier.materialRealNum + '" class="form-control supplierMaterialNum actualPurchaseNum" id="actualPurchaseNum_' + tableId + '" readonly>' +
'<div class ="col-sm-6">' + '</div>' +
'<input type="text" name="materialNum" class="form-control supplierMaterialNum actualPurchaseNum" id="actualPurchaseNum_' + tableId + '">' + '</div>' +
'</div>' + '<div class="col-xs-6 form-group">' +
'</div>' + '<label class="col-sm-4">计划交付时间: </label>' +
'<div class="col-xs-6 form-group">' + '<div class ="col-sm-6">' +
'<label class="col-sm-4">计划交付时间: </label>' + '<div class="input-group date"> ' +
'<div class ="col-sm-6">' + '<input type="text" name="deliveryTime" value="' + supplier.deliveryTime + '" class="form-control supplierDeliveryTime" id="deliveryTime_' + tableId + '" disabled >' +
'<div class="input-group date"> ' + '<span class="input-group-addon"><i class="fa fa-calendar"></i></span>' +
'<input type="text" name="deliveryTime" class="form-control supplierDeliveryTime" id="deliveryTime_' + tableId + '">' + '</div> ' +
'<span class="input-group-addon"><i class="fa fa-calendar"></i></span>' + '</div>' +
'</div> ' + '</div>' +
'</div>' + '</div>' +
'</div>' +
'</div>' +
'</div>'); '</div>');
if (supplier.supplierCode != undefined && supplier.supplierCode != '' && supplier.supplierCode != null) { if (supplier.supplierCode != undefined && supplier.supplierCode != '' && supplier.supplierCode != null) {
$supplierInfo.append($headerContent); $supplierInfo.append($headerContent);
@ -357,6 +392,127 @@
$tableWrapper.append($header).append($table); $tableWrapper.append($header).append($table);
$('#supplierMaterial').append($tableWrapper); $('#supplierMaterial').append($tableWrapper);
} }
// 新增函数:重新计算某物料的采购数量合计、不含税采购总价和含税采购总价
function recalculateTotals(tableId) {
var $tableWrapper = $('#material-' + tableId);
var totalNoRmb = 0;
var totalRmb = 0;
var totalActualPurchase = 0;
var $suplierInfo = $tableWrapper.find('.supplier-card');
//获取所有物料表中供应商列表数据,实际采购数合计,不含税总价,含税采购总价
$suplierInfo.find('.supplier_card').each(function() {
let purchaseNum = parseFloat($(this).find('.actualPurchaseNum').val()) || 0;
let noRmbPrice = parseFloat($(this).find('.supplierMaterialNoRmb').text().trim()) || 0;
let rmbPrice = parseFloat($(this).find('.supplierMaterialRmb').text().trim()) || 0;
totalNoRmb += purchaseNum * noRmbPrice;
totalRmb += purchaseNum * rmbPrice;
totalActualPurchase = totalActualPurchase + purchaseNum;
});
//物料的实际采购数合计
$('#materialAmountSum_' + tableId).val(totalActualPurchase);
//物料的实际不含税采购总价:
$('#materialNoRmbSum_' + tableId).val(parseFloat(totalNoRmb));
//物料的实际含税总价:
$('#materialRmbSum_' + tableId).val(parseFloat(totalRmb));
// 采购物料合计
materialActualPurchaseSum();
}
function materialActualPurchaseSum(){
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(materialAmount);
//采购数量合计
$('#purchaseSum').val(totalActualPurchase);
//采购不含税总价
$('#purchaseNoRmbSum').val(totalNoRmb);
//采购含税总价
$('#purchaseRmbSum').val(totalRmb);
}
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 + '" readonly>' +
'</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 + '" readonly>' +
'</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 + '" 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: 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列表函数 // 加载仓库Id列表函数
$("#form-cgjl-edit").validate({focusCleanup: true}); $("#form-cgjl-edit").validate({focusCleanup: true});
//open打开时,模态框foot下新增审核通过和审核拒绝按钮 //open打开时,模态框foot下新增审核通过和审核拒绝按钮
@ -412,7 +568,6 @@
$.each(data, function(index, item) { $.each(data, function(index, item) {
selectElement.append('<option value="' + item.stockNO + '">' + item.stockNO + '</option>'); selectElement.append('<option value="' + item.stockNO + '">' + item.stockNO + '</option>');
}); // 遍历返回的数据,添加为下拉框的选项 }); // 遍历返回的数据,添加为下拉框的选项
// $('#warehouseCode').val(purchaseOrder.stockNO);
} else { } else {
$.modal.errMsg("数据为空"); $.modal.errMsg("数据为空");
} }

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

@ -3,34 +3,34 @@
<head> <head>
<th:block th:include="include :: header('采购经理审核')" /> <th:block th:include="include :: header('采购经理审核')" />
<th:block th:include="include :: select2-css" /> <th:block th:include="include :: select2-css" />
<style>
.fixed-table-container {
border: 0px solid #ddd;
min-height: 110px;
}
</style>
</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-cgjl-edit" th:object="${formData}"> <form class="form-horizontal m" id="form-purchaseOrder-cgjl" th:object="${formData}">
<input name="purchaseOrderId" th:field="*{purchaseOrderId}" type="hidden"> <input name="purchaseOrderId" th:field="*{purchaseOrderId}" type="hidden">
<input name="purchaseOrderCode" th:field="*{purchaseOrderCode}" 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">
<input name="instanceId" th:field="*{instanceId}" type="hidden"> <input name="instanceId" th:field="*{instanceId}" type="hidden">
<input name="instanceType" th:field="*{instanceType}" type="hidden"> <input name="instanceType" th:field="*{instanceType}" type="hidden">
<input type="hidden" name="p_COM_comment" /> <input type="hidden" name="p_COM_comment" />
<div class="form-group" hidden="hidden">
<label class="col-sm-6 control-label">采购单号:</label>
<div class="col-sm-6">
<input name="purchaseOrderCode" th:field="*{purchaseOrderCode}" class="form-control" type="text" readonly>
</div>
</div>
<div class="form-group" hidden="hidden"> <div class="form-group" hidden="hidden">
<label class="col-sm-6 control-label">申请人:</label> <label class="col-sm-6 control-label">申请人:</label>
<div class="col-sm-6"> <div class="col-sm-6">
<input name="applyUser" th:field="*{applyUser}" class="form-control" type="text" readonly> <input name="applyUser" th:field="*{applyUser}" class="form-control" type="text" disabled>
</div> </div>
</div> </div>
<div class="form-group" hidden="hidden"> <div class="form-group" hidden="hidden">
<label class="col-sm-6 control-label">申请时间:</label> <label class="col-sm-6 control-label">申请时间:</label>
<div class="col-sm-6"> <div class="col-sm-6">
<div class="input-group date"> <div class="input-group date">
<input name="applyTime" th:value="${#dates.format(formData.applyTime, 'yyyy-MM-dd HH:mm')}" class="form-control" type="text" readonly> <input name="applyTime" th:value="${#dates.format(formData.applyTime, 'yyyy-MM-dd HH:mm')}" class="form-control" type="text" disabled>
<span class="input-group-addon" disabled><i class="fa fa-calendar"></i></span> <span class="input-group-addon" disabled><i class="fa fa-calendar"></i></span>
</div> </div>
</div> </div>
@ -38,20 +38,21 @@
<div class="form-group" hidden="hidden"> <div class="form-group" hidden="hidden">
<label class="col-sm-6 control-label">标题:</label> <label class="col-sm-6 control-label">标题:</label>
<div class="col-sm-6"> <div class="col-sm-6">
<input name="title" th:field="*{applyTitle}" class="form-control" type="text" readonly> <input name="title" th:field="*{applyTitle}" class="form-control" type="text" disabled>
</div> </div>
</div> </div>
<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">
<input id="purchasePlanCodes" name="purchasePlanCode" class="form-control" type="text"> <input id="purchasePlanCodes" name="purchasePlanCode" class="form-control" type="text" disabled/>
</div> </div>
</div> </div>
<div class="container"> <div class="container">
<ul class="nav nav-tabs" role="tablist"> <ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active"><a href="#supplierModel" aria-controls="supplierModel" role="tab" data-toggle="tab">按供应商展示</a></li> <li role="presentation" ><a href="#supplierModel" aria-controls="supplierModel" role="tab" data-toggle="tab">按供应商展示</a></li>
<li role="presentation"><a href="#purchasePlanModel" aria-controls="purchasePlanModel" role="tab" data-toggle="tab">按采购计划展示</a></li> <li role="presentation" class="active"><a href="#purchasePlanModel" aria-controls="purchasePlanModel" role="tab" data-toggle="tab">按采购计划展示</a></li>
</ul> </ul>
<div class="tab-content"> <div class="tab-content">
<div role="tabpanel" class="tab-pane " id="supplierModel"> <div role="tabpanel" class="tab-pane " id="supplierModel">
<div class="container" id="supplierMaterial"> <div class="container" id="supplierMaterial">
@ -65,6 +66,66 @@
</div> </div>
</div> </div>
</div> </div>
<div class="container">
<div class="row"><h4 class="card-header">公司地址:</h4></div>
<div class="col-xs-6">
<label for="stockNo" class="col-sm-6 col-form-label">仓库ID:</label>
<div class="col-sm-5">
<select class="form-control" name="stockNo" id="stockNo" disabled ></select>
</div>
</div>
<div class="col-xs-6">
<label for="stockName" class="col-sm-6 col-form-label">仓库名称:</label>
<div class="col-sm-5">
<input type="text" class="form-control" name="stockName" id="stockName" disabled/>
</div>
</div>
<div class="col-xs-6">
<label for="stockContact" class="col-sm-6 col-form-label">收货人:</label>
<div class="col-sm-5">
<input type="text" name="stockContact" class="form-control" id="stockContact" disabled />
</div>
</div>
<div class="col-xs-6">
<label for="stockPhone" class="col-sm-6 col-form-label">收货电话:</label>
<div class="col-sm-5">
<input type="text" name="stockPhone" class="form-control" id="stockPhone" placeholder="请输入收货电话" disabled />
</div>
</div>
<div class="col-xs-6">
<label for="stockAddress" class="col-sm-6 col-form-label">详细地址:</label>
<div class="col-sm-5">
<textarea class="form-control" name="stockAddress" id="stockAddress" disabled></textarea>
</div>
</div>
</div>
<div class="container">
<div class="row"><h4 class="card-header">订单合计:</h4></div>
<div class="col-xs-6">
<label for="purchaseMaterialSum" class="col-sm-6 col-form-label">物料合计:</label>
<div class="col-sm-5">
<input type="text" class="form-control" id="purchaseMaterialSum" disabled />
</div>
</div>
<div class="col-xs-6">
<label for="purchaseSum" class="col-sm-6 col-form-label">采购合计:</label>
<div class="col-sm-5">
<input type="text" class="form-control" id="purchaseSum" disabled />
</div>
</div>
<div class="col-xs-6">
<label for="purchaseNoRmbSum" class="col-sm-5 col-form-label">不含税采购总价:</label>
<div class="col-sm-6">
<input type="text" class="form-control" id="purchaseNoRmbSum" disabled />
</div>
</div>
<div class="col-xs-6">
<label for="purchaseRmbSum" class="col-sm-5 col-form-label">含税采购总价:</label>
<div class="col-sm-6">
<input type="text" class="form-control" id="purchaseRmbSum" disabled />
</div>
</div>
</div>
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label is-required" for="cgjlVerifyApproved">审批意见:</label> <label class="col-sm-3 control-label is-required" for="cgjlVerifyApproved">审批意见:</label>
<div class="col-sm-6"> <div class="col-sm-6">
@ -82,62 +143,7 @@
</div> </div>
</div> </div>
</form> </form>
<div class="container">
<div class="row"><h4 class="card-header">公司地址:</h4></div>
<div class="row">
<label for="stockNo" class="col-sm-2 col-form-label">仓库ID:</label>
<div class="col-sm-4">
<select class="form-control" name="stockNo" id="stockNo" ></select>
</div>
<label for="stockName" class="col-sm-2 col-form-label">仓库名称:</label>
<div class="col-sm-4">
<input type="text" class="form-control" name="stockName" id="stockName">
</div>
</div>
<div class="row">
<label for="stockContact" class="col-sm-2 col-form-label">收货人:</label>
<div class="col-sm-4">
<input type="text" name="stockContact" class="form-control" id="stockContact" >
</div>
<label for="stockPhone" class="col-sm-2 col-form-label">收货电话:</label>
<div class="col-sm-4">
<input type="text" name="stockPhone" class="form-control" id="stockPhone" placeholder="请输入收货电话">
</div>
</div>
<div class="form-group">
<label for="stockAddress" class="col-sm-2 col-form-label">详细地址:</label>
<div class="col-sm-4">
<textarea class="form-control" name="stockAddress" id="stockAddress"></textarea>
</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" value="0" 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" value="0" 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" value="0" 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" value="0" id="purchaseRmbSum">
</div>
</div>
</div>
</div> </div>
<th:block th:include="include :: footer" /> <th:block th:include="include :: footer" />
<th:block th:include="include :: select2-js" /> <th:block th:include="include :: select2-js" />
@ -151,10 +157,10 @@
var processMethodDatas = [[${@dict.getType('processMethod')}]]; var processMethodDatas = [[${@dict.getType('processMethod')}]];
var warehouseDeptDatas = [[${@dict.getType('warehouseDept')}]]; var warehouseDeptDatas = [[${@dict.getType('warehouseDept')}]];
var loginName = [[${@permission.getPrincipalProperty('loginName')}]]; var loginName = [[${@permission.getPrincipalProperty('loginName')}]];
$("#form-plan-purchaseOrder-add").validate({focusCleanup: true}); $("#form-purchaseOrder-cgjl").validate({focusCleanup: true});
var purchasePlanChildList = []; var purchasePlanChildList = [];
var purchasePlanCodes = []; var purchasePlanCodes = [];
var formId = "form-plan-purchaseOrder-add"; var formId = "form-purchaseOrder-cgjl";
//根据物料物料数量添加物料分类表,自动生成类似的表单对象 //根据物料物料数量添加物料分类表,自动生成类似的表单对象
//初始根据采购计划单,涉及到物料做分类表 //初始根据采购计划单,涉及到物料做分类表
//根据采购计划单,获取物料信息,自动生成物料的供应商分类表 //根据采购计划单,获取物料信息,自动生成物料的供应商分类表
@ -167,7 +173,6 @@
// 假设qualityOrderCode已经定义或者可以通过某种方式获取到 // 假设qualityOrderCode已经定义或者可以通过某种方式获取到
$(function() { $(function() {
// 初始化时默认加载仓库ID列表 // 初始化时默认加载仓库ID列表
loadWarehouseCodes();
// 假设purchaseOrderCode已经定义或者可以通过某种方式获取到 // 假设purchaseOrderCode已经定义或者可以通过某种方式获取到
var purchaseOrderCode = [[${formData.purchaseOrderCode}]]; // 这里需要实际赋值,比如从前端某个地方读取 var purchaseOrderCode = [[${formData.purchaseOrderCode}]]; // 这里需要实际赋值,比如从前端某个地方读取
var purchaseOrderId = [[${formData.purchaseOrderId}]]; var purchaseOrderId = [[${formData.purchaseOrderId}]];
@ -197,6 +202,16 @@
createTableForSupplier(supplierCode, supplierData); createTableForSupplier(supplierCode, supplierData);
} }
} }
loadWarehouseCodes();
//物料合计 = 物料实际采购数合计,不含税总价,含税采购总价不为null的情况可以合计物料,否则跳过
$("#purchaseMaterialSum").val(purchaseOrder.materialSum);
//采购数量合计
$('#purchaseSum').val(purchaseOrder.materialSum);
//采购不含税总价
$('#purchaseNoRmbSum').val(purchaseOrder.noRmbSum);
//采购含税总价
$('#purchaseRmbSum').val(purchaseOrder.rmbSum);
$('#stockNo').val(purchaseOrder.stockNo);
//按照物料的维度查看采购订单信息 //按照物料的维度查看采购订单信息
// 初始化表格 // 初始化表格
@ -210,14 +225,27 @@
var $tableWrapper = $('<div id="material-' + tableId + '""></div>'); var $tableWrapper = $('<div id="material-' + tableId + '""></div>');
// 将整个物料信息容器添加到页面 // 将整个物料信息容器添加到页面
$('#purchasePlanMaterial').append($tableWrapper); $('#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 = var $headerDiv =
$('<div class="row"><div class="col-xs-12"><h3>' + $('<div class="row">' +
'<span><strong>物料 ' + (index + 1) + ': </strong><strong>关联订单号: </strong></span><span class="correlationCodes" id="correlateion-' + tableId + ' ">' + material.purchasePlanCorrelationCode '<div class="col-xs-12">' +
+ '</span>' + '<h3>' +
'</h3><div class="col-sm-12"><table class="table-materialCode" id="' + materialTable + '">' + '<table/>' + '<span><strong>物料 ' + (index + 1) + ': </strong><strong>关联订单号: </strong></span><span class="correlationCodes" id="correlateion-' + tableId + ' ">' + material.purchasePlanCorrelationCode + '</span>' +
'</div></div></div>'); '</h3>' +
'<div class="col-sm-12">' +
'<table class="table-materialCode" id="' + materialTable + '">' + '<table/>' +
'</div>' +
'</div>' +
'</div>');
$tableWrapper.append($headerDiv); $tableWrapper.append($headerDiv);
//创建物料库存容器 //创建物料库存容器
var $stockWrapper = $('<div class="row"><div class="inventory-count " id=" inventory-count-' + tableId + '">'+ var $stockWrapper = $('<div class="row"><div class="inventory-count " id=" inventory-count-' + tableId + '">'+
@ -235,37 +263,40 @@
var materialData = [materialObj]; var materialData = [materialObj];
materialList.push(material); materialList.push(material);
tables(materialTable, materialData); tables(materialTable, materialData);
var $supplierInfo = $('<div class="supplier-card " style="height: 20px;" id="supplierInfo_' + tableId + '"></div>');
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;
});
}
//如果物料下的供应商为空,则不需要添加供应商信息,并在容器中添加一个提示信息:暂无供应商信息,请先添加供应商信息。 //如果物料下的供应商为空,则不需要添加供应商信息,并在容器中添加一个提示信息:暂无供应商信息,请先添加供应商信息。
const uniqueSuppliers = []; if (material.purchaseOrderChildSupplierList.length <= 0) {
if (material.purchaseSupplierList.length <= 0) {
var $noSupplierDiv = $('<div class="no-supplier">暂无供应商信息,请先添加供应商信息。</div>'); var $noSupplierDiv = $('<div class="no-supplier">暂无供应商信息,请先添加供应商信息。</div>');
$tableWrapper.append($noSupplierDiv); $tableWrapper.append($noSupplierDiv);
} }
else{ else{
material.purchaseSupplierList.forEach(supplier => {
const key = `${supplier.supplierCode}_${supplier.materialCode}`;
if (!uniqueSuppliers.map(s => `${s.supplierCode}_${s.materialCode}`).includes(key)) {
uniqueSuppliers.push(supplier);
}
});
// 循环处理每个供应商的信息 // 循环处理每个供应商的信息
uniqueSuppliers.forEach(function (supplier, supplierIndex) { uniqueSuppliers.forEach(function (supplier, supplierIndex) {
//如果供应商相同,则不需要再次添加供应商信息 //如果供应商相同,则不需要再次添加供应商信息
// 卡片样式容器,用于包裹每个供应商的信息 // 卡片样式容器,用于包裹每个供应商的信息
// 构建供应商信息头部 // 构建供应商信息头部
var $headerContent = var $headerContent =
$('<div class="card-header supplier_card" id = "supplier-' + tableId + '_' + supplierIndex + '">' + $( '<div class="card-header supplier_card" id = "supplier-' + tableId + '_' + supplierIndex + '" xmlns="http://www.w3.org/1999/html">' +
'<div class="row">' + '<div class="row">' +
'<div class="crad-text">'+ '<div class="crad-text">'+
'<h4>供应商 ' + (supplierIndex + 1) + ':' + '</h4>' + '<span><strong>供应商 ' + (supplierIndex + 1) + ': </strong></span>' + '<span class="supplierCode">' + supplier.supplierCode + '</span>' + '-' + '<span class="supplierName">' + supplier.supplierName + '</span>' +
'<span class="supplierCode">' + supplier.supplierCode + '</span>' + '-' + '-最新不含税采购价: ' +'<span id="supplierMaterialNoRmb-' + tableId + '" class="supplierMaterialNoRmb"></strong>' + supplier.materialRealNoRmb +'</strong></span>'+
'<span class="supplierName">' + supplier.supplierName + '</span>' + ' RMB 最新含税采购价: ' +'<span class="supplierMaterialRmb"><strong>' + supplier.materialRealRmb + '</strong> RMB </span>' +
'-最新不含税采购价: ' +'<span id="supplierMaterialNoRmb-' + tableId + '" class="supplierMaterialNoRmb">' + supplier.materialNoRmb +'</span>'+
' RMB 最新含税采购价: ' +'<span class="supplierMaterialRmb">' + supplier.materialRmb + '</span> RMB ' +
'<span class="supplierPurchasePlanCode" hidden="hidden" >' + material.planCodes + '</span>' + '<span class="supplierPurchasePlanCode" hidden="hidden" >' + material.planCodes + '</span>' +
'<span class="supplierCorrelationCode" hidden="hidden" >' + material.correlationCodes + '</span>' + '<span class="supplierCorrelationCode" hidden="hidden" >' + material.correlationCode + '</span>' +
'<span class="supplierPurchaseQuoteCode" hidden="hidden" >' + supplier.purchaseQuoteCode + '</span>' + '<span class="supplierPurchaseQuoteCode" hidden="hidden" >' + supplier.purchaseQuoteCode + '</span>' +
'</div>' + '</div>' +
'</div>' + '</div>' +
@ -273,14 +304,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" class="form-control supplierMaterialNum actualPurchaseNum" id="actualPurchaseNum_' + tableId + '">' + '<input type="text" name="materialNum" value="' + supplier.materialRealNum + '" class="form-control supplierMaterialNum actualPurchaseNum" id="actualPurchaseNum_' + tableId + '" disabled>' +
'</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" class="form-control supplierDeliveryTime" id="deliveryTime_' + tableId + '">' + '<input type="text" name="deliveryTime" value="' + supplier.deliveryTime + '" class="form-control supplierDeliveryTime" id="deliveryTime_' + tableId + '" disabled >' +
'<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>' +
@ -402,69 +433,6 @@
$tableWrapper.append($header).append($table); $tableWrapper.append($header).append($table);
$('#supplierMaterial').append($tableWrapper); $('#supplierMaterial').append($tableWrapper);
} }
// 加载仓库Id列表函数
$("#form-cgjl-edit").validate({focusCleanup: true});
//open打开时,模态框foot下新增审核通过和审核拒绝按钮
function submitHandler() {
if ($.validate.form()) {
if ($('textarea[name="comment"]').val()) {
$('input[name="p_COM_comment"]').val($('textarea[name="comment"]').val());
}
var taskId = [[${taskId}]];
$.operate.save(prefix + "/complete/" + taskId, $('#form-cgjl-edit').serialize());
}
}
//获取仓库相关信息Select2,根据仓库ID查询仓库名称
$('#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('查询仓库名称时发生错误!');
}
});
}
else {$('input[name="warehouseName"]').val('');}// 如果没有选择仓库ID,清空仓库名称输入框
});
// 加载仓库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>');
}); // 遍历返回的数据,添加为下拉框的选项
// $('#warehouseCode').val(formData.stockNO);
} else {
$.modal.errMsg("数据为空");
}
}
});
}
// 新增函数:重新计算某物料的采购数量合计、不含税采购总价和含税采购总价 // 新增函数:重新计算某物料的采购数量合计、不含税采购总价和含税采购总价
function recalculateTotals(tableId) { function recalculateTotals(tableId) {
var $tableWrapper = $('#material-' + tableId); var $tableWrapper = $('#material-' + tableId);
@ -503,9 +471,9 @@
//采购含税总价 = 所有物料的含税总价合计 //采购含税总价 = 所有物料的含税总价合计
//查询物料表下吗整合的物料的实际采购数合计,物料的实际不含税采购总价,物料的实际含税总价 //查询物料表下吗整合的物料的实际采购数合计,物料的实际不含税采购总价,物料的实际含税总价
var supplierInfo = $tableWrapper.find('#supplierInfo_' + tableId ); var supplierInfo = $tableWrapper.find('#supplierInfo_' + tableId );
let purchaseNum = parseInt(supplierInfo.find('.actualPurchaseTotalSum').val().trim()) || 0; let purchaseNum = parseInt(supplierInfo.find('.actualPurchaseTotalSum').val()) || 0;
let noRmbPrice = parseFloat(supplierInfo.find('.actualPurchaseTotal').val().trim()) || 0; let noRmbPrice = parseFloat(supplierInfo.find('.actualPurchaseTotal').val()) || 0;
let rmbPrice = parseFloat(supplierInfo.find('.actualPurchaseTotalTax').val().trim()) || 0; let rmbPrice = parseFloat(supplierInfo.find('.actualPurchaseTotalTax').val()) || 0;
if (purchaseNum > 0) { if (purchaseNum > 0) {
materialAmount += 1; materialAmount += 1;
} }
@ -526,28 +494,29 @@
var $totalSection = $( var $totalSection = $(
'<div class="card">' + '<div class="card">' +
'<div class="card-body" class="supplierTotal_' + tableId + '">' + '<div class="card-body" class="supplierTotal_' + tableId + '">' +
'<div class="form-row">' + '<div class="col-xs-4">' +
'<label for="actualPurchaseTotal" class="col-sm-4">实际采购数合计:</label>' + '<label for="actualPurchaseTotal" class="col-sm-5">实际采购数合计:</label>' +
'<div class="col-sm-8">' + '<div class="col-sm-6">' +
'<input type="number" name="materialAmountSum" class="form-control actualPurchaseTotalSum" id="materialAmountSum_' + tableId + '">' + '<input type="number" name="materialAmountSum" class="form-control actualPurchaseTotalSum" id="materialAmountSum_' + tableId + '" disabled>' +
'</div>' + '</div>' +
'</div>' + '</div>' +
'<div class="form-row">' + '<div class="col-xs-4">' +
'<label for="actualPurchaseTotal" class="col-sm-4">不含税采购总价:</label>' + '<label for="actualPurchaseTotal" class="col-sm-5">不含税采购总价:</label>' +
'<div class="col-sm-8">' + '<div class="col-sm-6">' +
'<input type="number" name="materialNoRmbSum" class="form-control actualPurchaseTotal" id="materialNoRmbSum_' + tableId + '" ' + '<input type="number" name="materialNoRmbSum" class="form-control actualPurchaseTotal" id="materialNoRmbSum_' + tableId + '" disabled>' +
'</div>' + '</div>' +
'</div>' + '</div>' +
'<div class="form-row">' + '<div class="col-xs-4">' +
'<label for="actualPurchaseTotalTax" class="col-sm-4">含税采购总价:</label>' + '<label for="actualPurchaseTotalTax" class="col-sm-5">含税采购总价:</label>' +
'<div class="col-sm-8">' + '<div class="col-sm-6">' +
'<input type="number" name="materialRmbSum" class="form-control actualPurchaseTotalTax" id="materialRmbSum_' + tableId + '">' + '<input type="number" name="materialRmbSum" class="form-control actualPurchaseTotalTax" id="materialRmbSum_' + tableId + '" disabled>' +
'</div>' + '</div>' +
'</div>' + '</div>' +
'</div>'+ '</div>'+
'</div>'); '</div>');
element.append($totalSection); element.append($totalSection);
} }
// 创建表格并添加到页面
function tables(tableId, data) { function tables(tableId, data) {
$('#' + tableId).bootstrapTable({ $('#' + tableId).bootstrapTable({
showExport: false, showExport: false,
@ -584,92 +553,65 @@
], ],
}); });
} }
function submitHandlerPurchaseOrder() {
if ($.validate.form()) { // 加载仓库Id列表函数
var materialSum = 0; $("#form-cgjl-edit").validate({focusCleanup: true});
var materialRealSum = 0; //open打开时,模态框foot下新增审核通过和审核拒绝按钮
var materialNoRmbSum = 0; //获取仓库相关信息Select2,根据仓库ID查询仓库名称
var materialRmbSum = 0; function loadWarehouseCodes() {
//添加去除供应商编号数组 var url = ctx + 'stock/stockInfo/getAllWarehouseCode';
var supplierNumList = []; $.ajax({
var purchaseOrder = { type: 'GET', // 请求类型
supplierNum: 0, materialNum: 0, noRmbSum: 0, rmbSum: 0, url: url, // 后端接口URL
stockNo: $("#stockNo").val(), dataType: 'json', // 预期服务器返回的数据类型
stockName: $("#stockName").val(), success: function(data) {
stockAddress: $("#stockAddress").val(), if (data && Array.isArray(data)) {
stockContact: $("#stockContact").val(), var selectElement = $('#stockNo'); // 获取仓库编号下拉框元素
stockPhone: $("#stockPhone").val(), selectElement.empty();// 清空下拉框现有选项
purchaseOrderChildList: [], $.each(data, function(index, item) {
}; selectElement.append('<option value="' + item.stockNO + '">' + item.stockNO + '</option>');
// 遍历每个物料容器 }); // 遍历返回的数据,添加为下拉框的选项
$('.table-materialCode').each(function (index, tableElement) { } else {
var tableId = tableIdList[index]; $.modal.errMsg("数据为空");
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) { $('#stockNo').on('change', function() {
var supplierCode = $(this).find('.supplierCode').text().trim(); var selectedWarehouseCode = $(this).val(); // 获取选中的仓库ID
var supplierName = $(this).find('.supplierName').text().trim(); if (selectedWarehouseCode) {
var materialRealNum = parseInt($(this).find('.actualPurchaseNum').val()) || 0; // 发起Ajax请求获取仓库名称
var materialRealRmb = parseFloat($(this).find('.supplierMaterialRmb').text()) || 0; $.ajax({
var materialRealNoRmb = parseFloat($(this).find('.supplierMaterialNoRmb').text()) || 0; type: 'GET',
var deliveryTime = $(this).find('.supplierDeliveryTime').val(); url: ctx +'stock/stockInfo/getStockNameByWarehouseCode/' + selectedWarehouseCode,
var purchasePlanCode = $(this).find('.supplierPurchasePlanCode').text().trim(); dataType: 'json', // 假设返回的数据格式是JSON
var correlationCode = $(this).find('.supplierCorrelationCode').text().trim(); success: function(data) {
var purchaseQuoteCode = $(this).find('.supplierPurchaseQuoteCode').text().trim(); console.log(data);
var materialRealRmbSum = parseFloat(materialRealRmb * materialRealNum); // 将获取到的仓库名称填充到输入框
var materialRealNoRmbSum = parseFloat(materialRealNoRmb * materialRealNum); if(data.data == null){
materialRealSum += materialRealNum; // 如果返回的数据有问题,可以给出提示或处理
materialNoRmbSum += materialRealNoRmbSum; $.modal.alertWarning('未能获取到仓库名称!');
materialRmbSum += materialRealRmbSum;
if (supplierNumList.indexOf(supplierCode) === -1) {
supplierNumList.push(supplierCode);
purchaseOrder.supplierNum += 1;
} }
var materialData = { $('input[name="stockName"]').val(data.data.stockName);
materialCode: materialObj.materialCode, $('input[name="stockAddress"]').val(data.data.stockAddr);
materialName: materialObj.materialName, $('input[name="stockContact"]').val(data.data.stockManager);
materialType: materialObj.materialType, $('input[name="stockPhone"]').val(data.data.stockManagerPhone);
materialBrand: materialObj.brand, },
materialDescribe: materialObj.describe, error: function(jqXHR, textStatus, errorThrown) {
materialProcessMethod: materialObj.processMethod, console.error('Error:', textStatus, errorThrown);
materialUnit: materialObj.unit, $.modal.alertWarning('查询仓库名称时发生错误!');
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()); else {$('input[name="warehouseName"]').val('');}// 如果没有选择仓库ID,清空仓库名称输入框
var purchaseSum = parseFloat($('#purchaseSum').val()); });
var purchaseNoRmbSum = parseFloat($('#purchaseNoRmbSum').val()); function submitHandler() {
var purchaseRmbSum = parseFloat($('#purchaseRmbSum').val()); if ($.validate.form()) {
// 将合计值附加到purchaseOrder对象 if ($('textarea[name="comment"]').val()) {
purchaseOrder.materialAmount = purchaseAmount; $('input[name="p_COM_comment"]').val($('textarea[name="comment"]').val());
purchaseOrder.materialSum = purchaseSum; }
purchaseOrder.materialNoRmbSum = purchaseNoRmbSum; var taskId = [[${taskId}]];
purchaseOrder.materialRmbSum = purchaseRmbSum; $.operate.save(prefix + "/complete/" + taskId, $('#form-purchaseOrder-cgjl').serialize());
purchaseOrder.supplierNum = supplierNumList.length;
// 发送数据到后端API
$.operate.saveJson(prefix + "/addPurchaseOrder", JSON.stringify(purchaseOrder));
} }
} }
</script> </script>

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

@ -1,45 +1,129 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.w3.org/1999/xhtml"> <html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.w3.org/1999/xhtml">
<head> <head>
<th:block th:include="include :: header('采购经理审核')" /> <th:block th:include="include :: header('采购主管审核')" />
<th:block th:include="include :: select2-css" /> <th:block th:include="include :: select2-css" />
<style>
.fixed-table-container {
border: 0px solid #ddd;
min-height: 110px;
}
</style>
</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-cgzg-edit" th:object="${formData}"> <form class="form-horizontal m" id="form-purchaseOrder-cgzg" th:object="${formData}">
<input name="purchaseOrderId" th:field="*{purchaseOrderId}" type="hidden"> <input name="purchaseOrderId" th:field="*{purchaseOrderId}" type="hidden">
<input name="purchaseOrderCode" th:field="*{purchaseOrderCode}" 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">
<input name="instanceId" th:field="*{instanceId}" type="hidden"> <input name="instanceId" th:field="*{instanceId}" type="hidden">
<input name="instanceType" th:field="*{instanceType}" type="hidden"> <input name="instanceType" th:field="*{instanceType}" type="hidden">
<input type="hidden" name="p_COM_comment" /> <input type="hidden" name="p_COM_comment" />
<div class="form-group" hidden="hidden">
<div class="form-group">
<label class="col-sm-6 control-label">采购单号:</label>
<div class="col-sm-6">
<input name="purchaseOrderCode" th:field="*{purchaseOrderCode}" class="form-control" type="text" readonly>
</div>
</div>
<div class="form-group">
<label class="col-sm-6 control-label">申请人:</label> <label class="col-sm-6 control-label">申请人:</label>
<div class="col-sm-6"> <div class="col-sm-6">
<input name="applyUser" th:field="*{applyUser}" class="form-control" type="text" readonly> <input name="applyUser" th:field="*{applyUser}" class="form-control" type="text" disabled>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group" hidden="hidden">
<label class="col-sm-6 control-label">申请时间:</label> <label class="col-sm-6 control-label">申请时间:</label>
<div class="col-sm-6"> <div class="col-sm-6">
<div class="input-group date"> <div class="input-group date">
<input name="applyTime" th:value="${#dates.format(formData.applyTime, 'yyyy-MM-dd HH:mm')}" class="form-control" type="text" readonly> <input name="applyTime" th:value="${#dates.format(formData.applyTime, 'yyyy-MM-dd HH:mm')}" class="form-control" type="text" disabled>
<span class="input-group-addon" disabled><i class="fa fa-calendar"></i></span> <span class="input-group-addon" disabled><i class="fa fa-calendar"></i></span>
</div> </div>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group" hidden="hidden">
<label class="col-sm-6 control-label">标题:</label> <label class="col-sm-6 control-label">标题:</label>
<div class="col-sm-6"> <div class="col-sm-6">
<input name="title" th:field="*{applyTitle}" class="form-control" type="text" readonly> <input name="title" th:field="*{applyTitle}" class="form-control" type="text" disabled>
</div>
</div>
<div class="col-xs-12">
<label class="col-sm-4 control-label">已选择采购计划:</label>
<div class="col-sm-7">
<input id="purchasePlanCodes" name="purchasePlanCode" class="form-control" type="text" disabled/>
</div>
</div>
<div class="container">
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" ><a href="#supplierModel" aria-controls="supplierModel" role="tab" data-toggle="tab">按供应商展示</a></li>
<li role="presentation" class="active"><a href="#purchasePlanModel" aria-controls="purchasePlanModel" role="tab" data-toggle="tab">按采购计划展示</a></li>
</ul>
<div class="tab-content">
<div role="tabpanel" class="tab-pane " id="supplierModel">
<div class="container" id="supplierMaterial">
</div>
</div>
<div role="tabpanel" class="tab-pane active" id="purchasePlanModel">
<div class="container" id="purchasePlanMaterial">
</div>
</div>
</div>
</div>
<div class="container">
<div class="row"><h4 class="card-header">公司地址:</h4></div>
<div class="col-xs-6">
<label for="stockNo" class="col-sm-6 col-form-label">仓库ID:</label>
<div class="col-sm-5">
<select class="form-control" name="stockNo" id="stockNo" disabled ></select>
</div>
</div>
<div class="col-xs-6">
<label for="stockName" class="col-sm-6 col-form-label">仓库名称:</label>
<div class="col-sm-5">
<input type="text" class="form-control" name="stockName" id="stockName" disabled/>
</div>
</div>
<div class="col-xs-6">
<label for="stockContact" class="col-sm-6 col-form-label">收货人:</label>
<div class="col-sm-5">
<input type="text" name="stockContact" class="form-control" id="stockContact" disabled />
</div>
</div>
<div class="col-xs-6">
<label for="stockPhone" class="col-sm-6 col-form-label">收货电话:</label>
<div class="col-sm-5">
<input type="text" name="stockPhone" class="form-control" id="stockPhone" placeholder="请输入收货电话" disabled />
</div>
</div>
<div class="col-xs-6">
<label for="stockAddress" class="col-sm-6 col-form-label">详细地址:</label>
<div class="col-sm-5">
<textarea class="form-control" name="stockAddress" id="stockAddress" disabled></textarea>
</div>
</div>
</div>
<div class="container">
<div class="row"><h4 class="card-header">订单合计:</h4></div>
<div class="col-xs-6">
<label for="purchaseMaterialSum" class="col-sm-6 col-form-label">物料合计:</label>
<div class="col-sm-5">
<input type="text" class="form-control" id="purchaseMaterialSum" disabled />
</div>
</div>
<div class="col-xs-6">
<label for="purchaseSum" class="col-sm-6 col-form-label">采购合计:</label>
<div class="col-sm-5">
<input type="text" class="form-control" id="purchaseSum" disabled />
</div>
</div>
<div class="col-xs-6">
<label for="purchaseNoRmbSum" class="col-sm-5 col-form-label">不含税采购总价:</label>
<div class="col-sm-6">
<input type="text" class="form-control" id="purchaseNoRmbSum" disabled />
</div>
</div>
<div class="col-xs-6">
<label for="purchaseRmbSum" class="col-sm-5 col-form-label">含税采购总价:</label>
<div class="col-sm-6">
<input type="text" class="form-control" id="purchaseRmbSum" disabled />
</div>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
@ -59,25 +143,477 @@
</div> </div>
</div> </div>
</form> </form>
</div> </div>
<th:block th:include="include :: footer" /> <th:block th:include="include :: footer" />
<th:block th:include="include :: select2-js" /> <th:block th:include="include :: select2-js" />
<script th:src="@{/js/activiti.js}"></script> <script th:src="@{/js/activiti.js}"></script>
<script th:inline="javascript"> <script th:inline="javascript">
var prefix = ctx + "purchase/purchaseOrder"; var prefix = ctx + "purchase/purchaseOrder";
var purchaseOrder = [[${formData}]]; var purchaseOrder = [[${formData}]];
$("#form-cgzg-edit").validate({focusCleanup: true}); var materialTypeDatas = [[${@category.getChildByCode('materialType')}]];
var auditStatusDatas = [[${@dict.getType('auditStatus')}]];
var sysUnitClassDatas = [[${@dict.getType('sys_unit_class')}]];
var processMethodDatas = [[${@dict.getType('processMethod')}]];
var warehouseDeptDatas = [[${@dict.getType('warehouseDept')}]];
var loginName = [[${@permission.getPrincipalProperty('loginName')}]];
$("#form-purchaseOrder-cgzg").validate({focusCleanup: true});
var purchasePlanChildList = [];
var purchasePlanCodes = [];
var formId = "form-purchaseOrder-cgzg";
//根据物料物料数量添加物料分类表,自动生成类似的表单对象
//初始根据采购计划单,涉及到物料做分类表
//根据采购计划单,获取物料信息,自动生成物料的供应商分类表
//获取表单的id;
var materialList = [];
var tableIdList = [];
var $supplierForm;
var tableDatas = [];
//获取采购计划单的物料信息
// 假设qualityOrderCode已经定义或者可以通过某种方式获取到
$(function() {
// 初始化时默认加载仓库ID列表
// 假设purchaseOrderCode已经定义或者可以通过某种方式获取到
var purchaseOrderCode = [[${formData.purchaseOrderCode}]]; // 这里需要实际赋值,比如从前端某个地方读取
var purchaseOrderId = [[${formData.purchaseOrderId}]];
// 初始化表格,假设purchasePlanChildList已定义并包含了需要处理的数据
$.getJSON(prefix + "/editPurchaserOrder/" + purchaseOrderId, function(data) {
$("#purchasePlanCodes").val(data.data.purchasePlanCodes);
var datas = data.data.purchasePlanChildList;
purchasePlanChildList = datas;
var supplierCodes = data.data.supplierCodes;
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);
}
}
loadWarehouseCodes();
//物料合计 = 物料实际采购数合计,不含税总价,含税采购总价不为null的情况可以合计物料,否则跳过
$("#purchaseMaterialSum").val(purchaseOrder.materialSum);
//采购数量合计
$('#purchaseSum').val(purchaseOrder.materialSum);
//采购不含税总价
$('#purchaseNoRmbSum').val(purchaseOrder.noRmbSum);
//采购含税总价
$('#purchaseRmbSum').val(purchaseOrder.rmbSum);
$('#stockNo').val(purchaseOrder.stockNo);
//按照物料的维度查看采购订单信息
// 初始化表格
// 假设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 + '" 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) {
var tableId = 'bootstrap-table-' + supplierCode.replace(/[^a-z0-9]/gi, '_').toLowerCase();
tableDatas.push(tableId);
var $tableWrapper = $('<div class="table-responsive"></div>');
// 确保supplierData至少有一条记录,并从中提取供应商详细信息
var supplierInfo = supplierData.length > 0 ? supplierData[0] : {}; // 默认为空对象,以防数据不存在
// 构建含有额外供应商信息的标题字符串
var headerTitle = '供应商: ' + supplierCode + ' - ' + supplierInfo.supplierName;
var $header = $('<h4>' + headerTitle + '</h4>');
var $table = $('<table id="' + tableId + '" class="table table-striped table-bordered"></table>');
$table.bootstrapTable({
data: supplierData,
columns: [
{ checkbox: false, visible: false },
{ title: '供应商ID', field: 'supplierCode', visible: false },
{ title: '料号', field: 'materialCode' },
{ title: '图片', field: 'materialPhotoUrl', 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: 'materialDescribe' },
{ title: '品牌', field: 'materialBrand' },
{ title: '加工类型', field: 'materialProcessMethod', align: 'center', formatter: function(value, row, index) {
return $.table.selectDictLabel(processMethodDatas, value);
}
},
{ title: '单位', field: 'materialUnit', align: 'center' },
{ title: '入库部门', field: 'warehouseDept', align: 'center', formatter: function(value, row, index) {
return $.table.selectDictLabel(warehouseDeptDatas, value);
}
},
{ title: '计划采购数', field: 'materialNum' },
{ title: '币种', field: '' },
{ title: '不含税采购价', field: 'materialNoRmb' },
{ title: '含税采购价', field: 'materialRmb' },
{ title: '实际采购数', field: 'materialRealNum"' },
{ title: '实际不含税采购金额', field: 'materialRealNoRmb' },
{ title: '实际含税采购金额', field: 'materialRealRmb' },
{ title: '已入库数', field: 'actualHasArrivedNum' },
]
});
$tableWrapper.append($header).append($table);
$('#supplierMaterial').append($tableWrapper);
}
// 新增函数:重新计算某物料的采购数量合计、不含税采购总价和含税采购总价
function recalculateTotals(tableId) {
var $tableWrapper = $('#material-' + tableId);
var totalNoRmb = 0;
var totalRmb = 0;
var totalActualPurchase = 0;
var $suplierInfo = $tableWrapper.find('.supplier-card');
//获取所有物料表中供应商列表数据,实际采购数合计,不含税总价,含税采购总价
$suplierInfo.find('.supplier_card').each(function() {
let purchaseNum = parseFloat($(this).find('.actualPurchaseNum').val()) || 0;
let noRmbPrice = parseFloat($(this).find('.supplierMaterialNoRmb').text().trim()) || 0;
let rmbPrice = parseFloat($(this).find('.supplierMaterialRmb').text().trim()) || 0;
totalNoRmb += purchaseNum * noRmbPrice;
totalRmb += purchaseNum * rmbPrice;
totalActualPurchase = totalActualPurchase + purchaseNum;
});
//物料的实际采购数合计
$('#materialAmountSum_' + tableId).val(totalActualPurchase);
//物料的实际不含税采购总价:
$('#materialNoRmbSum_' + tableId).val(parseFloat(totalNoRmb));
//物料的实际含税总价:
$('#materialRmbSum_' + tableId).val(parseFloat(totalRmb));
// 采购物料合计
materialActualPurchaseSum();
}
function materialActualPurchaseSum(){
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(materialAmount);
//采购数量合计
$('#purchaseSum').val(totalActualPurchase);
//采购不含税总价
$('#purchaseNoRmbSum').val(totalNoRmb);
//采购含税总价
$('#purchaseRmbSum').val(totalRmb);
}
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>');
}); // 遍历返回的数据,添加为下拉框的选项
} 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('查询仓库名称时发生错误!');
}
});
}
else {$('input[name="warehouseName"]').val('');}// 如果没有选择仓库ID,清空仓库名称输入框
});
function submitHandler() { function submitHandler() {
if ($.validate.form()) { if ($.validate.form()) {
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 taskId = [[${taskId}]];
$.operate.save(prefix + "/complete/" + taskId, $('#form-cgzg-edit').serialize()); $.operate.save(prefix + "/complete/" + taskId, $('#form-purchaseOrder-cgzg').serialize());
} }
} }
</script> </script>
</body> </body>
</html> </html>

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

@ -1,45 +1,129 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.w3.org/1999/xhtml"> <html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.w3.org/1999/xhtml">
<head> <head>
<th:block th:include="include :: header('副总经理审核')" /> <th:block th:include="include :: header('采购主管审核')" />
<th:block th:include="include :: select2-css" /> <th:block th:include="include :: select2-css" />
<style>
.fixed-table-container {
border: 0px solid #ddd;
min-height: 110px;
}
</style>
</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-fzjl-edit" th:object="${formData}"> <form class="form-horizontal m" id="form-purchaseOrder-fzjl" th:object="${formData}">
<input name="purchaseOrderId" th:field="*{purchaseOrderId}" type="hidden"> <input name="purchaseOrderId" th:field="*{purchaseOrderId}" type="hidden">
<input name="purchaseOrderCode" th:field="*{purchaseOrderCode}" 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">
<input name="instanceId" th:field="*{instanceId}" type="hidden"> <input name="instanceId" th:field="*{instanceId}" type="hidden">
<input name="instanceType" th:field="*{instanceType}" type="hidden"> <input name="instanceType" th:field="*{instanceType}" type="hidden">
<input type="hidden" name="p_COM_comment" /> <input type="hidden" name="p_COM_comment" />
<div class="form-group" hidden="hidden">
<div class="form-group">
<label class="col-sm-6 control-label">采购单号:</label>
<div class="col-sm-6">
<input name="purchaseOrderCode" th:field="*{purchaseOrderCode}" class="form-control" type="text" readonly>
</div>
</div>
<div class="form-group">
<label class="col-sm-6 control-label">申请人:</label> <label class="col-sm-6 control-label">申请人:</label>
<div class="col-sm-6"> <div class="col-sm-6">
<input name="applyUser" th:field="*{applyUser}" class="form-control" type="text" readonly> <input name="applyUser" th:field="*{applyUser}" class="form-control" type="text" disabled>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group" hidden="hidden">
<label class="col-sm-6 control-label">申请时间:</label> <label class="col-sm-6 control-label">申请时间:</label>
<div class="col-sm-6"> <div class="col-sm-6">
<div class="input-group date"> <div class="input-group date">
<input name="applyTime" th:value="${#dates.format(formData.applyTime, 'yyyy-MM-dd HH:mm')}" class="form-control" type="text" readonly> <input name="applyTime" th:value="${#dates.format(formData.applyTime, 'yyyy-MM-dd HH:mm')}" class="form-control" type="text" disabled>
<span class="input-group-addon" disabled><i class="fa fa-calendar"></i></span> <span class="input-group-addon" disabled><i class="fa fa-calendar"></i></span>
</div> </div>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group" hidden="hidden">
<label class="col-sm-6 control-label">标题:</label> <label class="col-sm-6 control-label">标题:</label>
<div class="col-sm-6"> <div class="col-sm-6">
<input name="title" th:field="*{applyTitle}" class="form-control" type="text" readonly> <input name="title" th:field="*{applyTitle}" class="form-control" type="text" disabled>
</div>
</div>
<div class="col-xs-12">
<label class="col-sm-4 control-label">已选择采购计划:</label>
<div class="col-sm-7">
<input id="purchasePlanCodes" name="purchasePlanCode" class="form-control" type="text" disabled/>
</div>
</div>
<div class="container">
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" ><a href="#supplierModel" aria-controls="supplierModel" role="tab" data-toggle="tab">按供应商展示</a></li>
<li role="presentation" class="active"><a href="#purchasePlanModel" aria-controls="purchasePlanModel" role="tab" data-toggle="tab">按采购计划展示</a></li>
</ul>
<div class="tab-content">
<div role="tabpanel" class="tab-pane " id="supplierModel">
<div class="container" id="supplierMaterial">
</div>
</div>
<div role="tabpanel" class="tab-pane active" id="purchasePlanModel">
<div class="container" id="purchasePlanMaterial">
</div>
</div>
</div>
</div>
<div class="container">
<div class="row"><h4 class="card-header">公司地址:</h4></div>
<div class="col-xs-6">
<label for="stockNo" class="col-sm-6 col-form-label">仓库ID:</label>
<div class="col-sm-5">
<select class="form-control" name="stockNo" id="stockNo" disabled ></select>
</div>
</div>
<div class="col-xs-6">
<label for="stockName" class="col-sm-6 col-form-label">仓库名称:</label>
<div class="col-sm-5">
<input type="text" class="form-control" name="stockName" id="stockName" disabled/>
</div>
</div>
<div class="col-xs-6">
<label for="stockContact" class="col-sm-6 col-form-label">收货人:</label>
<div class="col-sm-5">
<input type="text" name="stockContact" class="form-control" id="stockContact" disabled />
</div>
</div>
<div class="col-xs-6">
<label for="stockPhone" class="col-sm-6 col-form-label">收货电话:</label>
<div class="col-sm-5">
<input type="text" name="stockPhone" class="form-control" id="stockPhone" placeholder="请输入收货电话" disabled />
</div>
</div>
<div class="col-xs-6">
<label for="stockAddress" class="col-sm-6 col-form-label">详细地址:</label>
<div class="col-sm-5">
<textarea class="form-control" name="stockAddress" id="stockAddress" disabled></textarea>
</div>
</div>
</div>
<div class="container">
<div class="row"><h4 class="card-header">订单合计:</h4></div>
<div class="col-xs-6">
<label for="purchaseMaterialSum" class="col-sm-6 col-form-label">物料合计:</label>
<div class="col-sm-5">
<input type="text" class="form-control" id="purchaseMaterialSum" disabled />
</div>
</div>
<div class="col-xs-6">
<label for="purchaseSum" class="col-sm-6 col-form-label">采购合计:</label>
<div class="col-sm-5">
<input type="text" class="form-control" id="purchaseSum" disabled />
</div>
</div>
<div class="col-xs-6">
<label for="purchaseNoRmbSum" class="col-sm-5 col-form-label">不含税采购总价:</label>
<div class="col-sm-6">
<input type="text" class="form-control" id="purchaseNoRmbSum" disabled />
</div>
</div>
<div class="col-xs-6">
<label for="purchaseRmbSum" class="col-sm-5 col-form-label">含税采购总价:</label>
<div class="col-sm-6">
<input type="text" class="form-control" id="purchaseRmbSum" disabled />
</div>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
@ -59,6 +143,7 @@
</div> </div>
</div> </div>
</form> </form>
</div> </div>
<th:block th:include="include :: footer" /> <th:block th:include="include :: footer" />
<th:block th:include="include :: select2-js" /> <th:block th:include="include :: select2-js" />
@ -66,17 +151,469 @@
<script th:inline="javascript"> <script th:inline="javascript">
var prefix = ctx + "purchase/purchaseOrder"; var prefix = ctx + "purchase/purchaseOrder";
var purchaseOrder = [[${formData}]]; var purchaseOrder = [[${formData}]];
$("#form-fzjl-edit").validate({focusCleanup: true}); var materialTypeDatas = [[${@category.getChildByCode('materialType')}]];
var auditStatusDatas = [[${@dict.getType('auditStatus')}]];
var sysUnitClassDatas = [[${@dict.getType('sys_unit_class')}]];
var processMethodDatas = [[${@dict.getType('processMethod')}]];
var warehouseDeptDatas = [[${@dict.getType('warehouseDept')}]];
var loginName = [[${@permission.getPrincipalProperty('loginName')}]];
$("#form-purchaseOrder-fzjl").validate({focusCleanup: true});
var purchasePlanChildList = [];
var purchasePlanCodes = [];
var formId = "form-purchaseOrder-fzjl";
//根据物料物料数量添加物料分类表,自动生成类似的表单对象
//初始根据采购计划单,涉及到物料做分类表
//根据采购计划单,获取物料信息,自动生成物料的供应商分类表
//获取表单的id;
var materialList = [];
var tableIdList = [];
var $supplierForm;
var tableDatas = [];
//获取采购计划单的物料信息
// 假设qualityOrderCode已经定义或者可以通过某种方式获取到
$(function() {
// 初始化时默认加载仓库ID列表
// 假设purchaseOrderCode已经定义或者可以通过某种方式获取到
var purchaseOrderCode = [[${formData.purchaseOrderCode}]]; // 这里需要实际赋值,比如从前端某个地方读取
var purchaseOrderId = [[${formData.purchaseOrderId}]];
// 初始化表格,假设purchasePlanChildList已定义并包含了需要处理的数据
$.getJSON(prefix + "/editPurchaserOrder/" + purchaseOrderId, function(data) {
$("#purchasePlanCodes").val(data.data.purchasePlanCodes);
var datas = data.data.purchasePlanChildList;
purchasePlanChildList = datas;
var supplierCodes = data.data.supplierCodes;
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);
}
}
loadWarehouseCodes();
//物料合计 = 物料实际采购数合计,不含税总价,含税采购总价不为null的情况可以合计物料,否则跳过
$("#purchaseMaterialSum").val(purchaseOrder.materialSum);
//采购数量合计
$('#purchaseSum').val(purchaseOrder.materialSum);
//采购不含税总价
$('#purchaseNoRmbSum').val(purchaseOrder.noRmbSum);
//采购含税总价
$('#purchaseRmbSum').val(purchaseOrder.rmbSum);
$('#stockNo').val(purchaseOrder.stockNo);
//按照物料的维度查看采购订单信息
// 初始化表格
// 假设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 + '" 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) {
var tableId = 'bootstrap-table-' + supplierCode.replace(/[^a-z0-9]/gi, '_').toLowerCase();
tableDatas.push(tableId);
var $tableWrapper = $('<div class="table-responsive"></div>');
// 确保supplierData至少有一条记录,并从中提取供应商详细信息
var supplierInfo = supplierData.length > 0 ? supplierData[0] : {}; // 默认为空对象,以防数据不存在
// 构建含有额外供应商信息的标题字符串
var headerTitle = '供应商: ' + supplierCode + ' - ' + supplierInfo.supplierName;
var $header = $('<h4>' + headerTitle + '</h4>');
var $table = $('<table id="' + tableId + '" class="table table-striped table-bordered"></table>');
$table.bootstrapTable({
data: supplierData,
columns: [
{ checkbox: false, visible: false },
{ title: '供应商ID', field: 'supplierCode', visible: false },
{ title: '料号', field: 'materialCode' },
{ title: '图片', field: 'materialPhotoUrl', 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: 'materialDescribe' },
{ title: '品牌', field: 'materialBrand' },
{ title: '加工类型', field: 'materialProcessMethod', align: 'center', formatter: function(value, row, index) {
return $.table.selectDictLabel(processMethodDatas, value);
}
},
{ title: '单位', field: 'materialUnit', align: 'center' },
{ title: '入库部门', field: 'warehouseDept', align: 'center', formatter: function(value, row, index) {
return $.table.selectDictLabel(warehouseDeptDatas, value);
}
},
{ title: '计划采购数', field: 'materialNum' },
{ title: '币种', field: '' },
{ title: '不含税采购价', field: 'materialNoRmb' },
{ title: '含税采购价', field: 'materialRmb' },
{ title: '实际采购数', field: 'materialRealNum"' },
{ title: '实际不含税采购金额', field: 'materialRealNoRmb' },
{ title: '实际含税采购金额', field: 'materialRealRmb' },
{ title: '已入库数', field: 'actualHasArrivedNum' },
]
});
$tableWrapper.append($header).append($table);
$('#supplierMaterial').append($tableWrapper);
}
// 新增函数:重新计算某物料的采购数量合计、不含税采购总价和含税采购总价
function recalculateTotals(tableId) {
var $tableWrapper = $('#material-' + tableId);
var totalNoRmb = 0;
var totalRmb = 0;
var totalActualPurchase = 0;
var $suplierInfo = $tableWrapper.find('.supplier-card');
//获取所有物料表中供应商列表数据,实际采购数合计,不含税总价,含税采购总价
$suplierInfo.find('.supplier_card').each(function() {
let purchaseNum = parseFloat($(this).find('.actualPurchaseNum').val()) || 0;
let noRmbPrice = parseFloat($(this).find('.supplierMaterialNoRmb').text().trim()) || 0;
let rmbPrice = parseFloat($(this).find('.supplierMaterialRmb').text().trim()) || 0;
totalNoRmb += purchaseNum * noRmbPrice;
totalRmb += purchaseNum * rmbPrice;
totalActualPurchase = totalActualPurchase + purchaseNum;
});
//物料的实际采购数合计
$('#materialAmountSum_' + tableId).val(totalActualPurchase);
//物料的实际不含税采购总价:
$('#materialNoRmbSum_' + tableId).val(parseFloat(totalNoRmb));
//物料的实际含税总价:
$('#materialRmbSum_' + tableId).val(parseFloat(totalRmb));
// 采购物料合计
materialActualPurchaseSum();
}
function materialActualPurchaseSum(){
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(materialAmount);
//采购数量合计
$('#purchaseSum').val(totalActualPurchase);
//采购不含税总价
$('#purchaseNoRmbSum').val(totalNoRmb);
//采购含税总价
$('#purchaseRmbSum').val(totalRmb);
}
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>');
}); // 遍历返回的数据,添加为下拉框的选项
} 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('查询仓库名称时发生错误!');
}
});
}
else {$('input[name="warehouseName"]').val('');}// 如果没有选择仓库ID,清空仓库名称输入框
});
function submitHandler() { function submitHandler() {
if ($.validate.form()) { if ($.validate.form()) {
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 taskId = [[${taskId}]];
$.operate.save(prefix + "/complete/" + taskId, $('#form-fzjl-edit').serialize()); $.operate.save(prefix + "/complete/" + taskId, $('#form-purchaseOrder-fzjl').serialize());
} }
} }
</script> </script>
</body> </body>
</html> </html>

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

@ -3,7 +3,15 @@
<head> <head>
<th:block th:include="include :: header('驳回调整')" /> <th:block th:include="include :: header('驳回调整')" />
<th:block th:include="include :: select2-css" /> <th:block th:include="include :: select2-css" />
<th:block th:include="include :: datetimepicker-css" />
<th:block th:include="include :: bootstrap-editable-css" />
<link th:href="@{/ajax/libs/element-ui/element-ui.css}" rel="stylesheet"/> <link th:href="@{/ajax/libs/element-ui/element-ui.css}" rel="stylesheet"/>
<style>
.fixed-table-container {
border: 0px solid #ddd;
min-height: 120px;
}
</style>
</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">
@ -36,6 +44,91 @@
<input name="title" th:field="*{applyTitle}" class="form-control" type="text" readonly> <input name="title" th:field="*{applyTitle}" class="form-control" type="text" readonly>
</div> </div>
</div> </div>
<div class="col-xs-12">
<label class="col-sm-4 control-label">已选择采购计划:</label>
<div class="col-sm-7">
<input id="purchasePlanCodes" name="purchasePlanCode" class="form-control" type="text" disabled/>
</div>
</div>
<div class="container">
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" ><a href="#supplierModel" aria-controls="supplierModel" role="tab" data-toggle="tab">按供应商展示</a></li>
<li role="presentation" class="active"><a href="#purchasePlanModel" aria-controls="purchasePlanModel" role="tab" data-toggle="tab">按采购计划展示</a></li>
</ul>
<div class="tab-content">
<div role="tabpanel" class="tab-pane " id="supplierModel">
<div class="container" id="supplierMaterial">
</div>
</div>
<div role="tabpanel" class="tab-pane active" id="purchasePlanModel">
<div class="container" id="purchasePlanMaterial">
</div>
</div>
</div>
</div>
<div class="container">
<div class="row"><h4 class="card-header">公司地址:</h4></div>
<div class="col-xs-6">
<label for="stockNo" class="col-sm-6 col-form-label">仓库ID:</label>
<div class="col-sm-5">
<select class="form-control" name="stockNo" id="stockNo" disabled ></select>
</div>
</div>
<div class="col-xs-6">
<label for="stockName" class="col-sm-6 col-form-label">仓库名称:</label>
<div class="col-sm-5">
<input type="text" class="form-control" name="stockName" id="stockName" disabled/>
</div>
</div>
<div class="col-xs-6">
<label for="stockContact" class="col-sm-6 col-form-label">收货人:</label>
<div class="col-sm-5">
<input type="text" name="stockContact" class="form-control" id="stockContact" disabled />
</div>
</div>
<div class="col-xs-6">
<label for="stockPhone" class="col-sm-6 col-form-label">收货电话:</label>
<div class="col-sm-5">
<input type="text" name="stockPhone" class="form-control" id="stockPhone" placeholder="请输入收货电话" disabled />
</div>
</div>
<div class="col-xs-6">
<label for="stockAddress" class="col-sm-6 col-form-label">详细地址:</label>
<div class="col-sm-5">
<textarea class="form-control" name="stockAddress" id="stockAddress" disabled></textarea>
</div>
</div>
</div>
<div class="container">
<div class="row"><h4 class="card-header">订单合计:</h4></div>
<div class="col-xs-6">
<label for="purchaseMaterialSum" class="col-sm-6 col-form-label">物料合计:</label>
<div class="col-sm-5">
<input type="text" class="form-control" id="purchaseMaterialSum" disabled />
</div>
</div>
<div class="col-xs-6">
<label for="purchaseSum" class="col-sm-6 col-form-label">采购合计:</label>
<div class="col-sm-5">
<input type="text" class="form-control" id="purchaseSum" disabled />
</div>
</div>
<div class="col-xs-6">
<label for="purchaseNoRmbSum" class="col-sm-5 col-form-label">不含税采购总价:</label>
<div class="col-sm-6">
<input type="text" class="form-control" id="purchaseNoRmbSum" disabled />
</div>
</div>
<div class="col-xs-6">
<label for="purchaseRmbSum" class="col-sm-5 col-form-label">含税采购总价:</label>
<div class="col-sm-6">
<input type="text" class="form-control" id="purchaseRmbSum" disabled />
</div>
</div>
</div>
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label" for="reApply">是否继续申请:</label> <label class="col-sm-3 control-label" for="reApply">是否继续申请:</label>
<div class="col-sm-8"> <div class="col-sm-8">

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

@ -10,6 +10,10 @@
background-color: #f9f9f9; background-color: #f9f9f9;
} }
.inventory-count p {margin: 0;} .inventory-count p {margin: 0;}
.fixed-table-container {
border: 0px solid #ddd;
min-height: 120px;
}
/*.inventory-count span {font-weight: bold;}*/ /*.inventory-count span {font-weight: bold;}*/
</style> </style>
</head> </head>
@ -29,33 +33,33 @@
<div class="container"> <div class="container">
<div class="row"><h4 class="card-header">公司地址:</h4></div> <div class="row"><h4 class="card-header">公司地址:</h4></div>
<div class="form-group"> <div class="form-group">
<label for="stockNo" class="col-sm-2 col-form-label">仓库ID:</label> <label for="stockNo" class="col-sm-2 col-form-label is-required">仓库ID:</label>
<div class="col-sm-4"> <div class="col-sm-4">
<select class="form-control" name="stockNo" id="stockNo" ></select> <select class="form-control" name="stockNo" id="stockNo" required></select>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="stockName" class="col-sm-2 col-form-label">仓库名称:</label> <label for="stockName" class="col-sm-2 col-form-label is-required">仓库名称:</label>
<div class="col-sm-4"> <div class="col-sm-4">
<input type="text" class="form-control" name="stockName" id="stockName"> <input type="text" class="form-control" name="stockName" id="stockName" required>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="stockContact" class="col-sm-2 col-form-label">收货人:</label> <label for="stockContact" class="col-sm-2 col-form-label">收货人:</label>
<div class="col-sm-4"> <div class="col-sm-4">
<input type="text" name="stockContact" class="form-control" id="stockContact" > <input type="text" name="stockContact" class="form-control" id="stockContact" readonly>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="stockPhone" class="col-sm-2 col-form-label">收货电话:</label> <label for="stockPhone" class="col-sm-2 col-form-label">收货电话:</label>
<div class="col-sm-4"> <div class="col-sm-4">
<input type="text" name="stockPhone" class="form-control" id="stockPhone" placeholder="请输入收货电话"> <input type="text" name="stockPhone" class="form-control" id="stockPhone" placeholder="请输入收货电话" readonly>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="stockAddress" class="col-sm-2 col-form-label">详细地址:</label> <label for="stockAddress" class="col-sm-2 col-form-label">详细地址:</label>
<div class="col-sm-4"> <div class="col-sm-4">
<textarea class="form-control" name="stockAddress" id="stockAddress"></textarea> <textarea class="form-control" name="stockAddress" id="stockAddress" readonly></textarea>
</div> </div>
</div> </div>
</div> </div>
@ -64,25 +68,25 @@
<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="number" class="form-control" value="0" id="purchaseMaterialSum"> <input type="number" class="form-control" value="0" id="purchaseMaterialSum" readonly>
</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="number" class="form-control" value="0" id="purchaseSum"> <input type="number" class="form-control" value="0" id="purchaseSum" readonly>
</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="number" class="form-control" value="0" id="purchaseNoRmbSum"> <input type="number" class="form-control" value="0" id="purchaseNoRmbSum" readonly>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="purchaseRmbSum" class="col-sm-2 col-form-label">含税采购总价:</label> <label for="purchaseRmbSum" class="col-sm-2 col-form-label">含税采购总价:</label>
<div class="col-sm-4"> <div class="col-sm-4">
<input type="number" class="form-control" value="0" id="purchaseRmbSum"> <input type="number" class="form-control" value="0" id="purchaseRmbSum" readonly>
</div> </div>
</div> </div>
</div> </div>
@ -142,10 +146,10 @@
$tableWrapper.append($headerDiv); $tableWrapper.append($headerDiv);
//创建物料库存容器 //创建物料库存容器
var $stockWrapper = $('<div class="row">' + var $stockWrapper = $('<div class="row">' +
'<div class="inventory-count " id=" inventory-count-' + tableId + '">'+ '<h4 class="inventory-count " id=" inventory-count-' + tableId + '">'+
'<span><strong>可用库存数:</strong></span>'+'<span id="stock-count-' + tableId + '">10 </span>'+'<span>注:含其他订单待领取的库存,仅供参考,请以实际为准.</span>'+ '<span><strong>可用库存数:</strong></span>'+'<span id="stock-count-' + tableId + '">10 </span>'+'<span> 注:含其他订单待领取的库存,仅供参考,请以实际为准.</span>'+
'</div>' + '</h4>' +
'</div>'); '</div>');
$tableWrapper.append($stockWrapper); $tableWrapper.append($stockWrapper);
var materialObj = { var materialObj = {
purchasePlanCode: material.purchasePlanCode, purchasePlanCode: material.purchasePlanCode,
@ -185,36 +189,39 @@
// 构建供应商信息头部 // 构建供应商信息头部
var $headerContent = var $headerContent =
$('<div class="card-header supplier_card" id = "supplier-' + tableId + '_' + supplierIndex + '">' + $('<div class="card-header supplier_card" id = "supplier-' + tableId + '_' + supplierIndex + '">' +
'<div class="row">' + '<div class="row">' +
'<div class="crad-text">'+ '<div class="crad-text">'+
'<h4>供应商 ' + (supplierIndex + 1) + ':' + '</h4>' + '<h4>'+
'<span class="supplierCode">' + supplier.supplierCode + '</span>' + '-' + '<span>供应商 ' + (supplierIndex + 1) + ':' + '</span>' +
'<span class="supplierName">' + supplier.supplierName + '</span>' + '<span class="supplierCode">' + supplier.supplierCode + '</span>' + '-' +
'-最新不含税采购价: ' +'<span id="supplierMaterialNoRmb-' + tableId + '" class="supplierMaterialNoRmb">' + supplier.materialNoRmb +'</span>'+ '<span class="supplierName">' + supplier.supplierName + '</span>' +
' RMB 最新含税采购价: ' +'<span class="supplierMaterialRmb">' + supplier.materialRmb + '</span> RMB ' + '-最新不含税采购价: ' +'<span id="supplierMaterialNoRmb-' + tableId + '" class="supplierMaterialNoRmb">' + supplier.materialNoRmb +'</span>'+
'<span class="supplierPurchasePlanCode" hidden="hidden" >' + material.planCodes + '</span>' + ' RMB 最新含税采购价: ' +'<span class="supplierMaterialRmb">' + supplier.materialRmb + '</span> RMB ' +
'<span class="supplierCorrelationCode" hidden="hidden" >' + material.correlationCodes + '</span>' + '<span class="supplierPurchasePlanCode" hidden="hidden" >' + material.planCodes + '</span>' +
'<span class="supplierPurchaseQuoteCode" hidden="hidden" >' + supplier.purchaseQuoteCode + '</span>' + '<span class="supplierCorrelationCode" hidden="hidden" >' + material.correlationCodes + '</span>' +
'</div>' + '<span class="supplierPurchaseQuoteCode" hidden="hidden" >' + supplier.purchaseQuoteCode + '</span>' +
'</h4>' +
'</div>' +
'</div>' +
'<div class="row">' +
'<div class="col-xs-6">' +
'<label class="col-sm-4 is-required"> 实际采购数: </label>' +
'<div class ="col-sm-6">' +
'<input type="text" name="materialNum" class="form-control supplierMaterialNum actualPurchaseNum" id="actualPurchaseNum_' + tableId + '" required />' +
'</div>' + '</div>' +
'<div class="row">' + '</div>' +
'<div class="col-xs-6 form-group">' + '<div class="col-xs-6">' +
'<label class="col-sm-4"> 实际采购数: </label>' + '<label class="col-sm-4 is-required">计划交付时间: </label>' +
'<div class ="col-sm-6">' + '<div class ="col-sm-6">' +
'<input type="text" name="materialNum" class="form-control supplierMaterialNum actualPurchaseNum" id="actualPurchaseNum_' + tableId + '">' + '<div class="input-group date"> ' +
'</div>' + '<input type="text" name="deliveryTime" class="form-control supplierDeliveryTime" id="deliveryTime_' + tableId + '" required />' +
'</div>' + '<span class="input-group-addon"><i class="fa fa-calendar"></i></span>' +
'<div class="col-xs-6 form-group">' + '</div> ' +
'<label class="col-sm-4">计划交付时间: </label>' +
'<div class ="col-sm-6">' +
'<div class="input-group date"> ' +
'<input type="text" name="deliveryTime" class="form-control supplierDeliveryTime" id="deliveryTime_' + tableId + '">' +
'<span class="input-group-addon"><i class="fa fa-calendar"></i></span>' +
'</div> ' +
'</div>' +
'</div>' +
'</div>' + '</div>' +
'</div>'); '</div>' +
'</div>' +
'</div>');
if (supplier.supplierCode != undefined && supplier.supplierCode != '' && supplier.supplierCode != null) { if (supplier.supplierCode != undefined && supplier.supplierCode != '' && supplier.supplierCode != null) {
$supplierInfo.append($headerContent); $supplierInfo.append($headerContent);
// 构建供应商信息下的输入表单 // 构建供应商信息下的输入表单
@ -340,28 +347,27 @@
$('#purchaseRmbSum').val(totalRmb); $('#purchaseRmbSum').val(totalRmb);
} }
function tableSetup(element, tableId) { function tableSetup(element, tableId) {
var $totalSection = $( var $totalSection = $('<div class="card">' +
'<div class="card">' + '<div class="card-body" class="supplierTotal_' + tableId + '">' +
'<div class="card-body" class="supplierTotal_' + tableId + '">' + '<div class="col-xs-4">' +
'<div class="form-row">' + '<label for="actualPurchaseTotal" class="col-sm-5">实际采购数合计:</label>' +
'<label for="actualPurchaseTotal" class="col-sm-4">实际采购数合计:</label>' + '<div class="col-sm-6">' +
'<div class="col-sm-8">' + '<input type="number" name="materialAmountSum" class="form-control actualPurchaseTotalSum" id="materialAmountSum_' + tableId + '" >' +
'<input type="number" name="materialAmountSum" class="form-control actualPurchaseTotalSum" id="materialAmountSum_' + tableId + '">' + '</div>' +
'</div>' + '</div>' +
'</div>' + '<div class="col-xs-4">' +
'<div class="form-row">' + '<label for="actualPurchaseTotal" class="col-sm-5">不含税采购总价:</label>' +
'<label for="actualPurchaseTotal" class="col-sm-4">不含税采购总价:</label>' + '<div class="col-sm-6">' +
'<div class="col-sm-8">' + '<input type="number" name="materialNoRmbSum" class="form-control actualPurchaseTotal" id="materialNoRmbSum_' + tableId + '" >' +
'<input type="number" name="materialNoRmbSum" class="form-control actualPurchaseTotal" id="materialNoRmbSum_' + tableId + '" ' + '</div>' +
'</div>' + '</div>' +
'</div>' + '<div class="col-xs-4">' +
'<div class="form-row">' + '<label for="actualPurchaseTotalTax" class="col-sm-5">含税采购总价:</label>' +
'<label for="actualPurchaseTotalTax" class="col-sm-4">含税采购总价:</label>' + '<div class="col-sm-6">' +
'<div class="col-sm-8">' + '<input type="number" name="materialRmbSum" class="form-control actualPurchaseTotalTax" id="materialRmbSum_' + tableId + '" >' +
'<input type="number" name="materialRmbSum" class="form-control actualPurchaseTotalTax" id="materialRmbSum_' + tableId + '">' + '</div>' +
'</div>' + '</div>' +
'</div>' + '</div>'+
'</div>'+
'</div>'); '</div>');
element.append($totalSection); element.append($totalSection);
} }
@ -431,9 +437,9 @@
var materialRealNum = parseInt($(this).find('.actualPurchaseNum' ).val()) || 0; var materialRealNum = parseInt($(this).find('.actualPurchaseNum' ).val()) || 0;
var materialRealRmb = parseFloat($(this).find('.supplierMaterialRmb').text()) || 0; var materialRealRmb = parseFloat($(this).find('.supplierMaterialRmb').text()) || 0;
var materialRealNoRmb = parseFloat($(this).find('.supplierMaterialNoRmb').text()) || 0; var materialRealNoRmb = parseFloat($(this).find('.supplierMaterialNoRmb').text()) || 0;
var deliveryTime = $(this).find('.supplierDeliveryTime' ).val(); var deliveryTime = $(this).find('.supplierDeliveryTime').val();
var purchasePlanCode = $(this).find('.supplierPurchasePlanCode').text().trim(); var purchasePlanCode = $(this).find('.supplierPurchasePlanCode').text().trim();
var correlationCode = $(this).find('.supplierCorrelationCode' ).text().trim(); var correlationCode = $(this).find('.supplierCorrelationCode').text().trim();
var purchaseQuoteCode = $(this).find('.supplierPurchaseQuoteCode').text().trim(); var purchaseQuoteCode = $(this).find('.supplierPurchaseQuoteCode').text().trim();
var materialRealRmbSum = parseFloat(materialRealRmb * materialRealNum); var materialRealRmbSum = parseFloat(materialRealRmb * materialRealNum);
var materialRealNoRmbSum = parseFloat(materialRealNoRmb * materialRealNum); var materialRealNoRmbSum = parseFloat(materialRealNoRmb * materialRealNum);

Loading…
Cancel
Save