|
|
@ -1,52 +1,64 @@ |
|
|
|
<!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 :: datetimepicker-css" /> |
|
|
|
<style> |
|
|
|
.supplier-value span {margin-right: 10px;} |
|
|
|
</style> |
|
|
|
</head> |
|
|
|
<body class="white-bg"> |
|
|
|
<div class="wrapper wrapper-content animated fadeInRight ibox-content"> |
|
|
|
<form class="form-horizontal m" id="form-addPurchaseStorage-edit" th:object="${purchaseOrder}"> |
|
|
|
<input type="hidden" name="warehouseCode" th:field="*{stockNo}"/> |
|
|
|
<div class="form-group"> |
|
|
|
<label class="col-sm-3 control-label is-required">采购单号:</label> |
|
|
|
<label class="col-sm-3 control-label">采购单号:</label> |
|
|
|
<div class="col-sm-8"> |
|
|
|
<input name="relatedOrderCode" th:field="*{purchaseOrderCode}" class="form-control" type="text" required readonly> |
|
|
|
<input name="purchaseOrderCode" th:field="*{purchaseOrderCode}" class="form-control" type="text" readonly> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="form-group"> |
|
|
|
<label class="col-sm-3 control-label is-required">入库类别:</label> |
|
|
|
<label class="col-sm-3 control-label ">供应商ID:</label> |
|
|
|
<div class="col-sm-8"> |
|
|
|
<select name="eceiptType" class="form-control m-b" th:with="type=${@dict.getType('purchase_warehouse_type')}" required> |
|
|
|
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" ></option> |
|
|
|
</select> |
|
|
|
<input name="supplierCode" th:field="*{supplierCode}" class="form-control" type="text" readonly> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="form-group"> |
|
|
|
<label class="col-sm-3 control-label is-required">到货时间:</label> |
|
|
|
<label class="col-sm-3 control-label is-required">供应商名称:</label> |
|
|
|
<div class="col-sm-8"> |
|
|
|
<input name="supplierName" th:field="*{supplierName}" class="form-control" type="text" required readonly> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
<div class="form-group"> |
|
|
|
<label class="col-sm-3 control-label">到货时间:</label> |
|
|
|
<div class="col-sm-8"> |
|
|
|
<div class="input-group date"> |
|
|
|
<input name="arrivedTime" class="form-control" placeholder="yyyy-MM-dd" type="text" required readonly> |
|
|
|
<input name="arrivedTime" class="form-control" placeholder="yyyy-MM-dd" type="text" readonly> |
|
|
|
<span class="input-group-addon"><i class="fa fa-calendar"></i></span> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<!-- <div class="container" >--> |
|
|
|
<!--供应商物料相关--> |
|
|
|
<div id="tablesContainer" class="col-md-12" style="margin-left: auto;margin-right:auto"> |
|
|
|
<!-- <!– 表格将在这里动态生成 –>--> |
|
|
|
</div> |
|
|
|
<!-- </div>--> |
|
|
|
|
|
|
|
</form> |
|
|
|
|
|
|
|
|
|
|
|
<!--物料信息--> |
|
|
|
<div class="container"> |
|
|
|
<div class="row"> |
|
|
|
<div class="col-sm-12 select-table table-striped"> |
|
|
|
<table id="bootstrap-table"></table> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
</div> |
|
|
|
<th:block th:include="include :: footer" /> |
|
|
|
<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 auditStatusDatas = [[${@dict.getType('auditStatus')}]]; |
|
|
|
var useStatusDatas = [[${@dict.getType('useStatus')}]]; |
|
|
|
var processMethodDatas = [[${@dict.getType('processMethod')}]]; |
|
|
@ -55,165 +67,102 @@ |
|
|
|
var warehouseDeptDatas = [[${@dict.getType('warehouseDept')}]]; |
|
|
|
var purchaseOrderCode = [[${purchaseOrder.purchaseOrderCode}]]; |
|
|
|
$("#form-addPurchaseStorage-edit").validate({ focusCleanup: true}); |
|
|
|
//生成的不同table的id集合 |
|
|
|
var tableDatas = []; |
|
|
|
|
|
|
|
|
|
|
|
//物料信息展示列表 |
|
|
|
$(function() { |
|
|
|
// 假设qualityOrderCode已经定义或者可以通过某种方式获取到 |
|
|
|
var purchaseOrderCode = [[${purchaseOrder.purchaseOrderCode}]]; // 这里需要实际赋值,比如从前端某个地方读取 |
|
|
|
$.getJSON(prefix + "/detailListGroupedBySupplier?qualityOrderCode=" + purchaseOrderCode, function(data) { |
|
|
|
for (var supplierCode in data) { |
|
|
|
if (data.hasOwnProperty(supplierCode)) { |
|
|
|
var supplierData = data[supplierCode]; |
|
|
|
createTableForSupplier(supplierCode, supplierData); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
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 ='供应商'+'</br>'+supplierCode + ' - ' + supplierInfo.supplierName ; |
|
|
|
var $header = $('<h4>' + headerTitle + '</h4>'); |
|
|
|
var $table = $('<table id="' + tableId + '" class="table table-striped table-bordered"></table>'); |
|
|
|
$table.bootstrapTable({ |
|
|
|
data: supplierData, |
|
|
|
columns: [ |
|
|
|
{checkbox: false,visible: false}, |
|
|
|
{title: '供应商ID',field: 'supplierCode',visible: false}, |
|
|
|
{title: '料号',field: 'materialCode'}, |
|
|
|
{title: '物料名称',field: 'materialName'}, |
|
|
|
{title: '物料类型',field: 'materialType', |
|
|
|
var options = { |
|
|
|
modalName: "选择物料", |
|
|
|
url: prefix + "/selectOrderChildMaterialList", |
|
|
|
queryParams: queryParams, |
|
|
|
showSearch: false, |
|
|
|
showRefresh: false, |
|
|
|
showToggle: false, |
|
|
|
showColumns: false, |
|
|
|
pagination: false, // 设置不分页 |
|
|
|
columns: [{ |
|
|
|
checkbox: true |
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
title: '料号', |
|
|
|
field: 'materialNo', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '物料名称', |
|
|
|
field: 'materialName', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '物料类型', |
|
|
|
field: 'materialType', |
|
|
|
formatter: function (value,row, index) { |
|
|
|
$.table.selectCategoryLabel(materialTypeDatas, value) |
|
|
|
} |
|
|
|
}, |
|
|
|
{title: '物料图片地址',field: 'materialPhotourl', |
|
|
|
formatter: function (value, row, index) { |
|
|
|
$.table.imageView(value) |
|
|
|
} |
|
|
|
{ |
|
|
|
title: '物料型号', |
|
|
|
field: 'materialModel', |
|
|
|
}, |
|
|
|
{title: '物料描述',field: 'materialDescribe',}, |
|
|
|
{title: '物料品牌',field: 'materialBrand',}, |
|
|
|
{title: '物料单位',field: 'materialUnit', |
|
|
|
{ |
|
|
|
title: '物料品牌', |
|
|
|
field: 'materialBrand', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '物料单位', |
|
|
|
field: 'materialUnit', |
|
|
|
formatter:function (value) { |
|
|
|
return $.table.selectDictLabel(materialUnitDatas, value); |
|
|
|
} |
|
|
|
}, |
|
|
|
{title: '物料加工方式',field: 'materialProcessMethod', |
|
|
|
{ |
|
|
|
title: '物料描述', |
|
|
|
field: 'materialDescribe', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '物料加工方式', |
|
|
|
field: 'materialProcessMethod', |
|
|
|
formatter:function (value) { |
|
|
|
return $.table.selectDictLabel(processMethodDatas, value); |
|
|
|
} |
|
|
|
}, |
|
|
|
{title: '入库部门',field: 'warehouseDept',visible: false, |
|
|
|
{ |
|
|
|
title: '物料入库部门', |
|
|
|
field: 'materialDeptType', |
|
|
|
formatter:function (value) { |
|
|
|
return $.table.selectDictLabel(warehouseDeptDatas, value); |
|
|
|
} |
|
|
|
}, |
|
|
|
{title: '计划采购数',field: 'materialNum',}, |
|
|
|
{title: '实际采购数',field: 'materialRealNum',}, |
|
|
|
{title: '交付时间',field: 'deliveryTime',}, |
|
|
|
{title: '计划采购数',field: 'planPurchaseNum',}, |
|
|
|
{title: '实际采购数',field: 'actualPurchaseNum',}, |
|
|
|
{title: '交付时间',field: 'planDeliveryTime',}, |
|
|
|
{title: '通知已到货数',field: 'notifyHasArrivedNum', |
|
|
|
formatter: function (value, row, index) { |
|
|
|
if (value == null || value == '') { |
|
|
|
value = 0; |
|
|
|
} |
|
|
|
return value; |
|
|
|
} |
|
|
|
}, |
|
|
|
{title: '暂收数',field: 'temporaryNum',}, |
|
|
|
|
|
|
|
{title: '已入库数',field: 'hasStorageNum', |
|
|
|
formatter: function (value, row, index) { |
|
|
|
if (value == null || value == '') { |
|
|
|
value = 0; |
|
|
|
} |
|
|
|
return value; |
|
|
|
} |
|
|
|
}, |
|
|
|
{title: '通知到货数',field: 'notifyArriveNum',editable: { |
|
|
|
type: 'text', |
|
|
|
title: '通知到货数', |
|
|
|
validate: function (value, row, index) { |
|
|
|
var num = parseInt(value); |
|
|
|
if (isNaN(num)) { |
|
|
|
return '请输入数字'; |
|
|
|
} else if (num < 0) { |
|
|
|
return '不能小于0'; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
{title: '通知到货数',field: 'notifyArriveNum' |
|
|
|
} |
|
|
|
] |
|
|
|
}); |
|
|
|
$tableWrapper.append($header).append($table); |
|
|
|
$('#tablesContainer').append($tableWrapper); |
|
|
|
} |
|
|
|
var relatedOrderCode = [[${purchaseOrder.purchaseOrderCode}]]; |
|
|
|
var warehouseCode = [[${purchaseOrder.stockNo}]]; |
|
|
|
var warehouseName = [[${purchaseOrder.stockName}]]; |
|
|
|
var warehouseDetailAddress = [[${purchaseOrder.stockAddress}]]; |
|
|
|
function submitHandler() { |
|
|
|
const storageOrderData = $("#form-addPurchaseStorage-edit").serializeArray().reduce((obj, item) => { |
|
|
|
obj[item.name] = item.value; |
|
|
|
return obj; |
|
|
|
}, {}); |
|
|
|
// 初始化一个数组用于存放所有表格的数据 |
|
|
|
let allMaterialDataList = []; |
|
|
|
for(let i in tableDatas){ |
|
|
|
$('#' + tableDatas[i]).each(function() { |
|
|
|
const tableData = $(this).bootstrapTable('getData'); |
|
|
|
console.log(JSON.stringify(tableData)); |
|
|
|
// 将表数据转换成与qualityReportData格式一致的数组 |
|
|
|
var materialDataList = tableData.map(function (item) { |
|
|
|
// 根据实际字段名调整 |
|
|
|
return { |
|
|
|
"supplierCode": item.supplierCode, |
|
|
|
"supplierName":item.supplierName, |
|
|
|
"materialNo": item.materialCode, |
|
|
|
"materialName": item.materialName, |
|
|
|
"materialType": item.materialType, |
|
|
|
"materialPhotourl": item.materialPhotourl, |
|
|
|
"materialDescribe": item.materialDescribe, |
|
|
|
"materialBrand": item.materialBrand, |
|
|
|
"materialUnit": item.materialUnit, |
|
|
|
"materialDeptType": item.warehouseDept, |
|
|
|
"materialProcessMethod": item.materialProcessMethod, |
|
|
|
"notifyHasArrivedNum": item.notifyHasArrivedNum, |
|
|
|
"hasStorageNum": item.hasStorageNum, //已入库数量 |
|
|
|
"notifyArriveNum": item.notifyArriveNum, //通知到货数量 |
|
|
|
"relatedOrderCode":purchaseOrderCode |
|
|
|
}; |
|
|
|
}); |
|
|
|
allMaterialDataList = allMaterialDataList.concat(materialDataList); |
|
|
|
}); |
|
|
|
} |
|
|
|
const combinedData = Object.assign({}, storageOrderData, { |
|
|
|
relatedOrderCode:relatedOrderCode, |
|
|
|
warehouseCode:warehouseCode, |
|
|
|
warehouseName:warehouseName, |
|
|
|
warehouseDetailAddress:warehouseDetailAddress, |
|
|
|
warehouseStorageOrderDetailList: allMaterialDataList |
|
|
|
}); |
|
|
|
// 合并表单数据和表格数据 |
|
|
|
// const combinedData = Object.assign({}, ...complaintNoticeData.array(item => ({ [item.name]: item.value })), ...materialData); |
|
|
|
// 使用 JSON.stringify() 序列化数据 |
|
|
|
const jsonData = JSON.stringify(combinedData); |
|
|
|
// 发送 AJAX 请求到后端接口 |
|
|
|
$.operate.saveJson(prefix + "/addPurchaseOrderStorageSave", jsonData); |
|
|
|
$.table.init(options); |
|
|
|
}) |
|
|
|
|
|
|
|
function queryParams(params) { |
|
|
|
var curParams = { |
|
|
|
// 传递参数查询参数 |
|
|
|
purchaseOrderCode: purchaseOrder.purchaseOrderCode |
|
|
|
}; |
|
|
|
return curParams; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$("input[name='arrivedTime']").datetimepicker({ |
|
|
|
format: "yyyy-mm-dd", |
|
|
|
minView: "month", |
|
|
|
autoclose: true, |
|
|
|
}).datetimepicker("update", new Date());; |
|
|
|
|
|
|
|
$("input[name='deliveryInspectionTime']").datetimepicker({ |
|
|
|
format: "yyyy-mm-dd", |
|
|
|
minView: "month", |
|
|
|
autoclose: true |
|
|
|
}); |
|
|
|
</script> |
|
|
|
</body> |
|
|
|
</html> |