refactor(product): 优化产品列表和订单编辑功能
- 移除部分冗余代码 -改进价格格式化和计算逻辑 - 调整产品列表显示和选择功能 - 优化订单编辑界面布局master
parent
2ea2477b99
commit
5ea8fa9c5b
|
@ -94,6 +94,7 @@
|
|||
|
||||
<!-- JS 函数引用或内联 -->
|
||||
<script th:inline="javascript"> /*<![CDATA[*/
|
||||
const updatePriceProductList=['8813A3YA','8813A3YB','8813A7U4','8813A7U2']
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
// 初始化删除逻辑等
|
||||
$('.productTable .delRow').on('click', function () {
|
||||
|
@ -113,6 +114,10 @@
|
|||
|
||||
function addProduct(data) {
|
||||
let length = $('#productTable tbody').find('tr').length
|
||||
let flag=true
|
||||
if (data){
|
||||
flag =! updatePriceProductList.filter(item=>item===data.productBomCode).length>0;
|
||||
}
|
||||
let tr = $(`
|
||||
<tr>
|
||||
<td style="text-align: center;" class="indexBox">${length + 1}</td>
|
||||
|
@ -122,7 +127,7 @@
|
|||
<td><input value="${data.quantity || ''}" name="softwareProjectProductInfoList[${length}].quantity" type="number" class="form-control quantity" step="1" required></td>
|
||||
<td>
|
||||
<input value="${data.cataloguePrice || ''}" name="softwareProjectProductInfoList[${length}].cataloguePrice" readonly type="hidden" class="form-control cataloguePrice" required>
|
||||
<input value="${data.cataloguePriceFormmat || ''}" readonly type="text" class="form-control cataloguePrice" required>
|
||||
<input value="${data.cataloguePriceFormmat || ''}" readonly="${flag}" type="text" class="form-control catalogue-price-format" required>
|
||||
</td>
|
||||
<td>
|
||||
<input value="${data.guidanceDiscount || ''}" name="softwareProjectProductInfoList[${length}].guidanceDiscount" readonly type="hidden" class="form-control guidanceDiscount" >
|
||||
|
@ -155,6 +160,10 @@
|
|||
|
||||
function addProduct2(data) {
|
||||
let length = $('#productTable2 tbody').find('tr').length
|
||||
let flag=true
|
||||
if (data){
|
||||
flag =! updatePriceProductList.filter(item=>item===data.productBomCode).length>0;
|
||||
}
|
||||
let tr = $(`
|
||||
<tr>
|
||||
<td style="text-align: center;" class="indexBox">${length + 1}</td>
|
||||
|
@ -164,7 +173,7 @@
|
|||
<td><input value="${data.quantity || ''}" name="hardwareProjectProductInfoList[${length}].quantity" type="number" class="form-control quantity" step="1" required></td>
|
||||
<td>
|
||||
<input value="${data.cataloguePrice || ''}" name="hardwareProjectProductInfoList[${length}].cataloguePrice" readonly type="hidden" class="form-control cataloguePrice" required>
|
||||
<input value="${data.cataloguePriceFormmat || ''}" readonly type="text" class="form-control cataloguePrice" required>
|
||||
<input value="${data.cataloguePriceFormmat || ''}" readonly="${flag}" type="text" class="form-control catalogue-price-format" required>
|
||||
</td>
|
||||
<td>
|
||||
<input value="${data.guidanceDiscount || ''}" name="hardwareProjectProductInfoList[${length}].guidanceDiscount" readonly type="hidden" class="form-control guidanceDiscount" >
|
||||
|
@ -197,6 +206,15 @@
|
|||
|
||||
function addProduct3(data) {
|
||||
let length = $('#productTable3 tbody').find('tr').length
|
||||
let flag=true
|
||||
console.log(data)
|
||||
if (data){
|
||||
console.log(data)
|
||||
|
||||
flag =! updatePriceProductList.filter(item=>item===data.productBomCode).length>0;
|
||||
console.log(flag)
|
||||
}
|
||||
|
||||
let tr = $(`
|
||||
<tr>
|
||||
<td style="text-align: center;" class="indexBox">${length + 1}</td>
|
||||
|
@ -205,11 +223,12 @@
|
|||
<td><textarea name="maintenanceProjectProductInfoList[${length}].productDesc" required class="form-control productDesc" placeholder="自动带入" readonly>${data.productDesc || ''}</textarea></td>
|
||||
<td><input value="${data.quantity || ''}" name="maintenanceProjectProductInfoList[${length}].quantity" type="number" class="form-control quantity" step="1" required></td>
|
||||
<td><input value="${data.cataloguePrice || ''}" name="maintenanceProjectProductInfoList[${length}].cataloguePrice" readonly type="hidden" class="form-control cataloguePrice" required>
|
||||
<input value="${data.cataloguePriceFormmat || ''}" readonly type="text" class="form-control cataloguePrice" required>
|
||||
<input value="${data.cataloguePriceFormmat || ''}" ${flag?"readonly":''} onfocus="getData(this,'cataloguePrice')" onblur="this.value=formatAmountNumber(this.value)" type="text" class="form-control catalogue-price-format" required>
|
||||
</td>
|
||||
<td>
|
||||
<input value="${data.guidanceDiscount || ''}" name="maintenanceProjectProductInfoList[${length}].guidanceDiscount" readonly type="hidden" class="form-control guidanceDiscount" >
|
||||
<label style="display: flex;align-items: center"><input style="width: calc(100% - 10px);" value="${data.guidanceDiscountFormat || ''}" readonly type="number" min="0" max="100" step="0.01" class="form-control guidance-discount-format" required>%
|
||||
<label style="display: flex;align-items: center">
|
||||
<input style="width: calc(100% - 10px);" value="${data.guidanceDiscountFormat || ''}" readonly type="number" min="0" max="100" step="0.01" class="form-control guidance-discount-format" required>%
|
||||
</label>
|
||||
</td>
|
||||
<td><input value="${data.discount || ''}" name="maintenanceProjectProductInfoList[${length}].discount" type="hidden" class="form-control discount" required>
|
||||
|
@ -256,43 +275,44 @@
|
|||
$(this).parent().parent().find('.catalogueAllPrice-formmat').val(formatAmountNumber((num * cateVal).toFixed(2)))
|
||||
}
|
||||
})
|
||||
$('.productTable .cataloguePrice').on('input', function () {
|
||||
$('.productTable .catalogue-price-format').on('input', function () {
|
||||
let val = $(this).val()
|
||||
$(this).parent().parent().find('.price').val(val)
|
||||
let quantity = $(this).parent().parent().find('.quantity').val()
|
||||
let discount=$(this).parent().parent().find('.discount').val()
|
||||
if (discount && val){
|
||||
$(this).parent().parent().find('.price').val((val * discount).toFixed(2))
|
||||
let price = $(this).parent().parent().find('.price').val()
|
||||
$(this).parent().parent().find('.price-formmat').val(formatAmountNumber(price))
|
||||
if (quantity){
|
||||
$(this).parent().parent().find('.allPrice').val((quantity * val * discount).toFixed(2))
|
||||
let allPrice = $(this).parent().parent().find('.allPrice').val()
|
||||
$(this).parent().parent().find('.allPrice-formmat').val(formatAmountNumber(allPrice))
|
||||
}
|
||||
}
|
||||
if (quantity && val) {
|
||||
$(this).parent().parent().find('.catalogueAllPrice').val((val * quantity).toFixed(2))
|
||||
$(this).parent().parent().find('.catalogueAllPrice-formmat').val(formatAmountNumber((val * quantity).toFixed(2)))
|
||||
}
|
||||
$(this).parent().parent().find('.cataloguePrice').val(val)
|
||||
// let quantity = $(this).parent().parent().find('.quantity').val()
|
||||
// let discount=$(this).parent().parent().find('.discount').val()
|
||||
// if (discount && val){
|
||||
// $(this).parent().parent().find('.price').val((val * discount).toFixed(2))
|
||||
// let price = $(this).parent().parent().find('.price').val()
|
||||
// $(this).parent().parent().find('.price-formmat').val(formatAmountNumber(price))
|
||||
// if (quantity){
|
||||
// $(this).parent().parent().find('.allPrice').val((quantity * val * discount).toFixed(2))
|
||||
// let allPrice = $(this).parent().parent().find('.allPrice').val()
|
||||
// $(this).parent().parent().find('.allPrice-formmat').val(formatAmountNumber(allPrice))
|
||||
// }
|
||||
// }
|
||||
// if (quantity && val) {
|
||||
// $(this).parent().parent().find('.catalogueAllPrice').val((val * quantity).toFixed(2))
|
||||
// $(this).parent().parent().find('.catalogueAllPrice-formmat').val(formatAmountNumber((val * quantity).toFixed(2)))
|
||||
// }
|
||||
|
||||
})
|
||||
// $('.productTable .guidanceDiscount-format').on('input', function () {
|
||||
// let val = $(this).val()
|
||||
// let cataloguePrice = $(this).parent().parent().find('.cataloguePrice').val()
|
||||
// $(this).parent().parent().find('.discount').val(val)
|
||||
// $(this).parent().parent().find('.price').val((cataloguePrice * val).toFixed(2))
|
||||
// $(this).parent().parent().find('.price-formmat').val(Number((cataloguePrice * val).toFixed(2)).toLocaleString("en-US"))
|
||||
// let price = $(this).parent().parent().find('.price').val()
|
||||
// let quantity = $(this).parent().parent().find('.quantity').val()
|
||||
// if (price && quantity) {
|
||||
// $(this).parent().parent().find('.allPrice').val((price * quantity).toFixed(2))
|
||||
// $(this).parent().parent().find('.allPrice-formmat').val(Number((price * quantity).toFixed(2)).toLocaleString("en-US"))
|
||||
// }
|
||||
// })
|
||||
$('.productTable .guidance-discount-format').on('input', function () {
|
||||
let val = $(this).val()
|
||||
let discount = (val/100).toFixed(4)
|
||||
// let cataloguePrice = $(this).parent().parent().find('.cataloguePrice').val()
|
||||
$(this).parent().parent().find('.guidanceDiscount').val(discount)
|
||||
// $(this).parent().parent().find('.price').val((cataloguePrice * val).toFixed(2))
|
||||
// $(this).parent().parent().find('.price-formmat').val(Number((cataloguePrice * val).toFixed(2)).toLocaleString("en-US"))
|
||||
// let price = $(this).parent().parent().find('.price').val()
|
||||
// let quantity = $(this).parent().parent().find('.quantity').val()
|
||||
// if (price && quantity) {
|
||||
// $(this).parent().parent().find('.allPrice').val((price * quantity).toFixed(2))
|
||||
// $(this).parent().parent().find('.allPrice-formmat').val(Number((price * quantity).toFixed(2)).toLocaleString("en-US"))
|
||||
// }
|
||||
})
|
||||
$('.productTable .discount-format').on('change', function () {
|
||||
let percentageDiscount = $(this).val()
|
||||
let discount = (percentageDiscount/100).toFixed(3)
|
||||
let discount = (percentageDiscount/100).toFixed(4)
|
||||
$(this).parent().parent().find('.discount').val(discount)
|
||||
let val = $(this).parent().parent().parent().find('.cataloguePrice').val()
|
||||
$(this).parent().parent().parent().find('.price').val((val * discount).toFixed(2))
|
||||
|
@ -337,11 +357,20 @@
|
|||
function doSubmitProduct(index, layero, ele) {
|
||||
var rows = layero.find("iframe")[0].contentWindow.getSelections();
|
||||
$(ele).parent().parent().find('.productBomCode').val(rows[0].productCode)
|
||||
|
||||
$(ele).parent().parent().find('.model').val(rows[0].model)
|
||||
$(ele).parent().parent().find('.productDesc').val(rows[0].description)
|
||||
$(ele).parent().parent().find('.guidanceDiscount').val(rows[0].guidanceDiscount)
|
||||
$(ele).parent().parent().find('.guidance-discount-format').val(formatAmountNumber(rows[0].guidanceDiscount*100))
|
||||
$(ele).parent().parent().find('.cataloguePrice').val(rows[0].cataloguePrice)
|
||||
$(ele).parent().parent().find('.catalogue-price-format').val(formatAmountNumber(rows[0].cataloguePrice))
|
||||
let flag = updatePriceProductList.filter(item=>item===rows[0].productCode).length>0;
|
||||
if (flag){
|
||||
$(ele).parent().parent().find('.catalogue-price-format').attr('readonly',false)
|
||||
// $(ele).parent().parent().find('.guidance-discount-format').attr('readonly',false)
|
||||
}else{
|
||||
$(ele).parent().parent().find('.catalogue-price-format').attr('readonly',true)
|
||||
}
|
||||
$.modal.close(index);
|
||||
}
|
||||
|
||||
|
|
|
@ -132,9 +132,9 @@
|
|||
</div>
|
||||
<div class="col-sm-6">
|
||||
<div class="form-group">
|
||||
<label class="col-sm-4 control-label is-required">客户联系人:</label>
|
||||
<label class="col-sm-4 control-label ">客户联系人:</label>
|
||||
<div class="col-sm-8">
|
||||
<input name="customerContact" class="form-control" type="text" required>
|
||||
<input name="customerContact" class="form-control" type="text" >
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -149,9 +149,9 @@
|
|||
|
||||
<div class="col-sm-6">
|
||||
<div class="form-group">
|
||||
<label class="col-sm-4 control-label is-required">客户电话:</label>
|
||||
<label class="col-sm-4 control-label ">客户电话:</label>
|
||||
<div class="col-sm-8">
|
||||
<input name="customerPhone" class="form-control" type="text" required>
|
||||
<input name="customerPhone" class="form-control" type="text" >
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -135,10 +135,10 @@
|
|||
</div>
|
||||
<div class="col-sm-6">
|
||||
<div class="form-group">
|
||||
<label class="col-sm-4 control-label is-required">客户联系人:</label>
|
||||
<label class="col-sm-4 control-label ">客户联系人:</label>
|
||||
<div class="col-sm-8">
|
||||
<input name="customerContact" th:field="*{customerContact}" class="form-control"
|
||||
type="text" required>
|
||||
type="text" >
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -153,9 +153,9 @@
|
|||
</div>
|
||||
<div class="col-sm-6">
|
||||
<div class="form-group">
|
||||
<label class="col-sm-4 control-label is-required">客户电话:</label>
|
||||
<label class="col-sm-4 control-label ">客户电话:</label>
|
||||
<div class="col-sm-8">
|
||||
<input name="customerPhone" th:field="*{customerPhone}" class="form-control" type="text" required>
|
||||
<input name="customerPhone" th:field="*{customerPhone}" class="form-control" type="text" >
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -197,14 +197,14 @@
|
|||
|
||||
</tr>
|
||||
<tr>
|
||||
<td>代理商<span class="is-required">*</span></td>
|
||||
<td>代理商</td>
|
||||
<td >
|
||||
<input name="partnerName" class="form-control" type="text" required
|
||||
<input name="partnerName" class="form-control" type="text"
|
||||
onclick="selectPartner()">
|
||||
<input name="partnerCode" class="form-control" type="hidden">
|
||||
</td>
|
||||
<td>代理商联系人<span class="is-required">*</span></td>
|
||||
<td><input name="partnerUserName" class="form-control" type="text" required></td>
|
||||
<td>代理商联系人</td>
|
||||
<td><input name="partnerUserName" class="form-control" type="text" ></td>
|
||||
<td>代理商 TEL</td>
|
||||
<td><input name="contactWay" class="form-control" maxlength="11" type="text"></td>
|
||||
</tr>
|
||||
|
@ -340,7 +340,7 @@
|
|||
// 获取隐藏字段
|
||||
const rawInput = document.getElementById('estimatedAmount');
|
||||
// 去除逗号并过滤非数字字符
|
||||
let rawValue = displayInput.value.replace(/[^0-9]/g, '');
|
||||
let rawValue =displayInput.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');
|
||||
|
||||
// 更新隐藏字段的值
|
||||
rawInput.value = rawValue;
|
||||
|
|
|
@ -214,15 +214,15 @@
|
|||
|
||||
</tr>
|
||||
<tr>
|
||||
<td>代理商<span class="is-required">*</span></td>
|
||||
<td>代理商</td>
|
||||
<td >
|
||||
<input name="partnerName" class="form-control" type="text" required
|
||||
<input name="partnerName" class="form-control" type="text"
|
||||
onclick="selectPartner()" th:field="*{partnerName}">
|
||||
<input name="partnerCode" class="form-control" type="hidden" th:field="*{partnerCode}">
|
||||
</td>
|
||||
<td>代理商联系人<span class="is-required">*</span></td>
|
||||
<td>代理商联系人</td>
|
||||
<td><input name="partnerUserName" th:field="*{partnerUserName}" class="form-control" type="text"
|
||||
required></td>
|
||||
></td>
|
||||
<td>代理商 TEL</td>
|
||||
<td><input name="contactWay" th:field="*{contactWay}" class="form-control" type="text"></td>
|
||||
</tr>
|
||||
|
|
|
@ -358,6 +358,7 @@
|
|||
var maintenanceProjectProductInfoList = []
|
||||
|
||||
function initProductList() {
|
||||
initProjectList()
|
||||
let data = {
|
||||
pageSize: 100000,
|
||||
pageNum: 1,
|
||||
|
@ -381,7 +382,6 @@
|
|||
model: '',
|
||||
productCode: ''
|
||||
})
|
||||
initProjectList()
|
||||
});
|
||||
})
|
||||
});
|
||||
|
|
|
@ -382,7 +382,7 @@ public class ProjectOrderInfoServiceImpl implements IProjectOrderInfoService {
|
|||
Sheet sheet = writeSheetHolder.getSheet();
|
||||
|
||||
// 基础列范围(前 25 列)
|
||||
if (columnIndex >= 0 && columnIndex <= 26) {
|
||||
if (columnIndex >= 0 && columnIndex <= 30) {
|
||||
// 自适应列宽逻辑
|
||||
sheet.setColumnWidth(columnIndex, 256 * 30); // 设置固定宽度为 20 个字符
|
||||
}
|
||||
|
@ -439,12 +439,12 @@ public class ProjectOrderInfoServiceImpl implements IProjectOrderInfoService {
|
|||
|
||||
|
||||
// 添加软件产品列
|
||||
for (int i = 1; i <= maxSoftware; i++) {
|
||||
headerList.add(Collections.singletonList("软件编码" + i));
|
||||
headerList.add(Collections.singletonList("型号" + i));
|
||||
headerList.add(Collections.singletonList("数量" + i));
|
||||
headerList.add(Collections.singletonList("总价" + i));
|
||||
}
|
||||
// for (int i = 1; i <= maxSoftware; i++) {
|
||||
// headerList.add(Collections.singletonList("软件编码" + i));
|
||||
// headerList.add(Collections.singletonList("型号" + i));
|
||||
// headerList.add(Collections.singletonList("数量" + i));
|
||||
// headerList.add(Collections.singletonList("总价" + i));
|
||||
// }
|
||||
|
||||
// 添加终端产品列
|
||||
for (int i = 1; i <= maxHardware; i++) {
|
||||
|
@ -519,12 +519,15 @@ public class ProjectOrderInfoServiceImpl implements IProjectOrderInfoService {
|
|||
for (int i = 0; i < maxSoftware; i++) {
|
||||
if (CollUtil.isNotEmpty(info.getSoftwareProjectProductInfoList()) && i < info.getSoftwareProjectProductInfoList().size()) {
|
||||
ProjectProductInfo productInfo = info.getSoftwareProjectProductInfoList().get(i);
|
||||
totalPrice = addProductRow(productInfo, row, totalPrice);
|
||||
if (productInfo != null && StringUtils.isNotEmpty(productInfo.getProductBomCode())
|
||||
&& MAINTENANCE_SERVICES.contains(productInfo.getProductBomCode())
|
||||
&& productInfo.getAllPrice() != null) {
|
||||
maintenancePrice = maintenancePrice.add(productInfo.getAllPrice());
|
||||
if (productInfo.getAllPrice() != null) {
|
||||
totalPrice = totalPrice.add(productInfo.getAllPrice());
|
||||
}
|
||||
// totalPrice = addProductRow(productInfo, row, totalPrice);
|
||||
// if (productInfo != null && StringUtils.isNotEmpty(productInfo.getProductBomCode())
|
||||
// && MAINTENANCE_SERVICES.contains(productInfo.getProductBomCode())
|
||||
// && productInfo.getAllPrice() != null) {
|
||||
// maintenancePrice = maintenancePrice.add(productInfo.getAllPrice());
|
||||
// }
|
||||
|
||||
staticsNum(wssDto, productInfo, WSS_LIST);
|
||||
staticsNum(wspDto, productInfo, WSP_LIST);
|
||||
|
@ -532,7 +535,7 @@ public class ProjectOrderInfoServiceImpl implements IProjectOrderInfoService {
|
|||
staticsNum(oneStorDto, productInfo, ONE_STOR_LIST);
|
||||
staticsNum(nVIDIADto, productInfo, N_VIDIA_LIST);
|
||||
} else {
|
||||
addProductRow(null, row, totalPrice);
|
||||
// addProductRow(null, row, totalPrice);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -576,7 +579,7 @@ public class ProjectOrderInfoServiceImpl implements IProjectOrderInfoService {
|
|||
addProductRow(null, row, totalPrice);
|
||||
}
|
||||
}
|
||||
|
||||
// totalPrice = totalPrice.add(wssDto.getAllPrice()).add(wspDto.getAllPrice()).add(lsDto.getAllPrice()).add(oneStorDto.getAllPrice()).add(nVIDIADto.getAllPrice());
|
||||
row.add(totalPrice.toString());
|
||||
//维保金额
|
||||
row.add(11, maintenancePrice.toString());
|
||||
|
|
|
@ -119,18 +119,18 @@ public class ProjectProductInfoServiceImpl implements IProjectProductInfoService
|
|||
if (stringJoiner.length() > 0) {
|
||||
throw new ServiceException(StringUtils.format("产品编码[{}]在产品库中未找到,请确认后重试", stringJoiner.toString()));
|
||||
}
|
||||
for (ProjectProductInfo info : list) {
|
||||
//计算价格 防止前端价格计算错误
|
||||
if (info.getGuidanceDiscount() != null && info.getDiscount() == null) {
|
||||
info.setDiscount(info.getGuidanceDiscount());
|
||||
}
|
||||
if (info.getCataloguePrice() != null && info.getDiscount() != null) {
|
||||
info.setPrice(info.getCataloguePrice().multiply(info.getDiscount()).setScale(2, RoundingMode.HALF_UP));
|
||||
}
|
||||
if (info.getPrice() != null && info.getQuantity() != null) {
|
||||
info.setAllPrice(info.getPrice().multiply(new BigDecimal(info.getQuantity())).setScale(2, RoundingMode.HALF_UP));
|
||||
}
|
||||
}
|
||||
// for (ProjectProductInfo info : list) {
|
||||
// //计算价格 防止前端价格计算错误
|
||||
// if (info.getGuidanceDiscount() != null && info.getDiscount() == null) {
|
||||
// info.setDiscount(info.getGuidanceDiscount());
|
||||
// }
|
||||
// if (info.getCataloguePrice() != null && info.getDiscount() != null) {
|
||||
// info.setPrice(info.getCataloguePrice().multiply(info.getDiscount()).setScale(2, RoundingMode.HALF_UP));
|
||||
// }
|
||||
// if (info.getPrice() != null && info.getQuantity() != null) {
|
||||
// info.setAllPrice(info.getPrice().multiply(new BigDecimal(info.getQuantity())).setScale(2, RoundingMode.HALF_UP));
|
||||
// }
|
||||
// }
|
||||
|
||||
List<ProjectProductInfo> projectProductInfos = projectProductInfoMapper.selectProjectProductInfoListByProjectId(Collections.singletonList(list.get(0).getProjectId()));
|
||||
Set<Long> idSet = list.stream().map(ProjectProductInfo::getId).collect(Collectors.toSet());
|
||||
|
|
Loading…
Reference in New Issue