Browse Source

[feat]

项目引进新版表单向导技术,并且设置为通用方法
按照新版prd调整
新增采购计划前端列表页面,按照新版prd调整布局和样式:采用主子表的形式展示数据,操作栏和表头按钮都按照统一样式调整
新增采购计划添加采购订单前端页面,按照新版prd完成第一步选择供应商的数据展示
新增 购计划添加采购订单第一步 选择供应商Vo实体用于前端选择供应商展示
新增 根据采购计划编号集合查询采购计划后端方法
新增 通过采购计划单号集合查询采购计划子表数据
采购计划Controller层新增 加载添加采购订单页面后端接口;新增 添加采购订单展示选择供应商列表后端接口
新增 根据计划编号集合查询采购计划单方法
新增 添加采购订单展示选择供应商列表实现:显示字段包括供应商ID、供应商名称、可供应物料数,字段(可供应物料总数):该供应商针对已选采购计划单的物料种数里,可供应的物料数,排序:优先按【可供应物料数】排序,数字越大,排序越靠前
新增 通过采购报价单号查找所有采购报价子表集合方法
新增 查找所有可用的采购报价的数据方法
dev
liuxiaoxu 1 week ago
parent
commit
4a14f0eb92
  1. 69
      ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchasePlanController.java
  2. 20
      ruoyi-admin/src/main/java/com/ruoyi/purchase/domain/Vo/PurchasePlanSelectSupplierVo.java
  3. 6
      ruoyi-admin/src/main/java/com/ruoyi/purchase/mapper/PurchasePlanChildMapper.java
  4. 8
      ruoyi-admin/src/main/java/com/ruoyi/purchase/mapper/PurchasePlanMapper.java
  5. 9
      ruoyi-admin/src/main/java/com/ruoyi/purchase/mapper/PurchaseQuoteChildMapper.java
  6. 8
      ruoyi-admin/src/main/java/com/ruoyi/purchase/mapper/PurchaseQuoteMapper.java
  7. 3
      ruoyi-admin/src/main/java/com/ruoyi/purchase/service/IPurchaseOrderService.java
  8. 14
      ruoyi-admin/src/main/java/com/ruoyi/purchase/service/IPurchasePlanService.java
  9. 98
      ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchasePlanServiceImpl.java
  10. 9
      ruoyi-admin/src/main/resources/mapper/purchase/PurchasePlanChildMapper.xml
  11. 9
      ruoyi-admin/src/main/resources/mapper/purchase/PurchasePlanMapper.xml
  12. 16
      ruoyi-admin/src/main/resources/mapper/purchase/PurchaseQuoteChildMapper.xml
  13. 7
      ruoyi-admin/src/main/resources/mapper/purchase/PurchaseQuoteMapper.xml
  14. 9
      ruoyi-admin/src/main/resources/templates/include.html
  15. 804
      ruoyi-admin/src/main/resources/templates/purchase/purchasePlan/addPurchaseOrder.html
  16. 14
      ruoyi-admin/src/main/resources/templates/purchase/purchasePlan/purchasePlan.html

69
ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchasePlanController.java

@ -4,9 +4,11 @@ import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.ruoyi.common.core.text.Convert; import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.purchase.domain.PurchasePlan; import com.ruoyi.purchase.domain.PurchasePlan;
import com.ruoyi.purchase.domain.PurchasePlanChild; import com.ruoyi.purchase.domain.PurchasePlanChild;
import com.ruoyi.purchase.domain.PurchaseQuoteChild; import com.ruoyi.purchase.domain.PurchaseQuoteChild;
import com.ruoyi.purchase.domain.Vo.PurchasePlanSelectSupplierVo;
import com.ruoyi.purchase.service.IPurchasePlanChildService; import com.ruoyi.purchase.service.IPurchasePlanChildService;
import com.ruoyi.purchase.service.IPurchaseQuoteChildService; import com.ruoyi.purchase.service.IPurchaseQuoteChildService;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
@ -113,31 +115,58 @@ public class PurchasePlanController extends BaseController
mmap.put("purchasePlan", purchasePlan); mmap.put("purchasePlan", purchasePlan);
return prefix + "/edit"; return prefix + "/edit";
} }
/**
*
* 加载添加采购订单页面
* */
@GetMapping("/addPurchaseOrder/{purchasePlanCodes}") @GetMapping("/addPurchaseOrder/{purchasePlanCodes}")
public String addPurchaseOrder(@PathVariable("purchasePlanCodes") String purchasePlanCodes,ModelMap mmap){ public String addPurchaseOrder(@PathVariable("purchasePlanCodes") String purchasePlanCodes,ModelMap mmap){
//purchasePlanCodes去除重复数据,purchasePlanCodeArray作为数组类型去除
Set<String> uniquePurchasePlanCode = Arrays.stream(purchasePlanCodes.split(",")).collect(Collectors.toSet()); List<String> purchasePlanCodeList = new ArrayList<>();
// 直接使用String的split方法分割字符串,然后转为Stream去重,最后再拼接回字符串
String uniquePurchasePlanCodes = String.join(",", uniquePurchasePlanCode); PurchasePlan purchasePlanOne = new PurchasePlan();
//去除重复的计划单号 if (StringUtils.isNotEmpty(purchasePlanCodes)){
//查询相关采购计划数据 String[] splitSalesOrderCode = purchasePlanCodes.split(",");
List<PurchasePlan> purchasePlanList = purchasePlanService.selectPurchasePlanByPlanCode(uniquePurchasePlanCodes); purchasePlanCodeList = Arrays.asList(splitSalesOrderCode);
//根据采购计划编号查询对应的采购报价数据
List<PurchasePlanChild> purchasePlanChildList = purchasePlanChildService.getPurchasePlanChildByPlanCodes(uniquePurchasePlanCodes);
for(PurchasePlanChild purchasePlanChild : purchasePlanChildList){
String materialCode = purchasePlanChild.getMaterialNo();
// List<PurchaseQuoteChild> purchaseQuoteChildList = purchaseQuoteChildService.selectQuoteChildByMaterialCode(materialCode);
// purchasePlanChild.setPurchaseSupplierList(purchaseQuoteChildList);
} }
//再根据采购计划编号分组查询对应的采购报价数据分组 List<PurchasePlan> purchasePlanList = purchasePlanService.selectPurchaseOrderByPlanCodeList(purchasePlanCodeList);
//用stream流处理相同供应商\物料\
//将供应商信息解析成List<PurchaseSupplier> //计划采购总数
mmap.put("purchasePlanList", purchasePlanList); int allPurchaseSum = purchasePlanList.stream().mapToInt(PurchasePlan::getPurchaseSum).sum();
mmap.put("purchasePlanCodes", uniquePurchasePlanCodes);
mmap.put("purchasePlanChildList", purchasePlanChildList); //物料合计
int allMaterialSum = purchasePlanList.stream().mapToInt(PurchasePlan::getMaterialSum).sum();
purchasePlanOne.setMaterialSum(allMaterialSum);
purchasePlanOne.setPlanPurchaseSum(allPurchaseSum);
purchasePlanOne.setPurchasePlanCode(purchasePlanCodes);
mmap.put("purchasePlanOne",purchasePlanOne);
return prefix + "/addPurchaseOrder"; return prefix + "/addPurchaseOrder";
} }
/**
*
* 添加采购订单展示选择供应商列表
* */
@PostMapping("/selectSupplierOneList")
@ResponseBody
public TableDataInfo selectSupplierOneList(PurchasePlan purchasePlan)
{
startPage();
List<PurchasePlanSelectSupplierVo> list = purchasePlanService.selectSupplierOneList(purchasePlan);
return getDataTable(list);
}
@GetMapping("/detail/{purchasePlanId}") @GetMapping("/detail/{purchasePlanId}")
public String detail(@PathVariable("purchasePlanId") Long purchasePlanId, ModelMap mmap) public String detail(@PathVariable("purchasePlanId") Long purchasePlanId, ModelMap mmap)
{ {

20
ruoyi-admin/src/main/java/com/ruoyi/purchase/domain/Vo/PurchasePlanSelectSupplierVo.java

@ -0,0 +1,20 @@
package com.ruoyi.purchase.domain.Vo;
import lombok.Data;
/**
* 采购计划添加采购订单第一步 选择供应商Vo
* */
@Data
public class PurchasePlanSelectSupplierVo{
/** 供应商ID*/
private String supplierCode;
/** 供应商名称*/
private String supplierName;
/** 可供应物料数*/
private Integer availableMaterialNum;
}

6
ruoyi-admin/src/main/java/com/ruoyi/purchase/mapper/PurchasePlanChildMapper.java

@ -95,4 +95,10 @@ public interface PurchasePlanChildMapper
* 通过物料号和采购计划单号查询采购计划子表数据 * 通过物料号和采购计划单号查询采购计划子表数据
* */ * */
PurchasePlanChild selectPurchasePlanChildByCodeAndNo(PurchasePlanChild purchasePlanChild); PurchasePlanChild selectPurchasePlanChildByCodeAndNo(PurchasePlanChild purchasePlanChild);
/*
*
* 通过采购计划单号集合查询采购计划子表数据
* */
List<PurchasePlanChild> selectPurchasePlanChildPlanCodeList(List<String> purchasePlanCodeList);
} }

8
ruoyi-admin/src/main/java/com/ruoyi/purchase/mapper/PurchasePlanMapper.java

@ -79,4 +79,12 @@ public interface PurchasePlanMapper
public PurchasePlan selectPurchasePlanByPlanCode(String purchasePlanCode); public PurchasePlan selectPurchasePlanByPlanCode(String purchasePlanCode);
public List<PurchasePlan> selectPurchasePlanByPlanCodes(String[] planCode); public List<PurchasePlan> selectPurchasePlanByPlanCodes(String[] planCode);
/**
* 根据计划编号集合查询采购计划单
*
* @param purchasePlanCodeList 计划编号集合
* @return 采购计划单列表
*/
List<PurchasePlan> selectPurchaseOrderByPlanCodeList(List<String> purchasePlanCodeList);
} }

9
ruoyi-admin/src/main/java/com/ruoyi/purchase/mapper/PurchaseQuoteChildMapper.java

@ -79,5 +79,14 @@ public interface PurchaseQuoteChildMapper
*/ */
public int restorePurchaseQuoteChildById(Long purchaseQuoteChildId); public int restorePurchaseQuoteChildById(Long purchaseQuoteChildId);
List<PurchaseQuoteChild> selectQuoteChildByMaterialCode(String materialCode); List<PurchaseQuoteChild> selectQuoteChildByMaterialCode(String materialCode);
/**
* 通过采购报价单号查找所有采购报价子表集合
* */
List<PurchaseQuoteChild> selectPurchaseQuoteChildListByQuoteCodeList(List<String> purchaseQuoteCodes);
} }

8
ruoyi-admin/src/main/java/com/ruoyi/purchase/mapper/PurchaseQuoteMapper.java

@ -4,6 +4,8 @@ import com.github.pagehelper.Page;
import com.ruoyi.purchase.domain.Vo.PurchaseQuoteVo; import com.ruoyi.purchase.domain.Vo.PurchaseQuoteVo;
import com.ruoyi.purchase.domain.PurchaseQuote; import com.ruoyi.purchase.domain.PurchaseQuote;
import java.util.List;
/** /**
* 采购报价单Mapper接口 * 采购报价单Mapper接口
* *
@ -108,4 +110,10 @@ public interface PurchaseQuoteMapper
public Integer cancelPurchaseQuoteByQuoteCodes(String[] purchaseQuoteCodes); public Integer cancelPurchaseQuoteByQuoteCodes(String[] purchaseQuoteCodes);
public Page<PurchaseQuote> selectPurchaseQuoteList2(PurchaseQuote purchaseQuote); public Page<PurchaseQuote> selectPurchaseQuoteList2(PurchaseQuote purchaseQuote);
/**
* 查找所有可用的采购报价的数据
* */
List<PurchaseQuote> selectPurchaseQuoteAllList();
} }

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

@ -3,6 +3,7 @@ package com.ruoyi.purchase.service;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.purchase.domain.PurchaseOrder; import com.ruoyi.purchase.domain.PurchaseOrder;
import com.ruoyi.purchase.domain.PurchaseOrderVo; import com.ruoyi.purchase.domain.PurchaseOrderVo;
import com.ruoyi.purchase.domain.PurchasePlan;
import com.ruoyi.warehouse.domain.WarehouseStorageOrder; import com.ruoyi.warehouse.domain.WarehouseStorageOrder;
import org.activiti.engine.runtime.ProcessInstance; import org.activiti.engine.runtime.ProcessInstance;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -97,4 +98,6 @@ public interface IPurchaseOrderService
* 导入采购订单供应商合同 * 导入采购订单供应商合同
* */ * */
AjaxResult uploadSingleFile(MultipartFile file,String purchaseOrderCode); AjaxResult uploadSingleFile(MultipartFile file,String purchaseOrderCode);
} }

14
ruoyi-admin/src/main/java/com/ruoyi/purchase/service/IPurchasePlanService.java

@ -3,6 +3,7 @@ package com.ruoyi.purchase.service;
import com.ruoyi.erp.domain.vo.ErpDevelopModifyorderVo; import com.ruoyi.erp.domain.vo.ErpDevelopModifyorderVo;
import com.ruoyi.purchase.domain.PurchasePlan; import com.ruoyi.purchase.domain.PurchasePlan;
import com.ruoyi.purchase.domain.PurchasePlanChild; import com.ruoyi.purchase.domain.PurchasePlanChild;
import com.ruoyi.purchase.domain.Vo.PurchasePlanSelectSupplierVo;
import com.ruoyi.system.domain.SysMakeorderBom; import com.ruoyi.system.domain.SysMakeorderBom;
import java.util.List; import java.util.List;
@ -31,6 +32,13 @@ public interface IPurchasePlanService
*/ */
public List<PurchasePlan> selectPurchasePlanList(PurchasePlan purchasePlan); public List<PurchasePlan> selectPurchasePlanList(PurchasePlan purchasePlan);
/**
* 根据采购计划编号集合查询采购计划
* */
List<PurchasePlan> selectPurchaseOrderByPlanCodeList(List<String> purchasePlanCodeList);
/** /**
* 新增采购计划单 * 新增采购计划单
* *
@ -88,4 +96,10 @@ public interface IPurchasePlanService
* 开发修改单审核通过后生成采购计划 * 开发修改单审核通过后生成采购计划
* */ * */
void generatePurchasePlanByDevelopModifyorder(ErpDevelopModifyorderVo erpDevelopModifyorderVo); void generatePurchasePlanByDevelopModifyorder(ErpDevelopModifyorderVo erpDevelopModifyorderVo);
/**
*
* 添加采购订单展示选择供应商列表
* */
List<PurchasePlanSelectSupplierVo> selectSupplierOneList(PurchasePlan purchasePlan);
} }

98
ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchasePlanServiceImpl.java

@ -17,12 +17,20 @@ import com.ruoyi.erp.mapper.ErpDevelopModifyorderDetailMapper;
import com.ruoyi.erp.service.IErpBomService; import com.ruoyi.erp.service.IErpBomService;
import com.ruoyi.purchase.domain.PurchasePlan; import com.ruoyi.purchase.domain.PurchasePlan;
import com.ruoyi.purchase.domain.PurchasePlanChild; import com.ruoyi.purchase.domain.PurchasePlanChild;
import com.ruoyi.purchase.domain.PurchaseQuote;
import com.ruoyi.purchase.domain.PurchaseQuoteChild;
import com.ruoyi.purchase.domain.Vo.PurchasePlanSelectSupplierVo;
import com.ruoyi.purchase.mapper.PurchasePlanChildMapper; import com.ruoyi.purchase.mapper.PurchasePlanChildMapper;
import com.ruoyi.purchase.mapper.PurchaseQuoteChildMapper;
import com.ruoyi.purchase.mapper.PurchaseQuoteMapper;
import com.ruoyi.system.domain.SysMakeOrder; import com.ruoyi.system.domain.SysMakeOrder;
import com.ruoyi.system.domain.SysMakeorderBom; import com.ruoyi.system.domain.SysMakeorderBom;
import com.ruoyi.system.domain.SysSalesOrderChild; import com.ruoyi.system.domain.SysSalesOrderChild;
import com.ruoyi.system.domain.SysSupplier;
import com.ruoyi.system.domain.Vo.SysSupplierVo;
import com.ruoyi.system.mapper.SysMakeOrderMapper; import com.ruoyi.system.mapper.SysMakeOrderMapper;
import com.ruoyi.system.mapper.SysSalesOrderChildMapper; import com.ruoyi.system.mapper.SysSalesOrderChildMapper;
import com.ruoyi.system.mapper.SysSupplierMapper;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -61,6 +69,15 @@ public class PurchasePlanServiceImpl implements IPurchasePlanService
@Autowired @Autowired
private IErpBomService erpBomService; private IErpBomService erpBomService;
@Autowired
private PurchaseQuoteMapper purchaseQuoteMapper;
@Autowired
private PurchaseQuoteChildMapper purchaseQuoteChildMapper;
@Autowired
private SysSupplierMapper sysSupplierMapper;
/** /**
* 查询采购计划单 * 查询采购计划单
* *
@ -85,6 +102,87 @@ public class PurchasePlanServiceImpl implements IPurchasePlanService
return purchasePlanMapper.selectPurchasePlanList(purchasePlan); return purchasePlanMapper.selectPurchasePlanList(purchasePlan);
} }
/**
* 根据计划编号集合查询采购计划单
*
* @param purchasePlanCodeList 计划编号集合
* @return 采购计划单列表
*/
@Override
public List<PurchasePlan> selectPurchaseOrderByPlanCodeList(List<String> purchasePlanCodeList) {
List<PurchasePlan> purchasePlanList = purchasePlanMapper.selectPurchaseOrderByPlanCodeList(purchasePlanCodeList);
return purchasePlanList;
}
/**
*
* 添加采购订单展示选择供应商列表
* */
@Override
public List<PurchasePlanSelectSupplierVo> selectSupplierOneList(PurchasePlan purchasePlan) {
String purchasePlanCode = purchasePlan.getPurchasePlanCode();
List<String> purchasePlanCodeList = new ArrayList<>();
if (StringUtils.isNotEmpty(purchasePlanCode)){
String[] splitSalesOrderCode = purchasePlanCode.split(",");
purchasePlanCodeList = Arrays.asList(splitSalesOrderCode);
}
List<PurchasePlan> purchasePlanList = purchasePlanMapper.selectPurchaseOrderByPlanCodeList(purchasePlanCodeList);
//采购计划子表数据
List<PurchasePlanChild> purchasePlanChildList = purchasePlanChildMapper.selectPurchasePlanChildPlanCodeList(purchasePlanCodeList);
//查找采购报价的数据
List<PurchaseQuote> purchaseQuoteList = purchaseQuoteMapper.selectPurchaseQuoteAllList();
List<String> purchaseQuoteCodes = purchaseQuoteList.stream().map(PurchaseQuote::getPurchaseQuoteCode).collect(Collectors.toList());
//查找采购报价子表的数据
List<PurchaseQuoteChild> purchaseQuoteChildList = purchaseQuoteChildMapper.selectPurchaseQuoteChildListByQuoteCodeList(purchaseQuoteCodes);
//获取采购计划中的物料编号
Set<String> planMaterialNos = purchasePlanChildList.stream().map(PurchasePlanChild::getMaterialNo).collect(Collectors.toSet());
//根据供应商编号对采购报价子表进行分组
Map<String, List<PurchaseQuoteChild>> quoteChildBySupplier = purchaseQuoteChildList.stream().collect(Collectors.groupingBy(PurchaseQuoteChild::getSupplierCode));
//提取采购报价中的所有supplierCode
List<String> supplierCodes = purchaseQuoteList.stream().map(PurchaseQuote::getSupplierQuoteCode).distinct().collect(Collectors.toList());
// 创建结果列表
List<PurchasePlanSelectSupplierVo> result = new ArrayList<>();
// 遍历每个 supplierCode
for (Map.Entry<String, List<PurchaseQuoteChild>> entry : quoteChildBySupplier.entrySet()) {
String supplierCode = entry.getKey();
List<PurchaseQuoteChild> supplierQuoteChildren = entry.getValue();
SysSupplier sysSupplier = sysSupplierMapper.selectSysSupplierByCode(supplierCode);
// 提取这些 purchaseQuoteChild 中的所有 materialCode
Set<String> supplierMaterialCodes = supplierQuoteChildren.stream()
.map(PurchaseQuoteChild::getMaterialCode)
.filter(planMaterialNos::contains)
.collect(Collectors.toSet());
// 创建 PurchasePlanSelectSupplierVo 对象
PurchasePlanSelectSupplierVo vo = new PurchasePlanSelectSupplierVo();
vo.setSupplierCode(supplierCode);
vo.setSupplierName(sysSupplier.getSupplierName());
vo.setAvailableMaterialNum(supplierMaterialCodes.size());
// 将结果添加到结果列表中
result.add(vo);
}
//去掉没有可供应物料数的供应商
result = result.stream().filter(item->item.getAvailableMaterialNum() > 0).collect(Collectors.toList());
//对结果进行排序,按可用物料数量降序
result.sort(Comparator.comparingInt(PurchasePlanSelectSupplierVo::getAvailableMaterialNum).reversed());
return result;
}
/** /**
* 新增采购计划单 * 新增采购计划单
* *

9
ruoyi-admin/src/main/resources/mapper/purchase/PurchasePlanChildMapper.xml

@ -51,6 +51,15 @@
where purchase_plan_child_id = #{purchasePlanChildId} where purchase_plan_child_id = #{purchasePlanChildId}
</select> </select>
<select id="selectPurchasePlanChildPlanCodeList" parameterType="String" resultMap="PurchasePlanChildResult">
<include refid="selectPurchasePlanChildVo"/>
where purchase_plan_code in
<foreach collection="list" item="purchasePlanCode" open="(" separator="," close=")">
#{purchasePlanCode}
</foreach>
</select>
<insert id="insertPurchasePlanChild" parameterType="PurchasePlanChild" useGeneratedKeys="true" keyProperty="purchasePlanChildId"> <insert id="insertPurchasePlanChild" parameterType="PurchasePlanChild" useGeneratedKeys="true" keyProperty="purchasePlanChildId">
insert into purchase_plan_child insert into purchase_plan_child
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">

9
ruoyi-admin/src/main/resources/mapper/purchase/PurchasePlanMapper.xml

@ -48,6 +48,15 @@
where purchase_plan_id = #{purchasePlanId} where purchase_plan_id = #{purchasePlanId}
</select> </select>
<select id="selectPurchaseOrderByPlanCodeList" parameterType="String" resultMap="PurchasePlanResult">
<include refid="selectPurchasePlanVo"/>
where purchase_plan_code in
<foreach item="purchasePlanCode" collection="list" separator="," open="(" close=")">
#{purchasePlanCode}
</foreach>
</select>
<insert id="insertPurchasePlan" parameterType="PurchasePlan" useGeneratedKeys="true" keyProperty="purchasePlanId"> <insert id="insertPurchasePlan" parameterType="PurchasePlan" useGeneratedKeys="true" keyProperty="purchasePlanId">
insert into purchase_plan insert into purchase_plan
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">

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

@ -69,6 +69,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where purchase_quote_child_id = #{purchaseQuoteChildId} where purchase_quote_child_id = #{purchaseQuoteChildId}
</select> </select>
<select id="selectPurchaseQuoteChildAllList" resultMap="PurchaseQuoteChildResult">
<include refid="selectPurchaseQuoteChildVo"/>
</select>
<select id="selectPurchaseQuoteChildListByQuoteCodeList" parameterType="Long" resultMap="PurchaseQuoteChildResult">
<include refid="selectPurchaseQuoteChildVo"/>
where purchase_quote_code in
<foreach item="purchaseQuoteCode" collection="list" separator="," open="(" close=")">
#{purchaseQuoteCode}
</foreach>
</select>
<insert id="insertPurchaseQuoteChild" parameterType="PurchaseQuoteChild" useGeneratedKeys="true" keyProperty="purchaseQuoteChildId"> <insert id="insertPurchaseQuoteChild" parameterType="PurchaseQuoteChild" useGeneratedKeys="true" keyProperty="purchaseQuoteChildId">
insert into purchase_quote_child insert into purchase_quote_child
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
@ -226,4 +241,5 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
quote.use_status = '1'; quote.use_status = '1';
</select> </select>
</mapper> </mapper>

7
ruoyi-admin/src/main/resources/mapper/purchase/PurchaseQuoteMapper.xml

@ -159,7 +159,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
on p.purchase_quote_id = file.rel_id on p.purchase_quote_id = file.rel_id
where p.purchase_quote_id = #{purchaseQuoteId} where p.purchase_quote_id = #{purchaseQuoteId}
</select> </select>
<select id="selectPurchaseQuoteAllList" resultMap="PurchaseQuoteResult">
<include refid="selectPurchaseQuoteVo"/>
where audit_status = '1' and use_status = '1'
</select>
<insert id="insertPurchaseQuote" parameterType="PurchaseQuote" useGeneratedKeys="true" keyProperty="purchaseQuoteId"> <insert id="insertPurchaseQuote" parameterType="PurchaseQuote" useGeneratedKeys="true" keyProperty="purchaseQuoteId">
insert into purchase_quote insert into purchase_quote
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">

9
ruoyi-admin/src/main/resources/templates/include.html

@ -179,6 +179,15 @@
<script th:src="@{/ajax/libs/smartwizard/jquery.smartWizard.min.js}"></script> <script th:src="@{/ajax/libs/smartwizard/jquery.smartWizard.min.js}"></script>
</div> </div>
<!-- jquery.smartwizard表单向导插件 -->
<div th:fragment="jquery-smartwizard-css">
<link th:href="@{/ajax/libs/smartwizard/smart_wizard_all.min.css?v=5.1.1}" rel="stylesheet"/>
</div>
<div th:fragment="jquery-smartwizard-js">
<script th:src="@{/ajax/libs/smartwizard/jquery.smartWizard.min.js?v=5.1.1}"></script>
</div>
<!-- ECharts百度统计图表插件 --> <!-- ECharts百度统计图表插件 -->
<div th:fragment="echarts-js"> <div th:fragment="echarts-js">
<script th:src="@{/ajax/libs/report/echarts/echarts-all.js}"></script> <script th:src="@{/ajax/libs/report/echarts/echarts-all.js}"></script>

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

@ -1,570 +1,298 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" > <html lang="zh">
<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 :: jquery-smartwizard-css" />
<th:block th:include="include :: datetimepicker-css" />
<th:block th:include="include :: bootstrap-editable-css" />
<style>
.inventory-count {
background-color: #f9f9f9;
}
.inventory-count p {margin: 0;}
.fixed-table-container {
border: 0px solid #ddd;
min-height: 120px;
}
/*.inventory-count span {font-weight: bold;}*/
</style>
</head> </head>
<body class="white-bg"> <style type="text/css">
<div class="wrapper wrapper-content animated fadeInRight ibox-content"> /* 如果要让工具栏固定在页面底部,使用下面的样式,不需要的可以注释 */
<form class="form-horizontal m" id="form-plan-purchaseOrder-add" th:object="${purchasePlanList}"> .sw>.toolbar-bottom{
<div class="col-xs-12"> z-index: 100;
<label class="col-sm-4 control-label">已选择采购计划:</label> bottom: 0px;
<div class="col-sm-7"> left: 0;
<input id="purchasePlanCodes" name="purchasePlanCode" class="form-control" type="text"> width: 100%;
</div> position: fixed;
</div> text-align: right;
<div class="container" id="material"> background: #fff;
box-shadow: 0 -2px 6px 1px hsla(223,8%,83%,.5);
border-top: 1px solid #e3e4e8;
}
/* 如果设置了是否自动调节高度为false,需要加滚动条 */
.sw>.tab-content{
overflow-x: hidden;
overflow-y: auto;
}
</div> .tab-content {
</form> height: auto !important; /* 重写高度 */
<div class="container"> }
<div class="row"><h4 class="card-header">公司地址:</h4></div>
<div class="form-group"> /* 解决工具栏无法固定底部的问题(如果页面没有animated类可以不写这部分代码) */
<label for="stockNo" class="col-sm-2 col-form-label is-required">仓库ID:</label> .animated {
<div class="col-sm-4"> animation-fill-mode: none;
<select class="form-control" name="stockNo" id="stockNo" required></select> -webkit-animation-fill-mode: none;
</div> -moz-animation-fill-mode: none;
</div> -o-animation-fill-mode: none;
<div class="form-group"> }
<label for="stockName" class="col-sm-2 col-form-label is-required">仓库名称:</label> </style>
<div class="col-sm-4">
<input type="text" class="form-control" name="stockName" id="stockName" required>
</div> <body class="gray-bg">
</div> <div class="wrapper wrapper-content animated fadeInRight" style="height: 100%;">
<div class="form-group"> <div class="row">
<label for="stockContact" class="col-sm-2 col-form-label">收货人:</label> <div class="col-sm-12">
<div class="col-sm-4"> <div class="ibox">
<input type="text" name="stockContact" class="form-control" id="stockContact" readonly> <div class="ibox-content">
</div> <div id="smartwizard">
</div> <ul class="nav">
<div class="form-group"> <li class="nav-item">
<label for="stockPhone" class="col-sm-2 col-form-label">收货电话:</label> <a class="nav-link" href="#step-1"> 第一步 </a>
<div class="col-sm-4"> </li>
<input type="text" name="stockPhone" class="form-control" id="stockPhone" placeholder="请输入收货电话" readonly> <li class="nav-item">
</div> <a class="nav-link" href="#step-2"> 第二步 </a>
</div> </li>
<div class="form-group"> </ul>
<label for="stockAddress" class="col-sm-2 col-form-label">详细地址:</label> <div class="tab-content">
<div class="col-sm-4"> <div id="step-1" class="tab-pane" role="tabpanel" aria-labelledby="step-1">
<textarea class="form-control" name="stockAddress" id="stockAddress" readonly></textarea> <div>
</div> <form class="m-t" id="form-addPurchaseOrder-addOne" th:object="${purchasePlanOne}">
</div> <div class="container">
</div> <div class="row">
<div class="container"> <div class="col-12">
<div class="row"><h4 class="card-header">订单合计:</h4></div> <h3 class="mb-4">已选采购计划单</h3>
<div class="form-group"> </div>
<label for="purchaseMaterialSum" class="col-sm-2 col-form-label">物料合计:</label> </div>
<div class="col-sm-4">
<input type="number" class="form-control" value="0" id="purchaseMaterialSum" readonly> <div class="form-group row">
</div> <label for="purchasePlanCode" class="col-sm-2 col-form-label">已选择采购计划单号:</label>
</div> <div class="col-sm-10">
<div class="form-group"> <input id="purchasePlanCode" name="purchasePlanCode" th:field="*{purchasePlanCode}" class="form-control" type="text" readonly>
<label for="purchaseSum" class="col-sm-2 col-form-label">采购合计:</label> </div>
<div class="col-sm-4"> </div>
<input type="number" class="form-control" value="0" id="purchaseSum" readonly>
</div> <div class="form-group row">
</div> <label for="materialSum" class="col-sm-2 col-form-label">物料合计:</label>
<div class="form-group"> <div class="col-sm-4">
<label for="purchaseNoRmbSum" class="col-sm-2 col-form-label">不含税采购总价:</label> <input id="materialSum" name="materialSum" th:field="*{materialSum}" class="form-control" type="text" readonly>
<div class="col-sm-4"> </div>
<input type="number" class="form-control" value="0" id="purchaseNoRmbSum" readonly> <label for="planPurchaseSum" class="col-sm-2 col-form-label">计划采购总数:</label>
</div> <div class="col-sm-4">
</div> <input id="planPurchaseSum" name="planPurchaseSum" th:field="*{planPurchaseSum}" class="form-control" type="text" readonly>
<div class="form-group"> </div>
<label for="purchaseRmbSum" class="col-sm-2 col-form-label">含税采购总价:</label> </div>
<div class="col-sm-4"> </div>
<input type="number" class="form-control" value="0" id="purchaseRmbSum" readonly>
<div class="container">
<div class="row">
<div class="col-12">
<h3 class="mb-4">选择供应商</h3>
</div>
</div>
<div class="form-group row">
<div class="col-sm-12 select-table table-striped">
<table id="selectSupplier-bootstrap-table"></table>
</div>
</div>
</div>
</form>
<!-- <div class="container-div row">-->
<!-- <div class="row">-->
<!-- <div class="col-sm-12 search-collapse">-->
<!-- <form id="formId">-->
<!-- <div class="select-list">-->
<!-- <ul>-->
<!-- <li>-->
<!-- <label>供应商ID:</label>-->
<!-- <input type="text" name="supplierCode"/>-->
<!-- </li>-->
<!-- <li>-->
<!-- <label>供应商名称:</label>-->
<!-- <input type="text" name="supplierName"/>-->
<!-- </li>-->
<!-- <li>-->
<!-- <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>-->
<!-- <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>-->
<!-- </li>-->
<!-- </ul>-->
<!-- </div>-->
<!-- </form>-->
<!-- </div>-->
<!-- <div class="col-sm-12 select-table table-striped">-->
<!-- <table id="selectSupplier-bootstrap-table"></table>-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
</div>
</div>
<div id="step-2" class="tab-pane" role="tabpanel" aria-labelledby="step-2">
<div>
<form class="form form-horizontal m-t">
<div class="form-group">
<label class="col-sm-3 control-label">性别:</label>
<div class="col-sm-8">
<select name="sex" class="form-control m-b" th:with="type=${@dict.getType('sys_user_sex')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div> </div>
</div> </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 :: jquery-smartwizard-js" />
<th:block th:include="include :: datetimepicker-js" /> <script>
<th:block th:include="include :: bootstrap-table-editable-js" />
<script th:inline="javascript"> var prefix = ctx + "purchase/purchasePlan"
var prefix = ctx + "purchase/purchaseOrder";
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-plan-purchaseOrder-add").validate({focusCleanup: true});
var purchasePlanChildList = [[${purchasePlanChildList}]];
var purchasePlanList = [[${purchasePlanList}]];
var purchasePlanCodes = [[${purchasePlanCodes}]];
var formId = "form-plan-purchaseOrder-add";
//根据物料物料数量添加物料分类表,自动生成类似的表单对象
//初始根据采购计划单,涉及到物料做分类表
//根据采购计划单,获取物料信息,自动生成物料的供应商分类表
//获取表单的id;
var materialList = [];
var tableIdList = [];
var $supplierForm;
//获取采购计划单的物料信息
//获取
// 假设qualityOrderCode已经定义或者可以通过某种方式获取到
$(function() {
$("#purchasePlanCodes").val(purchasePlanCodes);
// 初始化表格
// 假设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>');
// 将整个物料信息容器添加到页面
$('#material').append($tableWrapper);
// 添加关联销售订单号信息
// 创建表格的容器
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.correlationCodes + '</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">' +
'<h4 class="inventory-count " id=" inventory-count-' + tableId + '">'+
'<span><strong>可用库存数:</strong></span>'+'<span id="stock-count-' + tableId + '">10 </span>'+'<span> 注:含其他订单待领取的库存,仅供参考,请以实际为准.</span>'+
'</h4>' +
'</div>');
$tableWrapper.append($stockWrapper);
var materialObj = {
purchasePlanCode: material.purchasePlanCode,
materialCode: material.materialCode,
photoUrl: material.photoUrl,
materialName: material.materialName,
materialType: material.materialType,
describe: material.describe,
brand: material.brand,
processMethod: material.processMethod,
unit: material.unit,
warehouseDept:material.warehouseDept,
materialNum: material.materialNum,
};
var materialData = [materialObj]; // Bootstrap Table需要一个数组作为数据源
materialList.push(material);
tables(materialTable, materialData);
var $supplierInfo = $('<div class="supplier-card " style="height: 20px;" id="supplierInfo_' + tableId + '"></div>');
//如果物料下的供应商为空,则不需要添加供应商信息,并在容器中添加一个提示信息:暂无供应商信息,请先添加供应商信息。
const uniqueSuppliers = [];
if (material.purchaseSupplierList.length <= 0) {
var $noSupplierDiv = $('<div class="no-supplier">暂无供应商信息,请先添加供应商信息。</div>');
$tableWrapper.append($noSupplierDiv);
}
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) {
//如果供应商相同,则不需要再次添加供应商信息
// 卡片样式容器,用于包裹每个供应商的信息
// 构建供应商信息头部
var $headerContent =
$('<div class="card-header supplier_card" id = "supplier-' + tableId + '_' + supplierIndex + '">' +
'<div class="row">' +
'<div class="crad-text">'+
'<h4>'+
'<span>供应商 ' + (supplierIndex + 1) + ':' + '</span>' +
'<span class="supplierCode">' + supplier.supplierCode + '</span>' + '-' +
'<span class="supplierName">' + supplier.supplierName + '</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="supplierCorrelationCode" hidden="hidden" >' + material.correlationCodes + '</span>' +
'<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="col-xs-6">' +
'<label class="col-sm-4 is-required">计划交付时间: </label>' +
'<div class ="col-sm-6">' +
'<div class="input-group date"> ' +
'<input type="text" name="deliveryTime" class="form-control supplierDeliveryTime" id="deliveryTime_' + tableId + '" required />' +
'<span class="input-group-addon"><i class="fa fa-calendar"></i></span>' +
'</div> ' +
'</div>' +
'</div>' +
'</div>' +
'</div>'); $(document).ready(function() {
if (supplier.supplierCode != undefined && supplier.supplierCode != '' && supplier.supplierCode != null) { // 工具栏按钮
$supplierInfo.append($headerContent); var btnFinish = $('<a id="btn-finish"></a>').text('完成')
// 构建供应商信息下的输入表单 .addClass('btn btn-info')
$supplierForm = $('<div class="card-body" id="card_body_' + tableId + '"></div>'); .on('click', function(){ submit(); });
// 实际采购数输入框 var btnCancel = $('<a id="btn-cancel"></a>').text('取消')
// 其他表单项可以根据需要类似添加 .addClass('btn btn-danger')
$supplierInfo.append($supplierForm); .on('click', function(){ $('#smartwizard').smartWizard("reset"); });
}else{ // 下面两个按钮是为了因为插件默认的是botton,这里换成<a>,也可以选择用样式替换,或者不替换
var $noSupplierDiv = $('<div class="no-supplier">暂无供应商信息,请先添加供应商信息。</div>'); var btnNext = $('<a id="btn-next"></a>').text('下一步')
$supplierInfo.append($noSupplierDiv); .addClass('btn btn-info')
} .on('click', function(){ $('#smartwizard').smartWizard("next");});
}); var btnPrev = $('<a id="btn-prev"></a>').text('上一步')
$tableWrapper.append($supplierInfo); .addClass('btn btn-success disabled')
.on('click', function(){ $('#smartwizard').smartWizard("prev"); });
// 初始化表单向导组件
$('#smartwizard').smartWizard({
theme: 'arrows', // default, arrows, dots, progress
autoAdjustHeight : false, // 自动调整高度, 默认true
enableURLhash:false, //开启URL hash,开启后点击浏览器前进后退按钮会执行下一步和上一步操作
transition: {
animation: 'slide-horizontal', // Effect on navigation, none/fade/slide-horizontal/slide-vertical/slide-swing
},
toolbarSettings: {
showNextButton: false,// 因为上面自定义了下一步按钮, 所以隐藏掉插件自带的按钮, 如果不使用自定义按钮, 需要改为true或者去掉该属性
showPreviousButton: false,// 因为上面自定义了上一步按钮, 所以隐藏掉插件自带的按钮, 如果不使用自定义按钮, 需要改为true或者去掉该属性
toolbarExtraButtons: [btnCancel,btnPrev,btnNext,btnFinish]// 扩展的按钮集合
} }
tableSetup($supplierInfo, tableId);
}); });
// 给实际采购数的输入框绑定事件处理器 });
$('.actualPurchaseNum').off('blur').on('blur', function(event) {
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,则显示供应商采购总价 function submit(){
if (purchaseNum > 0) { var data = {};
$supplierInfo.find('.supplierPurchaseTotal').removeClass('hidden'); $('.form').each(function (index, form){
$supplierInfo.find('.supplierPurchaseTotalRmb').removeClass('hidden'); // 这里可以使用$.common.formToJSON(formId); 需要在form上加id
$.each($(form).serializeArray(), function(i, field) {
if(data[field.name]) {
data[field.name] += ("," + field.value);
} else { } else {
// 否则隐藏供应商采购总价 data[field.name] = field.value;
$supplierInfo.find('.supplierPurchaseTotal').addClass('hidden');
$supplierInfo.find('.supplierPurchaseTotalRmb').addClass('hidden');
} }
});
recalculateTotals(tableId); // 重新计算当前物料的合计
});
// 定义一个函数来重新计算当前物料的合计
// 初始化总计
purchasePlanChildList.forEach(function (material, index) {
recalculateTotals('materialCode-' + index);
});
});
// 新增函数:重新计算某物料的采购数量合计、不含税采购总价和含税采购总价
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().trim()) || 0;
let noRmbPrice = parseFloat(supplierInfo.find('.actualPurchaseTotal').val().trim()) || 0;
let rmbPrice = parseFloat(supplierInfo.find('.actualPurchaseTotalTax').val().trim()) || 0;
if (purchaseNum > 0) {
materialAmount += 1;
}
totalActualPurchase += purchaseNum;
totalNoRmb += noRmbPrice;
totalRmb += rmbPrice;
}); });
//物料合计 = 物料实际采购数合计,不含税总价,含税采购总价不为null的情况可以合计物料,否则跳过 alert(JSON.stringify(data))
$("#purchaseMaterialSum").val(materialAmount);
//采购数量合计
$('#purchaseSum').val(totalActualPurchase);
//采购不含税总价
$('#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 + '" 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({ $("#smartwizard").on("showStep", function(e, anchorObject, stepNumber, stepDirection, stepPosition) {
showExport: false, // 下面按钮是工具栏的
showFooter: false, $("#btn-prev").removeClass('disabled');
$("#btn-next").removeClass('disabled');
$("#btn-finish").removeClass('disabled');
if(stepPosition === 'first') {
$("#btn-prev").addClass('disabled');
$("#btn-finish").addClass('disabled');
} else if(stepPosition === 'last') {
$("#btn-next").addClass('disabled');
} else {
$("#btn-prev").removeClass('disabled');
$("#btn-next").removeClass('disabled');
$("#btn-finish").addClass('disabled');
}
});
// 该事件在离开某个步骤之前触发
$("#smartwizard").on("leaveStep", function(e, anchorObject, currentStepNumber, nextStepNumber, stepDirection) {
if(stepDirection == 'forward'){
var form = $("#step-" + (currentStepNumber + 1)).find('.form');
if(form.length > 0){
return form.validate().form();
}
return true;
}
return true;
});
$("#theme-selector").on("change", function() {
// Change theme
var options = {
theme : $(this).val()
};
$('#smartwizard').smartWizard("setOptions", options);
return true;
});
$("#reset-btn").on("click", function() {
// Reset wizard
$('#smartwizard').smartWizard("reset");
return true;
});
$("#prev-btn").on("click", function() {
// Navigate previous
$('#smartwizard').smartWizard("prev");
return true;
});
$("#next-btn").on("click", function() {
// Navigate next
$('#smartwizard').smartWizard("next");
return true;
});
$(function() {
var options = {
id: "selectSupplier-bootstrap-table",
url: prefix + "/selectSupplierOneList",
queryParams: queryParamsOne,
search: false,
showSearch: false, showSearch: false,
showRefresh: false, showRefresh: false,
showToggle: false,
showColumns: false,
showColumns: false, showColumns: false,
showToggle: false, showToggle: false,
data: data, modalName: "选择供应商",
height: 70, columns: [{checkbox: true},
columns: [ { title: '供应商ID',field: 'supplierCode'},
{checkbox: false}, {title: '供应商名称',field: 'supplierName'},
{title: '料号', field: 'materialCode'}, {title: '可供应物料数',field: 'availableMaterialNum'},
{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'},
], ],
}); };
} $.table.init(options);
function submitHandler() { });
if ($.validate.form()) {
var materialSum = 0;
var materialRealSum = 0;
var materialNoRmbSum = 0;
var materialRmbSum = 0;
//添加去除供应商编号数组
var supplierNumList = [];
var purchaseOrder = {
supplierNum: 0,materialNum: 0,noRmbSum: 0,rmbSum: 0,
stockNo: $("#stockNo").val(),
stockName: $("#stockName").val(),
stockAddress: $("#stockAddress").val(),
stockContact: $("#stockContact").val(),
stockPhone: $("#stockPhone").val(),
purchaseOrderChildList: [],
};
// 遍历每个物料容器
$('.table-materialCode').each(function(index, tableElement) {
var tableId = tableIdList[index];
let materialObj = materialList[index];
var $tableWrapper = $('#material-' + tableId);
if (typeof materialObj === 'undefined') return;
var $suplierInfo = $tableWrapper.find('.supplier-card');
$suplierInfo.find('.supplier_card').each(function(supplierIndex, supplierCard) {
var supplierCode = $(this).find('.supplierCode').text().trim();
var supplierName = $(this).find('.supplierName').text().trim();
var materialRealNum = parseInt($(this).find('.actualPurchaseNum' ).val()) || 0;
var materialRealRmb = parseFloat($(this).find('.supplierMaterialRmb').text()) || 0;
var materialRealNoRmb = parseFloat($(this).find('.supplierMaterialNoRmb').text()) || 0;
var deliveryTime = $(this).find('.supplierDeliveryTime').val();
var purchasePlanCode = $(this).find('.supplierPurchasePlanCode').text().trim();
var correlationCode = $(this).find('.supplierCorrelationCode').text().trim();
var purchaseQuoteCode = $(this).find('.supplierPurchaseQuoteCode').text().trim();
var materialRealRmbSum = parseFloat(materialRealRmb * materialRealNum);
var materialRealNoRmbSum = parseFloat(materialRealNoRmb * materialRealNum);
materialRealSum += materialRealNum;
materialNoRmbSum += materialRealNoRmbSum;
materialRmbSum += materialRealRmbSum;
if (supplierNumList.indexOf(supplierCode) === -1) {
supplierNumList.push(supplierCode);
purchaseOrder.supplierNum += 1;
}
var materialData = {
materialCode: materialObj.materialCode,
materialName: materialObj.materialName,
materialType: materialObj.materialType,
materialBrand:materialObj.brand,
materialDescribe: materialObj.describe,
materialProcessMethod:materialObj.processMethod,
materialUnit:materialObj.unit,
materialPhotoUrl: materialObj.photoUrl,
warehouseDept: materialObj.warehouseDept,
materialNum: materialObj.materialNum,
supplierCode: supplierCode,
supplierName: supplierName,
materialNoRmb: materialObj.materialNoRmb,
materialRmb: materialObj.materialRmb,
materialRealNum: materialRealNum,
materialRealRmb: materialRealRmb,
materialRealNoRmb: materialRealNoRmb,
materialRealRmbSum: materialRealRmbSum,
materialRealNoRmbSum: materialRealNoRmbSum,
deliveryTime: deliveryTime,
purchasePlanCode:purchasePlanCode,
correlationCode:correlationCode,
purchaseQuoteCode: purchaseQuoteCode,
};
purchaseOrder.purchaseOrderChildList.push(materialData);
});
});
// 获取采购物料合计,采购物料实际合计,采购物料实际非人民币合计,采购物料实际人民币合计
var purchaseAmount = parseFloat($('#purchaseMaterialSum').val());
var purchaseSum = parseFloat($('#purchaseSum').val());
var purchaseNoRmbSum = parseFloat($('#purchaseNoRmbSum').val());
var purchaseRmbSum = parseFloat($('#purchaseRmbSum').val());
// 将合计值附加到purchaseOrder对象
purchaseOrder.materialAmount = purchaseAmount;
purchaseOrder.materialSum = purchaseSum;
purchaseOrder.materialNoRmbSum = purchaseNoRmbSum;
purchaseOrder.materialRmbSum = purchaseRmbSum;
purchaseOrder.supplierNum = supplierNumList.length;
// 发送数据到后端API
$.operate.saveJson(prefix + "/addPurchaseOrder",JSON.stringify(purchaseOrder));
} function queryParamsOne(params){
var curParams = {
purchasePlanCode : $("#purchasePlanCode").val()
};
return curParams
} }
//获取仓库相关信息Select2
//根据仓库ID查询仓库名称
$(function() {
// 初始化时默认加载仓库ID列表
loadWarehouseCodes();
// 监听仓库ID下拉框的变化
$("input[name='deliveryTime']").datepicker({
language: 'zh-CN',
todayHighlight: true,
format: "yyyy-mm-dd",
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('查询仓库名称时发生错误!');
}
});
} else {
// 如果没有选择仓库ID,清空仓库名称输入框
$('input[name="warehouseName"]').val('');
}
});
// 加载仓库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();
// 添加默认选项(如果需要)编辑时不需要添加默认选项
// selectElement.append('<option value="">所有</option>');
// 遍历返回的数据,添加为下拉框的选项
$.each(data, function(index, item) {
// 仓库ID
selectElement.append('<option value="' + item.stockNO + '">' + item.stockNO + '</option>');
});
// $('#warehouseCode').val(stockNO);
} else {
$.modal.errMsg("数据为空");
}
}
});
}
</script> </script>
</body> </body>
</html> </html>

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

@ -52,7 +52,7 @@
</div> </div>
<div class="btn-group-sm" id="toolbar" role="group"> <div class="btn-group-sm" id="toolbar" role="group">
<a class="btn btn-warning" onclick="addPurchaseOrder()" shiro:hasPermission="purchase:purchasePlan:add"> <a class="btn btn-success" onclick="addPurchaseOrder()" shiro:hasPermission="purchase:purchasePlan:add">
<i class="fa fa-download"></i> 添加采购单 <i class="fa fa-download"></i> 添加采购单
</a> </a>
</div> </div>
@ -80,10 +80,7 @@
url: prefix + "/list", url: prefix + "/list",
createUrl: prefix + "/add", createUrl: prefix + "/add",
updateUrl: prefix + "/edit/{id}", updateUrl: prefix + "/edit/{id}",
removeUrl: prefix + "/remove",
cancelUrl: prefix + "/cancel/{id}",
detailUrl: prefix + "/detail/{id}", detailUrl: prefix + "/detail/{id}",
restoreUrl: prefix + "/restore/{id}",
exportUrl: prefix + "/export", exportUrl: prefix + "/export",
modalName: "采购计划单", modalName: "采购计划单",
detailView: true, detailView: true,
@ -119,9 +116,10 @@
{title: '操作',align: 'center', {title: '操作',align: 'center',
formatter: function(value, row, index) { formatter: function(value, row, index) {
var actions = []; var actions = [];
actions.push('<a class="btn btn-success btn-xs ' + actions.push('<a class=" ' +
editFlag + '" href="javascript:void(0)" onclick="$.operate.detail(\'' + row.purchasePlanId + '\')"><i class="fa fa-edit"></i>详情</a> '); editFlag + '" href="javascript:void(0)" onclick="$.operate.detail(\'' + row.purchasePlanId + '\')"><i class="fa fa-edit"></i>详情</a> ');
return actions.join(''); var actionLinks = actions.join('');
return $.table.dropdownToggle(actionLinks);
} }
} }
] ]
@ -187,7 +185,9 @@
purchasePlanCodes = selections[0].purchasePlanCode; purchasePlanCodes = selections[0].purchasePlanCode;
} }
} }
$.modal.open("新增采购订单", prefix + "/addPurchaseOrder/" + purchasePlanCodes);
var url = prefix + "/addPurchaseOrder/" + purchasePlanCodes;
$.modal.open("新增采购订单", url);
} }
</script> </script>
</body> </body>

Loading…
Cancel
Save