王晓迪
3 months ago
14 changed files with 1605 additions and 1434 deletions
@ -1,506 +1,424 @@ |
|||
<!DOCTYPE html> |
|||
<html lang="zh" xmlns:th="http://www.thymeleaf.org" > |
|||
<head> |
|||
<th:block th:include="include :: header('采购订单详情')" /> |
|||
<th:block th:include="include :: header('编辑采购订单')" /> |
|||
<th:block th:include="include :: select2-css" /> |
|||
<th:block th:include="include :: datetimepicker-css" /> |
|||
<link th:href="@{/ajax/libs/select2/select2.css}" rel="stylesheet"> |
|||
<link th:href="@{/ajax/libs/select2/select2-bootstrap.css}" rel="stylesheet"> |
|||
<th:block th:include="include :: bootstrap-editable-css"/> |
|||
<style> |
|||
.other-container { |
|||
width: 90%; |
|||
height: 200px; |
|||
margin: auto; |
|||
} |
|||
.other { |
|||
margin-top: 20px; |
|||
} |
|||
h4 { |
|||
display: inline-block; |
|||
margin-right: 20px; |
|||
} |
|||
.modal-body{ |
|||
height: 550px; |
|||
} |
|||
iframe{ |
|||
width: 100%; |
|||
height: 500px; |
|||
frameborder: 0; |
|||
border: 0; |
|||
display: inline-block; |
|||
} |
|||
</style> |
|||
<th:block th:include="include :: bootstrap-editable-css" /> |
|||
</head> |
|||
<body class="white-bg"> |
|||
<div class="wrapper wrapper-content animated fadeInRight ibox-content"> |
|||
<form class="form-horizontal m" id="form-purchaseOrder-detail" th:object="${purchaseOrder}"> |
|||
<input name="purchaseOrderId" th:field="*{purchaseOrderId}" type="hidden"> |
|||
<div class="form-group"> |
|||
<label class="col-sm-3 control-label">采购单号:</label> |
|||
<div class="col-sm-8"> |
|||
<input name="purchaseOrderCode" th:field="*{purchaseOrderCode}" class="form-control" type="text" readonly> |
|||
</div> |
|||
<div class="wrapper wrapper-content animated fadeInRight ibox-content"> |
|||
<form class="form-horizontal m" id="form-purchaseOrder-detail" th:object="${purchaseOrder}"> |
|||
<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"> |
|||
</div> |
|||
<div class="form-group"> |
|||
<label class="col-sm-3 control-label">采购类别:</label> |
|||
<div class="col-sm-8"> |
|||
<!-- <input name="purchaseCategory" th:field="*{purchaseCategory}" class="form-control" type="text">--> |
|||
<select name="purchaseCategory" th:field="*{purchaseCategory}" class="form-control m-b" th:with="type=${@dict.getType('purchase_category')}"> |
|||
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option> |
|||
</select> |
|||
</div> |
|||
<div class="container"> |
|||
<ul class="nav nav-tabs" role="tablist"> |
|||
<li role="presentation" class="active"><a href="#supplierModel" aria-controls="supplierModel" role="tab" data-toggle="tab">按供应商展示</a></li> |
|||
<li role="presentation"><a href="purchasePlanModel" aria-controls="purchasePlanModel" role="tab" data-toggle="tab">按采购计划展示</a></li> |
|||
</ul> |
|||
|
|||
<div class="tab-content"> |
|||
<div role="tabpanel" class="tab-pane" id="supplierModel"> |
|||
<div class="container" id="supplierMaterial"> |
|||
|
|||
</div> |
|||
</div> |
|||
</div> |
|||
<div class="container"> |
|||
<!--物料相关--> |
|||
<div class="row"> |
|||
<div class="col-sm-12" id="tablesContainer"> |
|||
<!-- 表格将在这里动态生成 --> |
|||
<div role="tabpanel" class="tab-pane active" id="purchasePlanModel"> |
|||
<div class="container" id="purchasePlanMaterial"> |
|||
|
|||
</div> |
|||
</div> |
|||
</div> |
|||
</form> |
|||
</div> |
|||
</form> |
|||
<div class="container"> |
|||
<div class="row"><h4 class="card-header">公司地址:</h4></div> |
|||
<div class="row"> |
|||
<label for="stockNo" class="col-sm-2 col-form-label">仓库ID:</label> |
|||
<div class="col-sm-4"> |
|||
<select class="form-control" name="stockNo" id="stockNo" ></select> |
|||
</div> |
|||
<label for="stockName" class="col-sm-2 col-form-label">仓库名称:</label> |
|||
<div class="col-sm-4"> |
|||
<input type="text" class="form-control" name="stockName" id="stockName"> |
|||
</div> |
|||
</div> |
|||
<div class="row"> |
|||
<label for="stockContact" class="col-sm-2 col-form-label">收货人:</label> |
|||
<div class="col-sm-4"> |
|||
<input type="text" name="stockContact" class="form-control" id="stockContact" > |
|||
</div> |
|||
<label for="stockPhone" class="col-sm-2 col-form-label">收货电话:</label> |
|||
<div class="col-sm-4"> |
|||
<input type="text" name="stockPhone" class="form-control" id="stockPhone" placeholder="请输入收货电话"> |
|||
</div> |
|||
</div> |
|||
<div class="form-group"> |
|||
<label for="stockAddress" class="col-sm-2 col-form-label">详细地址:</label> |
|||
<div class="col-sm-4"> |
|||
<textarea class="form-control" name="stockAddress" id="stockAddress"></textarea> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<div class="other-container"> |
|||
<div class="other"> |
|||
<br><hr> |
|||
<h4>选择采购信息</h4> |
|||
<a class="btn btn-primary" onclick="showQuotationModal()"><i class="fa fa-plus"></i> 选择材料</a> |
|||
<a class="btn btn-danger" onclick="removeMaterial()" ><i class="fa fa-remove"></i> 删除材料</a> |
|||
<div class="col-sm-12 select-table table-striped"> |
|||
<table id="addQuotationTable" style="white-space:nowrap"></table> |
|||
<div class="container"> |
|||
<div class="row"><h4 class="card-header">订单合计:</h4></div> |
|||
<div class="form-group"> |
|||
<label for="purchaseMaterialSum" class="col-sm-2 col-form-label">物料合计:</label> |
|||
<div class="col-sm-4"> |
|||
<input type="text" class="form-control" value="0" id="purchaseMaterialSum"> |
|||
</div> |
|||
</div> |
|||
<div class="modal inmodal" id="supplierQuotationModal" |
|||
role="dilog" aria-hidden="true"> |
|||
|
|||
<!-- 查询供应商报价--> |
|||
<div class="modal-dialog" style="width: 1000px;background-color: #FFFFFF"> |
|||
|
|||
<div class="modal-content" style="background-color: #FFFFFF"> |
|||
|
|||
<div class="modal-body"> |
|||
<div class="container-div"> |
|||
<div class="row"> |
|||
<div class="col-sm-12 search-collapse"> |
|||
<form id="quotationFormId"> |
|||
<div class="select-list"> |
|||
<ul> |
|||
<li> |
|||
<label>报价编码:</label> |
|||
<input type="text" name="quotationCode"/> |
|||
</li> |
|||
<li> |
|||
<label>原辅料代码:</label> |
|||
<input type="text" name="rawSubsidiaryCode"/> |
|||
|
|||
</li> |
|||
<li> |
|||
<label>原辅料名称:</label> |
|||
<input type="text" name="rawSubsidiaryName"/> |
|||
</li> |
|||
<!-- <li>--> |
|||
<!-- <label>供应商名称:</label>--> |
|||
<!-- <input type="text" name="supplierName"/>--> |
|||
|
|||
<!-- </li>--> |
|||
<li> |
|||
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search('quotationFormId','quotationTable')"><i |
|||
class="fa fa-search"></i> 搜索</a> |
|||
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset('quotationFormId','quotationTable')"><i |
|||
class="fa fa-refresh"></i> 重置</a> |
|||
</li> |
|||
</ul> |
|||
</div> |
|||
</form> |
|||
</div> |
|||
<div class="col-sm-12 select-table table-striped"> |
|||
<table id="quotationTable" style="white-space:nowrap"></table> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<div class="modal-footer"> |
|||
<a class="btn btn-warning btn-rounded" onclick="addQuotationToTable()">确认添加</a> |
|||
<a class="btn btn-primary btn-rounded" onclick="closeQuotationModal()">关闭</a> |
|||
</div> |
|||
</div> |
|||
|
|||
<div class="form-group"> |
|||
<label for="purchaseSum" class="col-sm-2 col-form-label">采购合计:</label> |
|||
<div class="col-sm-4"> |
|||
<input type="text" class="form-control" value="0" id="purchaseSum"> |
|||
</div> |
|||
</div> |
|||
<div class="form-group"> |
|||
<label for="purchaseNoRmbSum" class="col-sm-2 col-form-label">不含税采购总价:</label> |
|||
<div class="col-sm-4"> |
|||
<input type="text" class="form-control" value="0" id="purchaseNoRmbSum"> |
|||
</div> |
|||
</div> |
|||
<div class="form-group"> |
|||
<label for="purchaseRmbSum" class="col-sm-2 col-form-label">含税采购总价:</label> |
|||
<div class="col-sm-4"> |
|||
<input type="text" class="form-control" value="0" id="purchaseRmbSum"> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
|
|||
<th:block th:include="include :: footer" /> |
|||
<th:block th:include="include :: datetimepicker-js" /> |
|||
<th:block th:include="include :: select2-js"/> |
|||
<th:block th:include="include :: bootstrap-table-editable-js"/> |
|||
<script th:inline="javascript"> |
|||
|
|||
var getData = [[${purchaseOrder}]]; |
|||
|
|||
|
|||
var commonCurrencyDatas = [[${@dict.getType('sys_common_currency')}]]; |
|||
var purchasingUnitDatas = [[${@dict.getType('sys_unit_class')}]]; |
|||
var materialTypeDatas = [[${@dict.getType('ck_meterialt_type')}]]; |
|||
var confirmTaxDatas = [[${@dict.getType('sys_whether')}]]; |
|||
var currentQuoteDatas = [[${@dict.getType('sys_whether')}]]; |
|||
var confirmNoDatas = [[${@dict.getType('sys_whether')}]]; |
|||
var auditNoDatas = [[${@dict.getType('sys_whether')}]]; |
|||
var approveNoDatas = [[${@dict.getType('sys_whether')}]]; |
|||
|
|||
var prefix = ctx + "purchase/purchaseOrder"; |
|||
var prefixSupplierQuotation = ctx + 'system/supplierquotation' |
|||
var prefixPurchaseMaterial = ctx + 'purchase/purchaseMaterial' |
|||
|
|||
$("#form-purchaseOrder-detail").validate({ |
|||
focusCleanup: true |
|||
}); |
|||
|
|||
function submitHandler() { |
|||
// if ($.validate.form()) { |
|||
// $.operate.save(prefix + "/edit", $('#form-purchaseOrder-detail').serialize()); |
|||
// } |
|||
let getData=$('#addQuotationTable').bootstrapTable('getData', true) |
|||
if(getData.length > 0){ |
|||
if ($.validate.form()) { |
|||
$.modal.confirm("确认以上修改吗?", function (){ |
|||
//确认添加选中的物料数据 |
|||
confirmQuotation(); |
|||
$.operate.save(prefix + "/edit", $('#form-purchaseOrder-detail').serialize()); |
|||
}) |
|||
<th:block th:include="include :: footer" /> |
|||
<th:block th:include="include :: select2-js" /> |
|||
<th:block th:include="include :: datetimepicker-js" /> |
|||
<th:block th:include="include :: bootstrap-table-editable-js" /> |
|||
<script th:inline="javascript"> |
|||
var prefix = ctx + "purchase/purchaseOrder"; |
|||
var purchaseOrder = [[${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 = []; |
|||
var purchasePlanCodes = []; |
|||
var formId = "form-plan-purchaseOrder-add"; |
|||
//根据物料物料数量添加物料分类表,自动生成类似的表单对象 |
|||
//初始根据采购计划单,涉及到物料做分类表 |
|||
//根据采购计划单,获取物料信息,自动生成物料的供应商分类表 |
|||
//获取表单的id; |
|||
var materialList = []; |
|||
var tableIdList = []; |
|||
var $supplierForm; |
|||
var tableDatas = []; |
|||
//获取采购计划单的物料信息 |
|||
// 假设qualityOrderCode已经定义或者可以通过某种方式获取到 |
|||
$(function() { |
|||
// 初始化时默认加载仓库ID列表 |
|||
loadWarehouseCodes(); |
|||
// 假设purchaseOrderCode已经定义或者可以通过某种方式获取到 |
|||
var purchaseOrderCode = [[${purchaseOrder.purchaseOrderCode}]]; // 这里需要实际赋值,比如从前端某个地方读取 |
|||
var purchaseOrderId = [[${purchaseOrder.purchaseOrderId}]]; |
|||
// 初始化表格,假设purchasePlanChildList已定义并包含了需要处理的数据 |
|||
$.getJSON(prefix + "/editPurchaserOrder/" + purchaseOrderId, function(data) { |
|||
$("#purchasePlanCodes").val(data.data.purchasePlanCodes); |
|||
var datas = data.data.purchasePlanChildList; |
|||
purchasePlanChildList = datas; |
|||
var supplierCodes = data.data.supplierCodes; |
|||
var supplierMaterials = {}; |
|||
datas.forEach(function(item) { |
|||
var supplierCode = item.supplierCode; |
|||
var materialCode = item.materialCode; |
|||
// 如果供应商还没有在对象中,就创建一个新的对象 |
|||
if (!supplierMaterials[supplierCode]) {supplierMaterials[supplierCode] = {};} |
|||
// 如果该物料还没有在供应商的对象中,就添加它 |
|||
if (!supplierMaterials[supplierCode][materialCode]) { |
|||
supplierMaterials[supplierCode][materialCode] = { |
|||
...item, materialNum: 0 // 初始化数量为0 |
|||
}; |
|||
} |
|||
supplierMaterials[supplierCode][materialCode].materialNum += item.materialNum; |
|||
}); |
|||
for (var supplierCode in supplierMaterials) { |
|||
if (supplierMaterials.hasOwnProperty(supplierCode)) { |
|||
var supplierData = Object.values(supplierMaterials[supplierCode]); |
|||
createTableForSupplier(supplierCode, supplierData); |
|||
} |
|||
} else { |
|||
$.modal.alertWarning("未选择产品,请选择!") |
|||
} |
|||
} |
|||
|
|||
$("input[name='billingDate']").datetimepicker({ |
|||
format: "yyyy-mm-dd", |
|||
minView: "month", |
|||
autoclose: true, |
|||
todayBtn: true |
|||
}); |
|||
|
|||
$(function() { |
|||
//初始化添加材料表 |
|||
$('#addQuotationTable').bootstrapTable({ |
|||
url: prefixPurchaseMaterial + '/list', |
|||
pagination: true, |
|||
pageNumber: 1, |
|||
pageSize: 10, |
|||
method: "post", |
|||
contentType: "application/x-www-form-urlencoded", |
|||
striped: true, // 是否显示行间隔色 |
|||
cache: false, // 是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*) |
|||
showToggle: false, // 是否显示详细视图和列表视图的切换按钮 |
|||
cardView: false, // 是否显示详细视图 |
|||
detailView: false, // 是否显示父子表 |
|||
smartDisplay: false, // 加了这个才显示每页显示的行数 |
|||
showExport: false, // 是否显示导出按钮 |
|||
clickToSelect: true, |
|||
paginationDetailHAlign: ' hiddenDetailInfo', |
|||
height: 250, |
|||
uniqueId: 'purchaseOrderChildId', |
|||
queryParams: function (params) { |
|||
//console.log("123"); |
|||
var curParams = { |
|||
// 传递参数查询参数 |
|||
pageSize: params.limit, |
|||
pageNum: params.offset / params.limit + 1, |
|||
purchaseOrderCode: getData.purchaseOrderCode, |
|||
supplierCode: getData.supplierCode, |
|||
supplierName: getData.supplierName |
|||
}; |
|||
// console.log(data[0].enterpriseCode) |
|||
return curParams |
|||
}, |
|||
columns: [{ |
|||
checkbox: true |
|||
}, |
|||
{ |
|||
title: '采购订单子表id', |
|||
field: 'purchaseOrderChildId', |
|||
visible: false |
|||
}, |
|||
{ |
|||
title: '关联采购订单号', |
|||
field: 'purchaseOrderCode', |
|||
}, |
|||
{ |
|||
title: '供应商代码', |
|||
field: 'supplierCode', |
|||
}, |
|||
{ |
|||
title: '供应商名称', |
|||
field: 'supplierName', |
|||
}, |
|||
{ |
|||
title: '物料料号', |
|||
field: 'materialCode', |
|||
}, |
|||
{ |
|||
title: '物料名称', |
|||
field: 'materialName', |
|||
}, |
|||
{ |
|||
title: '物料不含税单价', |
|||
field: 'materialNormb', |
|||
}, |
|||
{ |
|||
title: '物料含税单价', |
|||
field: 'materialRmb', |
|||
}, |
|||
{ |
|||
title: '采购物料数量', |
|||
field: 'materialNum', |
|||
}, |
|||
{ |
|||
title: '物料合计', |
|||
field: 'materialAmount', |
|||
}, |
|||
{ |
|||
title: '数量合计', |
|||
field: 'materialSum', |
|||
}, |
|||
{ |
|||
title: '不含税总价(RMB)', |
|||
field: 'materialNormbsum', |
|||
}, |
|||
{ |
|||
title: '含税总价(RMB)', |
|||
field: 'materialRmbsum', |
|||
}, |
|||
{ |
|||
title: '交货时间', |
|||
field: 'deliveryTime', |
|||
}, |
|||
{ |
|||
title: '收货状态', |
|||
field: 'eceiptStatus', |
|||
}, |
|||
{ |
|||
title: '打款结案状态', |
|||
field: 'paymentStatus', |
|||
}, |
|||
{ |
|||
title: '税率', |
|||
field: 'taxRate', |
|||
}, |
|||
] |
|||
}) |
|||
|
|||
}); |
|||
//按照物料的维度查看采购订单信息 |
|||
// 初始化表格 |
|||
// 假设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 $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 $supplierInfo = $('<div class="supplier-card " style="height: 20px;" id="supplierInfo_' + tableId + '"></div>'); |
|||
|
|||
/*供应商列表*/ |
|||
$.ajax({ |
|||
url: ctx + 'system/supplier/list', |
|||
type: 'post', |
|||
success: function (res) { |
|||
console.log(res) |
|||
if (res.rows.length > 0) { |
|||
var suppliertData = res.rows; |
|||
//alert(JSON.stringify(data)); |
|||
for (let i in suppliertData) { |
|||
// console.log(finishProductData[i].finishProductCode) |
|||
$("#form-purchaseOrder-detail select[name='supplierCode']").append("<option value='" + suppliertData[i].supplierCode + "'>" + suppliertData[i].supplierCode + "</option>"); |
|||
} |
|||
$("#form-purchaseOrder-detail select[name='supplierCode']").val(getData.supplierCode).trigger("change") |
|||
$("#form-purchaseOrder-detail select[name='supplierCode']").change(function () { |
|||
var code = $(this).val(); |
|||
for (let i=0;i<suppliertData.length;i++) { |
|||
if (suppliertData[i].supplierCode == code) { |
|||
$("#form-purchaseOrder-detail input[name='supplierName']").val(suppliertData[i].supplierName); |
|||
$("#form-purchaseOrder-detail input[name='customerContact']").val(suppliertData[i].customerContact); |
|||
$("#form-purchaseOrder-detail input[name='contactNumber']").val(suppliertData[i].contactNumber); |
|||
$("#form-purchaseOrder-detail input[name='customerFax']").val(suppliertData[i].customerFax); |
|||
$("#form-purchaseOrder-detail input[name='paymentTerms']").val(suppliertData[i].paymentTerms); |
|||
$("#form-purchaseOrder-detail input[name='taxRate']").val(suppliertData[i].taxRate); |
|||
} |
|||
//如果物料下的供应商为空,则不需要添加供应商信息,并在容器中添加一个提示信息:暂无供应商信息,请先添加供应商信息。 |
|||
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); |
|||
} |
|||
}) |
|||
|
|||
} else { |
|||
$.modal.msgError(res.msg); |
|||
}); |
|||
// 循环处理每个供应商的信息 |
|||
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>供应商 ' + (supplierIndex + 1) + ':' + '</h4>' + |
|||
'<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>' + |
|||
'</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" class="form-control supplierMaterialNum actualPurchaseNum" id="actualPurchaseNum_' + tableId + '">' + |
|||
'</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" class="form-control supplierDeliveryTime" id="deliveryTime_' + tableId + '">' + |
|||
'<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); |
|||
} |
|||
} |
|||
}) |
|||
/*用户列表*/ |
|||
$.ajax({ |
|||
url: ctx + 'system/user/list', |
|||
type: 'post', |
|||
success: function (res) { |
|||
console.log(res) |
|||
if (res.rows.length > 0) { |
|||
var usertData = res.rows; |
|||
//alert(JSON.stringify(data)); |
|||
for (let i in usertData) { |
|||
// console.log(finishProductData[i].finishProductCode) |
|||
$("#form-purchaseOrder-detail select[name='purchaseCommander']").append("<option value='" + usertData[i].userName + "'>" + usertData[i].userName + "</option>"); |
|||
tableSetup($supplierInfo, tableId); |
|||
}); |
|||
// 给实际采购数的输入框绑定事件处理器 |
|||
$('.actualPurchaseNum').off('keyup').on('keyup', function(event) { |
|||
if (event.keyCode === 13) { |
|||
var $supplierInfo = $(this).closest('.supplier-card'); |
|||
var $supplierCard = $(this).closest('.supplier_card'); |
|||
var crad = $supplierInfo.attr('id'); |
|||
var tableId = crad.split('_')[1]; |
|||
var purchaseNum = parseFloat($(this).val()) || 0; |
|||
var noRmbPrice = parseFloat($(this).find('.supplierMaterialNoRmb').text().trim()) || 0; |
|||
var rmbPrice = parseFloat($(this).find('.supplierMaterialRmb').text().trim()) || 0; |
|||
var materialIndex = tableId.split('-')[1]; |
|||
// 确保实际采购数不超过计划采购数 |
|||
var maxPurchaseNum = parseFloat(materialList[materialIndex].materialNum); |
|||
// if (purchaseNum > maxPurchaseNum) { |
|||
// purchaseNum = maxPurchaseNum; |
|||
// $(this).val(maxPurchaseNum); |
|||
// } |
|||
//物料所有的供应商的采购数加起来超出了materialList[materialIndex].materialNum,就提示超出计划采购数 |
|||
let actualPurchaseNum = 0; |
|||
$supplierCard.find('.actualPurchaseNum').each(function () { |
|||
actualPurchaseNum += parseInt($(this).val()) || 0; |
|||
}); |
|||
if (actualPurchaseNum > maxPurchaseNum) { |
|||
actualPurchaseNum - maxPurchaseNum; |
|||
} |
|||
// 更新供应商采购总价 |
|||
$supplierInfo.find('.supplierPurchaseTotal').val(parseFloat(Number(purchaseNum * noRmbPrice).toFixed(2))); |
|||
if (rmbPrice) { |
|||
$supplierInfo.find('.supplierPurchaseTotalRmb').val(parseFloat(Number(purchaseNum * rmbPrice).toFixed(2))); |
|||
} |
|||
$("#form-purchaseOrder-detail select[name='purchaseCommander']").val(getData.purchaseCommander).trigger("change") |
|||
} else { |
|||
$.modal.msgError(res.msg); |
|||
} |
|||
} |
|||
}) |
|||
|
|||
/*添加报价信息*/ |
|||
//点击按钮显示报价信息模态框 |
|||
function showQuotationModal() { |
|||
if ($.validate.form()) { |
|||
$("#supplierQuotationModal").modal("show"); |
|||
//显示报价信息 |
|||
showQuotationData(); |
|||
} else { |
|||
$.modal.alertWarning("请填写必填项"); |
|||
} |
|||
} |
|||
|
|||
//关闭报价信息模态框 |
|||
function closeQuotationModal() { |
|||
$("#supplierQuotationModal").modal("hide"); |
|||
} |
|||
|
|||
//显示报价信息 |
|||
function showQuotationData() { |
|||
var supplierCode = $("#form-purchaseOrder-detail select[name='supplierCode']").val() |
|||
$("#quotationTable").bootstrapTable("destroy") |
|||
var options = { |
|||
id: 'quotationTable', |
|||
url: prefixSupplierQuotation + "/list", |
|||
modalName: "供应商报价", |
|||
pagination: true, |
|||
pageNumber: 1, |
|||
pageSize: 10, |
|||
showRefresh: false, |
|||
showToggle: false, |
|||
clickToSelect: true, |
|||
queryParams: function (params) { |
|||
var curParams = { |
|||
// 传递参数查询参数 |
|||
pageSize: params.limit, |
|||
pageNum: params.offset / params.limit + 1, |
|||
supplierCode: supplierCode |
|||
}; |
|||
let json = $.extend(curParams, $.common.formToJSON("quotationFormId")); |
|||
return json; |
|||
}, |
|||
columns: [ |
|||
{title: '采购单子表编号',field: 'purchaseOrderChildId',visible: false}, |
|||
{title: '关联采购订单号',field: 'purchaseOrderCode',visible: false}, |
|||
{title: '供应商ID',field: 'supplierCode',}, |
|||
{title: '供应商名称',field: 'supplierName',}, |
|||
{title: '物料合计',field: 'materialAmount',}, |
|||
{title: '数量合计',field: 'materialSum',}, |
|||
{title: '不含税总价(RMB)',field: 'materialNoRmbSum',}, |
|||
{title: '含税总价(RMB)',field: 'materialRmbSum',}, |
|||
{title:'收货状态',field: 'eceiptStatus',formatter: function (value, row, index) { |
|||
$.table.selectDictLabel(eceiptStatusDatas, value);} |
|||
}, |
|||
{title:'打款状态',field: 'paymentStatus',formatter: function (value, row, index) { |
|||
$.table.selectDictLabel(paymentStatusDatas, value);} |
|||
}, |
|||
{title: '交货时间',field: 'deliveryTime',visible: false}, |
|||
] |
|||
|
|||
}; |
|||
$.table.init(options); |
|||
} |
|||
// 如果采购数量大于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'); |
|||
} |
|||
|
|||
//表中添加选中的物料信息 |
|||
function addQuotationToTable() { |
|||
var data = $("#quotationTable").bootstrapTable("getSelections"); |
|||
var count = $('#addQuotationTable').bootstrapTable('getData').length; |
|||
var purchaseOrderNumber = $("input[name='purchaseOrderNumber']").val(); |
|||
var supplierCode = $("select[name='supplierCode']").val(); |
|||
var supplierName = $("input[name='supplierName']").val(); |
|||
// console.log(data); |
|||
// console.log(count); |
|||
for (var i = 0; i < data.length; i++) { |
|||
let rawSubsidiary = $('#addQuotationTable').bootstrapTable('getRowByUniqueId', data[i].rawSubsidiaryCode); |
|||
if (rawSubsidiary != null) { |
|||
alert(rawSubsidiary.rawSubsidiaryName + "已存在,不可重复添加!"); |
|||
continue; |
|||
recalculateTotals(tableId); // 重新计算当前物料的合计 |
|||
} |
|||
$("#addQuotationTable").bootstrapTable('insertRow', { |
|||
index: count + i, |
|||
row: { |
|||
purchaseOrderNumber: purchaseOrderNumber, |
|||
supplierCode: supplierCode, |
|||
supplierName: supplierName, |
|||
materialQuantity: '', |
|||
amountMoney: '', |
|||
deliveryTime: '', |
|||
purchaseExplain: '', |
|||
accountReconciliationFlag: 0 |
|||
}); |
|||
// 定义一个函数来重新计算当前物料的合计 |
|||
// 初始化总计 |
|||
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); |
|||
} |
|||
// 加载仓库Id列表函数 |
|||
$("#form-cgjl-edit").validate({focusCleanup: true}); |
|||
//open打开时,模态框foot下新增审核通过和审核拒绝按钮 |
|||
function submitHandler() { |
|||
if ($.validate.form()) { |
|||
if ($('textarea[name="comment"]').val()) { |
|||
$('input[name="p_COM_comment"]').val($('textarea[name="comment"]').val()); |
|||
} |
|||
|
|||
$("#quotationTable").bootstrapTable("uncheckAll"); |
|||
closeQuotationModal(); |
|||
var taskId = [[${taskId}]]; |
|||
$.operate.save(prefix + "/complete/" + taskId, $('#form-cgjl-edit').serialize()); |
|||
} |
|||
|
|||
//确认添加选中的物料数据 |
|||
function confirmQuotation() { |
|||
$("#addQuotationTable").bootstrapTable('refresh'); |
|||
let data = $('#addQuotationTable').bootstrapTable('getData', true); |
|||
// console.log(data) |
|||
if (data.length > 0) { |
|||
for (var i = 0; i < data.length; i++) { |
|||
data[i].purchaseOrderNumber = $("input[name='purchaseOrderNumber']").val(); |
|||
data[i].supplierCode = $("select[name='supplierCode']").val(); |
|||
data[i].supplierName = $("input[name='supplierName']").val(); |
|||
} |
|||
//获取仓库相关信息Select2,根据仓库ID查询仓库名称 |
|||
$('#stockNo').on('change', function() { |
|||
var selectedWarehouseCode = $(this).val(); // 获取选中的仓库ID |
|||
if (selectedWarehouseCode) { |
|||
// 发起Ajax请求获取仓库名称 |
|||
$.ajax({ |
|||
type: 'GET', |
|||
url: ctx +'stock/stockInfo/getStockNameByWarehouseCode/' + selectedWarehouseCode, |
|||
dataType: 'json', // 假设返回的数据格式是JSON |
|||
success: function(data) { |
|||
console.log(data); |
|||
// 将获取到的仓库名称填充到输入框 |
|||
if(data.data == null){ |
|||
// 如果返回的数据有问题,可以给出提示或处理 |
|||
$.modal.alertWarning('未能获取到仓库名称!'); |
|||
} |
|||
$('input[name="stockName"]').val(data.data.stockName); |
|||
$('input[name="stockAddress"]').val(data.data.stockAddr); |
|||
$('input[name="stockContact"]').val(data.data.stockManager); |
|||
$('input[name="stockPhone"]').val(data.data.stockManagerPhone); |
|||
}, |
|||
error: function(jqXHR, textStatus, errorThrown) { |
|||
console.error('Error:', textStatus, errorThrown); |
|||
$.modal.alertWarning('查询仓库名称时发生错误!'); |
|||
} |
|||
$.ajax({ |
|||
url: prefixPurchaseMaterial + '/addEditSave', |
|||
type: "POST", |
|||
data: { |
|||
data: JSON.stringify(data) |
|||
}, |
|||
dataType: "json", |
|||
success: function (resp) { |
|||
// console.log(data) |
|||
console.log(resp) |
|||
}, |
|||
|
|||
}) |
|||
} |
|||
}); |
|||
} |
|||
|
|||
// 批量删除成品 |
|||
function removeMaterial() { |
|||
var addQuotationTableData = $("#addQuotationTable").bootstrapTable("getSelections"); |
|||
var ids = []; |
|||
var rawSubsidiaryCodes=[]; |
|||
for (let i = 0;i < addQuotationTableData.length;i++) { |
|||
ids.push(addQuotationTableData[i].purchaseMaterialId) |
|||
rawSubsidiaryCodes.push(addQuotationTableData[i].rawSubsidiaryCode) |
|||
} |
|||
// console.log(ids) |
|||
if (addQuotationTableData.length > 0) { |
|||
$.modal.confirm("是否确认要删除选中的产品?", function (){ |
|||
$.ajax({ |
|||
url: prefixPurchaseMaterial + "/removeMaterial", |
|||
type: "POST", |
|||
data: { |
|||
ids: JSON.stringify(ids) |
|||
}, |
|||
success: function (res) { |
|||
// console.log(ids) |
|||
// console.log(res) |
|||
$.modal.msgSuccess("删除成功") |
|||
// $("#addProductTable").bootstrapTable('refreshOptions', {pageNumber: 1}); // pageNumber:1, 指定页码为第1页 |
|||
// $("#addProductTable").bootstrapTable('refresh'); |
|||
$("#addQuotationTable").bootstrapTable ('remove', { field: 'rawSubsidiaryCode', values: rawSubsidiaryCodes }) |
|||
} |
|||
}) |
|||
}) |
|||
|
|||
} else { |
|||
alert("请选择需要删除的数据") |
|||
else {$('input[name="warehouseName"]').val('');}// 如果没有选择仓库ID,清空仓库名称输入框 |
|||
}); |
|||
// 加载仓库Id列表函数 |
|||
function loadWarehouseCodes() { |
|||
var url = ctx + 'stock/stockInfo/getAllWarehouseCode'; |
|||
$.ajax({ |
|||
type: 'GET', // 请求类型 |
|||
url: url, // 后端接口URL |
|||
dataType: 'json', // 预期服务器返回的数据类型 |
|||
success: function(data) { |
|||
if (data && Array.isArray(data)) { |
|||
var selectElement = $('#stockNo'); // 获取仓库编号下拉框元素 |
|||
selectElement.empty();// 清空下拉框现有选项 |
|||
$.each(data, function(index, item) { |
|||
selectElement.append('<option value="' + item.stockNO + '">' + item.stockNO + '</option>'); |
|||
}); // 遍历返回的数据,添加为下拉框的选项 |
|||
// $('#warehouseCode').val(purchaseOrder.stockNO); |
|||
} else { |
|||
$.modal.errMsg("数据为空"); |
|||
} |
|||
} |
|||
|
|||
} |
|||
</script> |
|||
}); |
|||
} |
|||
</script> |
|||
</body> |
|||
</html> |
File diff suppressed because it is too large
Loading…
Reference in new issue