Browse Source

[feat]

采购订单前端页面,去掉之前测试的审核按钮和方法
按照新版prd调整,新增采购经理审核页面;新增副总经理审核页面
采购订单Controller层:去掉之前没有的添加采购订单接口、修改采购订单接口;新增采购订单完成任务后端接口,处理审核通过和审核拒绝的业务;去掉之前的加载采购订单审核页面接口;
采购订单mapper层新增 根据采购单号修改采购订单方法
采购订单iml层:修改采购订单添加方法,计划采购数为待采购数;新增修改采购订单的方法:加上 处理审核拒绝的情况,新增 purchaseOrderAuditRefuse方法实现:得到采购订单子表的数据、得到采购计划单号的集合、得到采购计划主表数据、得到采购计划子表数据、创建一个 map 用于快速查找采购计划子表数据、用于存储每个采购计划的总变动量,使用三次循环 按创建时间排序,区分剩余数量大于0和等于0的情况;将采购订单子表中的实际采购数量分配给采购计划子表、将采购订单子表中的实际采购数量分配给采购计划子表;新增 更新采购计划主表方法;新增更新采购计划主表的方法;新增更新采购计划主表状态的方法;新增更新采购计划子表状态的方法
采购计划mapper新增 根据计划编号查询采购计划单方法
dev
liuxiaoxu 5 days ago
parent
commit
fb317ff3c6
  1. 127
      ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseOrderController.java
  2. 9
      ruoyi-admin/src/main/java/com/ruoyi/purchase/mapper/PurchaseOrderMapper.java
  3. 7
      ruoyi-admin/src/main/java/com/ruoyi/purchase/mapper/PurchasePlanMapper.java
  4. 173
      ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchaseOrderServiceImpl.java
  5. 48
      ruoyi-admin/src/main/resources/mapper/purchase/PurchaseOrderMapper.xml
  6. 5
      ruoyi-admin/src/main/resources/mapper/purchase/PurchasePlanMapper.xml
  7. 10
      ruoyi-admin/src/main/resources/templates/purchase/purchaseOrder/purchaseOrder.html
  8. 708
      ruoyi-admin/src/main/resources/templates/purchase/purchaseOrder/taskCgjlVerify.html
  9. 40
      ruoyi-admin/src/main/resources/templates/purchase/purchaseOrder/taskFzjlVerify.html

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

@ -171,34 +171,6 @@ public class PurchaseOrderController extends BaseController
}
/**
* 新增采购订单
*/
@GetMapping("/add")
public String add()
{
return prefix + "/add";
}
/**
* 新增保存采购订单
*/
@RequiresPermissions("purchase:purchaseOrder:add")
@Log(title = "采购订单", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave( @RequestBody PurchaseOrder purchaseOrder) {
purchaseOrder.setAuditStatus("0");
purchaseOrder.setUseStatus("0");
purchaseOrder.setDelFlag("0");
// 数据校验,确保前端传入数据格式正确
// 生成采购订单编号
// 执行主表插入操作
purchaseOrderService.insertPurchaseOrder(purchaseOrder);
//物料的供应商整合,生成该订单相关的应付账款
return AjaxResult.success(); // 假设toAjax方法处理成功逻辑
}
/**
* 采购计划添加采购订单
@ -215,58 +187,10 @@ public class PurchaseOrderController extends BaseController
return AjaxResult.success();
}
/**
* 修改采购订单
*/
@GetMapping("/edit/{purchaseOrderId}")
public String edit(@PathVariable("purchaseOrderId") Long purchaseOrderId, ModelMap mmap)
{
PurchaseOrder purchaseOrder = purchaseOrderService.selectPurchaseOrderById(purchaseOrderId);
//获取子表信息
List<PurchaseOrderChild> purchaseOrderChildList = purchaseOrderChildService.selectPurchaseOrderChildByOrderCode(purchaseOrder.getPurchaseOrderCode());
//Set<String>子表供应商的信息 供应商编号-供应商名称
//Set<String>子表采购计划单信息
// Set<String> supplierCodes = new HashSet<>();
// Set<String> purchasePlanCodes = new HashSet<>();
// for(PurchaseOrderChild purchaseOrderChild : purchaseOrderChildList){
// supplierCodes.add(purchaseOrderChild.getSupplierCode());
// purchasePlanCodes.add(purchaseOrderChild.getPurchasePlanCode());
// }
// purchaseOrder.setPurchaseOrderChildList(purchaseOrderChildList);
// mmap.put("supplierCodes", supplierCodes);
// mmap.put("purchasePlanCodes", purchasePlanCodes);
// mmap.put("purchaseOrder", purchaseOrder);
return prefix + "/edit";
}
@GetMapping("/editPurchaserOrder/{purchaseOrderId}")
@ResponseBody
public AjaxResult editPurchaser(@PathVariable("purchaseOrderId") Long purchaseOrderId, ModelMap mmap)
{
PurchaseOrder purchaseOrder = purchaseOrderService.selectPurchaseOrderById(purchaseOrderId);
//获取子表信息
List<PurchaseOrderChild> purchaseOrderChildList = purchaseOrderChildService.selectPurchaseOrderChildByOrderCode(purchaseOrder.getPurchaseOrderCode());
//Set<String>子表供应商的信息 供应商编号-供应商名称
//Set<String>子表采购计划单信息
Set<String> supplierCodes = new HashSet<>();
Set<String> purchasePlanCodes = new HashSet<>();
// for(PurchaseOrderChild purchaseOrderChild : purchaseOrderChildList){
// //获取区分的供应商物料信息
// if(!purchasePlanCodes.contains(purchaseOrderChild.getPurchasePlanCode())){
// purchasePlanCodes.add(purchaseOrderChild.getPurchasePlanCode());
// }
// //获取区分的采购计划单信息
// if(!supplierCodes.contains(purchaseOrderChild.getSupplierCode())){
// supplierCodes.add(purchaseOrderChild.getSupplierCode());
// }
// supplierCodes.add(purchaseOrderChild.getSupplierCode());
// }
// mmap.put("supplierCodes", supplierCodes);
// mmap.put("purchasePlanCodes", purchasePlanCodes);
// mmap.put("purchaseOrder", purchaseOrder);
// mmap.put("purchasePlanChildList",purchaseOrderChildList);
return AjaxResult.success(mmap);
}
@GetMapping("/detail/{purchaseOrderId}")
public String detail(@PathVariable("purchaseOrderId") Long purchaseOrderChildId, ModelMap mmap)
{
@ -316,17 +240,11 @@ public class PurchaseOrderController extends BaseController
// .collect(Collectors.groupingBy(PurchaseOrderChild::getSupplierCode));
// return groupedDetails;
// }
/**
* 修改保存采购订单
*/
@RequiresPermissions("purchase:purchaseOrder:edit")
@Log(title = "采购订单", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(PurchaseOrder purchaseOrder)
{
return toAjax(purchaseOrderService.updatePurchaseOrder(purchaseOrder));
}
/**
* 加载审批弹窗
* @param taskId
@ -360,20 +278,25 @@ public class PurchaseOrderController extends BaseController
String instanceType = purchaseOrderVo.getInstanceType();
boolean approvedFlag = processService.complete(taskId, instanceId, purchaseOrderVo.getApplyTitle(), purchaseOrderVo.getPurchaseOrderCode(),
"purchaseOrder", new HashMap<String, Object>(), request);
if(!approvedFlag){
// 审核状态-审核拒绝
purchaseOrderVo.setAuditStatus("2");
}
// 如果任务已结束更新业务表状态
boolean processIsFinish = processService.judgeProcessIsFinish(instanceId);
if (processIsFinish) {
// 审核通过
purchaseOrderVo.setAuditStatus("1");
if(!approvedFlag){
// 审核状态-审核拒绝
purchaseOrderVo.setAuditStatus("2");
}
// 提交
if("submit".equals(instanceType)){
// 使用状态-是
purchaseOrderVo.setUseStatus("1");
purchaseOrderService.addPurchaseOrderPayable(purchaseOrderVo);
//purchaseOrderService.addPurchaseOrderPayable(purchaseOrderVo);
}
// 作废
else if("cancel".equals(instanceType)){
@ -407,19 +330,7 @@ public class PurchaseOrderController extends BaseController
/**
* 加载采购订单审核页面
*/
@GetMapping("/auditPurchaseOrder/{purchaseOrderId}")
public String auditPurchaseOrder(@PathVariable("purchaseOrderId") Long purchaseOrderId,ModelMap mmap){
//purchasePlanCodes去除重复数据,purchasePlanCodeArray作为数组类型去除
//查询相关采购计划数据
PurchaseOrder purchaseOrder = purchaseOrderService.selectPurchaseOrderById(purchaseOrderId);
//根据采购计划编号查询对应的采购报价数据
//再根据采购计划编号分组查询对应的采购报价数据分组
mmap.put("purchaseOrder", purchaseOrder);
return prefix + "/taskFzjlVerify";
}

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

@ -59,6 +59,15 @@ public interface PurchaseOrderMapper
*/
public int updatePurchaseOrder(PurchaseOrder purchaseOrder);
/**
* 根据采购单号修改采购订单
*
* */
int updatePurchaseOrderCode(PurchaseOrder purchaseOrder);
/**
* 删除采购订单
*

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

@ -28,6 +28,12 @@ public interface PurchasePlanMapper
*/
public List<PurchasePlan> selectPurchasePlanList(PurchasePlan purchasePlan);
/**
* 根据计划编号查询采购计划单
* */
public PurchasePlan selectPurchasePlanByPlanCode(String purchasePlanCode);
/**
* 新增采购计划单
*
@ -76,7 +82,6 @@ public interface PurchasePlanMapper
*/
public int restorePurchasePlanById(Long purchasePlanId);
public PurchasePlan selectPurchasePlanByPlanCode(String purchasePlanCode);
public List<PurchasePlan> selectPurchasePlanByPlanCodes(String[] planCode);

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

@ -545,9 +545,6 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
}
//新增采购订单子表
private void buildPurchaseChild(List<PurchasePlanSelectMaterialVo> purchasePlanSelectMaterialVoList, PurchaseOrder purchaseOrder) {
List<PurchaseOrderChild> purchaseOrderChildren = new ArrayList<>();
@ -572,7 +569,7 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
purchaseOrderChild.setSharedInventoryOccupancyNum(purchasePlanSelectMaterialVo.getSharedInventoryOccupancyNum());
purchaseOrderChild.setMaterialNormbSum(purchasePlanSelectMaterialVo.getMaterialNoRmbSum());
purchaseOrderChild.setMaterialRmbSum(purchasePlanSelectMaterialVo.getMaterialRmbSum());
purchaseOrderChild.setPlanPurchaseNum(purchasePlanSelectMaterialVo.getThisPurchaseNum());
purchaseOrderChild.setPlanPurchaseNum(purchasePlanSelectMaterialVo.getPurchaseNum());
purchaseOrderChild.setActualPurchaseNum(purchasePlanSelectMaterialVo.getThisPurchaseNum());
purchaseOrderChild.setCreateBy(ShiroUtils.getLoginName());
purchaseOrderChild.setCreateTime(new Date());
@ -596,13 +593,176 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
* @param purchaseOrder 采购订单
* @return 结果
*/
@Transactional(rollbackFor = Exception.class)
@Override
public int updatePurchaseOrder(PurchaseOrder purchaseOrder)
{
purchaseOrder.setCreateTime(DateUtils.getNowDate());
purchaseOrder.setCreateBy(ShiroUtils.getLoginName());
//处理审核拒绝的情况
if (purchaseOrder.getAuditStatus().equals("2")){
purchaseOrderAuditRefuse(purchaseOrder);
}
return purchaseOrderMapper.updatePurchaseOrder(purchaseOrder);
}
/**
* 采购订单审核拒绝需要更新采购计划数据采购计划子表数据
* */
private void purchaseOrderAuditRefuse(PurchaseOrder purchaseOrder) {
Long purchaseOrderId = purchaseOrder.getPurchaseOrderId();
PurchaseOrderVo purchaseOrderVo = purchaseOrderMapper.selectPurchaseOrderById(purchaseOrderId);
String purchaseOrderCode = purchaseOrderVo.getPurchaseOrderCode();
//得到采购订单子表的数据
List<PurchaseOrderChild> purchaseOrderChildList = purchaseOrderChildMapper.selectPurchaseOrderChildByOrderCode(purchaseOrderCode);
String purchasePlanCode = purchaseOrderVo.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);
// 创建一个 map 用于快速查找采购计划子表数据
Map<String, List<PurchasePlanChild>> purchasePlanChildMap = purchasePlanChildList.stream()
.collect(Collectors.groupingBy(PurchasePlanChild::getPurchasePlanCode));
// 用于存储每个采购计划的总变动量
Map<String, Integer> planSumChanges = new HashMap<>();
// 将采购订单子表中的实际采购数量分配给采购计划子表
// 将采购订单子表中的实际采购数量分配给采购计划子表
for (PurchaseOrderChild orderChild : purchaseOrderChildList) {
String materialNo = orderChild.getMaterialNo();
int actualPurchaseNum = orderChild.getActualPurchaseNum();
for (String planCode : purchasePlanCodeList) {
List<PurchasePlanChild> planChildren = purchasePlanChildMap.get(planCode);
if (planChildren != null) {
// 按创建时间排序
planChildren.sort(Comparator.comparing(PurchasePlanChild::getCreateTime));
for (PurchasePlanChild planChild : planChildren) {
if (planChild.getMaterialNo().equals(materialNo) && actualPurchaseNum > 0) {
int remainingPurchaseNum = planChild.getPlanPurchaseNum() - planChild.getActualPurchaseNum();
if (remainingPurchaseNum > 0) {
int consumeNum = Math.min(actualPurchaseNum, remainingPurchaseNum);
planChild.setActualPurchaseNum(planChild.getActualPurchaseNum() - consumeNum); // 减少实际采购数
planChild.setPurchaseNum(planChild.getPurchaseNum() + consumeNum); // 增加待采购数
actualPurchaseNum -= consumeNum;
updatePurchasePlanChildStatus(planChild);
// 更新采购计划子表
int updatePurchasePlanChildResult = purchasePlanChildMapper.updatePurchasePlanChild(planChild);
if (updatePurchasePlanChildResult <= 0) {
throw new BusinessException("更新采购计划子表数据失败");
}
// 记录采购计划主表的变动量
planSumChanges.put(planCode, planSumChanges.getOrDefault(planCode, 0) + consumeNum);
} else if (remainingPurchaseNum == 0) {
// 如果剩余待采购数为0,直接增加实际采购数
planChild.setActualPurchaseNum(planChild.getActualPurchaseNum() - actualPurchaseNum); // 减少实际采购数
planChild.setPurchaseNum(planChild.getPurchaseNum() + actualPurchaseNum); // 增加待采购数
updatePurchasePlanChildStatus(planChild);
// 更新采购计划子表
int updatePurchasePlanChildResult = purchasePlanChildMapper.updatePurchasePlanChild(planChild);
if (updatePurchasePlanChildResult <= 0) {
throw new BusinessException("更新采购计划子表数据失败");
}
// 记录采购计划主表的变动量
planSumChanges.put(planCode, planSumChanges.getOrDefault(planCode, 0) + actualPurchaseNum);
// 退出循环,因为已经分配完所有实际采购数
break;
}
}
}
}
}
}
// 更新采购计划主表
for (String planCode : planSumChanges.keySet()) {
int totalChange = planSumChanges.get(planCode);
refuseUpdatePurchasePlan(planCode, totalChange);
}
}
// 更新采购计划主表的方法
private void refuseUpdatePurchasePlan(String purchasePlanCode, int totalChange) {
PurchasePlan purchasePlan = purchasePlanMapper.selectPurchasePlanByPlanCode(purchasePlanCode);
if (purchasePlan != null) {
if (purchasePlan.getActualPurchaseSum() == null) {
purchasePlan.setActualPurchaseSum(0);
}
if (purchasePlan.getPurchaseSum() == null) {
purchasePlan.setPurchaseSum(0);
}
// 增加实际采购数
purchasePlan.setActualPurchaseSum(purchasePlan.getActualPurchaseSum() - totalChange);
// 减少待采购数
purchasePlan.setPurchaseSum(purchasePlan.getPurchaseSum() + totalChange);
// 更新采购计划主表的状态
updatePurchasePlanStatus(purchasePlan);
purchasePlan.setUpdateTime(new Date());
purchasePlan.setUpdateBy(ShiroUtils.getLoginName());
purchasePlanMapper.updatePurchasePlan(purchasePlan);
}
}
// 更新采购计划主表状态的方法
private void updatePurchasePlanStatus(PurchasePlan purchasePlan) {
if (purchasePlan.getActualPurchaseSum() > 0 &&purchasePlan.getActualPurchaseSum() < purchasePlan.getPlanPurchaseSum()) {
purchasePlan.setPurchasePlanStatus("1"); // 部分申请
} else if (purchasePlan.getActualPurchaseSum().equals(purchasePlan.getPlanPurchaseSum())) {
purchasePlan.setPurchasePlanStatus("2"); // 全部申请
} else if (purchasePlan.getPlanPurchaseSum().equals(purchasePlan.getPurchaseSum())) {
purchasePlan.setPurchasePlanStatus("0"); // 待申请
}
}
// 更新采购计划子表状态的方法
private void updatePurchasePlanChildStatus(PurchasePlanChild planChild) {
if (planChild != null) {
if (planChild.getActualPurchaseNum() > 0 && planChild.getActualPurchaseNum() < planChild.getPlanPurchaseNum()) {
planChild.setPurchasePlanStatus("1");// 部分申请
} else if (planChild.getActualPurchaseNum().equals(planChild.getPlanPurchaseNum())) {
planChild.setPurchasePlanStatus("2"); // 全部申请
} else if (planChild.getPlanPurchaseNum().equals(planChild.getPurchaseNum())) {
planChild.setPurchasePlanStatus("0");// 待申请
}
}
}
/**
* 修改采购订单
*
@ -612,7 +772,10 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
@Override
public int updatePurchaseOrderCode(PurchaseOrder purchaseOrder)
{
return 1;
purchaseOrder.setUpdateTime(DateUtils.getNowDate());
purchaseOrder.setUpdateBy(ShiroUtils.getLoginName());
return purchaseOrderMapper.updatePurchaseOrderCode(purchaseOrder);
}
/**

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

@ -204,6 +204,53 @@
where purchase_order_id = #{purchaseOrderId}
</update>
<update id="updatePurchaseOrderCode" parameterType="PurchaseOrder">
update purchase_order
<trim prefix="SET" suffixOverrides=",">
<if test="purchaseOrderCode != null">purchase_order_code = #{purchaseOrderCode},</if>
<if test="purchasePlanCode != null">purchase_plan_code = #{purchasePlanCode},</if>
<if test="warehouseStorageStatus != null">warehouse_storage_status = #{warehouseStorageStatus},</if>
<if test="paymentStatus != null">payment_status = #{paymentStatus},</if>
<if test="supplierCode != null">supplier_code = #{supplierCode},</if>
<if test="supplierName != null">supplier_name = #{supplierName},</if>
<if test="materialSum != null">material_sum = #{materialSum},</if>
<if test="actualPurchaseSum != null">actual_purchase_sum = #{actualPurchaseSum},</if>
<if test="sharedInventoryOccupancySum != null">shared_inventory_occupancy_sum = #{sharedInventoryOccupancySum},</if>
<if test="refundsExchangesSum != null">refunds_exchanges_sum = #{refundsExchangesSum},</if>
<if test="storageSum != null">storage_sum = #{storageSum},</if>
<if test="noRmbSum != null">noRmb_sum = #{noRmbSum},</if>
<if test="rmbSum != null">rmb_sum = #{rmbSum},</if>
<if test="eceiptType != null">eceipt_type = #{eceiptType},</if>
<if test="arrivedTime != null">arrived_time = #{arrivedTime},</if>
<if test="stockNo != null">stock_no = #{stockNo},</if>
<if test="stockName != null">stock_name = #{stockName},</if>
<if test="receivePerson != null">receive_person = #{receivePerson},</if>
<if test="receivePersonPhone != null">receive_person_phone = #{receivePersonPhone},</if>
<if test="receiveAddress != null">receive_address = #{receiveAddress},</if>
<if test="purchaseBuyer != null">purchase_buyer = #{purchaseBuyer},</if>
<if test="useStatus != null">use_status = #{useStatus},</if>
<if test="auditStatus != null">audit_status = #{auditStatus},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
<if test="instanceId != null">instance_id = #{instanceId},</if>
<if test="instanceType != null">instance_type = #{instanceType},</if>
<if test="submitInstanceId != null">submit_instance_id = #{submitInstanceId},</if>
<if test="cancelInstanceId != null">cancel_instance_id = #{cancelInstanceId},</if>
<if test="restoreInstanceId != null">restore_instance_id = #{restoreInstanceId},</if>
<if test="applyTitle != null">apply_title = #{applyTitle},</if>
<if test="applyUser != null">apply_user = #{applyUser},</if>
<if test="applyTime != null">apply_time = #{applyTime},</if>
</trim>
where purchase_order_code = #{purchaseOrderCode}
</update>
<delete id="deletePurchaseOrderById" parameterType="Long">
delete from purchase_order where purchase_order_id = #{purchaseOrderId}
</delete>
@ -223,4 +270,5 @@
update purchase_order set del_flag = '0' where purchase_order_id = #{purchaseOrderId}
</update>
</mapper>

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

@ -58,6 +58,11 @@
</foreach>
</select>
<select id="selectPurchasePlanByPlanCode" parameterType="String" resultMap="PurchasePlanResult">
<include refid="selectPurchasePlanVo"/>
where purchase_plan_code = #{purchasePlanCode}
</select>
<insert id="insertPurchasePlan" parameterType="PurchasePlan" useGeneratedKeys="true" keyProperty="purchasePlanId">
insert into purchase_plan
<trim prefix="(" suffix=")" suffixOverrides=",">

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

@ -263,7 +263,7 @@
}
actions.push('<a class="' + editFlag + '" href="javascript:void(0)" onclick="openAudit(\'' + row.purchaseOrderId + '\')"><i class="fa fa-edit"></i>审核</a> ');
//actions.push('<a class="' + editFlag + '" href="javascript:void(0)" onclick="openAudit(\'' + row.purchaseOrderId + '\')"><i class="fa fa-edit"></i>审核</a> ');
var actionLinks = actions.join('');
return $.table.dropdownToggle(actionLinks);
}
@ -274,14 +274,6 @@
//打开采购订单审核页面
function openAudit(purchaseOrderId){
var url = prefix + "/auditPurchaseOrder/" + purchaseOrderId;
$.modal.open("采购订单审核", url);
}
// 导出
function exportExcel(formId) {
// $.table.set();

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

@ -1,18 +1,12 @@
<!DOCTYPE html>
<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 :: select2-css" />
<style>
.fixed-table-container {
border: 0px solid #ddd;
min-height: 110px;
}
</style>
<th:block th:include="include :: header('副总经理审核')" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-purchaseOrder-cgjl" th:object="${formData}">
<form class="form form-horizontal m-t" id="form-purchaseOrder-cgjl" 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">
@ -20,135 +14,124 @@
<input name="instanceId" th:field="*{instanceId}" type="hidden">
<input name="instanceType" th:field="*{instanceType}" type="hidden">
<input type="hidden" name="p_COM_comment" />
<div class="form-group" hidden="hidden">
<label class="col-sm-6 control-label">申请人:</label>
<div class="col-sm-6">
<input name="applyUser" th:field="*{applyUser}" class="form-control" type="text" disabled>
</div>
</div>
<div class="form-group" hidden="hidden">
<label class="col-sm-6 control-label">申请时间:</label>
<div class="col-sm-6">
<div class="input-group date">
<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" 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">
<label class="col-sm-4 control-label">已选择采购计划:</label>
<div class="col-sm-7">
<input id="purchasePlanCodes" name="purchasePlanCode" class="form-control" type="text" disabled/>
</div>
</div>
<div class="container">
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" ><a href="#supplierModel" aria-controls="supplierModel" role="tab" data-toggle="tab">按供应商展示</a></li>
<li role="presentation" class="active"><a href="#purchasePlanModel" aria-controls="purchasePlanModel" role="tab" data-toggle="tab">按采购计划展示</a></li>
</ul>
<div class="tab-content">
<div role="tabpanel" class="tab-pane " id="supplierModel">
<div class="container" id="supplierMaterial">
<!-- 已选择采购计划单号-->
<div class="container">
<div class="row">
<div class="col-12">
<h3 class="mb-4">已选择采购计划单号:</h3>
</div>
</div>
<div role="tabpanel" class="tab-pane active" id="purchasePlanModel">
<div class="container" id="purchasePlanMaterial">
<div class="form-group row">
<label for="purchasePlanCode" class="col-sm-2 control-label">已选择采购计划单号:</label>
<div class="col-sm-10">
<input id="purchasePlanCode" name="purchasePlanCodes" th:field="*{purchasePlanCode}" class="form-control" type="text" readonly>
</div>
</div>
</div>
</div>
<div class="container">
<div class="row"><h4 class="card-header">公司地址:</h4></div>
<div class="col-xs-6">
<label for="stockNo" class="col-sm-6 col-form-label">仓库ID:</label>
<div class="col-sm-5">
<select class="form-control" name="stockNo" id="stockNo">
</select>
</div>
</div>
<div class="col-xs-6">
<label for="stockName" class="col-sm-6 col-form-label">仓库名称:</label>
<div class="col-sm-5">
<input type="text" class="form-control" name="stockName" id="stockName" disabled/>
<!-- 已选择供应商-->
<div class="container">
<div class="row">
<div class="col-12">
<h3 class="mb-4">已选择供应商:</h3>
</div>
</div>
<div class="col-xs-6">
<label for="stockContact" class="col-sm-6 col-form-label">收货人:</label>
<div class="col-sm-5">
<input type="text" name="stockContact" class="form-control" id="stockContact" disabled />
<div class="form-group row">
<label for="supplierCode" class="col-sm-2 control-label">供应商ID:</label>
<div class="col-sm-2">
<input id="supplierCode" th:field="*{supplierCode}" name="supplierCode" class="form-control" type="text" readonly>
</div>
<label for="supplierName" class="col-sm-2 control-label">供应商名称:</label>
<div class="col-sm-2">
<input id="supplierName" th:field="*{supplierName}" name="supplierName" class="form-control" type="text" readonly>
</div>
<div class="col-xs-6">
<label for="stockPhone" class="col-sm-6 col-form-label">收货电话:</label>
<div class="col-sm-5">
<input type="text" name="stockPhone" class="form-control" id="stockPhone" placeholder="请输入收货电话" disabled />
</div>
</div>
<div class="col-xs-6">
<label for="stockAddress" class="col-sm-6 col-form-label">详细地址:</label>
<div class="col-sm-5">
<textarea class="form-control" name="stockAddress" id="stockAddress" disabled></textarea>
<!--公司收货信息-->
<div class="container">
<div class="row">
<div class="col-12">
<h3 class="mb-4">公司收货信息:</h3>
</div>
</div>
<div class="form-group row">
<label for="stockNo" class="col-sm-2 control-label">仓库ID:</label>
<div class="col-sm-2">
<input id="stockNo" th:field="*{stockNo}" name="stockNo" class="form-control" type="text" readonly>
</div>
<div class="container">
<div class="row"><h4 class="card-header">订单合计:</h4></div>
<div class="col-xs-6">
<label for="purchaseMaterialSum" class="col-sm-6 col-form-label">物料合计:</label>
<div class="col-sm-5">
<input type="text" class="form-control" id="purchaseMaterialSum" disabled />
<label for="stockName" class="col-sm-2 control-label">仓库名称:</label>
<div class="col-sm-2">
<input id="stockName" th:field="*{stockName}" name="stockName" class="form-control" type="text" readonly>
</div>
</div>
<div class="col-xs-6">
<label for="purchaseSum" class="col-sm-6 col-form-label">采购合计:</label>
<div class="col-sm-5">
<input type="text" class="form-control" id="purchaseSum" disabled />
<div class="form-group row">
<label for="receivePerson" class="col-sm-2 control-label">收货人:</label>
<div class="col-sm-2">
<input id="receivePerson" th:field="*{receivePerson}" name="receivePerson" class="form-control" type="text" readonly>
</div>
<label for="receivePersonPhone" class="col-sm-2 control-label">收货电话:</label>
<div class="col-sm-2">
<input id="receivePersonPhone" th:field="*{receivePersonPhone}" name="receivePersonPhone" class="form-control" type="text" readonly>
</div>
<div class="col-xs-6">
<label for="purchaseNoRmbSum" class="col-sm-5 col-form-label">不含税采购总价:</label>
<div class="col-sm-6">
<input type="text" class="form-control" id="purchaseNoRmbSum" disabled />
<label for="receiveAddress" class="col-sm-2 control-label">收货地址:</label>
<div class="col-sm-2">
<input id="receiveAddress" th:field="*{receiveAddress}" name="receiveAddress" class="form-control" type="text" readonly>
</div>
</div>
<div class="col-xs-6">
<label for="purchaseRmbSum" class="col-sm-5 col-form-label">含税采购总价:</label>
<div class="col-sm-6">
<input type="text" class="form-control" id="purchaseRmbSum" disabled />
</div>
<!-- 审批-->
<div class="container">
<div class="row">
<div class="col-12">
<h3 class="mb-4">审批:</h3>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required" for="cgjlVerifyApproved">审批意见:</label>
<div class="col-sm-6">
<div class="form-group row">
<label for="cgjlVerifyApproved" class="col-sm-2 control-label">审批意见:</label>
<div class="col-sm-2">
<select name="p_B_cgjlVerifyApproved" id="cgjlVerifyApproved" class="form-control" required>
<option value=""></option>
<option value="true">同意</option>
<option value="false">拒绝</option>
</select>
</div>
<label for="comment" class="col-sm-2 control-label">批注:</label>
<div class="col-sm-2">
<textarea name="comment" id="comment" class="form-control"></textarea>
</div>
</div>
</div>
<!--采购信息-->
<div class="container">
<div class="row">
<div class="col-12">
<h3 class="mb-4">采购信息:</h3>
</div>
</div>
<div class="form-group">
<label class="col-sm-6 control-label">批注:</label>
<div class="col-sm-6">
<textarea name="comment" class="form-control"></textarea>
<div class="form-group row">
<div class="col-sm-12 select-table table-striped">
<table id="purchaseChild-bootstrap-table"></table>
</div>
</div>
</div>
</form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: select2-js" />
<script th:src="@{/js/activiti.js}"></script>
<script th:inline="javascript">
var prefix = ctx + "purchase/purchaseOrder";
@ -158,457 +141,126 @@
var sysUnitClassDatas = [[${@dict.getType('sys_unit_class')}]];
var processMethodDatas = [[${@dict.getType('processMethod')}]];
var warehouseDeptDatas = [[${@dict.getType('warehouseDept')}]];
var loginName = [[${@permission.getPrincipalProperty('loginName')}]];
$("#form-purchaseOrder-cgjl").validate({focusCleanup: true});
var purchasePlanChildList = [];
var purchasePlanCodes = [];
var formId = "form-purchaseOrder-cgjl";
//根据物料物料数量添加物料分类表,自动生成类似的表单对象
//初始根据采购计划单,涉及到物料做分类表
//根据采购计划单,获取物料信息,自动生成物料的供应商分类表
//获取表单的id;
var materialList = [];
var tableIdList = [];
var $supplierForm;
var tableDatas = [];
//获取采购计划单的物料信息
// 假设qualityOrderCode已经定义或者可以通过某种方式获取到
$(function() {
// 初始化时默认加载仓库ID列表
// 假设purchaseOrderCode已经定义或者可以通过某种方式获取到
var purchaseOrderCode = [[${formData.purchaseOrderCode}]]; // 这里需要实际赋值,比如从前端某个地方读取
var purchaseOrderId = [[${formData.purchaseOrderId}]];
loadWarehouseCodes();
//物料合计 = 物料实际采购数合计,不含税总价,含税采购总价不为null的情况可以合计物料,否则跳过
$("#purchaseMaterialSum").val(purchaseOrder.materialSum);
//采购数量合计
$('#purchaseSum').val(purchaseOrder.materialSum);
//采购不含税总价
$('#purchaseNoRmbSum').val(purchaseOrder.noRmbSum);
//采购含税总价
$('#purchaseRmbSum').val(purchaseOrder.rmbSum);
// 初始化表格,假设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);
}
}
//按照物料的维度查看采购订单信息
// 初始化表格
// 假设purchasePlanChildList已定义并包含了需要处理的数据
//物料列表
purchasePlanChildList.forEach(function (material, index) {
var tableId = 'materialCode-' + index;
var materialTable = "bootstrap-table_" + tableId;
tableIdList.push(tableId);
// 创建物料信息的容器
var $tableWrapper = $('<div id="material-' + tableId + '""></div>');
// 将整个物料信息容器添加到页面
$('#purchasePlanMaterial').append($tableWrapper);
var uniqueSuppliers = [];
////如果物料相同,则添加供应商信息,并对比现在的关系采购计划关联单号是否有包含,没有添加。有则不添加
material.purchaseOrderChildSupplierList.forEach(supplier => {
const key = `${supplier.supplierCode}_${supplier.materialCode}`;
if (!uniqueSuppliers.map(s => `${s.supplierCode}_${s.materialCode}`).includes(key)) {
uniqueSuppliers.push(supplier);
}
});
// 添加关联销售订单号信息
// 创建表格的容器
var $headerDiv =
$('<div class="row">' +
'<div class="col-xs-12">' +
'<h3>' +
'<span><strong>物料 ' + (index + 1) + ': </strong><strong>关联订单号: </strong></span><span class="correlationCodes" id="correlateion-' + tableId + ' ">' + material.purchasePlanCorrelationCode + '</span>' +
'</h3>' +
'<div class="col-sm-12">' +
'<table class="table-materialCode" id="' + materialTable + '">' + '<table/>' +
'</div>' +
'</div>' +
'</div>');
$tableWrapper.append($headerDiv);
//创建物料库存容器
var $stockWrapper = $('<div class="row"><div class="inventory-count " id=" inventory-count-' + tableId + '">'+
'<span><strong>可用库存数:</strong></span>'+'<span id="stock-count-' + tableId + '">10 </span>'+'<span>注:含其他订单待领取的库存,仅供参考,请以实际为准.</span>'+
'</div></div>');
$tableWrapper.append($stockWrapper);
var materialObj = {
purchasePlanCode: material.purchasePlanCode, materialCode: material.materialCode,
photoUrl: material.materialPhotourl, materialName: material.materialName,
materialType: material.materialType, describe: material.materialDescribe,
brand: material.materiaBrand, processMethod: material.materialProcessMethod,
unit: material.materialUnit, warehouseDept:material.warehouseDept,
materialNum: material.materialNum,
};
var materialData = [materialObj];
materialList.push(material);
tables(materialTable, materialData);
var supplierCode = material.supplierCode;
if (supplierCodes.includes(supplierCode)) {
var supplierInfo = $('#supplierInfo_' + tableId);
if (supplierInfo.length === 0) {
var $supplierInfo = $('<div class="supplier-card " style="height: 20px;" id="supplierInfo_' + tableId + '"></div>');
$tableWrapper.append($supplierInfo);
}
var supplierData = material.purchaseOrderChildSupplierList;
supplierData.forEach(function (supplier) {
var supplierCode = supplier.supplierCode;
});
}
//如果物料下的供应商为空,则不需要添加供应商信息,并在容器中添加一个提示信息:暂无供应商信息,请先添加供应商信息。
if (material.purchaseOrderChildSupplierList.length <= 0) {
var $noSupplierDiv = $('<div class="no-supplier">暂无供应商信息,请先添加供应商信息。</div>');
$tableWrapper.append($noSupplierDiv);
}
else{
// 循环处理每个供应商的信息
uniqueSuppliers.forEach(function (supplier, supplierIndex) {
//如果供应商相同,则不需要再次添加供应商信息
// 卡片样式容器,用于包裹每个供应商的信息
// 构建供应商信息头部
var $headerContent =
$( '<div class="card-header supplier_card" id = "supplier-' + tableId + '_' + supplierIndex + '" xmlns="http://www.w3.org/1999/html">' +
'<div class="row">' +
'<div class="crad-text">'+
'<span><strong>供应商 ' + (supplierIndex + 1) + ': </strong></span>' + '<span class="supplierCode">' + supplier.supplierCode + '</span>' + '-' + '<span class="supplierName">' + supplier.supplierName + '</span>' +
'-最新不含税采购价: ' +'<span id="supplierMaterialNoRmb-' + tableId + '" class="supplierMaterialNoRmb"></strong>' + supplier.materialRealNoRmb +'</strong></span>'+
' RMB 最新含税采购价: ' +'<span class="supplierMaterialRmb"><strong>' + supplier.materialRealRmb + '</strong> RMB </span>' +
'<span class="supplierPurchasePlanCode" hidden="hidden" >' + material.planCodes + '</span>' +
'<span class="supplierCorrelationCode" hidden="hidden" >' + material.correlationCode + '</span>' +
'<span class="supplierPurchaseQuoteCode" hidden="hidden" >' + supplier.purchaseQuoteCode + '</span>' +
'</div>' +
'</div>' +
'<div class="row">' +
'<div class="col-xs-6 form-group">' +
'<label class="col-sm-4"> 实际采购数: </label>' +
'<div class ="col-sm-6">' +
'<input type="text" name="materialNum" value="' + supplier.materialRealNum + '" class="form-control supplierMaterialNum actualPurchaseNum" id="actualPurchaseNum_' + tableId + '" disabled>' +
'</div>' +
'</div>' +
'<div class="col-xs-6 form-group">' +
'<label class="col-sm-4">计划交付时间: </label>' +
'<div class ="col-sm-6">' +
'<div class="input-group date"> ' +
'<input type="text" name="deliveryTime" value="' + supplier.deliveryTime + '" text="' + supplier.deliveryTime + '" class="form-control supplierDeliveryTime" id="deliveryTime_' + tableId + '" disabled >' +
'<span class="input-group-addon"><i class="fa fa-calendar"></i></span>' +
'</div> ' +
'</div>' +
'</div>' +
'</div>' +
'</div>');
if (supplier.supplierCode != undefined && supplier.supplierCode != '' && supplier.supplierCode != null) {
$supplierInfo.append($headerContent);
// 构建供应商信息下的输入表单
$supplierForm = $('<div class="card-body" id="card_body_' + tableId + '"></div>');
// 实际采购数输入框
// 其他表单项可以根据需要类似添加
$supplierInfo.append($supplierForm);
}else{
var $noSupplierDiv = $('<div class="no-supplier">暂无供应商信息,请先添加供应商信息。</div>');
$supplierInfo.append($noSupplierDiv);
}
});
$tableWrapper.append($supplierInfo);
function submitHandler() {
if ($.validate.form()) {
if ($('textarea[name="comment"]').val()) {
$('input[name="p_COM_comment"]').val($('textarea[name="comment"]').val());
}
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;
var taskId = [[${taskId}]];
$.operate.save(prefix + "/complete/" + taskId, $('#form-purchaseOrder-cgjl').serialize());
}
// 更新供应商采购总价
$supplierInfo.find('.supplierPurchaseTotal').val(parseFloat(Number(purchaseNum * noRmbPrice).toFixed(2)));
if (rmbPrice) {
$supplierInfo.find('.supplierPurchaseTotalRmb').val(parseFloat(Number(purchaseNum * rmbPrice).toFixed(2)));
}
// 如果采购数量大于0,则显示供应商采购总价
if (purchaseNum > 0) {
$supplierInfo.find('.supplierPurchaseTotal').removeClass('hidden');
$supplierInfo.find('.supplierPurchaseTotalRmb').removeClass('hidden');
} else {
// 否则隐藏供应商采购总价
$supplierInfo.find('.supplierPurchaseTotal').addClass('hidden');
$supplierInfo.find('.supplierPurchaseTotalRmb').addClass('hidden');
}
recalculateTotals(tableId); // 重新计算当前物料的合计
}
});
// 定义一个函数来重新计算当前物料的合计
// 初始化总计
purchasePlanChildList.forEach(function (material, index) {recalculateTotals('materialCode-' + index);});
});
});
function createTableForSupplier(supplierCode, supplierData) {
var tableId = 'bootstrap-table-' + supplierCode.replace(/[^a-z0-9]/gi, '_').toLowerCase();
tableDatas.push(tableId);
var $tableWrapper = $('<div class="table-responsive"></div>');
// 确保supplierData至少有一条记录,并从中提取供应商详细信息
var supplierInfo = supplierData.length > 0 ? supplierData[0] : {}; // 默认为空对象,以防数据不存在
// 构建含有额外供应商信息的标题字符串
var headerTitle = '供应商: ' + supplierCode + ' - ' + supplierInfo.supplierName;
var $header = $('<h4>' + headerTitle + '</h4>');
var $table = $('<table id="' + tableId + '" class="table table-striped table-bordered"></table>');
$table.bootstrapTable({
data: supplierData,
columns: [
{ checkbox: false, visible: false },
{ title: '供应商ID', field: 'supplierCode', visible: false },
{ title: '料号', field: 'materialCode' },
{ title: '图片', field: 'materialPhotoUrl',
formatter: function(value, row, index) {return $.table.imageView(value);}
},
{ title: '物料名称', field: 'materialName' },
{ title: '物料类型', field: 'materialType', align: 'center',
formatter: function(value, row, index) {return $.table.selectCategoryLabel(materialTypeDatas, value);}
},
{ title: '物料描述', field: 'materialDescribe' },
{ title: '品牌', field: 'materialBrand' },
{ title: '加工类型', field: 'materialProcessMethod', align: 'center',
formatter: function(value, row, index) {return $.table.selectDictLabel(processMethodDatas, value);}
},
{ title: '单位', field: 'materialUnit', align: 'center' },
{ title: '入库部门', field: 'warehouseDept', align: 'center',
formatter: function(value, row, index) {return $.table.selectDictLabel(warehouseDeptDatas, value);}
},
{ title: '计划采购数', field: 'materialNum' },
{ title: '币种', field: '' },
{ title: '不含税采购价', field: 'materialNoRmb' },
{ title: '含税采购价', field: 'materialRmb' },
{ title: '实际采购数', field: 'materialRealNum' },
{ title: '实际不含税采购金额', field: 'materialRealNoRmb' },
{ title: '实际含税采购金额', field: 'materialRealRmb' },
{ title: '已入库数', field: 'actualHasArrivedNum' },
]
});
$tableWrapper.append($header).append($table);
$('#supplierMaterial').append($tableWrapper);
}
// 新增函数:重新计算某物料的采购数量合计、不含税采购总价和含税采购总价
function recalculateTotals(tableId) {
var $tableWrapper = $('#material-' + tableId);
var totalNoRmb = 0;
var totalRmb = 0;
var totalActualPurchase = 0;
var $suplierInfo = $tableWrapper.find('.supplier-card');
//获取所有物料表中供应商列表数据,实际采购数合计,不含税总价,含税采购总价
$suplierInfo.find('.supplier_card').each(function() {
let purchaseNum = parseFloat($(this).find('.actualPurchaseNum').val()) || 0;
let noRmbPrice = parseFloat($(this).find('.supplierMaterialNoRmb').text().trim()) || 0;
let rmbPrice = parseFloat($(this).find('.supplierMaterialRmb').text().trim()) || 0;
totalNoRmb += purchaseNum * noRmbPrice;
totalRmb += purchaseNum * rmbPrice;
totalActualPurchase = totalActualPurchase + purchaseNum;
});
//物料的实际采购数合计
$('#materialAmountSum_' + tableId).val(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;
}
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,
$(function() {
var options = {
id: "purchaseChild-bootstrap-table",
url: prefix + "/selectOrderChildMaterialList",
queryParams: queryParams,
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);
}
showColumns:false,
modalName: "选择物料",
columns: [{checkbox: true},
{
title: '采购计划子表id',
field: 'purchasePlanChildId',
visible: false
},
{title: '物料名称', field: 'materialName'},
{title: '物料类型', field: 'materialType', align: 'center', formatter: function (value, row, index) {
{
title: '料号',
field: 'materialNo',
},
{
title: '物料名称',
field: 'materialName',
},
{
title: '物料类型',
field: 'materialType',
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: 'materialDescribe',
},
{title: '单位', field: 'unit', align: 'center', },
{title: '入库部门', field: 'warehouseDept', align: 'center', formatter: function (value, row, index) {
return $.table.selectDictLabel(warehouseDeptDatas, value);
}},
{title: '计划采购数', field: 'materialNum'},
],
});
}
// 加载仓库Id列表函数
$("#form-cgjl-edit").validate({focusCleanup: true});
//open打开时,模态框foot下新增审核通过和审核拒绝按钮
//获取仓库相关信息Select2,根据仓库ID查询仓库名称
function loadWarehouseCodes() {
var url = ctx + 'stock/stockInfo/getAllWarehouseCode';
$.ajax({
type: 'GET', // 请求类型
url: url, // 后端接口URL
dataType: 'json', // 预期服务器返回的数据类型
success: function(data) {
if (data && Array.isArray(data)) {
var selectElement = $('#stockNo'); // 获取仓库编号下拉框元素
selectElement.empty();// 清空下拉框现有选项
$.each(data, function(index, item) {
selectElement.append('<option value="' + item.stockNO + '">' + item.stockNO + '</option>');
}); // 遍历返回的数据,添加为下拉框的选项
//设备当前选择的值
selectElement.val(purchaseOrder.stockNo).trigger('change');
} else {
$.modal.errMsg("数据为空");
}
}
});
}
$('#stockNo').on('change', function() {
var selectedWarehouseCode = $(this).val(); // 获取选中的仓库ID
if (selectedWarehouseCode) {
// 发起Ajax请求获取仓库名称
$.ajax({
type: 'GET',
url: ctx +'stock/stockInfo/getStockNameByWarehouseCode/' + selectedWarehouseCode,
dataType: 'json', // 假设返回的数据格式是JSON
success: function(data) {
console.log(data);
// 将获取到的仓库名称填充到输入框
if(data.data == null){
// 如果返回的数据有问题,可以给出提示或处理
$.modal.alertWarning('未能获取到仓库名称!');
}
$('input[name="stockName"]').val(data.data.stockName);
$('input[name="stockAddress"]').val(data.data.stockAddr);
$('input[name="stockContact"]').val(data.data.stockManager);
$('input[name="stockPhone"]').val(data.data.stockManagerPhone);
{
title: '品牌',
field: 'materialBrand',
},
error: function(jqXHR, textStatus, errorThrown) {
console.error('Error:', textStatus, errorThrown);
$.modal.alertWarning('查询仓库名称时发生错误!');
{
title: '单位',
field: 'materialUnit',
formatter: function(value, row, index) {
return $.table.selectDictLabel(sysUnitClassDatas, value);
}
});
},
{
title: '型号',
field: 'materialModel',
},
{
title: '加工方式',
field: 'materialProcessMethod',
formatter: function(value, row, index) {
return $.table.selectDictLabel(processMethodDatas, value);
}
},
{
title: '计划采购数',
field: 'planPurchaseNum',
},
{
title: '实际采购数',
field: 'actualPurchaseNum',
},
{
title: '共享库存占用数',
field: 'sharedInventoryOccupancyNum',
},
{
title: '不含税总价',
field: 'materialNoRmbSum',
},
{
title: '含税总价',
field: 'materialRmbSum',
},
{
title: '交付时间',
field: 'planDeliveryTime',
},
],
};
$.table.init(options);
});
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-cgjl').serialize());
}
function queryParams(params){
var curParams = {
purchaseOrderCode : purchaseOrder.purchaseOrderCode
};
return curParams
}
</script>
</body>
</html>

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

@ -5,7 +5,16 @@
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form form-horizontal m-t" id="form-purchaseOrder-fzjl" th:object="${purchaseOrder}">
<form class="form form-horizontal m-t" id="form-purchaseOrder-fzjl" 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="p_COM_comment" />
<!-- 已选择采购计划单号-->
<div class="container">
<div class="row">
@ -77,6 +86,33 @@
</div>
</div>
</div>
<!-- 审批-->
<div class="container">
<div class="row">
<div class="col-12">
<h3 class="mb-4">审批:</h3>
</div>
</div>
<div class="form-group row">
<label for="fzjlVerifyApproved" class="col-sm-2 control-label">审批意见:</label>
<div class="col-sm-2">
<select name="p_B_fzjlVerifyApproved" id="fzjlVerifyApproved" class="form-control" required>
<option value=""></option>
<option value="true">同意</option>
<option value="false">拒绝</option>
</select>
</div>
<label for="comment" class="col-sm-2 control-label">批注:</label>
<div class="col-sm-2">
<textarea name="comment" id="comment" class="form-control"></textarea>
</div>
</div>
</div>
<!--采购信息-->
<div class="container">
<div class="row">
@ -99,7 +135,7 @@
<script th:src="@{/js/activiti.js}"></script>
<script th:inline="javascript">
var prefix = ctx + "purchase/purchaseOrder";
var purchaseOrder = [[${purchaseOrder}]];
var purchaseOrder = [[${formData}]];
var materialTypeDatas = [[${@category.getChildByCode('materialType')}]];
var auditStatusDatas = [[${@dict.getType('auditStatus')}]];
var sysUnitClassDatas = [[${@dict.getType('sys_unit_class')}]];

Loading…
Cancel
Save