diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/controller/SysCustomerQuoteController.java b/ruoyi-admin/src/main/java/com/ruoyi/system/controller/SysCustomerQuoteController.java index 516c4671..49eb1ebf 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/controller/SysCustomerQuoteController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/controller/SysCustomerQuoteController.java @@ -454,4 +454,20 @@ public class SysCustomerQuoteController extends BaseController return getDataTable(list); } + + /** + * 查询最新报价历史数据 + * */ + @GetMapping("/queryLatestRecentQuotation") + @ResponseBody + public AjaxResult recentQuotationHistoryData(@RequestParam("materialNo") String materialNo, @RequestParam("customerCode") String customerCode) + { + SysCustomerQuoteHistory sysCustomerQuoteHistory = new SysCustomerQuoteHistory(); + sysCustomerQuoteHistory.setMaterialCode(materialNo); + sysCustomerQuoteHistory.setCustomerCode(customerCode); + List sysCustomerQuoteHistories = quoteHistoryService.selectSysCustomerQuoteHistoryList(sysCustomerQuoteHistory); + List filterCustomerQuoteHistories = sysCustomerQuoteHistories.stream().filter(item -> item.getIsLatest().equals("1")).collect(Collectors.toList()); + return AjaxResult.success(filterCustomerQuoteHistories.get(0)); + } + } diff --git a/ruoyi-admin/src/main/resources/templates/system/customerQuote/add.html b/ruoyi-admin/src/main/resources/templates/system/customerQuote/add.html index 92ccc328..334d3d6b 100644 --- a/ruoyi-admin/src/main/resources/templates/system/customerQuote/add.html +++ b/ruoyi-admin/src/main/resources/templates/system/customerQuote/add.html @@ -367,7 +367,7 @@ { title: '最新报价(RMB)',field: 'recentQuotationRMB',align: 'center',}, { title: '最新报价(美元)',field: 'recentQuotationUSD',align: 'center',}, - { title: '最新报价历史',field: 'recentQuotationUSD',align: 'center', + { title: '最新报价历史',align: 'center', formatter: function (value, row, index) { var actions = []; @@ -575,7 +575,7 @@ // 初始化时也需要根据当前的货币类型设置一次 $("#commonCurrency_add").trigger('change'); // getBusinessMembers(); - getCustomerCode(); + // getCustomerCode(); }); //监听币种的变化 @@ -653,6 +653,7 @@ } var existingData = $("#bootstrap-sub-table-quoteChild").bootstrapTable('getData'); + var promises = []; // 存储要插入的新行 var newRows = []; @@ -671,50 +672,112 @@ } if (!isDuplicate) { - // 如果不存在,则准备插入新行 - newRows.push({ - materialId: rowData.id, - materialCode: rowData.materialNo, - materialName: rowData.materialName, - materialType: rowData.materialType, - describe: rowData.describe, - brand: rowData.brand, - unit: rowData.unit, - processMethod: rowData.processMethod, - photoUrl: rowData.photoUrl, - countTax: '', - usdTax: '', - materialNum: "", - materialSole: "", - materialRmb: "", - materialNoRmb: "", - materialNoUsd: "", - materialUsd: "", - materialUsdSum: "", - materialNoUsdSum: "", - materialNoRmbSum: "", - materialRmbSum: "", - createBy: "", - createTime: "", - updateBy: "", - updateTime: "", - remark: "", - }); + // 如果不存在,则准备插入新行,并发起查询请求 + promises.push(queryRecentQuotation(rowData.materialNo).then(function (quotationData) { + // 将查询结果赋值给 newRows 中的相应字段 + return { + materialId: rowData.id, + materialCode: rowData.materialNo, + materialName: rowData.materialName, + materialType: rowData.materialType, + describe: rowData.describe, + brand: rowData.brand, + unit: rowData.unit, + processMethod: rowData.processMethod, + photoUrl: rowData.photoUrl, + countTax: '', + usdTax: '', + materialNum: "", + materialSole: "", + recentQuotationRMB: quotationData.data.materialRmb || '', + recentQuotationUSD: quotationData.data.materialUsd || '', + materialRmb: "", + materialNoRmb: "", + materialNoUsd: "", + materialUsd: "", + materialUsdSum: "", + materialNoUsdSum: "", + materialNoRmbSum: "", + materialRmbSum: "", + createBy: "", + createTime: "", + updateBy: "", + updateTime: "", + remark: "", + }; + }).catch(function (error) { + // 返回一个默认对象以保证数据结构一致 + return { + materialId: rowData.id, + materialCode: rowData.materialNo, + materialName: rowData.materialName, + materialType: rowData.materialType, + describe: rowData.describe, + brand: rowData.brand, + unit: rowData.unit, + processMethod: rowData.processMethod, + photoUrl: rowData.photoUrl, + countTax: '', + usdTax: '', + materialNum: "", + materialSole: "", + recentQuotationRMB: '', + recentQuotationUSD: '', + materialRmb: "", + materialNoRmb: "", + materialNoUsd: "", + materialUsd: "", + materialUsdSum: "", + materialNoUsdSum: "", + materialNoRmbSum: "", + materialRmbSum: "", + createBy: "", + createTime: "", + updateBy: "", + updateTime: "", + remark: "", + }; + })); } else { $.modal.alertError("不能选择已添加过的相同料号"); } } - // 批量插入新行 - if (newRows.length > 0) { - for (var k = 0; k < newRows.length; k++) { - $("#bootstrap-sub-table-quoteChild").bootstrapTable('insertRow', { index: 1, row: newRows[k] }); + // 使用Promise.all等待所有查询完成 + Promise.all(promises).then(function (rows) { + newRows = rows.filter(row => !!row); // 清除可能的null或undefined + if (newRows.length > 0) { + // 批量插入新行 + for (var k = 0; k < newRows.length; k++) { + $("#bootstrap-sub-table-quoteChild").bootstrapTable('insertRow', { index: 1, row: newRows[k] }); + } } - } + layer.close(index); + }).catch(function (error) { + console.error('Some requests failed:', error); + layer.close(index); + }); + } - layer.close(index); + // 查找最新的报价数据 + function queryRecentQuotation(materialNo) { + return new Promise((resolve, reject) => { + // 使用AJAX请求从服务器获取最近的报价信息 + $.ajax({ + url: prefix + '/queryLatestRecentQuotation', // 假设这是你的API路径 + type: 'GET', + data: { materialNo: materialNo, customerCode: $("#customerCode").val() }, + success: function (data) { + resolve(data); // 成功时解析数据 + }, + error: function (jqXHR, textStatus, errorThrown) { + reject(new Error('查找最新报价数据失败')); // 失败时抛出错误 + } + }); + }); } + function insertRow() { if ($("#customerCode").val() == null || $("#customerCode").val() == '') { $.modal.alertWarning("请先选择客户"); @@ -817,6 +880,9 @@ $.modal.open("最新报价历史", url); } + + + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/system/customerQuote/detail.html b/ruoyi-admin/src/main/resources/templates/system/customerQuote/detail.html index 6a3c95ef..70db2877 100644 --- a/ruoyi-admin/src/main/resources/templates/system/customerQuote/detail.html +++ b/ruoyi-admin/src/main/resources/templates/system/customerQuote/detail.html @@ -115,7 +115,7 @@ -
+
选择报价信息