diff --git a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/controller/WarehouseStorageOrderController.java b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/controller/WarehouseStorageOrderController.java index f0dc761b..84291fdb 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/controller/WarehouseStorageOrderController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/controller/WarehouseStorageOrderController.java @@ -357,11 +357,10 @@ public class WarehouseStorageOrderController extends BaseController */ @ResponseBody @RequestMapping("/storagePurchaseDetailList") - public Map> storagePurchaseDetail(String warehouseStorageCode){ - List allDetails = storageOrderDetailService.selectStorageOrderDetailListByCode(warehouseStorageCode); - List filterAllDetails = allDetails.stream().filter(wso -> "1".equals(wso.getMaterialDeptType())).collect(Collectors.toList()); - Map> groupedDetails = filterAllDetails.stream().collect(Collectors.groupingBy(WarehouseStorageOrderDetail::getSupplierCode)); - return groupedDetails; + public TableDataInfo storagePurchaseDetail(String warehouseStorageCode){ + startPage(); + List list = storageOrderDetailService.selectStorageOrderDetailListByCode(warehouseStorageCode); + return getDataTable(list); } @@ -420,11 +419,10 @@ public class WarehouseStorageOrderController extends BaseController */ @ResponseBody @RequestMapping("/storagePurchaseWarehouseDetailList") - public Map> storagePurchaseWarehouseDetail(String warehouseStorageCode){ - List allDetails = storageOrderDetailService.selectStorageOrderDetailListByCode(warehouseStorageCode); - List filterAllDetails = allDetails.stream().filter(wso -> "0".equals(wso.getMaterialDeptType())).collect(Collectors.toList()); - Map> groupedDetails = filterAllDetails.stream().collect(Collectors.groupingBy(WarehouseStorageOrderDetail::getSupplierCode)); - return groupedDetails; + public TableDataInfo storagePurchaseWarehouseDetail(String warehouseStorageCode){ + startPage(); + List list = storageOrderDetailService.selectStorageOrderDetailListByCode(warehouseStorageCode); + return getDataTable(list); } diff --git a/ruoyi-admin/src/main/resources/templates/warehouse/storageOrder/storagePurchase.html b/ruoyi-admin/src/main/resources/templates/warehouse/storageOrder/storagePurchase.html index 618651f6..9e60d089 100644 --- a/ruoyi-admin/src/main/resources/templates/warehouse/storageOrder/storagePurchase.html +++ b/ruoyi-admin/src/main/resources/templates/warehouse/storageOrder/storagePurchase.html @@ -15,7 +15,7 @@
-
+
@@ -37,6 +37,38 @@
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
@@ -76,11 +108,11 @@
+
-
-
- +
+
@@ -95,67 +127,62 @@ var warehouseStorageCode = [[${warehouseStorageOrder.warehouseStorageCode}]] var warehouseCode = [[${warehouseStorageOrder.warehouseCode}]] var prefix = ctx + "warehouse/storageOrder"; - $("#form-temporaryPurchaseWarehouse-edit").validate({ + $("#form-storagePurchase-edit").validate({ focusCleanup: true }); - //生成的不同table的id集合 - var tableDatas = []; function submitHandler() { - 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 { - "warehouseStorageDetailId":item.warehouseStorageDetailId, - "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, - "hasStorageNum": item.hasStorageNum, - "notifyArriveNum": item.notifyArriveNum, - "actualArriveNum": item.actualArriveNum, - "temporaryQualifiedNum": item.temporaryQualifiedNum, - "temporaryRemark": item.temporaryRemark, - "temporaryReportUrl": item.temporaryReportUrl, - "storageNum": item.storageNum, - "storageLocation": item.storageLocation, - - // ...其他字段 - }; - }); - allMaterialDataList = allMaterialDataList.concat(materialDataList); + if ($.validate.form()) { + + + const storageOrderData = $("#form-storagePurchase-edit").serializeArray().reduce((obj, item) => { + obj[item.name] = item.value; + return obj; + }, {}); + + + var table = $('#bootstrap-table').bootstrapTable("getData"); + + var materialDataList = table.map(function(item) { + // 根据实际字段名调整 + return { + "warehouseStorageDetailId":item.warehouseStorageDetailId, + "supplierCode": item.supplierCode, + "materialNo": item.materialNo, + "materialName": item.materialName, + "materialType": item.materialType, + "materialPhotourl": item.materialPhotourl, + "materialDescribe": item.materialDescribe, + "materialModel": item.materialModel, + "materialBrand": item.materialBrand, + "materialUnit": item.materialUnit, + "materialProcessMethod": item.materialProcessMethod, + "notifyHasArrivedNum": item.notifyHasArrivedNum, + "actualHasArrivedNum": item.actualHasArrivedNum, + "temporaryHasQualifiedNum": item.temporaryHasQualifiedNum, + "hasStorageNum": item.hasStorageNum, + "notifyArriveNum": item.notifyArriveNum, + "actualArriveNum": item.actualArriveNum, + "temporaryQualifiedNum": item.temporaryQualifiedNum, + "temporaryRemark": item.temporaryRemark, + "temporaryReportUrl": item.temporaryReportUrl, + "storageNum": item.storageNum, + "storageLocation": item.storageLocation, + // ...其他字段 + }; }); - } - 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 + "/storagePurchase", jsonData); + const combinedData = Object.assign({}, storageOrderData, { + warehouseStorageOrderDetailList: materialDataList, + }); + // 合并表单数据和表格数据 + console.log(combinedData) + // 使用 JSON.stringify() 序列化数据 + const jsonData = JSON.stringify(combinedData); + // 发送 AJAX 请求到后端接口 + $.operate.saveJson(prefix + "/storagePurchase", jsonData); + } } $("input[name='arrivedTime']").datetimepicker({ @@ -170,38 +197,18 @@ autoclose: true }); - $(function() { - // 假设qualityOrderCode已经定义或者可以通过某种方式获取到 - var warehouseStorageCode = [[${warehouseStorageOrder.warehouseStorageCode}]]; // 这里需要实际赋值,比如从前端某个地方读取 - - $.getJSON(prefix + "/storagePurchaseDetailList?warehouseStorageCode=" + warehouseStorageCode, 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 = $('
'); - - // 确保supplierData至少有一条记录,并从中提取供应商详细信息 - var supplierInfo = supplierData.length > 0 ? supplierData[0] : {}; // 默认为空对象,以防数据不存在 - - // 构建含有额外供应商信息的标题字符串 - var headerTitle ='供应商'+'
'+supplierCode + ' - ' + (supplierInfo.supplierName || 'N/A') + - '
' + (supplierInfo.customerContact || 'N/A') + - ' - ' + (supplierInfo.contactNumber || 'N/A') + - ' - ' + (supplierInfo.supplierAddress || 'N/A'); - var $header = $('

' + headerTitle + '

'); - var $table = $('
'); - - $table.bootstrapTable({ - data: supplierData, + //物料信息展示列表 + $(function() { + var options = { + modalName: "选择物料", + url: prefix + "/storagePurchaseDetailList", + queryParams: queryParams, + showSearch: false, + showRefresh: false, + showToggle: false, + showColumns: false, + pagination: false, // 设置不分页 columns: [{ checkbox: true }, @@ -235,10 +242,15 @@ title: '物料描述', field: 'materialDescribe', }, + { + title: '物料型号', + field: 'materialModel', + }, { title: '物料品牌', field: 'materialBrand', }, + { title: '物料单位', field: 'materialUnit', @@ -259,7 +271,6 @@ { title: '暂收已合格数', field: 'temporaryHasQualifiedNum', - visible: false, }, { title: '已入库数', @@ -292,17 +303,29 @@ { title: '入库数', field: 'storageNum', - editable:{ - type: 'text', - mode:'inline', - validate: function (v) { - if (!v) return '数量不能为空'; - if (isNaN(v)) return '数量必须是数字'; - var processBadNum = parseInt(v); - if (processBadNum <= 0) return '数量必须是正整数'; + editable: { + validate: function(value) { + if ($.trim(value) === '') { + return '入库数不能为空'; + } + if (isNaN(value)) { + return '请输入有效的数字'; + } + if (value < 0) { + return '入库数不能小于0'; + } + //不能为小数 + if (value % 1 !== 0) { + return '入库数不能为小数'; + } }, }, formatter: function (value, row) { + // 检查 row 是否存在 + if (!row) { + return ""; + } + // 检查 storageNum 是否存在 if (row.storageNum === undefined || row.storageNum === null) { return ""; @@ -324,6 +347,11 @@ mode:'inline', }, formatter: function (value, row) { + // 检查 row 是否存在 + if (!row) { + return ""; + } + // 检查 storageLocation 是否存在 if (row.storageLocation === undefined || row.storageLocation === null) { return ""; @@ -336,17 +364,20 @@ return value; } } - }, - - ] - }); - - $tableWrapper.append($header).append($table); - $('#tablesContainer').append($tableWrapper); + },] + }; + $.table.init(options); + }) + + function queryParams(params) { + var curParams = { + // 传递参数查询参数 + warehouseStorageCode: warehouseStorageCode + }; + return curParams; } - //根据仓库ID查询仓库名称 $(document).ready(function() { // 初始化时默认加载仓库ID列表 diff --git a/ruoyi-admin/src/main/resources/templates/warehouse/storageOrder/storagePurchaseDetail.html b/ruoyi-admin/src/main/resources/templates/warehouse/storageOrder/storagePurchaseDetail.html index aeb95505..1a8abc57 100644 --- a/ruoyi-admin/src/main/resources/templates/warehouse/storageOrder/storagePurchaseDetail.html +++ b/ruoyi-admin/src/main/resources/templates/warehouse/storageOrder/storagePurchaseDetail.html @@ -3,6 +3,7 @@ +