fix(order): 优化订单导入功能

- 在订单导入时自动填充产品名称
- 调整折扣输入框的精度为万分之一
- 优化订单列表的显示格式
master
chenhao 2025-05-22 17:04:10 +08:00
parent 2d2b15283f
commit 6e65260cc4
3 changed files with 20 additions and 8 deletions

View File

@ -227,7 +227,7 @@
align: 'center',
title: '产品名称',
formatter: function (value, row, index) {
var html = $.common.sprintf("<p class='form-control-static'>%s</p>", value);
var html = $.common.sprintf("<input readonly class='form-control' type='text' name='orderListList[%s].productName' value='%s'>", index, value);
return html;
}
},
@ -253,9 +253,9 @@
field: 'discount',
align: 'center',
title: '折扣',
width: 70,
width: 90,
formatter: function (value, row, index) {
var html = $.common.sprintf("<input readonly class='form-control discount' type='number' name='orderListList[%s].discount' value='%s' step='0.1' max='1' min='0'>", index, value);
var html = $.common.sprintf("<input readonly class='form-control discount' type='number' name='orderListList[%s].discount' value='%s' step='0.0001' max='1' min='0'>", index, value);
return html;
}
},
@ -291,10 +291,11 @@
function addRow(row) {
var count = $("#" + table.options.id).bootstrapTable('getData').length;
var row = {
var newRow = {
index: $.table.serialNumber(count),
productId: row.productId,
productCode: row.productCode,
productName: row.productName,
quantity: row.quantity,
price: row.price,
amount: row.amount,
@ -304,7 +305,7 @@
deletedAt: row.deletedAt,
discount: row.discount,
}
sub.addRow(row);
sub.addRow(newRow);
}
@ -414,6 +415,7 @@
let data = JSON.parse(res.currentTarget.response)
if (data.code === 0) {
$.modal.msgSuccess('导入成功');
data.data.forEach((row) => {
addRow(row)
})

View File

@ -419,8 +419,9 @@
field: 'discount',
align: 'center',
title: '折扣',
width:90,
formatter: function (value, row, index) {
var html = $.common.sprintf("<input readonly class='form-control discount' type='number' name='orderListList[%s].discount' value='%s' step='0.1' max='1' min='0'>", index, value);
var html = $.common.sprintf("<input readonly class='form-control discount' type='number' name='orderListList[%s].discount' value='%s' step='0.0001' max='1' min='0'>", index, value);
return html;
}
},

View File

@ -2,8 +2,10 @@ package com.ruoyi.sip.controller;
import java.io.File;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
import cn.hutool.core.collection.CollUtil;
@ -218,9 +220,16 @@ public class OrderInfoController extends BaseController
}
//只处理当前产品表有的数据
List<ProductInfo> productInfos = productInfoService.selectProductInfoList(new ProductInfo());
Set<String> productSet = productInfos.stream().map(ProductInfo::getProductCode).collect(Collectors.toSet());
Map<String, ProductInfo> productInfoMap = productInfos.stream().collect(Collectors.toMap(ProductInfo::getProductCode, Function.identity(), (v1, v2) -> v1));
orderListList = orderListList.stream().filter(item -> item != null && StringUtils.isNotEmpty(item.getProductCode())
&& productSet.contains(item.getProductCode())).collect(Collectors.toList());
&& productInfoMap.containsKey(item.getProductCode()))
.collect(Collectors.toList());
for (OrderList orderList : orderListList) {
ProductInfo productInfo = productInfoMap.get(orderList.getProductCode());
if (productInfo != null) {
orderList.setProductName(productInfo.getProductName());
}
}
if (CollUtil.isEmpty(orderListList)){
throw new ServiceException("导入excel的产品均未在产品库中,导入失败");
}