|
|
@ -18,13 +18,13 @@ |
|
|
|
<div class="form-group"> |
|
|
|
<label class="col-sm-3 control-label">入库单号:</label> |
|
|
|
<div class="col-sm-8"> |
|
|
|
<input name="warehouseStorageCode" th:field="*{warehouseStorageCode}" class="form-control" type="text" disabled> |
|
|
|
<input name="warehouseStorageCode" th:field="*{warehouseStorageCode}" class="form-control" type="text" readonly> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="form-group"> |
|
|
|
<label class="col-sm-3 control-label">关联单号:</label> |
|
|
|
<div class="col-sm-8"> |
|
|
|
<input name="relatedOrderCode" th:field="*{relatedOrderCode}" class="form-control" type="text" disabled> |
|
|
|
<input name="relatedOrderCode" th:field="*{relatedOrderCode}" class="form-control" type="text" readonly> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="col-xs-12"> |
|
|
@ -39,7 +39,7 @@ |
|
|
|
<label class="col-sm-3 control-label">到货时间:</label> |
|
|
|
<div class="col-sm-8"> |
|
|
|
<div class="input-group date"> |
|
|
|
<input name="arrivedTime" th:value="${#dates.format(warehouseStorageOrder.arrivedTime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text" disabled> |
|
|
|
<input name="arrivedTime" th:value="${#dates.format(warehouseStorageOrder.arrivedTime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text" readonly> |
|
|
|
<span class="input-group-addon"><i class="fa fa-calendar"></i></span> |
|
|
|
</div> |
|
|
|
</div> |
|
|
@ -54,13 +54,15 @@ |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="form-group"> |
|
|
|
<label class="col-sm-3 control-label">仓库Id:</label> |
|
|
|
<label class="col-sm-4 control-label is-required">仓库ID:</label> |
|
|
|
<div class="col-sm-8"> |
|
|
|
<input name="warehouseCode" th:field="*{warehouseCode}" class="form-control" type="text"> |
|
|
|
<select class="form-control" id="warehouseCode" name="warehouseCode" th:field="*{warehouseCode}" required> |
|
|
|
<!-- 这里动态生成仓库ID选项 --> |
|
|
|
</select> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="form-group"> |
|
|
|
<label class="col-sm-3 control-label">仓库名称:</label> |
|
|
|
<label class="col-sm-4 control-label">仓库名称:</label> |
|
|
|
<div class="col-sm-8"> |
|
|
|
<input name="warehouseName" th:field="*{warehouseName}" class="form-control" type="text"> |
|
|
|
</div> |
|
|
@ -88,16 +90,66 @@ |
|
|
|
<script th:inline="javascript"> |
|
|
|
|
|
|
|
var warehouseStorageCode = [[${warehouseStorageOrder.warehouseStorageCode}]] |
|
|
|
|
|
|
|
var warehouseCode = [[${warehouseStorageOrder.warehouseCode}]] |
|
|
|
var prefix = ctx + "warehouse/storageOrder"; |
|
|
|
$("#form-temporaryPurchaseWarehouse-edit").validate({ |
|
|
|
focusCleanup: true |
|
|
|
}); |
|
|
|
|
|
|
|
//生成的不同table的id集合 |
|
|
|
var tableDatas = []; |
|
|
|
|
|
|
|
function submitHandler() { |
|
|
|
if ($.validate.form()) { |
|
|
|
$.operate.save(prefix + "/temporaryPurchaseWarehouse", $('#form-temporaryPurchaseWarehouse-edit').serialize()); |
|
|
|
const storageOrderData = $("#form-temporaryPurchaseWarehouse-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, |
|
|
|
"materialNo": item.materialNo, |
|
|
|
"materialName": item.materialName, |
|
|
|
"materialType": item.materialType, |
|
|
|
"materialPhotourl": item.materialPhotourl, |
|
|
|
"materialDescribe": item.materialDescribe, |
|
|
|
"materialBrand": item.materialBrand, |
|
|
|
"materialUnit": item.materialUnit, |
|
|
|
"materialProcessMethod": item.materialProcessMethod, |
|
|
|
"notifyHasArrivedNum": item.notifyHasArrivedNum, |
|
|
|
"actualHasArrivedNum": item.actualHasArrivedNum, |
|
|
|
"temporaryHasQualifiedNum": item.temporaryHasQualifiedNum, |
|
|
|
"qualityHasQualifiedNum": item.qualityHasQualifiedNum, |
|
|
|
"hasStorageNum": item.hasStorageNum, |
|
|
|
"notifyArriveNum": item.notifyArriveNum, |
|
|
|
"actualArriveNum": item.actualArriveNum, |
|
|
|
"temporaryQualifiedNum": item.temporaryQualifiedNum, |
|
|
|
"temporaryRemark": item.temporaryRemark, |
|
|
|
"temporaryReportUrl": item.temporaryReportUrl, |
|
|
|
// ...其他字段 |
|
|
|
}; |
|
|
|
}); |
|
|
|
allMaterialDataList = allMaterialDataList.concat(materialDataList); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
const combinedData = Object.assign({}, storageOrderData, { |
|
|
|
warehouseStorageOrderDetailList: allMaterialDataList |
|
|
|
}); |
|
|
|
// 合并表单数据和表格数据 |
|
|
|
// const combinedData = Object.assign({}, ...complaintNoticeData.array(item => ({ [item.name]: item.value })), ...materialData); |
|
|
|
console.log(combinedData) |
|
|
|
// 使用 JSON.stringify() 序列化数据 |
|
|
|
const jsonData = JSON.stringify(combinedData); |
|
|
|
// 发送 AJAX 请求到后端接口 |
|
|
|
$.operate.saveJson(prefix + "/temporaryPurchaseWarehouse", jsonData); |
|
|
|
} |
|
|
|
|
|
|
|
$("input[name='arrivedTime']").datetimepicker({ |
|
|
@ -125,9 +177,9 @@ |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
function createTableForSupplier(supplierCode, supplierData) { |
|
|
|
var tableId = 'bootstrap-table-' + supplierCode.replace(/[^a-z0-9]/gi, '_').toLowerCase(); |
|
|
|
tableDatas.push(tableId); |
|
|
|
var $tableWrapper = $('<div class="table-responsive mt-3"></div>'); |
|
|
|
|
|
|
|
// 确保supplierData至少有一条记录,并从中提取供应商详细信息 |
|
|
@ -253,6 +305,73 @@ |
|
|
|
$('#tablesContainer').append($tableWrapper); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//根据仓库ID查询仓库名称 |
|
|
|
$(document).ready(function() { |
|
|
|
// 初始化时默认加载仓库ID列表 |
|
|
|
loadWarehouseCodes(); |
|
|
|
|
|
|
|
// 监听仓库ID下拉框的变化 |
|
|
|
$('#warehouseCode').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="warehouseName"]').val(data.data.stockname); |
|
|
|
}, |
|
|
|
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 = $('#warehouseCode'); // 获取仓库编号下拉框元素 |
|
|
|
// 清空下拉框现有选项 |
|
|
|
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> |
|
|
|
</body> |
|
|
|
</html> |