Browse Source

[feat]: 修改:采购计划转采购订单新增时采购订单的供应商报价从手动点击enter键计算,改为实际采购数失去焦点计算。

修改:采购订单审核通过时,新增应付账款信息,根据供应商合计生成。
   修改:采购订单获取供应商采购通过的物料报价价格,查询最新供应商对该物料。
   修改:副经理审核页面,新采购订单所有价格计算最多只保留两位小数。
   修改:供应商根据供应商编号查询新增条件为审核通过的正在使用的供应商资料。
dev
zhangsiqi 3 months ago
parent
commit
f1950aca29
  1. 2
      ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseOrderController.java
  2. 7
      ruoyi-admin/src/main/java/com/ruoyi/purchase/domain/PurchaseOrder.java
  3. 18
      ruoyi-admin/src/main/java/com/ruoyi/purchase/domain/PurchaseOrderChild.java
  4. 47
      ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchaseOrderServiceImpl.java
  5. 2
      ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysSupplierServiceImpl.java
  6. 2
      ruoyi-admin/src/main/resources/mapper/system/SysSupplierMapper.xml
  7. 20
      ruoyi-admin/src/main/resources/templates/purchase/purchaseOrder/detail.html
  8. 6
      ruoyi-admin/src/main/resources/templates/purchase/purchaseOrder/purchaseOrder.html
  9. 22
      ruoyi-admin/src/main/resources/templates/purchase/purchaseOrder/taskCgjlVerify.html
  10. 18
      ruoyi-admin/src/main/resources/templates/purchase/purchaseOrder/taskCgzgVerify.html
  11. 18
      ruoyi-admin/src/main/resources/templates/purchase/purchaseOrder/taskFzjlVerify.html
  12. 561
      ruoyi-admin/src/main/resources/templates/purchase/purchaseOrder/taskModifyApply.html

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

@ -44,6 +44,7 @@ import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.ModelMap;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
@ -336,6 +337,7 @@ public class PurchaseOrderController extends BaseController
* @return
*/
@RequestMapping(value = "/complete/{taskId}", method = {RequestMethod.POST, RequestMethod.GET})
@Transactional(rollbackFor = Exception.class)
@ResponseBody
public AjaxResult complete(@PathVariable("taskId") String taskId, @RequestParam(value = "saveEntity", required = false) String saveEntity,
@ModelAttribute("preloadObj") PurchaseOrderVo purchaseOrderVo, HttpServletRequest request) {

7
ruoyi-admin/src/main/java/com/ruoyi/purchase/domain/PurchaseOrder.java

@ -4,6 +4,7 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import org.apache.poi.hpsf.Decimal;
import java.math.BigDecimal;
import java.util.Date;
@ -41,7 +42,7 @@ public class PurchaseOrder extends BaseEntity
@Excel(name="物料合计")
private Integer materialAmount;
@Excel(name="数量合计")
private Integer materialSum;
private BigDecimal materialSum;
@Excel(name="不含税总价(RMB)")
private BigDecimal noRmbSum;
@Excel(name="含税总价")
@ -266,11 +267,11 @@ public class PurchaseOrder extends BaseEntity
this.materialAmount = materialAmount;
}
public Integer getMaterialSum() {
public BigDecimal getMaterialSum() {
return materialSum;
}
public void setMaterialSum(Integer materialSum) {
public void setMaterialSum(BigDecimal materialSum) {
this.materialSum = materialSum;
}

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

@ -77,7 +77,7 @@ public class PurchaseOrderChild extends BaseEntity
/** 采购物料数量 */
@Excel(name = "计划采购物料数量")
private Long materialNum;
private BigDecimal materialNum;
/** 物料合计 */
@Excel(name = "物料合计")
@ -85,7 +85,7 @@ public class PurchaseOrderChild extends BaseEntity
/** 数量合计 */
@Excel(name = "数量合计")
private Long materialSum;
private BigDecimal materialSum;
/** 不含税总价(RMB) */
@Excel(name = "不含税总价(RMB)")
@ -97,7 +97,7 @@ public class PurchaseOrderChild extends BaseEntity
/*关联采购计划的关联单号*/
private String purchasePlanCorrelationCode;
@Excel(name="实际采购数")
private Long materialRealNum;
private BigDecimal materialRealNum;
@Excel(name="实际采购不含税单价")
private BigDecimal materialRealNoRmb;
@Excel(name="实际采购含税单价")
@ -268,12 +268,12 @@ public class PurchaseOrderChild extends BaseEntity
{
return materialRmb;
}
public void setMaterialNum(Long materialNum)
public void setMaterialNum(BigDecimal materialNum)
{
this.materialNum = materialNum;
}
public Long getMaterialNum()
public BigDecimal getMaterialNum()
{
return materialNum;
}
@ -286,12 +286,12 @@ public class PurchaseOrderChild extends BaseEntity
{
return materialAmount;
}
public void setMaterialSum(Long materialSum)
public void setMaterialSum(BigDecimal materialSum)
{
this.materialSum = materialSum;
}
public Long getMaterialSum()
public BigDecimal getMaterialSum()
{
return materialSum;
}
@ -400,11 +400,11 @@ public class PurchaseOrderChild extends BaseEntity
this.purchasePlanCorrelationCode = purchasePlanCorrelationCode;
}
public Long getMaterialRealNum() {
public BigDecimal getMaterialRealNum() {
return materialRealNum;
}
public void setMaterialRealNum(Long materialRealNum) {
public void setMaterialRealNum(BigDecimal materialRealNum) {
this.materialRealNum = materialRealNum;
}

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

@ -25,6 +25,7 @@ import com.ruoyi.common.utils.file.FileUploadUtils;
import com.ruoyi.erp.domain.ErpDevelopModifyorder;
import com.ruoyi.erp.mapper.ErpDevelopModifyorderMapper;
import com.ruoyi.financial.domain.FinancialAccountsPayable;
import com.ruoyi.financial.mapper.FinancialAccountsPayableMapper;
import com.ruoyi.financial.service.IFinancialAccountsPayableService;
import com.ruoyi.process.general.service.IProcessService;
import com.ruoyi.process.todoitem.mapper.BizTodoItemMapper;
@ -60,6 +61,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.ServletOutputStream;
@ -129,7 +131,7 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
private PurchasePlanMapper purchasePlanService;
@Autowired
private IFinancialAccountsPayableService financialAccountsPayableService;
private FinancialAccountsPayableMapper financialAccountsPayableMapper;
@Autowired
private ISysSupplierService sysSupplierService;
@ -242,7 +244,7 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
BigDecimal materialRmb = BigDecimal.ZERO;
BigDecimal materialNoRmbSum = BigDecimal.ZERO;
BigDecimal materialRmbSum = BigDecimal.ZERO;
Long materialNum = 0L;
BigDecimal materialNum = BigDecimal.ZERO;
int supplierNum = 0;
//根据上传的物料信息做采购订单子项
if (!CollectionUtils.isEmpty(purchaseOrder.getPurchaseOrderChildList())) {
@ -251,7 +253,7 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
if (purchaseOrder.getPurchaseOrderChildList() != null) {
List<PurchaseOrderChild> purchaseOrderChildList = purchaseOrder.getPurchaseOrderChildList();
//订单子表去除实际物料数量位null或者0的物料信息
purchaseOrderChildList = purchaseOrderChildList.stream().filter(child -> child.getMaterialRealNum() != null && child.getMaterialRealNum()!=0).collect(Collectors.toList());
purchaseOrderChildList = purchaseOrderChildList.stream().filter(child -> child.getMaterialRealNum() != null).collect(Collectors.toList());
for (PurchaseOrderChild child : purchaseOrderChildList) {
if (child.getCorrelationCode().contains(",")) {
String[] correlationCodes = child.getCorrelationCode().split(",");
@ -268,16 +270,16 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
// 获取物料供应商含税采购价格
BigDecimal suplierMaterialRmb = child.getMaterialRealRmb();
// 获取物料数量
Long suplierMaterialNum = child.getMaterialRealNum();
BigDecimal suplierMaterialNum = child.getMaterialRealNum();
if(suplierMaterialNoRmb == null){suplierMaterialNoRmb = BigDecimal.ZERO;}
if(suplierMaterialRmb == null){suplierMaterialRmb = BigDecimal.ZERO;}
if(suplierMaterialNum == null){suplierMaterialNum = 0L;}
if(suplierMaterialNum == null){suplierMaterialNum = new BigDecimal(0);}
//获取供应商不含税价格合计 = 物料数量 * 供应商采购不含税价格
BigDecimal suplierMaterialNoRmbSumLocal = suplierMaterialNoRmb.multiply(BigDecimal.valueOf(suplierMaterialNum));
BigDecimal suplierMaterialNoRmbSumLocal = suplierMaterialNoRmb.multiply(suplierMaterialNum);
//获取供应商含税价格合计 = 物料数量 * 供应商采购含税价格
BigDecimal suplierMaterialRmbSumLocal = suplierMaterialRmb.multiply(BigDecimal.valueOf(suplierMaterialNum));
BigDecimal suplierMaterialRmbSumLocal = suplierMaterialRmb.multiply(suplierMaterialNum);
// 累加物料数量
materialNum += suplierMaterialNum;
materialNum = materialNum.add(suplierMaterialNum);
// 累加物料总价
materialNoRmbSum = materialNoRmbSum.add(suplierMaterialNoRmbSumLocal);
// 累加物料含税总价
@ -310,6 +312,7 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
material.setMaterialRealRmbSum(suplierMaterialRmbSumLocal);
material.setMaterialRealNoRmbSum(suplierMaterialNoRmbSumLocal);
material.setCorrelationCode(child.getCorrelationCode());
material.setDeliveryTime(child.getDeliveryTime());
material.setPurchasePlanCode(child.getPurchasePlanCode());
material.setPurchaseQuoteCode(child.getPurchaseQuoteCode());
//收货状态,0:未收货,1:已收货 收款状态:0:待付款,1:已付款
@ -334,16 +337,16 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
// 获取物料供应商含税采购价格
BigDecimal suplierMaterialRmb = child.getMaterialRealRmb();
// 获取物料数量
Long suplierMaterialNum = child.getMaterialRealNum();
BigDecimal suplierMaterialNum = child.getMaterialRealNum();
if(suplierMaterialNoRmb == null){suplierMaterialNoRmb = BigDecimal.ZERO;}
if(suplierMaterialRmb == null){suplierMaterialRmb = BigDecimal.ZERO;}
if(suplierMaterialNum == null){suplierMaterialNum = 0L;}
if(suplierMaterialNum == null){suplierMaterialNum = new BigDecimal(0);}
//获取供应商不含税价格合计 = 物料数量 * 供应商采购不含税价格
BigDecimal suplierMaterialNoRmbSumLocal = suplierMaterialNoRmb.multiply(BigDecimal.valueOf(suplierMaterialNum));
BigDecimal suplierMaterialNoRmbSumLocal = suplierMaterialNoRmb.multiply(suplierMaterialNum);
//获取供应商含税价格合计 = 物料数量 * 供应商采购含税价格
BigDecimal suplierMaterialRmbSumLocal = suplierMaterialRmb.multiply(BigDecimal.valueOf(suplierMaterialNum));
BigDecimal suplierMaterialRmbSumLocal = suplierMaterialRmb.multiply(suplierMaterialNum);
// 累加物料数量
materialNum += suplierMaterialNum;
materialNum = materialNum.add(suplierMaterialNum);
// 累加物料总价
materialNoRmbSum = materialNoRmbSum.add(suplierMaterialNoRmbSumLocal);
// 累加物料含税总价
@ -595,20 +598,16 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
}
}
//每当当前供应商完成一次循环,生成一条供应商应付账款
SysSupplier sysSupplier = new SysSupplier();
sysSupplier.setSupplierCode(purchaseOrderChild.getSupplierCode());
List<SysSupplierVo> sysSupplierList = sysSupplierService.selectSysSupplierList(sysSupplier);
int supplierListSize = sysSupplierList.size();
if(supplierListSize == 0){
SysSupplier sysSupplier = sysSupplierService.selectSysSupplierByCode(purchaseOrderChild.getSupplierCode());
if(ObjectUtils.isEmpty(sysSupplier)){
continue;
}else{
SysSupplier sysSupplier1 = sysSupplierList.get(0);
//获取供应商开户银行
financialAccountsPayable.setOpenBank(sysSupplier1.getDepositBank());
financialAccountsPayable.setOpenBank(sysSupplier.getDepositBank());
//供应商银行账号
financialAccountsPayable.setOpenAccount(sysSupplier1.getBankAccount());
financialAccountsPayable.setOpenAccount(sysSupplier.getBankAccount());
//供应商付款条件
financialAccountsPayable.setPaymentCondition(sysSupplier1.getPaymentTerms());
financialAccountsPayable.setPaymentCondition(sysSupplier.getPaymentTerms());
}
//供应商编号
financialAccountsPayable.setSupplierCode(purchaseOrderChild.getSupplierCode());
@ -626,7 +625,9 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
financialAccountsPayable.setPriceIncludesTax(supplierRmbTaxPrice);
financialAccountsPayable.setStorageStatus("0");
financialAccountsPayable.setAccountsPayableStatus("0");
financialAccountsPayableService.insertFinancialAccountsPayable(financialAccountsPayable);
financialAccountsPayable.setCreateTime(DateUtils.getNowDate());
financialAccountsPayable.setCreateBy(purchaseOrderChild.getCreateBy());
financialAccountsPayableMapper.insertFinancialAccountsPayable(financialAccountsPayable);
}
//根据供应商编分组,合计供应商总共合计了多少数,采购物采购,采购物料料
return 1; // 返回成功标识

2
ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysSupplierServiceImpl.java

@ -1,6 +1,7 @@
package com.ruoyi.system.service.impl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.page.PageDomain;
import com.ruoyi.common.core.page.TableSupport;
@ -102,6 +103,7 @@ public class SysSupplierServiceImpl implements ISysSupplierService{
PageDomain pageDomain = TableSupport.buildPageRequest();
Integer pageNum = pageDomain.getPageNum();
Integer pageSize = pageDomain.getPageSize();
PageHelper.startPage(pageNum,pageSize);
Page<SysSupplierVo> list = (Page<SysSupplierVo>) sysSupplierMapper.selectSysSupplierList(sysSupplier);
Page<SysSupplierVo> returnList = new Page<>();
//PageHelper 仅对第一List分页有效

2
ruoyi-admin/src/main/resources/mapper/system/SysSupplierMapper.xml

@ -198,7 +198,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectSysSupplierByCode" parameterType="String" resultMap="SysSupplierResult">
<include refid="selectSysSupplierVo"/>
where supplier_code = #{supplierCode}
where supplier_code = #{supplierCode} and del_flag = '0' and use_status = '1' and audit_status = '1'
</select>

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

@ -171,6 +171,10 @@
//采购含税总价
$('#purchaseRmbSum').val(purchaseOrder.rmbSum);
$('#stockNo').val(purchaseOrder.stockNo);
$('#stockName').val(purchaseOrder.stockName);
$('#stockContact').val(purchaseOrder.stockContact);
$('#stockPhone').val(purchaseOrder.stockPhone);
$('#stockAddress').val(purchaseOrder.stockAddress);
//按照物料的维度查看采购订单信息
// 初始化表格
@ -383,7 +387,7 @@
{ title: '币种', field: '' },
{ title: '不含税采购价', field: 'materialNoRmb' },
{ title: '含税采购价', field: 'materialRmb' },
{ title: '实际采购数', field: 'materialRealNum"' },
{ title: '实际采购数', field: 'materialRealNum' },
{ title: '实际不含税采购金额', field: 'materialRealNoRmb' },
{ title: '实际含税采购金额', field: 'materialRealRmb' },
{ title: '已入库数', field: 'actualHasArrivedNum' },
@ -409,11 +413,11 @@
totalActualPurchase = totalActualPurchase + purchaseNum;
});
//物料的实际采购数合计
$('#materialAmountSum_' + tableId).val(totalActualPurchase);
$('#materialAmountSum_' + tableId).val(parseFloat(totalActualPurchase.toFixed(2)));
//物料的实际不含税采购总价:
$('#materialNoRmbSum_' + tableId).val(parseFloat(totalNoRmb));
$('#materialNoRmbSum_' + tableId).val(parseFloat(totalNoRmb.toFixed(2)));
//物料的实际含税总价:
$('#materialRmbSum_' + tableId).val(parseFloat(totalRmb));
$('#materialRmbSum_' + tableId).val(parseFloat(totalRmb.toFixed(2)));
// 采购物料合计
materialActualPurchaseSum();
}
@ -441,13 +445,13 @@
totalRmb += rmbPrice;
});
//物料合计 = 物料实际采购数合计,不含税总价,含税采购总价不为null的情况可以合计物料,否则跳过
$("#purchaseMaterialSum").val(materialAmount);
$("#purchaseMaterialSum").val(parseFloat(materialAmount.toFixed(2)));
//采购数量合计
$('#purchaseSum').val(totalActualPurchase);
$('#purchaseSum').val(parseFloat(totalActualPurchase.toFixed(2)));
//采购不含税总价
$('#purchaseNoRmbSum').val(totalNoRmb);
$('#purchaseNoRmbSum').val(parseFloat(totalNoRmb.toFixed(2)));
//采购含税总价
$('#purchaseRmbSum').val(totalRmb);
$('#purchaseRmbSum').val(parseFloat(totalRmb.toFixed(2)));
}
function tableSetup(element, tableId) {
var $totalSection = $(

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

@ -189,8 +189,10 @@
sortStable: true, // 设置为 true 将获得稳定的排序
modalName: "采购订单",
detailView: true,
fixedColumns: true, // 启用冻结列
fixedRightNumber: 1, // 冻结右列个数
// fixedColumns: true, // 是否启用冻结列(左侧)
// fixedNumber: 2, // 列冻结的个数(左侧)
// rightFixedColumns: true, // 是否启用冻结列(右侧)
// fixedRightNumber: 1, // 列冻结的个数(右侧)
method: 'post',
contentType: "application/x-www-form-urlencoded",
onExpandRow : function(index,row,$detail){

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

@ -212,6 +212,10 @@
//采购含税总价
$('#purchaseRmbSum').val(purchaseOrder.rmbSum);
$('#stockNo').val(purchaseOrder.stockNo);
$('#stockName').val(purchaseOrder.stockName);
$('#stockContact').val(purchaseOrder.stockContact);
$('#stockPhone').val(purchaseOrder.stockPhone);
$('#stockAddress').val(purchaseOrder.stockAddress);
//按照物料的维度查看采购订单信息
// 初始化表格
@ -424,7 +428,7 @@
{ title: '币种', field: '' },
{ title: '不含税采购价', field: 'materialNoRmb' },
{ title: '含税采购价', field: 'materialRmb' },
{ title: '实际采购数', field: 'materialRealNum"' },
{ title: '实际采购数', field: 'materialRealNum' },
{ title: '实际不含税采购金额', field: 'materialRealNoRmb' },
{ title: '实际含税采购金额', field: 'materialRealRmb' },
{ title: '已入库数', field: 'actualHasArrivedNum' },
@ -450,11 +454,11 @@
totalActualPurchase = totalActualPurchase + purchaseNum;
});
//物料的实际采购数合计
$('#materialAmountSum_' + tableId).val(totalActualPurchase);
$('#materialAmountSum_' + tableId).val(parseFloat(totalActualPurchase.toFixed(2)));
//物料的实际不含税采购总价:
$('#materialNoRmbSum_' + tableId).val(parseFloat(totalNoRmb));
$('#materialNoRmbSum_' + tableId).val(parseFloat(totalNoRmb.toFixed(2)));
//物料的实际含税总价:
$('#materialRmbSum_' + tableId).val(parseFloat(totalRmb));
$('#materialRmbSum_' + tableId).val(parseFloat(totalRmb.toFixed(2)));
// 采购物料合计
materialActualPurchaseSum();
}
@ -482,13 +486,13 @@
totalRmb += rmbPrice;
});
//物料合计 = 物料实际采购数合计,不含税总价,含税采购总价不为null的情况可以合计物料,否则跳过
$("#purchaseMaterialSum").val(materialAmount);
$("#purchaseMaterialSum").val(parseFloat(materialAmount.toFixed(2)));
//采购数量合计
$('#purchaseSum').val(totalActualPurchase);
$('#purchaseSum').val(parseFloat(totalActualPurchase.toFixed(2)));
//采购不含税总价
$('#purchaseNoRmbSum').val(totalNoRmb);
$('#purchaseNoRmbSum').val(parseFloat(totalNoRmb.toFixed(2)));
//采购含税总价
$('#purchaseRmbSum').val(totalRmb);
$('#purchaseRmbSum').val(parseFloat(totalRmb.toFixed(2)));
}
function tableSetup(element, tableId) {
var $totalSection = $(
@ -571,6 +575,7 @@
$.each(data, function(index, item) {
selectElement.append('<option value="' + item.stockNO + '">' + item.stockNO + '</option>');
}); // 遍历返回的数据,添加为下拉框的选项
//设备当前选择的值
} else {
$.modal.errMsg("数据为空");
}
@ -603,7 +608,6 @@
}
});
}
else {$('input[name="warehouseName"]').val('');}// 如果没有选择仓库ID,清空仓库名称输入框
});
function submitHandler() {
if ($.validate.form()) {

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

@ -212,6 +212,10 @@
//采购含税总价
$('#purchaseRmbSum').val(purchaseOrder.rmbSum);
$('#stockNo').val(purchaseOrder.stockNo);
$('#stockName').val(purchaseOrder.stockName);
$('#stockContact').val(purchaseOrder.stockContact);
$('#stockPhone').val(purchaseOrder.stockPhone);
$('#stockAddress').val(purchaseOrder.stockAddress);
//按照物料的维度查看采购订单信息
// 初始化表格
@ -450,11 +454,11 @@
totalActualPurchase = totalActualPurchase + purchaseNum;
});
//物料的实际采购数合计
$('#materialAmountSum_' + tableId).val(totalActualPurchase);
$('#materialAmountSum_' + tableId).val(parseFloat(totalActualPurchase.toFixed(2)));
//物料的实际不含税采购总价:
$('#materialNoRmbSum_' + tableId).val(parseFloat(totalNoRmb));
$('#materialNoRmbSum_' + tableId).val(parseFloat(totalNoRmb.toFixed(2)));
//物料的实际含税总价:
$('#materialRmbSum_' + tableId).val(parseFloat(totalRmb));
$('#materialRmbSum_' + tableId).val(parseFloat(totalRmb.toFixed(2)));
// 采购物料合计
materialActualPurchaseSum();
}
@ -482,13 +486,13 @@
totalRmb += rmbPrice;
});
//物料合计 = 物料实际采购数合计,不含税总价,含税采购总价不为null的情况可以合计物料,否则跳过
$("#purchaseMaterialSum").val(materialAmount);
$("#purchaseMaterialSum").val(parseFloat(materialAmount.toFixed(2)));
//采购数量合计
$('#purchaseSum').val(totalActualPurchase);
$('#purchaseSum').val(parseFloat(totalActualPurchase.toFixed(2)));
//采购不含税总价
$('#purchaseNoRmbSum').val(totalNoRmb);
$('#purchaseNoRmbSum').val(parseFloat(totalNoRmb.toFixed(2)));
//采购含税总价
$('#purchaseRmbSum').val(totalRmb);
$('#purchaseRmbSum').val(parseFloat(totalRmb.toFixed(2)));
}
function tableSetup(element, tableId) {
var $totalSection = $(

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

@ -212,6 +212,10 @@
//采购含税总价
$('#purchaseRmbSum').val(purchaseOrder.rmbSum);
$('#stockNo').val(purchaseOrder.stockNo);
$('#stockName').val(purchaseOrder.stockName);
$('#stockContact').val(purchaseOrder.stockContact);
$('#stockPhone').val(purchaseOrder.stockPhone);
$('#stockAddress').val(purchaseOrder.stockAddress);
//按照物料的维度查看采购订单信息
// 初始化表格
@ -450,11 +454,11 @@
totalActualPurchase = totalActualPurchase + purchaseNum;
});
//物料的实际采购数合计
$('#materialAmountSum_' + tableId).val(totalActualPurchase);
$('#materialAmountSum_' + tableId).val(parseFloat(totalActualPurchase.toFixed(2)));
//物料的实际不含税采购总价:
$('#materialNoRmbSum_' + tableId).val(parseFloat(totalNoRmb));
$('#materialNoRmbSum_' + tableId).val(parseFloat(totalNoRmb.toFixed(2)));
//物料的实际含税总价:
$('#materialRmbSum_' + tableId).val(parseFloat(totalRmb));
$('#materialRmbSum_' + tableId).val(parseFloat(totalRmb.toFixed(2)));
// 采购物料合计
materialActualPurchaseSum();
}
@ -482,13 +486,13 @@
totalRmb += rmbPrice;
});
//物料合计 = 物料实际采购数合计,不含税总价,含税采购总价不为null的情况可以合计物料,否则跳过
$("#purchaseMaterialSum").val(materialAmount);
$("#purchaseMaterialSum").val(parseFloat(materialAmount.toFixed(2)));
//采购数量合计
$('#purchaseSum').val(totalActualPurchase);
$('#purchaseSum').val(parseFloat(totalActualPurchase.toFixed(2)));
//采购不含税总价
$('#purchaseNoRmbSum').val(totalNoRmb);
$('#purchaseNoRmbSum').val(parseFloat(totalNoRmb.toFixed(2)));
//采购含税总价
$('#purchaseRmbSum').val(totalRmb);
$('#purchaseRmbSum').val(parseFloat(totalRmb.toFixed(2)));
}
function tableSetup(element, tableId) {
var $totalSection = $(

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

@ -1,47 +1,45 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.w3.org/1999/xhtml">
<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 :: datetimepicker-css" />
<th:block th:include="include :: bootstrap-editable-css" />
<link th:href="@{/ajax/libs/element-ui/element-ui.css}" rel="stylesheet"/>
<style>
.fixed-table-container {
border: 0px solid #ddd;
min-height: 120px;
min-height: 110px;
}
</style>
</head>
<body class="white-bg">
<div id="app" class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-edit" th:object="${formData}">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-purchaseOrder-modify" th:object="${formData}">
<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="taskName" th:field="*{taskName}" type="hidden">
<input name="instanceId" th:field="*{instanceId}" type="hidden">
<input name="instanceType" th:field="*{instanceType}" type="hidden">
<!--驳回调整允许更新内容-->
<input type="hidden" name="saveEntity" value="true" />
<div class="form-group">
<label class="col-sm-3 control-label">申请人:</label>
<div class="col-sm-8">
<input name="applyUserName" th:field="*{applyUserName}" class="form-control" type="text" readonly>
<input type="hidden" name="p_B_reApply" class="form-control m-b" />
<div class="form-group" hidden="hidden">
<label class="col-sm-6 control-label">申请人:</label>
<div class="col-sm-6">
<input name="applyUser" th:field="*{applyUser}" class="form-control" type="text" disabled>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">申请时间:</label>
<div class="col-sm-8">
<div class="form-group" hidden="hidden">
<label class="col-sm-6 control-label">申请时间:</label>
<div class="col-sm-6">
<div class="input-group date">
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
<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>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">标题:</label>
<div class="col-sm-8">
<input name="title" th:field="*{applyTitle}" class="form-control" type="text" readonly>
<div class="form-group" hidden="hidden">
<label class="col-sm-6 control-label">标题:</label>
<div class="col-sm-6">
<input name="title" th:field="*{applyTitle}" class="form-control" type="text" disabled>
</div>
</div>
<div class="col-xs-12">
@ -129,140 +127,503 @@
</div>
</div>
</div>
<div class="container">
<div class="form-group">
<label class="col-sm-3 control-label" for="reApply">是否继续申请:</label>
<div class="col-sm-8">
<select id="reApply" name="p_B_reApply" class="form-control m-b">
<select id="reApply" name="reApply" class="form-control m-b">
<option value="true">重新申请</option>
<option value="false">结束流程</option>
</select>
</div>
</div>
</div>
</form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: datetimepicker-js" />
<th:block th:include="include :: bootstrap-table-editable-js" />
<th:block th:include="include :: select2-js" />
<script th:src="@{/js/activiti.js}"></script>
<script th:inline="javascript">
var erpMaterial = [[${formData}]];
var prefix = ctx + "purchase/purchaseOrder";
var purchaseOrderCode = [[${purchaseOrder.purchaseOrderCode}]];
var warehouseCode = [[${purchaseOrder.stockNo}]];
var warehouseName = [[${purchaseOrder.stockName}]];
var warehouseDetailAddress = [[${purchaseOrder.stockAddress}]];
$("#form-gcjl-edit").validate({focusCleanup: true});
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-gcjl-edit').serialize());
}
}
var prefix = ctx + "purchase/purchaseOrder";
var purchaseOrder = [[${formData}]];
var materialTypeDatas = [[${@category.getChildByCode('materialType')}]];
var auditStatusDatas = [[${@dict.getType('auditStatus')}]];
var useStatusDatas = [[${@dict.getType('useStatus')}]];
var sysUnitClassDatas = [[${@dict.getType('sys_unit_class')}]];
var processMethodDatas = [[${@dict.getType('processMethod')}]];
var materialUnitDatas = [[${@dict.getType('sysUnitClassDatas')}]];
var materialTypeDatas = [[${@category.getChildByCode('materialType')}]];
$("#form-addPurchaseStorage-edit").validate({ focusCleanup: true});
//生成的不同table的id集合
var warehouseDeptDatas = [[${@dict.getType('warehouseDept')}]];
var loginName = [[${@permission.getPrincipalProperty('loginName')}]];
$("#form-purchaseOrder-modify").validate({focusCleanup: true});
var purchasePlanChildList = [];
var purchasePlanCodes = [];
var formId = "form-purchaseOrder-fzjl";
//根据物料物料数量添加物料分类表,自动生成类似的表单对象
//初始根据采购计划单,涉及到物料做分类表
//根据采购计划单,获取物料信息,自动生成物料的供应商分类表
//获取表单的id;
var materialList = [];
var tableIdList = [];
var $supplierForm;
var tableDatas = [];
$(function() {
//获取采购计划单的物料信息
// 假设qualityOrderCode已经定义或者可以通过某种方式获取到
var purchaseOrderCode = [[${purchaseOrder.purchaseOrderCode}]]; // 这里需要实际赋值,比如从前端某个地方读取
$.getJSON(prefix + "/detailListGroupedBySupplier?qualityOrderCode=" + purchaseOrderCode, function(data) {
for (var supplierCode in data) {
if (data.hasOwnProperty(supplierCode)) {
var supplierData = data[supplierCode];
$(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);
$('#stockName').val(purchaseOrder.stockName);
$('#stockContact').val(purchaseOrder.stockContact);
$('#stockPhone').val(purchaseOrder.stockPhone);
$('#stockAddress').val(purchaseOrder.stockAddress);
//按照物料的维度查看采购订单信息
// 初始化表格
// 假设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 mt-3"></div>');
var $tableWrapper = $('<div class="table-responsive"></div>');
// 确保supplierData至少有一条记录,并从中提取供应商详细信息
var supplierInfo = supplierData.length > 0 ? supplierData[0] : {}; // 默认为空对象,以防数据不存在
// 构建含有额外供应商信息的标题字符串
var headerTitle ='供应商'+'</br>'+supplierCode + ' - ' + supplierInfo.supplierName ;
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: 'materialName'},
{title: '物料类型',field: 'materialType',
formatter: function (value,row, index) {
$.table.selectCategoryLabel(materialTypeDatas, value)
{ 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: 'materialPhotourl',
formatter: function (value, row, index) {
$.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: 'materialUnit',
formatter:function (value) {
return $.table.selectDictLabel(materialUnitDatas, value);
{ title: '物料描述', field: 'materialDescribe' },
{ title: '品牌', field: 'materialBrand' },
{ title: '加工类型', field: 'materialProcessMethod', align: 'center', formatter: function(value, row, index) {
return $.table.selectDictLabel(processMethodDatas, value);
}
},
{title: '物料加工方式',field: 'materialProcessMethod',
formatter:function (value) {
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: 'materialRealNum',},
{title: '交付时间',field: 'deliveryTime',},
{title: '通知已到货数',field: 'notifyArriveNum',
formatter: function (value, row, index) {
if (value == null || value == '') {
return 0;
{ 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(parseFloat(totalActualPurchase.toFixed(2)));
//物料的实际不含税采购总价:
$('#materialNoRmbSum_' + tableId).val(parseFloat(totalNoRmb.toFixed(2)));
//物料的实际含税总价:
$('#materialRmbSum_' + tableId).val(parseFloat(totalRmb.toFixed(2)));
// 采购物料合计
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;
}
return value;
totalActualPurchase += purchaseNum;
totalNoRmb += noRmbPrice;
totalRmb += rmbPrice;
});
//物料合计 = 物料实际采购数合计,不含税总价,含税采购总价不为null的情况可以合计物料,否则跳过
$("#purchaseMaterialSum").val(parseFloat(materialAmount.toFixed(2)));
//采购数量合计
$('#purchaseSum').val(parseFloat(totalActualPurchase.toFixed(2)));
//采购不含税总价
$('#purchaseNoRmbSum').val(parseFloat(totalNoRmb.toFixed(2)));
//采购含税总价
$('#purchaseRmbSum').val(parseFloat(totalRmb.toFixed(2)));
}
function tableSetup(element, tableId) {
var $totalSection = $(
'<div class="card">' +
'<div class="card-body" class="supplierTotal_' + tableId + '">' +
'<div class="col-xs-4">' +
'<label for="actualPurchaseTotal" class="col-sm-5">实际采购数合计:</label>' +
'<div class="col-sm-6">' +
'<input type="number" name="materialAmountSum" class="form-control actualPurchaseTotalSum" id="materialAmountSum_' + tableId + '" disabled>' +
'</div>' +
'</div>' +
'<div class="col-xs-4">' +
'<label for="actualPurchaseTotal" class="col-sm-5">不含税采购总价:</label>' +
'<div class="col-sm-6">' +
'<input type="number" name="materialNoRmbSum" class="form-control actualPurchaseTotal" id="materialNoRmbSum_' + tableId + '" disabled>' +
'</div>' +
'</div>' +
'<div class="col-xs-4">' +
'<label for="actualPurchaseTotalTax" class="col-sm-5">含税采购总价:</label>' +
'<div class="col-sm-6">' +
'<input type="number" name="materialRmbSum" class="form-control actualPurchaseTotalTax" id="materialRmbSum_' + tableId + '" disabled>' +
'</div>' +
'</div>' +
'</div>'+
'</div>');
element.append($totalSection);
}
// 创建表格并添加到页面
function tables(tableId, data) {
$('#' + tableId).bootstrapTable({
showExport: false,
showFooter: false,
showSearch: false,
showRefresh: false,
showColumns: false,
showToggle: false,
data: data,
height: 70,
columns: [
{checkbox: false},
{title: '料号', field: 'materialCode'},
{title: '图片', field: 'photoUrl', formatter: function (value, row, index) {
return $.table.imageView(value);
}
},
{title: '已入库数',field: 'hasStorageNum',
formatter: function (value, row, index) {
if (value == null || value == '') {
return 0;
{title: '物料名称', field: 'materialName'},
{title: '物料类型', field: 'materialType', align: 'center', formatter: function (value, row, index) {
return $.table.selectCategoryLabel(materialTypeDatas, value);
}
return value;
},
{title: '物料描述', field: 'describe'},
{title: '品牌', field: 'brand'},
{title: '加工类型', field: 'processMethod', align: 'center', formatter: function (value, row, index) {
return $.table.selectDictLabel(processMethodDatas, value);
}
},
{title: '通知到货数',field: 'notifyArriveNum',
formatter: function (value, row, index) {
return '<input type="number" min="0" oninput="validity.valid || (value = 0)" data-id="notifyArriveNum" class="form-control" name="notifyArriveNum" value="'+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("数据为空");
}
}
]
});
$tableWrapper.append($header).append($table);
$('#tablesContainer').append($tableWrapper);
}
$("input[name='arrivedTime']").datetimepicker({
format: "yyyy-mm-dd",
minView: "month",
autoclose: true
$('#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('查询仓库名称时发生错误!');
}
});
$("input[name='deliveryInspectionTime']").datetimepicker({
format: "yyyy-mm-dd",
minView: "month",
autoclose: true
}
else {$('input[name="warehouseName"]').val('');}// 如果没有选择仓库ID,清空仓库名称输入框
});
// 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-purchaseOrder-modify').serialize());
// }
// }
function submitHandler() {
if ($.validate.form()) {
$("#p_B_reApply").val($("#reApply").val());
var taskId = [[${taskId}]];
var formData = $("#form-purchaseOrder-modify").serialize();
// 发送请求
$.operate.save(prefix + "/complete/" + taskId, formData)
}
}
</script>
</body>
</html>
Loading…
Cancel
Save