新增彩印通成本

This commit is contained in:
2026-06-25 12:54:47 +08:00
parent 88d097f630
commit 79f0ae9e07
7 changed files with 996 additions and 1 deletions
@@ -379,6 +379,7 @@ public class ProductController {
}
product.setRole(user.getRole());
PricingStrategy pricingStrategy = PricingStrategyFactory.getStrategy(product.getProTypeValue());
assert pricingStrategy != null;
PricingListVo listvo = pricingStrategy.calculatePrice(product, user.getRole());
if (listvo.getCode() != 0) {
return Msg.fail(listvo.getMsg());
@@ -408,6 +409,52 @@ public class ProductController {
return Msg.success().add("proList", proList);
}
@RequestMapping("/getProductCastPrice")
public Msg getProductCastPrice(Product product, HttpServletRequest request) {
SysUser user = (SysUser) request.getSession().getAttribute("USER_SESSION");
if (StringUtils.isEmpty(product.getCount()) || product.getCount() <= 0) {
return Msg.fail("数量必须大于0");
}
String size = product.getSize();
if (!StringUtils.isEmpty(size)) {
product.setLength(Double.valueOf(size.substring(0, size.indexOf("*"))));
String other_size = size;
if (size.contains(",")) {
size = size.split(",")[0];
}
if (size.indexOf(("*"), size.indexOf("*") + 1) == -1) {
product.setWidth(Double.valueOf(size.substring(size.indexOf("*") + 1)));
} else {
product.setWidth(Double.valueOf(size.substring(size.indexOf("*") + 1, size.indexOf(("*"), size.indexOf("*") + 1))));
product.setLength(Math.abs(Double.parseDouble(size.substring(size.indexOf(("*"), size.indexOf("*") + 1) + 1))));
}
}
product.setRole(user.getRole());
PricingListVo listvo = priceService.getCostPrice(product);
if (listvo.getCode() != 0) {
return Msg.fail(listvo.getMsg());
}
List<ProductVo> proList = listvo.getProList();
if (proList == null || proList.size() == 0 || proList.get(0).getPrice() == 0) {
return Msg.fail("暂无报价");
}
if (listvo.getCode() != 0) {
return Msg.fail(listvo.getMsg());
}
proList = listvo.getProList();
// 把角色存入,前台判断,区分不同价格
for (ProductVo p : proList) {
p.setRole(user.getRole());
}
return Msg.success().add("proList", proList);
}
/*public List<Product> f_getPrice( int priceArr[], int count, String craftMo) {
List<Product> list = new ArrayList<Product>();
Product p = new Product();
@@ -3,6 +3,7 @@ package lingtao.net.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lingtao.net.bean.Product;
import lingtao.net.util.PriceUtils;
import lingtao.net.vo.PricingListVo;
import lingtao.net.vo.ProductVo;
import lingtao.net.vo.ProvidePrice;
@@ -10,6 +11,7 @@ import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.regex.Matcher;
@@ -572,4 +574,223 @@ public class PriceService {
return new Province(province, city, district, detailAddress);
}
public PricingListVo getCostPrice(Product product) {
if (product.getProTypeValue() == null) {
return new PricingListVo(100, "暂无设置价格。");
}
if (!"彩印通".equals(product.getPlantName())) {
return new PricingListVo(100, "暂无设置价格。");
}
if ("彩印通".equals(product.getPlantName()) && "卡片".equals(product.getProTypeValue())) {
return getCYTCardPrice(product);
}
if ("彩印通".equals(product.getPlantName()) && "不干胶".equals(product.getProTypeValue())) {
return getCYTStickerPrice(product);
}
return null;
}
private PricingListVo getCYTStickerPrice(Product product) {
List<ProductVo> resultList = new ArrayList<>();
double width = product.getWidth();
double length = product.getLength();
int count = product.getCount();
int number = product.getNumber();
// 定义纸张尺寸(单位:毫米)
double paperLength = 287; // 纸张长度
double paperWidth = 406; // 纸张宽度
width = convertToMillimetersWithMargin(width, 2);
length = convertToMillimetersWithMargin(length, 2);
List<String> smallPaper = Arrays.asList("加厚铜版纸不干胶", "艾丽铜板不干胶", "特光不干胶", "铜板可移不干胶", "牛皮纸", "书写纸", "易碎纸", "大红洒金");
if (smallPaper.contains(product.getKind())) {
paperLength = 300; // 纸张长度
paperWidth = 420; // 纸张宽度
}
if (!isWithinPaperSize(width, length, paperLength, paperWidth)) {
return new PricingListVo(100, "超出纸张尺寸限制"); // 返回空列表表示不适用
}
double basePrice = 3;
if ("加厚铜版纸不干胶".equals(product.getKind())) {
basePrice = 2;
}
if ("黑胶铜版(遮盖/遮光)".equals(product.getKind())) {
basePrice = 4;
}
if ("牛皮纸".equals(product.getKind())) {
basePrice = 1.8;
}
if ("书写纸".equals(product.getKind())) {
basePrice = 1.8;
}
if ("易碎纸".equals(product.getKind())) {
basePrice = 4;
}
if ("洒金宣纸(白色)".equals(product.getKind())) {
basePrice = 4;
}
if ("超白浮雕纹".equals(product.getKind())) {
basePrice = 3.5;
}
if ("净白彩岩纹".equals(product.getKind())) {
basePrice = 3.5;
}
List<String> base_2 = Arrays.asList("艾丽铜板不干胶", "特光不干胶", "铜板可移不干胶", "大红洒金", "白布纹纸");
if (base_2.contains(product.getKind())) {
basePrice = 2.5;
}
basePrice = Math.max(2, basePrice);
// 计算一张纸能容纳的最大金属标数量
double maxItemsPerSheet = calculateMaxItemsPerSheet(length, width, paperLength, paperWidth);
// 计算所需纸张数量
int requiredSheets = calculateRequiredSheets(count, number, maxItemsPerSheet);
BigDecimal price = new BigDecimal(basePrice).multiply(new BigDecimal(requiredSheets)).setScale(2, RoundingMode.HALF_UP);
ProductVo pro = new ProductVo();
pro.setPrice(price.doubleValue());
pro.setCount(count);
pro.setNumber(number);
resultList.add(pro);
return new PricingListVo(resultList);
}
private PricingListVo getCYTCardPrice(Product product) {
List<ProductVo> resultList = new ArrayList<>();
double width = product.getWidth();
double length = product.getLength();
int count = product.getCount();
int number = product.getNumber();
// 定义纸张尺寸(单位:毫米)
double paperLength = 300; // 纸张长度
double paperWidth = 420; // 纸张宽度
width = convertToMillimetersWithMargin(width, 2);
length = convertToMillimetersWithMargin(length, 2);
if (!isWithinPaperSize(width, length, paperLength, paperWidth)) {
return new PricingListVo(100, "超出纸张尺寸限制"); // 返回空列表表示不适用
}
List<String> list = Arrays.asList("300克双铜纸", "300克单铜白卡", "300克冰白卡纸", "300克荷兰白卡", "300克水晶磨砂", "300克铂金磨砂", "300克米黄荷兰白", "300克雅典米白灵感纸", "300克米黄丝绵纸", "325克素面镭射卡白底", "330克超白草香纸", "350克雅柔纸", "350克冰白卡纸", "350克荷兰白卡", "350克布纹", "350克蛋壳纹", "350克安格纹", "350克刚古纹", "350克米黄刚古纹", "350克米黄冰白", "350克超白超感纸", "雅柔毯纹超白");
int[] counts = new int[]{0, 5, 10, 20, 25, 50};
double[] basePrices = new double[]{1.8, 9, 17, 34, 41.25, 82.5};
if ("300克单铜白卡".equals(product.getKind())) {
basePrices = new double[]{2, 10, 19, 38, 45, 90};
}
if ("300克冰白卡纸".equals(product.getKind())) {
basePrices = new double[]{2.5, 12.5, 24, 46, 55, 100};
}
if ("300克荷兰白卡".equals(product.getKind())) {
basePrices = new double[]{2.1, 10.5, 21, 40, 50, 90};
}
if ("300克水晶磨砂".equals(product.getKind())) {
basePrices = new double[]{5, 40, 47, 100, 107.5, 200};
}
if ("300克铂金磨砂".equals(product.getKind())) {
basePrices = new double[]{4.5, 22.5, 42, 80, 95, 175};
}
if ("300克米黄荷兰白".equals(product.getKind())) {
basePrices = new double[]{2.5, 12.5, 24, 46, 55, 100};
}
if ("300克雅典米白灵感纸".equals(product.getKind())) {
basePrices = new double[]{3, 15, 28, 52, 62.5, 115};
}
if ("300克米黄丝绵纸".equals(product.getKind())) {
basePrices = new double[]{3.5, 17.5, 34, 66, 80, 150};
}
if ("325克素面镭射卡白底".equals(product.getKind())) {
basePrices = new double[]{5, 25, 45, 86, 100, 190};
}
if ("330克超白草香纸".equals(product.getKind())) {
basePrices = new double[]{5, 25, 48, 90, 107.5, 200};
}
if ("350克雅柔纸".equals(product.getKind())) {
basePrices = new double[]{3, 15, 28, 54, 65, 125};
}
if ("350克米黄冰白".equals(product.getKind())) {
basePrices = new double[]{3, 15, 28, 54, 65, 125};
}
if ("雅柔毯纹超白".equals(product.getKind())) {
basePrices = new double[]{20, 38, 70, 82.5, 150};
}
List<String> list_100 = Arrays.asList("350克冰白卡纸", "350克荷兰白卡", "350克布纹", "350克蛋壳纹", "350克安格纹", "350克刚古纹", "350克米黄刚古纹", "350克超白超感纸");
if (list_100.contains(product.getKind())) {
basePrices = new double[]{2.5, 12.5, 24, 46, 55, 100};
}
// 计算一张纸能容纳的最大金属标数量
double maxItemsPerSheet = calculateMaxItemsPerSheet(length, width, paperLength, paperWidth);
// 计算所需纸张数量
int requiredSheets = calculateRequiredSheets(count, number, maxItemsPerSheet);
double basePrice = PriceUtils.TableCountDoublePrice(requiredSheets, basePrices, counts);
basePrice = Math.max(2.5, basePrice);
BigDecimal price = new BigDecimal(basePrice).multiply(new BigDecimal(requiredSheets)).setScale(2, RoundingMode.HALF_UP);
ProductVo pro = new ProductVo();
pro.setPrice(price.doubleValue());
pro.setCount(count);
pro.setNumber(number);
resultList.add(pro);
return new PricingListVo(resultList);
}
/**
* 将给定的尺寸转换为毫米,并在每边增加3毫米的边距
*
* @param size 需要转换的原始尺寸
* @return 转换后的尺寸,单位为毫米,包括边距
*/
private double convertToMillimetersWithMargin(double size, int num) {
return size * 10 + 2 * num; // 换成毫米,每边+2
}
/**
* 检查给定的长度和宽度是否在纸张尺寸范围内
*
* @param length 需要检查的长度
* @param width 需要检查的宽度
* @param paperLength 纸张的长度
* @param paperWidth 纸张的宽度
* @return 如果给定尺寸在纸张尺寸范围内,则返回true;否则返回false
*/
private boolean isWithinPaperSize(double length, double width, double paperLength, double paperWidth) {
return (length <= paperLength && width <= paperWidth) || (length <= paperWidth && width <= paperLength);
}
/**
* 计算每张纸最多可以容纳的物品数量
*
* @param length 物品的长度
* @param width 物品的宽度
* @param paperLength 纸张的长度
* @param paperWidth 纸张的宽度
* @return 每张纸最多可以容纳的物品数量
*/
private double calculateMaxItemsPerSheet(double length, double width, double paperLength, double paperWidth) {
return Math.max(
Math.floor(paperLength / length) * Math.floor(paperWidth / width),
Math.floor(paperLength / width) * Math.floor(paperWidth / length)
);
}
/**
* 计算完成指定数量的物品所需的纸张数量
*
* @param count 物品的总数量
* @param number 每个物品需要的数量
* @param maxItemsPerSheet 每张纸最多可以容纳的物品数量
* @return 完成指定数量的物品所需的纸张数量
*/
private int calculateRequiredSheets(int count, int number, double maxItemsPerSheet) {
return (int) Math.ceil((count * number) / maxItemsPerSheet);
}
}
@@ -4490,12 +4490,56 @@ public class ProductService {
case "躺椅":
priceList = getDeckCharitPrice(dto, width, length);
return chucklePrice(role, priceList, dto);
case "钥匙扣":
priceList = getKeychain(dto, width, length);
return chucklePrice(role, priceList, dto);
default:
break;
}
return null;
}
private List<Product> getKeychain(Product dto, Double width, Double length) {
List<String> carft_list = dto.getCraft() == null ? new ArrayList<>() : Arrays.asList(dto.getCraft());
List<Product> priceList = new ArrayList<>();
int count = dto.getCount();
int number = dto.getNumber();
double price = 0;
double min_price = 35;
if (width * length / 10000 < 0.001) {
double basePrice = 1;
price = basePrice * count * dto.getNumber();
} else {
double area = width * length / 10000 * count * dto.getNumber();
double[] areas = {0, 0.1, 0.15, 0.2, 0.3, 0.4, 0.5, 1, 2, 3, 5, 7, 9, 10, 20, 50};
int[] prices = {0, 1100, 1000, 950, 900, 850, 800, 750, 700, 650, 600, 550, 500, 480, 470, 460};
if ("4".equals(dto.getKindValue())) {
prices = new int[]{0, 1130, 1030, 980, 930, 880, 830, 780, 730, 680, 630, 580, 530, 510, 500, 490};
}
double last_price = 450;
price = PriceUtils.TableUnitPrice(area, prices, areas, last_price);
price = Math.max(price, min_price) + ((dto.getNumber() - 1) * 8);
}
double craft_price = 0;
if (!StringUtils.isEmpty(dto.getBianma())) {
double craft_base = 0.1;
if ("圆型钥匙扣银色".equals(dto.getBianma()) || "珠链银色".equals(dto.getBianma())) {
craft_base = 0;
}
craft_price = Math.ceil(craft_base * count * dto.getNumber());
}
String weight = df.format(width * length * 4.17 * dto.getCount() * 0.1 * number / 1000 * 2);
Product pro = new Product();
pro.setCount(dto.getCount());
pro.setNumber(dto.getNumber());
pro.setWeight(weight);
pro.setPrice(Math.ceil(price + craft_price));
priceList.add(pro);
return priceList;
}
private List<Product> getDeckCharitPrice(Product dto, Double width, Double length) {
List<String> craft_lists = dto.getCraft() == null ? new ArrayList<>() : Arrays.asList(dto.getCraft());
List<String> craft_list = new ArrayList<>(craft_lists);
@@ -3739,6 +3739,26 @@ public class PriceUtils {
return price;
}
public static double TableCountDoublePrice(double area, double[] price_list, int[] areas) {
double price = 0;
int startIndex = 0;
int endIndex = 0;
for (int i = 0; i < areas.length; i++) {
if (area > areas[i]) {
startIndex = endIndex;
endIndex = Math.min(i + 1, areas.length - 1);
}
}
if (startIndex == endIndex && startIndex == 0) {
price = price_list[endIndex];
} else if (startIndex == endIndex) {
price = (price_list[endIndex]);
} else {
price = ((areas[endIndex] - area) / (areas[endIndex] - areas[startIndex])) * price_list[startIndex] + ((area - areas[startIndex]) / (areas[endIndex] - areas[startIndex])) * price_list[endIndex];
}
return price;
}
public static double TableUnitPrice(double area, int[] price_list, double[] areas, double last_price) {
double price = 0;
int startIndex = 0;
@@ -55,6 +55,6 @@
select roleId from tbl_sys_user_role where userId = #{userId}
)
)
ORDER BY -orderNo DESC
ORDER BY orderNo ASC
</select>
</mapper>
@@ -0,0 +1,327 @@
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<%@include file="/views/common.jsp" %>
</head>
<body>
<div class="big_box">
<div class="left_div">
<form class="layui-form">
<p>
车间
</p>
<div class="layui-form-item">
<div class="layui-form-item">
<select class="select" name="plantName">
<option value="彩印通">彩印通</option>
</select>
</div>
</div>
<p>产品</p>
<div class="layui-form-item">
<select name="proTypeValue" id="proTypeValue" lay-filter="proTypeValue" class="select" lay-search>
<option value="卡片">卡片</option>
<option value="不干胶">不干胶</option>
</select>
</div>
<p>
材质
</p>
<div class="layui-form-item">
<select name="kind" id="kind" lay-filter="kind" class="select" lay-search>
<option value="300克双铜纸">300克双铜纸</option>
<option value="300克单铜白卡">300克单铜白卡</option>
<option value="300克冰白卡纸">300克冰白卡纸</option>
<option value="300克荷兰白卡">300克荷兰白卡</option>
<option value="300克水晶磨砂">300克水晶磨砂</option>
<option value="300克铂金磨砂">300克铂金磨砂</option>
<option value="300克米黄荷兰白">300克米黄荷兰白</option>
<option value="300克雅典米白灵感纸">300克雅典米白灵感纸</option>
<option value="300克米黄丝绵纸">300克米黄丝绵纸</option>
<option value="325克素面镭射卡白底">325克素面镭射卡白底</option>
<option value="330克超白草香纸">330克超白草香纸</option>
<option value="350克雅柔纸">350克雅柔纸</option>
<option value="350克冰白卡纸">350克冰白卡纸</option>
<option value="350克荷兰白卡">350克荷兰白卡</option>
<option value="350克布纹">350克布纹</option>
<option value="350克蛋壳纹">350克蛋壳纹</option>
<option value="350克安格纹">350克安格纹</option>
<option value="350克刚古纹">350克刚古纹</option>
<option value="350克米黄刚古纹">350克米黄刚古纹</option>
<option value="350克米黄冰白">350克米黄冰白</option>
<option value="350克超白超感纸">350克超白超感纸</option>
<option value="雅柔毯纹超白">雅柔毯纹超白</option>
</select>
</div>
<p>
尺寸(CM/厘米) <span style="font-size:14px;color:red">输入格式: 长 * 宽 </span>
</p>
<span class="ui_zdy_size">
<input type="text" id="size" name="size" placeholder="格式:长*宽" class="layui-input" autocomplete="off">
</span>
<p>
数量(个)
</p>
<div class="layui-form-item">
<input type="text" placeholder="请输入整数" autocomplete="off" name="count" class="layui-input" id="count">
</div>
<p>
款数
</p>
<div class="layui-form-item">
<input type="text" placeholder="请输入整数" autocomplete="off" name="number" id="number" value="1" class="layui-input"
lay-verify="number">
</div>
<p>
客户旺旺
</p>
<div class="layui-form-item">
<input type="text" placeholder="请输入客户旺旺号" autocomplete="off" name="wangwang" id="wangwang"
class="layui-input">
</div>
<p>
工艺
</p>
<div class="layui-form-item" id='card_craft'>
<div class="layui-input-block">
覆膜工艺:
<input type="checkbox" name="craft" lay-filter="ui_craft" value="哑膜" title="哑膜" checked>
</div>
<div class="layui-input-block">
裁切工艺:
<input type="checkbox" name="craft" lay-filter="ui_craft" value="直角裁切" title="直角裁切" checked>
<input type="checkbox" name="craft" lay-filter="ui_craft" value="模切" title="模切">
</div>
</div>
<div class="layui-form-item" id='sticker_craft'>
<div class="layui-input-block">
覆膜工艺:
<input type="checkbox" name="craft" lay-filter="ui_craft" value="哑膜" title="哑膜" checked>
<input type="checkbox" name="craft" lay-filter="ui_craft" value="亮膜" title="亮膜">
</div>
<div class="layui-input-block">
裁切工艺:
<input type="checkbox" name="craft" lay-filter="ui_craft" value="模切" title="模切" checked>
</div>
</div>
<hr>
<div class="layui-form-item">
<button class="layui-btn" lay-submit="" lay-filter="acount_btn">计算</button>
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
</div>
<h2>计算结果-
<button type="button" class="layui-btn layui-btn-primary layui-btn-sm copyResult"
onclick="copyResult()">点击复制
</button>
</h2>
<div>
<textarea rows="11" cols="75" id="span_result" readonly="readonly"></textarea>
<%@include file="../acountExpressFee.jsp" %>
</div>
<div>
<table class="layui-hide" id="priceTable" lay-filter="priceTable"></table>
</div>
</form>
</div>
<div class="right_div" style="margin-left:50px;">
<div class="layui-carousel" id="test1">
<div carousel-item id="carousel"></div>
<br>
<div id="remark" style="font-size:20px;color:red"></div>
</div>
</div>
</div>
</body>
<%@include file="/views/copyResult.jsp" %>
<script>
layui.use(['table', 'form', 'carousel'], function () {
var form = layui.form; //只有执行了这一步,部分表单元素才会自动修饰成功
var carousel = layui.carousel;
var table = layui.table;
$("#sticker_craft").hide();
$("#sticker_craft input").attr("disabled", true);
$("#sticker_craft select").attr("disabled", true);
form.on('select(proTypeValue)', function (data) {
let html = `<option value="300克双铜纸">300克双铜纸</option>
<option value="300克单铜白卡">300克单铜白卡</option>
<option value="300克冰白卡纸">300克冰白卡纸</option>
<option value="300克荷兰白卡">300克荷兰白卡</option>
<option value="300克水晶磨砂">300克水晶磨砂</option>
<option value="300克铂金磨砂">300克铂金磨砂</option>
<option value="300克米黄荷兰白">300克米黄荷兰白</option>
<option value="300克雅典米白灵感纸">300克雅典米白灵感纸</option>
<option value="300克米黄丝绵纸">300克米黄丝绵纸</option>
<option value="325克素面镭射卡白底">325克素面镭射卡白底</option>
<option value="330克超白草香纸">330克超白草香纸</option>
<option value="350克雅柔纸">350克雅柔纸</option>
<option value="350克冰白卡纸">350克冰白卡纸</option>
<option value="350克荷兰白卡">350克荷兰白卡</option>
<option value="350克布纹">350克布纹</option>
<option value="350克蛋壳纹">350克蛋壳纹</option>
<option value="350克安格纹">350克安格纹</option>
<option value="350克刚古纹">350克刚古纹</option>
<option value="350克米黄刚古纹">350克米黄刚古纹</option>
<option value="350克米黄冰白">350克米黄冰白</option>
<option value="350克超白超感纸">350克超白超感纸</option>
<option value="雅柔毯纹超白">雅柔毯纹超白</option>`;
$("#sticker_craft").hide();
$("#sticker_craft input").attr("disabled", true);
$("#sticker_craft select").attr("disabled", true);
$("#card_craft").hide();
$("#card_craft input").attr("disabled", true);
$("#card_craft select").attr("disabled", true);
if (data.value == '卡片') {
$("#card_craft").show();
$("#card_craft input").attr("disabled", false);
$("#card_craft select").attr("disabled", false);
}
if (data.value == '不干胶') {
$("#sticker_craft").show();
$("#sticker_craft input").attr("disabled", false);
$("#sticker_craft select").attr("disabled", false);
html = `<option value='加厚铜版纸不干胶'>加厚铜版纸不干胶</option>
<option value='艾丽铜板不干胶'>艾丽铜板不干胶</option>
<option value='特光不干胶'>特光不干胶</option>
<option value='铜板可移不干胶'>铜板可移不干胶</option>
<option value='黑胶铜版(遮盖/遮光)'>黑胶铜版(遮盖/遮光)</option>
<option value='牛皮纸'>牛皮纸</option>
<option value='书写纸'>书写纸</option>
<option value='易碎纸'>易碎纸</option>
<option value='大红洒金'>大红洒金</option>
<option value='白底洒金'>白底洒金</option>
<option value='白美纹'>白美纹</option>
<option value='白美纹洒金'>白美纹洒金</option>
<option value='洒金宣纸(白色)'>洒金宣纸(白色)</option>
<option value='水纹洒金'>水纹洒金</option>
<option value='刚古水纹纸(白色)'>刚古水纹纸(白色)</option>
<option value='大地纸(白草香)'>大地纸(白草香)</option>
<option value='米色七彩(树纹)'>米色七彩(树纹)</option>
<option value='白布纹纸'>白布纹纸</option>
<option value='超白浮雕纹'>超白浮雕纹</option>
<option value='净白彩岩纹'>净白彩岩纹</option>
<option value='珠光米黄莱妮纹'>珠光米黄莱妮纹</option>
<option value='珠光星翠'>珠光星翠</option>
<option value='珠光金黄'>珠光金黄</option>
<option value='珠光冰白'>珠光冰白</option>
<option value='莹光红'>莹光红</option>
<option value='黄色莹光纸'>黄色莹光纸</option>
<option value='橙色莹光纸'>橙色莹光纸</option>
<option value='绿色莹光纸'>绿色莹光纸</option>
`
}
$("select[name='kind']").empty().append(html);
form.render()
})
// 点击计算,计算价格
form.on('submit(acount_btn)', function (data) {
var number = $("#number").val();
var size = $("#size").val();
var count = $("#count").val();
var proTypeValue = $("#proTypeValue").val();
var kind = $("select[name='kind'] option:selected").text();
var craft = [];
$("input:checkbox[name='craft']:checked").each(function (i) {
// 没有被禁用的工艺加到arr中
if (!$(this).is(':disabled')) {
craft.push($(this).val());
}
});
$.ajax({
url: "${path}/getProductCastPrice",
type: "POST",
data: $(".big_box form").serialize(),
success: function (result) {
if (result.code == 100) {
layer.msg(result.msg, {offset: ['300px', '300px']}, function () {
});
return false;
}
var data = result.data.proList;
var span_result = proTypeValue + ' - ' + kind;
span_result += "-" + size + ' CM\n';
span_result += "工艺:" + craft + '\n';
for (let i = 0; i < data.length; i++) {
span_result += number + '款 各' + data[i].count + "张,共" + data[i].price + "元" + '\n'
data[i].number = number;
let providePrices = data[i].providePrices;
if (providePrices && providePrices.length > 0) {
for (let item in providePrices) {
span_result += providePrices[item].name + "" + providePrices[item].price + "元。共" + Number(data[i].price + providePrices[item].price).toFixed(2) + '\n'
}
}
}
$("#span_result").val(span_result);
//计算完自动复制文本
var e = document.getElementById("span_result");//对象是content
if (e.value != "") {
e.select();//选择对象
document.execCommand("Copy");//执行浏览器复制命令
}
//生成表格
table.render({
elem: '#priceTable',
even: true, //隔行变色
data: data, // 赋值已知数据
width: 500,
cols: [[
{
field: 'number',
width: '12%',
align: "center",
title: '款数'
}, {
field: 'count',
width: '16%',
align: "center",
title: '数量'
}, {
field: 'price',
width: '16%',
align: "center",
title: '报价'
}, {
field: 'wangwang',
align: "center",
width: '16%',
title: '折扣价'
}, {
field: 'wangwang',
align: "center",
width: '19%',
title: '跳楼价'
}, {
field: 'weight',
width: '21%',
align: "center",
title: '重量(kg'
}
]],
done: function () {
}
});
}
});
return false;
});
});
</script>
</html>
+336
View File
@@ -0,0 +1,336 @@
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<%@include file="/views/common.jsp" %>
</head>
<body>
<style>
#z4_craft .layui-form-select .layui-edge {
right: 20px;
}
</style>
<div class="big_box">
<div class="left_div">
<h1 class="h1">钥匙扣</h1> <span style="color:red;font-weight:700;"></span>
<hr>
<form class="layui-form">
<input type="hidden" name="proTypeValue" id="proTypeValue" class="layui-input" value="钥匙扣"/>
<p>
材质
</p>
<div class="layui-form-item">
<select name="kind" class="select" lay-search lay-filter="kind">
<option value="1">亚克力</option>
</select>
</div>
<p>
厚度
</p>
<div class="layui-form-item">
<select name="kindValue" class="select" lay-search lay-filter="kindValue">
<option value="3">3mm</option>
<option value="4">4mm</option>
</select>
</div>
<p>
尺寸(CM/厘米)
</p>
<div class="layui-form-item" id="ui_size">
<input type="text" name="size" placeholder="格式:长*宽" id="size" class="layui-input" autocomplete="off">
</div>
<p>
数量(个)
</p>
<div class="layui-form-item">
<input type="text" name="count" id="diyCount" placeholder="请输入整数" class="layui-input" autocomplete="off">
</div>
<p>
款数
</p>
<div class="layui-form-item">
<input type="text" placeholder="请输入整数" autocomplete="off" name="number" id="number" value="1"
class="layui-input" lay-verify="number">
</div>
<p>
客户旺旺
</p>
<div class="layui-form-item">
<input type="text" placeholder="请输入客户旺旺号" autocomplete="off" name="wangwang" id="wangwang"
class="layui-input">
</div>
<p>
工艺
</p>
<div class="layui-form-item" id='z4_craft'>
<div class="layui-input-block ">
常见工艺:
<input type="checkbox" name="craft" lay-filter="ui_craft" value="打孔" title="打孔" checked>
</div>
<div class="layui-input-block">
配件:
<input type="checkbox" name="craft" lay-filter="ui_craft" value="配件" title="配件">
<div class="layui-inline zyselect" style="width:200px; display:none">
<select name="bianma" class="layui-select ">
<option value="圆型钥匙扣银色">圆型钥匙扣银色</option>
<option value="星星钥匙扣金/银色">星星钥匙扣金/银色</option>
<option value="兔子钥匙扣金/银色">兔子钥匙扣金/银色</option>
<option value="龙虾型钥匙扣银色">龙虾型钥匙扣银色</option>
<option value="珠链银色">珠链银色</option>
<option value="方形钥匙扣/金/银色">方形钥匙扣/金/银色</option>
<option value="猫头钥匙扣金/银色">猫头钥匙扣金/银色</option>
<option value="猫钥匙扣金/银色">猫钥匙扣金/银色</option>
<option value="D字扣银色">D字扣银色</option>
<option value="挂绳">挂绳</option>
<option value="小樱花钥匙扣金/银色">小樱花钥匙扣金/银色</option>
<option value="心形钥匙扣金/银色">心形钥匙扣金/银色</option>
<option value="月亮钥匙扣金/银色">月亮钥匙扣金/银色</option>
<option value="钢丝圈红色">钢丝圈红色</option>
</select>
</div>
</div>
</div>
<div class="layui-input-block">
<input type="checkbox" name="craft" lay-filter="ui_craft" value="抠图" title="抠图">
<div class="layui-inline crop" style="display:none;width: 80px">
<input class="layui-input" type="text" name="cropNumber">
</div>
</div>
<hr>
<div class="layui-form-item">
<button class="layui-btn" lay-submit="" lay-filter="acount_btn">计算</button>
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
</div>
<h2>计算结果-
<button type="button" class="layui-btn layui-btn-primary layui-btn-sm copyResult"
onclick="copyResult()">点击复制
</button>
</h2>
<div>
<textarea rows="11" cols="75" id="span_result" readonly="readonly"></textarea>
<%@include file="../acountExpressFee.jsp" %>
</div>
<div>
<table class="layui-hide" id="priceTable" lay-filter="priceTable"></table>
</div>
</form>
</div>
<div class="right_div" style="margin-left:50px;">
<div class="layui-carousel" id="test1">
<div carousel-item id="carousel"></div>
<br>
<div id="remark" style="font-size:20px;color:red"></div>
</div>
</div>
</div>
</body>
<%@include file="/views/copyResult.jsp" %>
<script>
layui.use(['table', 'form', 'carousel'], function () {
var form = layui.form; //只有执行了这一步,部分表单元素才会自动修饰成功
var carousel = layui.carousel;
var table = layui.table;
//建造实例
ins = carousel.render({});
var html = " ";
var remark = " ";
// 清空轮播图
$("#carousel").empty();
$("#remark").empty();
$.ajax({
url: "${pageContext.request.contextPath}/getImgs",
type: "GET",
data: {
proTypeValue: $("#proTypeValue").val(),
kindValue: $('input[name="kindValue"]').val()
},
success: function (result) {
for (let i = 0; i < result.length; i++) {
// 只留一个remark
remark = "";
html += '<div><img style="width:100%;height: 100%;object-fit: contain" src="' + result[i].imgUrl + '"></div>';
remark += '<div><span>' + result[i].remark + '<span/></div>';
}
$("#carousel").append(html);
// 如果没有说明,就不显示null
if (remark.indexOf("null") < 0) {
$("#remark").append(remark);
}
// 如果没有轮播图就隐藏
if (result.length == 0) {
document.getElementById("test1").style.display = "none"; //隐藏
} else {
document.getElementById("test1").style.display = "block"; //显示
ins.reload({
elem: '#test1',
width: result[0].imgWidth, //设置容器宽度
height: result[0].imgHeight
});
}
}
});
form.on('checkbox(ui_craft)', function (data) {
let craft_list = [];
craft_list.push($("select[name='craft'] option:selected").val());
$("input[name='craft']:checked").each(function () {
if (!$(this).is(':disabled')) {
craft_list.push($(this).val());
}
}
);
$(".zyselect").hide();
$(".zyselect").find("select").prop("disabled", true)
if (craft_list.includes("配件")) {
$(".zyselect").show();
$(".zyselect").find("select").prop("disabled", false)
}
$(".crop").hide();
$(".crop").find("input").prop("disabled", true)
if (craft_list.includes("抠图")) {
$(".crop").show();
$(".crop").find("input").prop("disabled", false)
}
form.render();
})
// 点击计算,计算价格
form.on('submit(acount_btn)', function (data) {
var number = $("#number").val();
var size = $("#size").val();
var count = $("#count option:selected").val();
var kind = $("select[name='kind'] option:selected").text();
var kindValue = $("select[name='kindValue'] option:selected").text();
var craft = [];
if ($("input[name='switchCount']").is(":checked")) {
count = $("#count").val();
}
if (size == "") {
layer.msg('请填写尺寸!', {offset: ['300px', '300px']}, function () {
});
return false;
}
$("input:checkbox[name='craft']:checked").each(function (i) {
// 没有被禁用的工艺加到arr中
if (!$(this).is(':disabled')) {
if ($(this).val() == "抠图") {
craft.push($(this).val() + $("input[name='cropNumber']").val());
return;
} else if ($(this).val() == "配件") {
craft.push($("select[name='bianma'] option:selected").val());
} else {
craft.push($(this).val());
}
}
});
if ((size.split("*")[0] < 1 || size.split("*")[1] < 1)) {
layer.msg("最小尺寸不能小于1*1", {offset: ['300px', '300px']}, function () {
});
return false;
}
if ((size.split("*")[0] > 12 || size.split("*")[1] > 12)) {
layer.msg("最小尺寸不能小于12*12", {offset: ['300px', '300px']}, function () {
});
return false;
}
$.ajax({
url: "${path}/getThanSum",
type: "GET",
data: $(".big_box form").serialize(),
success: function (result) {
if (result.code == 100) {
layer.msg(result.msg, {offset: ['300px', '300px']}, function () {
});
return false;
}
var data = result.data.proList;
var span_result = '钥匙扣 - ' + kind + ' - ' + kindValue + ' - ' + size + ' cm (同款内容)\n';
span_result += `工艺:` + craft.join(",") + '\n';
if (number > 1) {
for (let i = 0; i < data.length; i++) {
span_result += number + '款 各' + data[i].count + "个,共" + data[i].price + "元" + '\n'
data[i].number = number;
}
} else {
for (let i = 0; i < data.length; i++) {
span_result += number + '款 ' + data[i].count + "个,共" + data[i].price + "元" + '\n'
data[i].number = number;
}
}
span_result += '包邮,免费设计呢~(偏远地区需补邮费)'
if (window.parent.system_isGai) {
span_result += "\n\n亲 现在下单可以参加淘宝活动8.5折折扣哦!"
}
addLog(span_result);
$("#span_result").val(span_result);
//计算完自动复制文本
var e = document.getElementById("span_result");//对象是content
if (e.value != "") {
e.select();//选择对象
document.execCommand("Copy");//执行浏览器复制命令
}
//生成表格
table.render({
elem: '#priceTable',
even: true, //隔行变色
data: data, // 赋值已知数据
width: 500,
cols: [[
{
field: 'number',
width: '12%',
align: "center",
title: '款数'
}, {
field: 'count',
width: '16%',
align: "center",
title: '数量'
}, {
field: 'price',
width: '16%',
align: "center",
title: '报价'
}, {
field: 'wangwang',
align: "center",
width: '16%',
title: '折扣价'
}, {
field: 'wangwang',
align: "center",
width: '19%',
title: '跳楼价'
}, {
field: 'weight',
width: '21%',
align: "center",
title: '重量(kg'
}
]],
done: function () {
}
});
}
});
return false;
});
});
</script>
</html>