瀏覽代碼

Merge branch 'master' of http://git.iamberry.com/hexiugang/iamberry-common-parent

# Conflicts:
#	watero-rst-interface/src/main/java/com/iamberry/rst/faces/cm/SalesOrderService.java
liujiankang 5 年之前
父節點
當前提交
4269d3afe7

+ 18 - 0
watero-rst-core/src/main/java/com.iamberry.rst.core/order/StrategyColor.java

@@ -8,6 +8,8 @@ public class StrategyColor implements Serializable {
     private Integer strategyId;
     private Integer colorId;
     private String colorName;
+    private Integer productId;
+    private String productName;
 
     public Integer getStrategyColorId() {
         return strategyColorId;
@@ -40,4 +42,20 @@ public class StrategyColor implements Serializable {
     public void setColorName(String colorName) {
         this.colorName = colorName;
     }
+
+    public Integer getProductId() {
+        return productId;
+    }
+
+    public void setProductId(Integer productId) {
+        this.productId = productId;
+    }
+
+    public String getProductName() {
+        return productName;
+    }
+
+    public void setProductName(String productName) {
+        this.productName = productName;
+    }
 }

+ 2 - 2
watero-rst-interface/src/main/java/com/iamberry/rst/faces/order/DeliveryStrategyService.java

@@ -36,13 +36,13 @@ public interface DeliveryStrategyService {
      * @param  deliveryStrategy
      * @return Integer
      */
-    Integer  save(DeliveryStrategy deliveryStrategy);
+    Integer  save(DeliveryStrategy deliveryStrategy,String strategyColorArray);
     /**
      * 修改数据
      * @param  deliveryStrategy
      * @return Integer
      */
-    Integer  update(DeliveryStrategy deliveryStrategy);
+    Integer  update(DeliveryStrategy deliveryStrategy,String strategyColorArray);
     /**
      * 删除数据
      * @param  strategyId

+ 7 - 48
watero-rst-service/src/main/java/com/iamberry/rst/service/cm/SalesOrderServiceImpl.java

@@ -779,24 +779,6 @@ public class SalesOrderServiceImpl implements SalesOrderService {
             for(DeliveryStrategy strategy : trategyList){
                 if(salesOrder.getSalesCompanyId().equals(strategy.getStrategyCompanyId())){
 
-
-                    /*if(salesOrder.getSalesStoreId().equals(strategy.getStrategyStoreId()) || strategy.getStrategyStoreId() == 0){
-                        if(strategy.getStrategyProvinceNumber() == 0 || (salesOrder.getSalesAddressInfo().indexOf(strategy.getStrategyProvinceName()))!=-1){
-                            //判断产品
-                            for(SalesOrderItem salesOrderItem : salesOrder.getSalesOrderItemList()){
-                                if(strategy.getStrategyProductId() == 0){
-                                        salesOrder.setSalesPostFirm(strategy.getStrategyPostFirm());
-                                        return;
-                                }else if(salesOrderItem.getItemProductId().equals(strategy.getStrategyProductId())){
-                                    if(strategy.getStrategyColorId() == 0 || salesOrderItem.getItemColorId().equals(strategy.getStrategyColorId())){
-                                        salesOrder.setSalesPostFirm(strategy.getStrategyPostFirm());
-                                        return;
-                                    }
-                                }
-                            }
-                        }
-                    }*/
-
                     //判断店铺
                     boolean isMeet1 = false;
                     if(strategy.getStrategyStoreId() == 0){
@@ -808,38 +790,16 @@ public class SalesOrderServiceImpl implements SalesOrderService {
                             }
                         }
                     }
-                    //判断产品
-                    boolean isMeet2 = false;
-                    if(strategy.getStrategyProductId() == 0){
-                        isMeet2 = true;
-                    }else{
-                        for(SalesOrderItem salesOrderItem : salesOrder.getSalesOrderItemList()){
-                            boolean isProduct = false;
-                            for(StrategyProduct strategyProduct : strategy.getListStrategyProduct()){
-                                if(salesOrderItem.getItemProductId().equals(strategyProduct.getProductId())){
-                                    isProduct = true;
-                                    break;
-                                }
-                            }
-                            if(!isProduct){
-                                isMeet2 = false;
-                                break;
-                            }else{
-                                isMeet2 = true;
-                            }
-                        }
-                    }
-                    //判断颜色
+                    //判断产品、颜色
                     boolean isMeet3 = false;
-                    if(strategy.getStrategyProductId() == 0 || strategy.getStrategyColorId() == 0){
-                        isMeet3 = true;
-                    }else{
                         for(SalesOrderItem salesOrderItem : salesOrder.getSalesOrderItemList()){
                             boolean isProduct = false;
                             for(StrategyColor strategyColor : strategy.getListStrategyColor()){
-                                if(salesOrderItem.getItemColorId().equals(strategyColor.getColorId())){
-                                    isProduct = true;
-                                    break;
+                                if(strategyColor.getProductId() == 0 || strategyColor.getProductId().equals(salesOrderItem.getItemProductId())){
+                                    if(strategyColor.getColorId() == 0 ||salesOrderItem.getItemColorId().equals(strategyColor.getColorId())){
+                                        isProduct = true;
+                                        break;
+                                    }
                                 }
                             }
                             if(!isProduct){
@@ -849,8 +809,7 @@ public class SalesOrderServiceImpl implements SalesOrderService {
                                 isMeet3 = true;
                             }
                         }
-                    }
-                    if(isMeet1 && isMeet2 && isMeet3){
+                    if(isMeet1  && isMeet3){
                         salesOrder.setSalesPostFirm(strategy.getStrategyPostFirm());
                         return;
                     }

+ 5 - 2
watero-rst-service/src/main/java/com/iamberry/rst/service/cm/mapper/salesOrderMapper.xml

@@ -2510,12 +2510,15 @@
       insert INTO tb_rst_order_strategy_color
       (
         strategy_id,
-        color_id
+        color_id,
+        product_id
       )
       VALUES
       (
         #{strategyId},
-        #{colorId})
+        #{colorId},
+        #{productId}
+        )
     </insert>
     <!-- 添加快递策略店铺项 -->
     <insert id="addStrategyStore" parameterType="StrategyStore">

+ 26 - 33
watero-rst-service/src/main/java/com/iamberry/rst/service/order/DeliveryStrategyServiceImpl.java

@@ -1,6 +1,7 @@
 package com.iamberry.rst.service.order;
 
 import com.github.pagehelper.PageHelper;
+import com.iamberry.rst.core.cm.SalesOrderItem;
 import com.iamberry.rst.core.order.DeliveryStrategy;
 import com.iamberry.rst.core.order.StrategyColor;
 import com.iamberry.rst.core.order.StrategyProduct;
@@ -11,6 +12,7 @@ import com.iamberry.rst.faces.order.DeliveryStrategyService;
 import com.iamberry.rst.service.cm.mapper.SalesOrderMapper;
 import com.iamberry.rst.service.order.mapper.DeliveryStrategyMapper;
 import com.iamberry.rst.util.PageUtil;
+import net.sf.json.JSONArray;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -47,27 +49,26 @@ public class DeliveryStrategyServiceImpl implements DeliveryStrategyService {
     }
     @Transactional
     @Override
-    public Integer save(DeliveryStrategy deliveryStrategy) {
+    public Integer save(DeliveryStrategy deliveryStrategy,String strategyColorArray) {
         DeliveryStrategy ds2 = new DeliveryStrategy();
         ds2.setStrategyPriority(deliveryStrategy.getStrategyPriority());
         updatePriority(ds2);
+
+
+
+
         deliveryStrategyMapper.save(deliveryStrategy);
+
+        JSONArray jsonArray = JSONArray.fromObject(strategyColorArray);
+        List<StrategyColor> strategyColorList = (List) JSONArray.toCollection(jsonArray, StrategyColor.class);
         //添加策略项
-        if(deliveryStrategy.getStrategyProducts() != null){
-            for(String prductId : deliveryStrategy.getStrategyProducts()){
-                StrategyProduct strategyProduct = new StrategyProduct();
-                strategyProduct.setStrategyId(deliveryStrategy.getStrategyId());
-                strategyProduct.setProductId(Integer.valueOf(prductId));
-                salesOrderMapper.addStrategyProduct(strategyProduct);
-            }
-        }
-        if(deliveryStrategy.getStrategyColors() != null){
-            for(String colorId : deliveryStrategy.getStrategyColors()){
-                StrategyColor strategyColor = new StrategyColor();
-                strategyColor.setStrategyId(deliveryStrategy.getStrategyId());
-                strategyColor.setColorId(Integer.valueOf(colorId));
-                salesOrderMapper.addStrategyColor(strategyColor);
-            }
+
+        for(StrategyColor strategyColor : strategyColorList){
+                StrategyColor color = new StrategyColor();
+                color.setStrategyId(deliveryStrategy.getStrategyId());
+                color.setColorId(Integer.valueOf(strategyColor.getColorId()));
+                color.setProductId(Integer.valueOf(strategyColor.getProductId()));
+                salesOrderMapper.addStrategyColor(color);
         }
         if(deliveryStrategy.getStrategyStores() != null){
             for(String storeId : deliveryStrategy.getStrategyStores()){
@@ -81,7 +82,7 @@ public class DeliveryStrategyServiceImpl implements DeliveryStrategyService {
     }
     @Transactional
     @Override
-    public Integer update(DeliveryStrategy deliveryStrategy) {
+    public Integer update(DeliveryStrategy deliveryStrategy,String strategyColorArray) {
         if(deliveryStrategy.getStrategyPriority() != null){
             DeliveryStrategy ds2 = new DeliveryStrategy();
             ds2.setStrategyPriority(deliveryStrategy.getStrategyPriority());
@@ -90,24 +91,16 @@ public class DeliveryStrategyServiceImpl implements DeliveryStrategyService {
         }
         //删除策略项
         deliveryStrategyMapper.delStrategyStore(deliveryStrategy.getStrategyId());
-        deliveryStrategyMapper.delStrategyProduct(deliveryStrategy.getStrategyId());
         deliveryStrategyMapper.delStrategyColor(deliveryStrategy.getStrategyId());
         //添加策略项
-        if(deliveryStrategy.getStrategyProducts() != null){
-            for(String prductId : deliveryStrategy.getStrategyProducts()){
-                StrategyProduct strategyProduct = new StrategyProduct();
-                strategyProduct.setStrategyId(deliveryStrategy.getStrategyId());
-                strategyProduct.setProductId(Integer.valueOf(prductId));
-                salesOrderMapper.addStrategyProduct(strategyProduct);
-            }
-        }
-        if(deliveryStrategy.getStrategyColors() != null){
-            for(String colorId : deliveryStrategy.getStrategyColors()){
-                StrategyColor strategyColor = new StrategyColor();
-                strategyColor.setStrategyId(deliveryStrategy.getStrategyId());
-                strategyColor.setColorId(Integer.valueOf(colorId));
-                salesOrderMapper.addStrategyColor(strategyColor);
-            }
+        JSONArray jsonArray = JSONArray.fromObject(strategyColorArray);
+        List<StrategyColor> strategyColorList = (List) JSONArray.toCollection(jsonArray, StrategyColor.class);
+        for(StrategyColor strategyColor : strategyColorList){
+            StrategyColor color = new StrategyColor();
+            color.setStrategyId(deliveryStrategy.getStrategyId());
+            color.setColorId(Integer.valueOf(strategyColor.getColorId()));
+            color.setProductId(Integer.valueOf(strategyColor.getProductId()));
+            salesOrderMapper.addStrategyColor(color);
         }
         if(deliveryStrategy.getStrategyStores() != null){
             for(String storeId : deliveryStrategy.getStrategyStores()){

+ 3 - 1
watero-rst-service/src/main/java/com/iamberry/rst/service/order/mapper/deliveryStrategyMapper.xml

@@ -194,9 +194,11 @@
     <select id="selectStrategyColor" parameterType="Integer" resultType="StrategyColor">
         SELECT
         sc.*,
-        pc.color_name AS colorName
+        pc.color_name AS colorName,
+        pi.product_name AS productName
         FROM tb_rst_order_strategy_color sc
         LEFT JOIN tb_rst_product_color pc on sc.color_id = pc.color_id
+        LEFT JOIN tb_rst_product_info pi on sc.product_id = pi.product_id
         where
         strategy_id = #{strategyId}
     </select>

+ 12 - 23
watero-rst-web/src/main/java/com/iamberry/rst/controllers/order/DeliveryStrategyController.java

@@ -18,6 +18,8 @@ import com.iamberry.rst.faces.order.LogisticsInfoService;
 import com.iamberry.rst.faces.product.ProductService;
 import com.iamberry.rst.utils.StitchAttrUtil;
 import com.iamberry.wechat.tools.ResponseJson;
+import net.sf.json.JSONArray;
+import net.sf.json.JSONObject;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -125,22 +127,23 @@ public class DeliveryStrategyController {
      */
     @ResponseBody
     @RequestMapping(value = "/addDeliveryStrategy")
-    public ResponseJson addDeliveryStrategy(HttpServletRequest request, DeliveryStrategy deliveryStrategy) throws Exception {
+    public ResponseJson addDeliveryStrategy(HttpServletRequest request, DeliveryStrategy deliveryStrategy,String strategyColorArray) throws Exception {
         ResponseJson msg = new ResponseJson();
         if(deliveryStrategy == null ){
             msg.setResultCode(500);
             msg.setReturnCode(500);
             return msg;
         }
+        JSONArray jsonArray = JSONArray.fromObject(strategyColorArray);
+        JSONObject jsonArray2  = jsonArray.getJSONObject(0);
+
         String[] storeId1 = request.getParameterValues("storeId1");
-        String[] productId1 = request.getParameterValues("productId1");
-        String[] productColorId1 = request.getParameterValues("productColorId1");
         if(storeId1 != null && storeId1.length > 0){
             deliveryStrategy.setStrategyStoreId(1);
             deliveryStrategy.setStrategyStores(storeId1);
         }else{
             deliveryStrategy.setStrategyStoreId(0);
-        }
+        }/*
         if(productId1 != null && productId1.length > 0){
             deliveryStrategy.setStrategyProductId(1);
             deliveryStrategy.setStrategyProducts(productId1);
@@ -153,10 +156,10 @@ public class DeliveryStrategyController {
         }else{
             deliveryStrategy.setStrategyProductId(0);
             deliveryStrategy.setStrategyColorId(0);
-        }
+        }*/
 
         deliveryStrategy.setStrategyStatus(1);
-        if(deliveryStrategyService.save(deliveryStrategy) > 0){
+        if(deliveryStrategyService.save(deliveryStrategy,strategyColorArray) > 0){
             msg.setResultCode(200);
             msg.setReturnCode(200);
         }else{
@@ -212,7 +215,7 @@ public class DeliveryStrategyController {
      */
     @ResponseBody
     @RequestMapping(value = "/updateDeliveryStrategy")
-    public ResponseJson updateDeliveryStrategy(HttpServletRequest request, DeliveryStrategy deliveryStrategy) throws Exception {
+    public ResponseJson updateDeliveryStrategy(HttpServletRequest request, DeliveryStrategy deliveryStrategy,String strategyColorArray) throws Exception {
         ResponseJson msg = new ResponseJson();
         if(deliveryStrategy == null ){
             msg.setResultCode(500);
@@ -220,28 +223,14 @@ public class DeliveryStrategyController {
             return msg;
         }
         String[] storeId1 = request.getParameterValues("storeId1");
-        String[] productId1 = request.getParameterValues("productId1");
-        String[] productColorId1 = request.getParameterValues("productColorId1");
         if(storeId1 != null && storeId1.length > 0){
             deliveryStrategy.setStrategyStoreId(1);
             deliveryStrategy.setStrategyStores(storeId1);
         }else{
             deliveryStrategy.setStrategyStoreId(0);
         }
-        if(productId1 != null && productId1.length > 0){
-            deliveryStrategy.setStrategyProductId(1);
-            deliveryStrategy.setStrategyProducts(productId1);
-            if(productColorId1 != null && productColorId1.length > 0){
-                deliveryStrategy.setStrategyColorId(1);
-                deliveryStrategy.setStrategyColors(productColorId1);
-            }else{
-                deliveryStrategy.setStrategyColorId(0);
-            }
-        }else{
-            deliveryStrategy.setStrategyProductId(0);
-            deliveryStrategy.setStrategyColorId(0);
-        }
-        if(deliveryStrategyService.update(deliveryStrategy) > 0){
+
+        if(deliveryStrategyService.update(deliveryStrategy,strategyColorArray) > 0){
             msg.setResultCode(200);
             msg.setReturnCode(200);
         }else{

+ 4 - 5
watero-rst-web/src/main/webapp/WEB-INF/views/order/downsingle/downsingleRule_list.ftl

@@ -33,8 +33,8 @@
 				<tr class="text-c">
                     <th width="100">优先级</th>
 					<th width="100">状态</th>
-					<th width="100">备注</th>
 					<th width="100">产品</th>
+                    <th width="100">备注</th>
 					<th width="100">创建时间</th>
 					<th width="100">操作</th>
 				</tr>
@@ -53,16 +53,15 @@
                                 </#if>
                             </td>
 							<td class="text-c" width="100">
-                                ${list.downsingleDesc!''}
-                            </td>
-
-							<td class="text-c" width="100">
                             <#if list.downsingleRuleItemList?? &&  (list.downsingleRuleItemList?size > 0) >
                                 <#list list.downsingleRuleItemList as Item>
                                     ${Item.productName!''}-${Item.colorName!''}*${Item.downsingleItemNum!''}
                                 </#list>
                             </#if>
                             </td>
+                            <td class="text-c" width="100">
+                                ${list.downsingleDesc!''}
+                            </td>
 							<td class="text-c" width="100">${list.downsingleCreateTime?string("yyyy-MM-dd HH:mm:ss")}</td>
 							<!-- 遍历操作 -->
 							<td class="td-manage text-c">

+ 2 - 2
watero-rst-web/src/main/webapp/WEB-INF/views/order/salesOrder/list_wait_send_order.ftl

@@ -538,7 +538,7 @@
                             $("#subOrderUl").append('<tr class="text-c order_tr">' +
                                     '<td><input type="checkbox" class="main_index" value="0" ></td>' +
                                     '<td>'+LogisticCode+'</td>' +
-                                    '<td>'+product+'</td>' +
+                                    '<td><span class="label label-success radius">'+product+'</span></td>' +
                                     '<td>'+salesOrder.salesAddressName +"/"+salesOrder.salesAddressTel+'</td>' +
                                     '</tr>');
                             product = "";
@@ -558,7 +558,7 @@
                                 $("#subOrderUl").append('<tr class="text-c order_tr">' +
                                         '<td><input type="checkbox" class="sub_index" value="'+index+'" ></td>' +
                                         '<td>'+item+'</td>' +
-                                        '<td>'+product+'</td>' +
+                                        '<td><span class="label label-success radius">'+product+'</span></td>' +
                                         '<td>'+salesOrder.salesAddressName +"/"+salesOrder.salesAddressTel+'</td>' +
                                         '</tr>');
                                 product = "";

File diff suppressed because it is too large
+ 1 - 1
watero-rst-web/src/main/webapp/WEB-INF/views/order/salesOrder/sales_order_list.ftl


+ 149 - 50
watero-rst-web/src/main/webapp/WEB-INF/views/order/strategy/add_deliveryStrategy.ftl

@@ -42,7 +42,7 @@
         .b-close{position: relative; display: inline-block;margin: 2px 0; padding:4px 1em 4px 4px; width: 150px;background: #f0f0f0;border: 1px solid rgba(0,0,0,.1);border-radius: 5px;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;cursor: pointer;}
         .my-close{position:absolute;right: 0.5em;top: 0.45em;width:0.15em;height:1em;background: #333;-webkit-transform: rotate(45deg);transform: rotate(45deg);display: inline-block;}
         .my-close:after{content: "";position: absolute;top: 0;left: 0;width:0.15em;height:1em;background: #333;-webkit-transform: rotate(270deg);transform: rotate(270deg);}
-
+        .my-btn-submit2{width: 88px;height: 30px; background-color: #50a2ea;color: #fff;border: 1px solid #50a2ea;cursor:pointer;margin: 10px 10px 0 10px;}
     </style>
     <meta name="keywords" content="${path}">
     <meta name="description" content="H-ui.admin v3.0,是一款由国人开发的轻量级扁平化网站后台模板,完全免费开源的网站后台管理系统模版,适合中小型CMS后台系统。">
@@ -109,6 +109,50 @@
             </div>
         </div>
         <div class="row cl">
+            <label class="form-label col-3 col-sm-3 huanhang" style="text-align: right;margin-top: 14px;"></label>
+            <div class="formControls col-3 col-sm-3 huanhang" >
+                <table class="table table-border table-bg table-bordered" style="margin-top: 10px;" id="all_product">
+                    <thead>
+                    <tr class="text-c">
+                        <th style="text-align: center;" width="10">产品</th>
+                        <th style="text-align: center;" width="10">颜色</th>
+                        <th style="text-align: center;" width="10">操作</th>
+                    </tr>
+                    </thead>
+                    <tbody id="add_product">
+                     <tr id="trid"><td colspan="3" class="td-manage text-c" >暂时没有产品信息,请添加!</td></tr>
+                    </tbody>
+                </table>
+                <button type="button" class="my-btn-submit2" onclick="isShow();" style="margin-top: 20px;">添加产品</button>
+            </div>
+        </div>
+        <div class="row cl" id="productDiv" style="display: none;">
+            <label class="form-label col-3 col-sm-3 huanhang" style="text-align: right;margin-top: 14px;"></label>
+            <div class="formControls col-9 col-sm-9 huanhang" style="margin: 10px 0px 10px 0;">
+                <div style="line-height: 30px;width: 400px;line-break: auto;background-color: #E6E6E6;padding-left: 10px;padding-bottom: 10px;">
+                    <span style="margin-bottom: 15px;">产品:</span><br>
+                    <select id="productId"  class="chosen2" class="my-select" style="width: 195px;">
+                        <option value="0">所有产品</option>
+                        <#if (productList?size > 0)>
+                            <#list productList as product>
+                                    <option value="${product.productId!""}" >${product.productName!""}</option>
+                            </#list>
+                        </#if>
+                    </select><br>
+                    颜色:<br>
+                    <select id="productColorId"  class="chosen2" class="my-select" style="width: 195px">
+                        <option value="0">所有颜色</option>
+                        <#if (productColorList?size > 0)>
+                            <#list productColorList as productColor>
+                                <option value="${productColor.colorId!""}" >${productColor.colorName!""}</option>
+                            </#list>
+                        </#if>
+                    </select><br>
+                    <button type="button" class="my-btn-submit2" onclick="addPorduct();" style="margin-top: 20px;">确认添加</button>
+                </div>
+            </div>
+        </div>
+        <#--<div class="row cl">
             <label class="form-label col-3 col-sm-3 huanhang" style="text-align: right;margin-top: 14px;"><span class="c-red">*</span>产品:</label>
             <div class="formControls col-9 col-sm-9 huanhang" style="margin: 10px 0px 10px 0;">
                 <select id="productId" name="strategyProductId" class="chosen" class="my-select" style="width: 195px">
@@ -155,7 +199,7 @@
                 </div>
 
             </div>
-        </div>
+        </div>-->
         <div class="row cl">
             <label class="form-label col-3 col-sm-3 huanhang" style="text-align: right;margin-top: 14px;"><span class="c-red">*</span>快递公司:</label>
             <div class="formControls col-9 col-sm-9 huanhang" style="margin: 10px 0px 10px 0;">
@@ -177,6 +221,7 @@
         <div class="row cl">
             <label class="form-label col-3 col-sm-3 huanhang" style="text-align: right;margin-top: 14px;"></label>
             <div class="formControls col-9 col-sm-9 huanhang" style="margin: 10px 0px 10px 0;padding-left: 0;">
+                <input type="hidden" id="strategyColorArray" name="strategyColorArray" value="">
                 <button type="button" class="my-btn-submit" onclick="addDeliveryStrategy();" style="margin-top: 20px;">确认新建</button>
             </div>
         </div>
@@ -184,6 +229,52 @@
 </article>
 <script type="text/javascript" src="${path}/common/lib/My97DatePicker/4.8/WdatePicker.js"></script>
 <script type="text/javascript">
+    function isShow() {
+        $("#productDiv").show();
+    }
+    function addPorduct() {
+        $("#trid").remove();
+
+        var productId = $("#productId").val();
+        var productColorId = $("#productColorId").val();
+        var productIdName = $("#productId").find("option:selected").text();
+        var productColorIdName = $("#productColorId").find("option:selected").text();
+        if(productId === "0"){
+            productColorId = 0;
+            productColorIdName = "所有颜色";
+        }
+        var isProduct = true;
+        $("#add_product").find("tr").each(function(){
+            var productIdc = $(this).find(".productId").val();
+            var productColorId = $(this).find(".productColorId").val();
+            if(productIdc === "0"){
+                /*layer.msg("已选择所有产品,请先删除!", {icon: 5, time: 2000});*/
+                $("#add_product").html("");
+            }
+            if(productColorId === "0" && productId == productIdc && productId != "0"){
+                layer.msg("已选择该产品所有颜色,请先删除!", {icon: 5, time: 2000});
+                isProduct = false;
+            }
+        });
+        if(!isProduct){
+            return;
+        }
+        var html = '<tr class="text-c">' +
+                ' <input type="hidden" class="productId" value="'+ productId +'">' +
+                ' <input type="hidden" class="productColorId" value="'+ productColorId +'">' +
+                ' <td>'+ productIdName +'</td>' +
+                ' <td>'+ productColorIdName +'</td>' +
+                ' <td><a onclick="updateProduct(this);">编辑</a>&nbsp;&nbsp;&nbsp;<a onclick="delEmployee(this);">删除</a></td>' +
+                ' </tr>';
+        if(productId === "0"){
+            $("#add_product").html(html);
+        }else{
+            $("#add_product").append(html);
+        }
+
+    }
+
+
     $('#storeId').change(function() {
         var name = $("#storeId option:selected").text();
         var id = $('#storeId').val();
@@ -204,66 +295,36 @@
         }
 
     });
-    $('#productId').change(function() {
-        var name = $("#productId option:selected").text();
-        var id = $('#productId').val();
-        var bl = true;
-        if(id != "" && id != 0) {
-            $("input[name='strategyProductId']").each(function (j, item) {
-                var s = $(item).val();
-                if (s === id) {
-                    bl = false;
-                }
-            });
-            if (bl) {
-                $("#configui2").append('<li class="b-close" id="productId1">' +
-                        ' <input type="hidden" value="' + id + '" name="productId1">' + name +
-                        '<span class="my-close" onclick="deleteli(this)"></span>' +
-                        '</li>');
-            }
-        }
-
-    });
-    $('#productColorId').change(function() {
-        var name = $("#productColorId option:selected").text();
-        var id = $('#productColorId').val();
-        var bl = true;
-        if(id != "" && id != 0) {
-            $("input[name='strategyColorId']").each(function (j, item) {
-                var s = $(item).val();
-                if (s === id) {
-                    bl = false;
-                }
-            });
-            if (bl) {
-                $("#configui3").append('<li class="b-close" id="productColorId1">' +
-                        ' <input type="hidden" value="' + id + '" name="productColorId1">' + name +
-                        '<span class="my-close" onclick="deleteli(this)"></span>' +
-                        '</li>');
-            }
-        }
 
-    });
     function deleteli(obj) {
         $(obj).parent().remove();
     }
-    /**
-     * 打开员工列表
-     */
-    function add_employee() {
-        layer_show("员工列表","${path}/admin/employee/employee_list?pageSize=1000","800","500");
-    }
 
 
     /**
-     *  删除员工
+     *  删除
      */
     function delEmployee($this){
-        $this.parents("tr").remove();
+        $($this).parent().parent().remove();
+        if($("table#all_product tr:visible").length == 1){
+            $("#add_product").html("<tr id=\"trid\"><td colspan=\"3\" class=\"td-manage text-c\" >暂时没有产品信息,请添加!</td></tr>");
+        }
+    }
+    /**
+     *  编辑
+     */
+    function updateProduct($this){
+        var productId = $($this).parent().parent().find(".productId").val();
+        var productColorId = $($this).parent().parent().find(".productColorId").val();
+        $("#productId").val(productId);
+        getProduct(productId);
+        $("#productColorId").val(productColorId);
+        $("#productId").trigger("chosen:updated");//初始化
+        $("#productColorId").trigger("chosen:updated");//初始化
     }
 
     /**
-     * 添加回访信息
+     * 添加
      */
     function addDeliveryStrategy() {
         var companyId = $("#companyId").val();
@@ -286,6 +347,23 @@
             layer.msg("优先级不能为空!", {icon: 5, time: 2000});
             return;
         }
+
+        //选择产品
+        var flag = false;
+        /*封装产品项*/
+        var strategyColorArray = new Array();
+        $("#add_product").find("tr").each(function(){
+            var strategyColor = new Object();
+            strategyColor.colorId = $(this).find(".productColorId").val();
+            strategyColor.productId = $(this).find(".productId").val();
+            strategyColorArray.push(strategyColor);
+            flag = true;
+        })
+        if(!flag){
+            layer.msg("必须要有一个产品!", {icon: 5, time: 5000});
+            return false;
+        }
+        $("#strategyColorArray").val(JSON.stringify(strategyColorArray));
             $.ajax({
                 cache: true,
                 type: "POST",
@@ -341,6 +419,11 @@
         getProduct($(this).children('option:selected').val())
     })
     function  getProduct(productId) {
+        if(productId === "0"){
+            $("#productColorId").html("<option value='0'>所有颜色</option>");
+            $("#productColorId").trigger("chosen:updated");//初始化
+            return;
+        }
         $.ajax({
             cache: true,
             type: "POST",
@@ -383,6 +466,22 @@
         group_search: false, //选项组是否可搜。此处搜索不可搜
         include_group_label_in_selected: true //选中选项是否显示选项分组。false不显示,true显示。默认false。
     });
+    $('.chosen2').chosen({
+        no_results_text: "没有找到结果!",//搜索无结果时显示的提示
+        search_contains:true,   //关键字模糊搜索。设置为true,只要选项包含搜索词就会显示;设置为false,则要求从选项开头开始匹配
+        allow_single_deselect:true, //单选下拉框是否允许取消选择。如果允许,选中选项会有一个x号可以删除选项
+        disable_search: false, //禁用搜索。设置为true,则无法搜索选项。
+        disable_search_threshold: 0, //当选项少等于于指定个数时禁用搜索。
+        inherit_select_classes: true, //是否继承原下拉框的样式类,此处设为继承
+        placeholder_text_single: '选择国家', //单选选择框的默认提示信息,当选项为空时会显示。如果原下拉框设置了data-placeholder,会覆盖这里的值。
+        width: '255px', //设置chosen下拉框的宽度。即使原下拉框本身设置了宽度,也会被width覆盖。
+        max_shown_results: 1000, //下拉框最大显示选项数量
+        display_disabled_options: false,
+        single_backstroke_delete: false, //false表示按两次删除键才能删除选项,true表示按一次删除键即可删除
+        case_sensitive_search: false, //搜索大小写敏感。此处设为不敏感
+        group_search: false, //选项组是否可搜。此处搜索不可搜
+        include_group_label_in_selected: true //选中选项是否显示选项分组。false不显示,true显示。默认false。
+    });
 </script>
 </body>
 </html>

+ 7 - 9
watero-rst-web/src/main/webapp/WEB-INF/views/order/strategy/deliveryStrategy_List.ftl

@@ -34,8 +34,7 @@
                     <th width="100">公司</th>
 					<th width="100">店铺</th>
 					<th width="100">地区</th>
-					<th width="100">产品</th>
-					<th width="100">颜色</th>
+					<th width="100">产品/颜色</th>
 					<th width="100">优先级</th>
 					<th width="100">快递</th>
 					<th width="100">操作</th>
@@ -63,7 +62,7 @@
                             <#else>
                                 ${list.strategyProvinceName!''}
                             </#if>
-                            </td>
+                            </td><#--
 							<td class="text-c" width="100">
                                 <#if list.strategyProductId == 0>
                                     所有产品
@@ -74,17 +73,16 @@
                                         </#list>
                                     </#if>
                                 </#if>
-                            </td>
+                            </td>-->
 							<td class="text-c" width="100">
-                                <#if list.strategyColorId == 0>
-                                    所有颜色
-                                <#else>
                                     <#if list.listStrategyColor?? &&  (list.listStrategyColor?size > 0) >
                                         <#list list.listStrategyColor as listColor>
-                                            ${listColor.colorName}<br>
+                                            <#if listColor.productId == 0>所有产品 <#else >${listColor.productName!''}</#if>
+                                            -
+                                            <#if listColor.colorId == 0>所有颜色<#else >${listColor.colorName!''}</#if>
+                                            <br>
                                         </#list>
                                     </#if>
-                                </#if>
                             </td>
 
 							<td class="text-c" width="100">${list.strategyPriority!''}</td>

+ 148 - 92
watero-rst-web/src/main/webapp/WEB-INF/views/order/strategy/update_deliveryStrategy.ftl

@@ -42,7 +42,7 @@
         .b-close{position: relative; display: inline-block;margin: 2px 0; padding:4px 1em 4px 4px; width: 150px;background: #f0f0f0;border: 1px solid rgba(0,0,0,.1);border-radius: 5px;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;cursor: pointer;}
         .my-close{position:absolute;right: 0.5em;top: 0.45em;width:0.15em;height:1em;background: #333;-webkit-transform: rotate(45deg);transform: rotate(45deg);display: inline-block;}
         .my-close:after{content: "";position: absolute;top: 0;left: 0;width:0.15em;height:1em;background: #333;-webkit-transform: rotate(270deg);transform: rotate(270deg);}
-
+        .my-btn-submit2{width: 88px;height: 30px; background-color: #50a2ea;color: #fff;border: 1px solid #50a2ea;cursor:pointer;margin: 10px 10px 0 10px;}
     </style>
     <meta name="keywords" content="${path}">
     <meta name="description" content="H-ui.admin v3.0,是一款由国人开发的轻量级扁平化网站后台模板,完全免费开源的网站后台管理系统模版,适合中小型CMS后台系统。">
@@ -116,66 +116,59 @@
                 </select>
             </div>
         </div>
-        <div class="row cl">
-            <label class="form-label col-3 col-sm-3 huanhang" style="text-align: right;margin-top: 14px;"><span class="c-red">*</span>产品:</label>
-            <div class="formControls col-9 col-sm-9 huanhang" style="margin: 10px 0px 10px 0;">
-                <select id="productId" name="strategyProductId" class="chosen" style="width: 195px">
-                    <option value="0" <#if deliveryStrategy.strategyProductId == 0>selected</#if>>所有产品</option>
-                    <#if (productList?size > 0)>
-                            <#list productList as product>
-                                <option value="${product.productId!""}">${product.productName!""}</option>
-                            </#list>
-                    </#if>
-                </select>
-            </div>
-        </div>
-        <div class="input-box" style="margin-top: -20px;">
-            <label class="form-label col-3 col-sm-3 huanhang" style="text-align: right;"></label>
-            <div class="formControls col-9 col-sm-9 huanhang" id="config2">
-                <div class="row">
-                    <ul class="close-box" id="configui2">
-                        <#if deliveryStrategy.listStrategyProduct?? &&  (deliveryStrategy.listStrategyProduct?size > 0) >
-                            <#list deliveryStrategy.listStrategyProduct as list>
-                                 <li class="b-close" id="productId1">
-                                     <input type="hidden" value="${list.productId}" name="productId1">${list.productName}
-                                     <span class="my-close" onclick="deleteli(this)"></span>
-                                 </li>
-                            </#list>
-                        </#if>
-                    </ul>
-                </div>
 
-            </div>
-        </div>
         <div class="row cl">
-            <label class="form-label col-3 col-sm-3 huanhang" style="text-align: right;margin-top: 14px;"><span class="c-red">*</span>产品:</label>
-            <div class="formControls col-9 col-sm-9 huanhang" style="margin: 10px 0px 10px 0;">
-                <select id="productColorId" name="strategyColorId" class="chosen" style="width: 195px">
-                    <option value="0" <#if deliveryStrategy.strategyColorId == 0>selected</#if>>所有颜色</option>
-                    <#if (productColorList?size > 0)>
-                        <#list productColorList as productColor>
-                            <option value="${productColor.colorId!""}">${productColor.colorName!""}</option>
+            <label class="form-label col-3 col-sm-3 huanhang" style="text-align: right;margin-top: 14px;"></label>
+            <div class="formControls col-3 col-sm-3 huanhang" >
+                <table class="table table-border table-bg table-bordered" style="margin-top: 10px;" id="all_product">
+                    <thead>
+                    <tr class="text-c">
+                        <th style="text-align: center;" width="10">产品</th>
+                        <th style="text-align: center;" width="10">颜色</th>
+                        <th style="text-align: center;" width="10">操作</th>
+                    </tr>
+                    </thead>
+                    <tbody id="add_product">
+                    <#if deliveryStrategy.listStrategyColor?? &&  (deliveryStrategy.listStrategyColor?size > 0) >
+                        <#list deliveryStrategy.listStrategyColor as list>
+                        <tr class="text-c">
+                            <input type="hidden" class="productId" value="${list.productId!''}">
+                            <input type="hidden" class="productColorId" value="${list.colorId!''}">
+                            <td>${list.productName!''}</td>
+                            <td>${list.colorName!''}</td>
+                            <td><a onclick="updateProduct(this);">编辑</a>&nbsp;&nbsp;&nbsp;<a onclick="delEmployee(this);">删除</a></td>
+                        </tr>
                         </#list>
                     </#if>
-                </select>
+                    </tbody>
+                </table>
+                <button type="button" class="my-btn-submit2" onclick="isShow();" style="margin-top: 20px;">添加产品</button>
             </div>
         </div>
-        <div class="input-box" style="margin-top: -20px;">
-            <label class="form-label col-3 col-sm-3 huanhang" style="text-align: right;"></label>
-            <div class="formControls col-9 col-sm-9 huanhang" id="config3">
-                <div class="row">
-                    <ul class="close-box" id="configui3">
-                        <#if deliveryStrategy.listStrategyColor?? &&  (deliveryStrategy.listStrategyColor?size > 0) >
-                            <#list deliveryStrategy.listStrategyColor as list>
-                                 <li class="b-close" id="productColorId1">
-                                     <input type="hidden" value="${list.colorId}" name="productColorId1">${list.colorName}
-                                     <span class="my-close" onclick="deleteli(this)"></span>
-                                 </li>
+        <div class="row cl" id="productDiv" style="display: none;">
+            <label class="form-label col-3 col-sm-3 huanhang" style="text-align: right;margin-top: 14px;"></label>
+            <div class="formControls col-9 col-sm-9 huanhang" style="margin: 10px 0px 10px 0;">
+                <div style="line-height: 30px;width: 400px;line-break: auto;background-color: #E6E6E6;padding-left: 10px;padding-bottom: 10px;">
+                    <span style="margin-bottom: 15px;">产品:</span><br>
+                    <select id="productId"  class="chosen2" class="my-select" style="width: 195px;">
+                        <option value="0">所有产品</option>
+                        <#if (productList?size > 0)>
+                            <#list productList as product>
+                                    <option value="${product.productId!""}" >${product.productName!""}</option>
                             </#list>
                         </#if>
-                    </ul>
+                    </select><br>
+                    颜色:<br>
+                    <select id="productColorId"  class="chosen2" class="my-select" style="width: 195px">
+                        <option value="0">所有颜色</option>
+                        <#if (productColorList?size > 0)>
+                            <#list productColorList as productColor>
+                                <option value="${productColor.colorId!""}" >${productColor.colorName!""}</option>
+                            </#list>
+                        </#if>
+                    </select><br>
+                    <button type="button" class="my-btn-submit2" onclick="addPorduct();" style="margin-top: 20px;">确认添加</button>
                 </div>
-
             </div>
         </div>
         <div class="row cl">
@@ -200,6 +193,7 @@
             <label class="form-label col-3 col-sm-3 huanhang" style="text-align: right;margin-top: 14px;"></label>
             <div class="formControls col-9 col-sm-9 huanhang" style="margin: 10px 0px 10px 0;">
                 <input type="hidden" name="strategyId" value="${deliveryStrategy.strategyId!""}">
+                <input type="hidden" id="strategyColorArray" name="strategyColorArray" value="">
                 <button type="button" class="my-btn-submit" onclick="addDeliveryStrategy();" style="margin-top: 20px;">确认修改</button>
             </div>
         </div>
@@ -207,6 +201,49 @@
 </article>
 <script type="text/javascript" src="${path}/common/lib/My97DatePicker/4.8/WdatePicker.js"></script>
 <script type="text/javascript">
+    function isShow() {
+        $("#productDiv").show();
+    }
+    function addPorduct() {
+        $("#trid").remove();
+        var productId = $("#productId").val();
+        var productColorId = $("#productColorId").val();
+        var productIdName = $("#productId").find("option:selected").text();
+        var productColorIdName = $("#productColorId").find("option:selected").text();
+        if(productId === "0"){
+            productColorId = 0;
+            productColorIdName = "所有颜色";
+        }
+        var isProduct = true;
+        $("#add_product").find("tr").each(function(){
+            var productIdc = $(this).find(".productId").val();
+            var productColorId = $(this).find(".productColorId").val();
+            if(productIdc === "0"){
+                /*layer.msg("已选择所有产品,请先删除!", {icon: 5, time: 2000});*/
+                $("#add_product").html("");
+            }
+            if(productColorId === "0" && productId == productIdc && productId != "0"){
+                layer.msg("已选择该产品所有颜色,请先删除!", {icon: 5, time: 2000});
+                isProduct = false;
+            }
+        });
+        if(!isProduct){
+            return;
+        }
+        var html = '<tr class="text-c">' +
+                ' <input type="hidden" class="productId" value="'+ productId +'">' +
+                ' <input type="hidden" class="productColorId" value="'+ productColorId +'">' +
+                ' <td>'+ productIdName +'</td>' +
+                ' <td>'+ productColorIdName +'</td>' +
+                ' <td><a onclick="updateProduct(this);">编辑</a>&nbsp;&nbsp;&nbsp;<a onclick="delEmployee(this);">删除</a></td>' +
+                ' </tr>';
+        if(productId === "0"){
+            $("#add_product").html(html);
+        }else{
+            $("#add_product").append(html);
+        }
+
+    }
     $('#storeId').change(function() {
         var name = $("#storeId option:selected").text();
         var id = $('#storeId').val();
@@ -227,51 +264,33 @@
         }
 
     });
-    $('#productId').change(function() {
-        var name = $("#productId option:selected").text();
-        var id = $('#productId').val();
-        var bl = true;
-        if(id != "" && id != 0) {
-            $("input[name='strategyProductId']").each(function (j, item) {
-                var s = $(item).val();
-                if (s === id) {
-                    bl = false;
-                }
-            });
-            if (bl) {
-                $("#configui2").append('<li class="b-close" id="productId1">' +
-                        ' <input type="hidden" value="' + id + '" name="productId1">' + name +
-                        '<span class="my-close" onclick="deleteli(this)"></span>' +
-                        '</li>');
-            }
-        }
-
-    });
-    $('#productColorId').change(function() {
-        var name = $("#productColorId option:selected").text();
-        var id = $('#productColorId').val();
-        var bl = true;
-        if(id != "" && id != 0) {
-            $("input[name='strategyColorId']").each(function (j, item) {
-                var s = $(item).val();
-                if (s === id) {
-                    bl = false;
-                }
-            });
-            if (bl) {
-                $("#configui3").append('<li class="b-close" id="productColorId1">' +
-                        ' <input type="hidden" value="' + id + '" name="productColorId1">' + name +
-                        '<span class="my-close" onclick="deleteli(this)"></span>' +
-                        '</li>');
-            }
-        }
 
-    });
     function deleteli(obj) {
         $(obj).parent().remove();
     }
 
-
+    /**
+     *  删除
+     */
+    function delEmployee($this){
+        $($this).parent().parent().remove();
+        if($("table#all_product tr:visible").length == 1){
+            $("#add_product").html("<tr id=\"trid\"><td colspan=\"3\" class=\"td-manage text-c\" >暂时没有产品信息,请添加!</td></tr>");
+        }
+    }
+    /**
+     *  编辑
+     */
+    function updateProduct($this){
+        $("#productDiv").show();
+        var productId = $($this).parent().parent().find(".productId").val();
+        var productColorId = $($this).parent().parent().find(".productColorId").val();
+        $("#productId").val(productId);
+        getProduct(productId);
+        $("#productColorId").val(productColorId);
+        $("#productId").trigger("chosen:updated");//初始化
+        $("#productColorId").trigger("chosen:updated");//初始化
+    }
 
     /**
      * 修改
@@ -297,6 +316,22 @@
             layer.msg("优先级不能为空!", {icon: 5, time: 2000});
             return;
         }
+        //选择产品
+        var flag = false;
+        /*封装产品项*/
+        var strategyColorArray = new Array();
+        $("#add_product").find("tr").each(function(){
+            var strategyColor = new Object();
+            strategyColor.colorId = $(this).find(".productColorId").val();
+            strategyColor.productId = $(this).find(".productId").val();
+            strategyColorArray.push(strategyColor);
+            flag = true;
+        })
+        if(!flag){
+            layer.msg("必须要有一个产品!", {icon: 5, time: 5000});
+            return false;
+        }
+        $("#strategyColorArray").val(JSON.stringify(strategyColorArray));
             $.ajax({
                 cache: true,
                 type: "POST",
@@ -350,6 +385,11 @@
         getProduct($(this).children('option:selected').val());
     })
     function  getProduct(productId) {
+        if(productId === "0"){
+            $("#productColorId").html("<option value='0'>所有颜色</option>");
+            $("#productColorId").trigger("chosen:updated");//初始化
+            return;
+        }
         $.ajax({
             cache: true,
             type: "POST",
@@ -392,6 +432,22 @@
         group_search: false, //选项组是否可搜。此处搜索不可搜
         include_group_label_in_selected: true //选中选项是否显示选项分组。false不显示,true显示。默认false。
     });
+    $('.chosen2').chosen({
+        no_results_text: "没有找到结果!",//搜索无结果时显示的提示
+        search_contains:true,   //关键字模糊搜索。设置为true,只要选项包含搜索词就会显示;设置为false,则要求从选项开头开始匹配
+        allow_single_deselect:true, //单选下拉框是否允许取消选择。如果允许,选中选项会有一个x号可以删除选项
+        disable_search: false, //禁用搜索。设置为true,则无法搜索选项。
+        disable_search_threshold: 0, //当选项少等于于指定个数时禁用搜索。
+        inherit_select_classes: true, //是否继承原下拉框的样式类,此处设为继承
+        placeholder_text_single: '选择国家', //单选选择框的默认提示信息,当选项为空时会显示。如果原下拉框设置了data-placeholder,会覆盖这里的值。
+        width: '255px', //设置chosen下拉框的宽度。即使原下拉框本身设置了宽度,也会被width覆盖。
+        max_shown_results: 1000, //下拉框最大显示选项数量
+        display_disabled_options: false,
+        single_backstroke_delete: false, //false表示按两次删除键才能删除选项,true表示按一次删除键即可删除
+        case_sensitive_search: false, //搜索大小写敏感。此处设为不敏感
+        group_search: false, //选项组是否可搜。此处搜索不可搜
+        include_group_label_in_selected: true //选中选项是否显示选项分组。false不显示,true显示。默认false。
+    });
 </script>
 </body>
 </html>