Browse Source

[feat] 工程管理

调整客户报价详情页面:table和上面的form保持一致
客户报价新增页面新增:查找最新的报价数据的js方法;修改批量新增前端方法,新增循环新增的时候加上异步处理的方式,获取最新报价RMB和USD的值,并进行赋值
客户报价Controller层:新增 查询最新报价历史数据后端接口,逻辑处理只返回一条数据:更新时间最新且审核通过
dev
liuxiaoxu 2 months ago
parent
commit
bc00166a7b
  1. 16
      ruoyi-admin/src/main/java/com/ruoyi/system/controller/SysCustomerQuoteController.java
  2. 140
      ruoyi-admin/src/main/resources/templates/system/customerQuote/add.html
  3. 2
      ruoyi-admin/src/main/resources/templates/system/customerQuote/detail.html

16
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<SysCustomerQuoteHistory> sysCustomerQuoteHistories = quoteHistoryService.selectSysCustomerQuoteHistoryList(sysCustomerQuoteHistory);
List<SysCustomerQuoteHistory> filterCustomerQuoteHistories = sysCustomerQuoteHistories.stream().filter(item -> item.getIsLatest().equals("1")).collect(Collectors.toList());
return AjaxResult.success(filterCustomerQuoteHistories.get(0));
}
}

140
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);
}
</script>
</body>
</html>

2
ruoyi-admin/src/main/resources/templates/system/customerQuote/detail.html

@ -115,7 +115,7 @@
<label class="col-sm-2">含税总价:</label><input placeholder="美元" class="col-sm-4" name="usdSum" id="usdSum_detail" th:field="*{usdSum}" type="number" disabled/>
</div>
</div>
<div class="other container">
<div class="container">
<div class="form-row">
<div class="btn-group-sm" id="toolbar" role="group">
<span>选择报价信息</span>

Loading…
Cancel
Save