Browse Source
项目引进新版表单向导技术,并且设置为通用方法 按照新版prd调整 新增采购计划前端列表页面,按照新版prd调整布局和样式:采用主子表的形式展示数据,操作栏和表头按钮都按照统一样式调整 新增采购计划添加采购订单前端页面,按照新版prd完成第一步选择供应商的数据展示 新增 购计划添加采购订单第一步 选择供应商Vo实体用于前端选择供应商展示 新增 根据采购计划编号集合查询采购计划后端方法 新增 通过采购计划单号集合查询采购计划子表数据 采购计划Controller层新增 加载添加采购订单页面后端接口;新增 添加采购订单展示选择供应商列表后端接口 新增 根据计划编号集合查询采购计划单方法 新增 添加采购订单展示选择供应商列表实现:显示字段包括供应商ID、供应商名称、可供应物料数,字段(可供应物料总数):该供应商针对已选采购计划单的物料种数里,可供应的物料数,排序:优先按【可供应物料数】排序,数字越大,排序越靠前 新增 通过采购报价单号查找所有采购报价子表集合方法 新增 查找所有可用的采购报价的数据方法dev
liuxiaoxu
1 week ago
16 changed files with 537 additions and 566 deletions
@ -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; |
||||
|
|
||||
|
} |
@ -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> 搜索</a>--> |
||||
|
<!-- <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i> 重置</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> |
||||
|
Loading…
Reference in new issue