产品需求功能完善
This commit is contained in:
parent
6deaf5ebfb
commit
de4349daec
|
|
@ -1,6 +1,9 @@
|
|||
package com.ruoyi.busi.controller;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.collections4.ListUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
|
@ -86,6 +89,15 @@ public class BusiProductRequireController extends BaseController
|
|||
@ResponseBody
|
||||
public AjaxResult addSave(BusiProductRequire busiProductRequire)
|
||||
{
|
||||
BusiProductRequire query = new BusiProductRequire();
|
||||
query.setOrderId(busiProductRequire.getOrderId());
|
||||
query.setColor(busiProductRequire.getColor());
|
||||
query.setSize(busiProductRequire.getSize());
|
||||
|
||||
List<BusiProductRequire> list = busiProductRequireService.selectBusiProductRequireList(query);
|
||||
if(!list.isEmpty()){
|
||||
return error("该订单已存在相同尺码颜色的产品");
|
||||
}
|
||||
return toAjax(busiProductRequireService.insertBusiProductRequire(busiProductRequire));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,9 +21,12 @@ public class BusiProductRequire extends BaseEntity
|
|||
/** ID主键 */
|
||||
private String id;
|
||||
|
||||
/** 订单ID */
|
||||
private String orderId;
|
||||
|
||||
/** 订单名称 */
|
||||
@Excel(name = "订单名称")
|
||||
private String orderId;
|
||||
private String orderName;
|
||||
|
||||
/** 数量 */
|
||||
@Excel(name = "数量")
|
||||
|
|
@ -110,11 +113,20 @@ public class BusiProductRequire extends BaseEntity
|
|||
this.busiMaterialRequireList = busiMaterialRequireList;
|
||||
}
|
||||
|
||||
public String getOrderName() {
|
||||
return orderName;
|
||||
}
|
||||
|
||||
public void setOrderName(String orderName) {
|
||||
this.orderName = orderName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("orderId", getOrderId())
|
||||
.append("orderName", getOrderName())
|
||||
.append("amount", getAmount())
|
||||
.append("size", getSize())
|
||||
.append("color", getColor())
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<resultMap type="BusiProductRequire" id="BusiProductRequireResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="orderId" column="order_id" />
|
||||
<result property="orderName" column="order_name" />
|
||||
<result property="amount" column="amount" />
|
||||
<result property="size" column="size" />
|
||||
<result property="color" column="color" />
|
||||
|
|
@ -35,23 +36,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</resultMap>
|
||||
|
||||
<sql id="selectBusiProductRequireVo">
|
||||
select id, order_id, amount, size, color, create_by, create_time, update_by, update_time, end_date from busi_product_require
|
||||
select A.id, A.order_id,B.order_name, A.amount,A.size, A.color, A.create_by, A.create_time, A.update_by, A.update_time, A.end_date
|
||||
from busi_product_require A LEFT JOIN busi_order B on A.order_id = B.id
|
||||
</sql>
|
||||
|
||||
<select id="selectBusiProductRequireList" parameterType="BusiProductRequire" resultMap="BusiProductRequireResult">
|
||||
<include refid="selectBusiProductRequireVo"/>
|
||||
<where>
|
||||
<if test="orderId != null and orderId != ''"> and order_id like concat('%', #{orderId}, '%')</if>
|
||||
<if test="size != null and size != ''"> and size = #{size}</if>
|
||||
<if test="color != null and color != ''"> and color = #{color}</if>
|
||||
<if test="orderId != null and orderId != ''"> and A.order_id = #{orderId}</if>
|
||||
<if test="size != null and size != ''"> and A.size = #{size}</if>
|
||||
<if test="color != null and color != ''"> and A.color = #{color}</if>
|
||||
</where>
|
||||
order by A.update_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectBusiProductRequireById" parameterType="String" resultMap="BusiProductRequireBusiMaterialRequireResult">
|
||||
select a.id, a.order_id, a.amount, a.size, a.color, a.create_by, a.create_time, a.update_by, a.update_time, a.end_date,
|
||||
select a.id, a.order_id,c.order_name, a.amount, a.size, a.color, a.create_by, a.create_time, a.update_by, a.update_time, a.end_date,
|
||||
b.id as sub_id, b.product_require_id as sub_product_require_id, b.amount as sub_amount, b.unit as sub_unit, b.color as sub_color, b.classify as sub_classify, b.create_by as sub_create_by, b.create_time as sub_create_time, b.update_by as sub_update_by, b.update_time as sub_update_time
|
||||
from busi_product_require a
|
||||
left join busi_material_require b on b.product_require_id = a.id
|
||||
left join busi_order c on c.id = a.order_id
|
||||
where a.id = #{id}
|
||||
</select>
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label is-required">所属订单:</label>
|
||||
<div class="col-sm-8">
|
||||
<!-- <input name="orderId" class="form-control" type="text" required>-->
|
||||
<input id="treeId" name="orderId" type="hidden">
|
||||
<input id="treeName" name="orderName" readonly="true" onclick="selectOrder(1)" class="form-control" type="text" required>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -70,11 +70,34 @@
|
|||
});
|
||||
|
||||
function submitHandler() {
|
||||
if ($.validate.form()) {
|
||||
if (sizeAndColorValidate() && $.validate.form()) {
|
||||
$.operate.save(prefix + "/add", $('#form-productRequire-add').serialize());
|
||||
}
|
||||
}
|
||||
|
||||
function sizeAndColorValidate() {
|
||||
var colors = $("table select[name$='color']");
|
||||
var classify = $("table select[name$='classify']");
|
||||
colors.removeClass("error");
|
||||
classify.removeClass("error");
|
||||
var colorAndClassify = [];
|
||||
var result = true;
|
||||
classify.each(function (i, ele) {
|
||||
var ele = colors[i].value + classify[i].value;
|
||||
var index = colorAndClassify.indexOf(ele);
|
||||
if ( index >= 0) {
|
||||
$(colors[i]).addClass("error");
|
||||
$(classify[i]).addClass("error");
|
||||
$(colors[index]).addClass("error");
|
||||
$(classify[index]).addClass("error");
|
||||
result = false;
|
||||
} else {
|
||||
colorAndClassify.push(ele);
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
$("input[name='endDate']").datetimepicker({
|
||||
format: "yyyy-mm-dd",
|
||||
minView: "month",
|
||||
|
|
@ -107,7 +130,7 @@
|
|||
align: 'center',
|
||||
title: '数量',
|
||||
formatter: function(value, row, index) {
|
||||
var html = $.common.sprintf("<input class='form-control' type='text' name='busiMaterialRequireList[%s].amount' value='%s'>", index, value);
|
||||
var html = $.common.sprintf("<input class='form-control digits required' type='text' name='busiMaterialRequireList[%s].amount' value='%s'>", index, value);
|
||||
return html;
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -12,19 +12,20 @@
|
|||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label is-required">所属订单:</label>
|
||||
<div class="col-sm-8">
|
||||
<input name="orderId" th:field="*{orderId}" class="form-control" type="text" required>
|
||||
<input name="orderId" th:field="*{orderId}" class="form-control" type="hidden">
|
||||
<input name="orderId" th:field="*{orderName}" class="form-control" type="text" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">数量:</label>
|
||||
<div class="col-sm-8">
|
||||
<input name="amount" th:field="*{amount}" class="form-control" type="text">
|
||||
<input name="amount" th:field="*{amount}" class="form-control digits required" type="text">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label is-required">尺码:</label>
|
||||
<div class="col-sm-8">
|
||||
<select name="size" class="form-control m-b" th:with="type=${@dict.getType('busi_size')}" required>
|
||||
<select name="size" class="form-control m-b" disabled th:with="type=${@dict.getType('busi_size')}" required>
|
||||
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{size}"></option>
|
||||
</select>
|
||||
</div>
|
||||
|
|
@ -32,7 +33,7 @@
|
|||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label is-required">颜色:</label>
|
||||
<div class="col-sm-8">
|
||||
<select name="color" class="form-control m-b" th:with="type=${@dict.getType('busi_color')}" required>
|
||||
<select name="color" class="form-control m-b" disabled th:with="type=${@dict.getType('busi_color')}" required>
|
||||
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{color}"></option>
|
||||
</select>
|
||||
</div>
|
||||
|
|
@ -70,14 +71,38 @@
|
|||
});
|
||||
|
||||
function submitHandler() {
|
||||
if ($.validate.form()) {
|
||||
if (colorAndClassifyValidate() && $.validate.form()) {
|
||||
$.operate.save(prefix + "/edit", $('#form-productRequire-edit').serialize());
|
||||
}
|
||||
}
|
||||
|
||||
function colorAndClassifyValidate() {
|
||||
var colors = $("table select[name$='color']");
|
||||
var classify = $("table select[name$='classify']");
|
||||
colors.removeClass("error");
|
||||
classify.removeClass("error");
|
||||
var colorAndClassify = [];
|
||||
var result = true;
|
||||
classify.each(function (i, ele) {
|
||||
var ele = colors[i].value + classify[i].value;
|
||||
var index = colorAndClassify.indexOf(ele);
|
||||
if ( index >= 0) {
|
||||
$(colors[i]).addClass("error");
|
||||
$(classify[i]).addClass("error");
|
||||
$(colors[index]).addClass("error");
|
||||
$(classify[index]).addClass("error");
|
||||
result = false;
|
||||
} else {
|
||||
colorAndClassify.push(ele);
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
$("input[name='endDate']").datetimepicker({
|
||||
format: "yyyy-mm-dd",
|
||||
minView: "month",
|
||||
startDate: new Date(),
|
||||
autoclose: true
|
||||
});
|
||||
|
||||
|
|
@ -107,7 +132,7 @@
|
|||
align: 'center',
|
||||
title: '数量',
|
||||
formatter: function(value, row, index) {
|
||||
var html = $.common.sprintf("<input class='form-control' type='text' name='busiMaterialRequireList[%s].amount' value='%s'>", index, value);
|
||||
var html = $.common.sprintf("<input class='form-control digits required' type='text' name='busiMaterialRequireList[%s].amount' value='%s'>", index, value);
|
||||
return html;
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@
|
|||
visible: false
|
||||
},
|
||||
{
|
||||
field: 'orderId',
|
||||
field: 'orderName',
|
||||
title: '订单名称'
|
||||
},
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue