wangxiaoming 5 rokov pred
rodič
commit
e2c9918142
26 zmenil súbory, kde vykonal 1693 pridanie a 128 odobranie
  1. 30 0
      watero-rst-core/src/main/java/com.iamberry.rst.core/order/Product.java
  2. 73 0
      watero-rst-core/src/main/java/com.iamberry.rst.core/order/ProductArea.java
  3. 52 0
      watero-rst-core/src/main/java/com.iamberry.rst.core/order/ProductAreaRela.java
  4. 10 0
      watero-rst-core/src/main/java/com.iamberry.rst.core/order/ProductColor.java
  5. 38 0
      watero-rst-interface/src/main/java/com/iamberry/rst/faces/product/ProductAreaRelaService.java
  6. 19 0
      watero-rst-interface/src/main/java/com/iamberry/rst/faces/product/ProductAreaService.java
  7. 1 1
      watero-rst-interface/src/main/java/com/iamberry/rst/faces/product/ProductColorService.java
  8. 6 0
      watero-rst-interface/src/main/java/com/iamberry/rst/faces/product/ProductService.java
  9. 57 0
      watero-rst-service/src/main/java/com/iamberry/rst/service/product/ProductAreaRelaServiceImpl.java
  10. 29 0
      watero-rst-service/src/main/java/com/iamberry/rst/service/product/ProductAreaServiceImpl.java
  11. 1 1
      watero-rst-service/src/main/java/com/iamberry/rst/service/product/ProductColorServiceImpl.java
  12. 148 2
      watero-rst-service/src/main/java/com/iamberry/rst/service/product/ProductServiceImpl.java
  13. 19 0
      watero-rst-service/src/main/java/com/iamberry/rst/service/product/mapper/ProductAreaMapper.java
  14. 47 0
      watero-rst-service/src/main/java/com/iamberry/rst/service/product/mapper/ProductAreaRelaMapper.java
  15. 9 1
      watero-rst-service/src/main/java/com/iamberry/rst/service/product/mapper/ProductColorMapper.java
  16. 34 0
      watero-rst-service/src/main/java/com/iamberry/rst/service/product/mapper/productAreaMapper.xml
  17. 76 0
      watero-rst-service/src/main/java/com/iamberry/rst/service/product/mapper/productAreaRelaMapper.xml
  18. 55 2
      watero-rst-service/src/main/java/com/iamberry/rst/service/product/mapper/productColorMapper.xml
  19. 9 1
      watero-rst-service/src/main/java/com/iamberry/rst/service/product/mapper/productMapper.xml
  20. 192 26
      watero-rst-web/src/main/java/com/iamberry/rst/controllers/product/AdminProductController.java
  21. 4 0
      watero-rst-web/src/main/resources/watero-rst-orm.xml
  22. 1 1
      watero-rst-web/src/main/webapp/WEB-INF/views/order/salesOrder/product_list.ftl
  23. 93 24
      watero-rst-web/src/main/webapp/WEB-INF/views/product/add_product.ftl
  24. 45 12
      watero-rst-web/src/main/webapp/WEB-INF/views/product/product_list.ftl
  25. 381 0
      watero-rst-web/src/main/webapp/WEB-INF/views/product/update_product.ftl
  26. 264 57
      watero-rst-web/src/main/webapp/common/js/product/product.js

+ 30 - 0
watero-rst-core/src/main/java/com.iamberry.rst.core/order/Product.java

@@ -47,6 +47,11 @@ public class Product implements Serializable {
     //是否可批发 1:可批发 2:不可批发'
     private Integer productWholesale;
 
+    //使用区域Strs
+    private String productAreaRelaStr;     //
+
+    private String colorBar;        //产品条码(SKU)
+
     //应用场景
 //    private Integer productApplied; // 1,销售产品  2,维修产品
 
@@ -54,6 +59,7 @@ public class Product implements Serializable {
 
     private List<FittingsInfo> fittingsList = new ArrayList<FittingsInfo>();   //产品配件集合
 
+    private List<ProductAreaRela> productAreaRelaList = new ArrayList<>();  //区域
 
     public Integer getProductId() {
         return productId;
@@ -182,6 +188,30 @@ public class Product implements Serializable {
         this.colorName = colorName;
     }
 
+    public List<ProductAreaRela> getProductAreaRelaList() {
+        return productAreaRelaList;
+    }
+
+    public void setProductAreaRelaList(List<ProductAreaRela> productAreaRelaList) {
+        this.productAreaRelaList = productAreaRelaList;
+    }
+
+    public String getProductAreaRelaStr() {
+        return productAreaRelaStr;
+    }
+
+    public void setProductAreaRelaStr(String productAreaRelaStr) {
+        this.productAreaRelaStr = productAreaRelaStr;
+    }
+
+    public String getColorBar() {
+        return colorBar;
+    }
+
+    public void setColorBar(String colorBar) {
+        this.colorBar = colorBar;
+    }
+
     @Override
     public String toString() {
         return "Product{" +

+ 73 - 0
watero-rst-core/src/main/java/com.iamberry.rst.core/order/ProductArea.java

@@ -0,0 +1,73 @@
+package com.iamberry.rst.core.order;
+
+import  java.util.Date;
+import  java.io.Serializable;
+/**
+ *  产品作用域类
+ * @author Administrator
+ * @Date 2019-07-12
+ */
+public class ProductArea  implements  Serializable{
+    private static final long serialVersionUID = -6487955202622900896L;
+    //产品作用域id
+    private Integer productAreaId;
+    //产品作用域名称
+    private String productAreaName;
+    //产品作用域状态 1:使用 2:禁用
+    private Integer productAreaStatus;
+    //产品作用域备注
+    private String productAreaRemark;
+    //创建时间'
+    private Date productAreaCreateTime;
+
+    //是否使用  1:选中 2:未选中
+    private Integer isUse;
+
+    public Integer getProductAreaId(){
+        return productAreaId;
+    }
+
+    public void setProductAreaId(Integer  productAreaId){
+        this.productAreaId=productAreaId;
+    }
+
+    public String getProductAreaName(){
+        return productAreaName;
+    }
+
+    public void setProductAreaName(String  productAreaName){
+        this.productAreaName=productAreaName;
+    }
+
+    public Integer getProductAreaStatus(){
+        return productAreaStatus;
+    }
+
+    public void setProductAreaStatus(Integer  productAreaStatus){
+        this.productAreaStatus=productAreaStatus;
+    }
+
+    public String getProductAreaRemark(){
+        return productAreaRemark;
+    }
+
+    public void setProductAreaRemark(String  productAreaRemark){
+        this.productAreaRemark=productAreaRemark;
+    }
+
+    public Date getProductAreaCreateTime(){
+        return productAreaCreateTime;
+    }
+
+    public void setProductAreaCreateTime(Date  productAreaCreateTime){
+        this.productAreaCreateTime=productAreaCreateTime;
+    }
+
+    public Integer getIsUse() {
+        return isUse;
+    }
+
+    public void setIsUse(Integer isUse) {
+        this.isUse = isUse;
+    }
+}

+ 52 - 0
watero-rst-core/src/main/java/com.iamberry.rst.core/order/ProductAreaRela.java

@@ -0,0 +1,52 @@
+package com.iamberry.rst.core.order;
+
+import  java.util.Date;
+import  java.io.Serializable;
+/**
+ *  产品作用域关联产品类
+ * @author Administrator
+ * @Date 2019-07-12
+ */
+public class ProductAreaRela  implements  Serializable{
+    private static final long serialVersionUID = 4429432987184370216L;
+    //
+    private Integer areaRelaId;
+    //产品id
+    private Integer productId;
+    //产品区域id
+    private Integer productAreaId;
+    //创建时间'
+    private Date areaRelaCreateTime;
+
+    public Integer getAreaRelaId(){
+        return areaRelaId;
+    }
+
+    public void setAreaRelaId(Integer  areaRelaId){
+        this.areaRelaId=areaRelaId;
+    }
+
+    public Integer getProductId(){
+        return productId;
+    }
+
+    public void setProductId(Integer  productId){
+        this.productId=productId;
+    }
+
+    public Integer getProductAreaId(){
+        return productAreaId;
+    }
+
+    public void setProductAreaId(Integer  productAreaId){
+        this.productAreaId=productAreaId;
+    }
+
+    public Date getAreaRelaCreateTime(){
+        return areaRelaCreateTime;
+    }
+
+    public void setAreaRelaCreateTime(Date  areaRelaCreateTime){
+        this.areaRelaCreateTime=areaRelaCreateTime;
+    }
+}

+ 10 - 0
watero-rst-core/src/main/java/com.iamberry.rst.core/order/ProductColor.java

@@ -55,6 +55,8 @@ public class ProductColor implements Serializable {
 
     private Integer typeCompany;        //所属公司
 
+    private Integer isUpdate;        //是否修改过   1:修改过   2:未曾修改
+
     public String getProductName() {
         return productName;
     }
@@ -215,6 +217,14 @@ public class ProductColor implements Serializable {
         this.colorMode = colorMode;
     }
 
+    public Integer getIsUpdate() {
+        return isUpdate;
+    }
+
+    public void setIsUpdate(Integer isUpdate) {
+        this.isUpdate = isUpdate;
+    }
+
     @Override
     public String toString() {
         return "ProductColor{" +

+ 38 - 0
watero-rst-interface/src/main/java/com/iamberry/rst/faces/product/ProductAreaRelaService.java

@@ -0,0 +1,38 @@
+package com.iamberry.rst.faces.product;
+
+import com.iamberry.rst.core.order.ProductAreaRela;
+
+import java.util.List;
+
+/**
+ *  产品作用域关联产品接口
+ * @author Administrator
+ * @Date 2019-07-12
+ */
+public interface ProductAreaRelaService {
+    /**
+     * 获取集合
+     * @param  productAreaRela
+     * @return List
+     */
+    List<ProductAreaRela> getProductAreaRelaList(ProductAreaRela  productAreaRela);
+    /**
+     * 查询单条数据
+     * @param  id
+     * @return  productAreaRela
+     */
+    ProductAreaRela  getProductAreaRelaById(Integer  id);
+    /**
+     * 增加数据 <集合>
+     * @param  productAreaRelaList
+     * @return Integer
+     */
+    Integer  saveList(List<ProductAreaRela>  productAreaRelaList);
+    /**
+     * 修改数据 <集合>
+     * @param  productAreaRelaList
+     * @return Integer
+     */
+    Integer  updateList(List<ProductAreaRela>  productAreaRelaList);
+
+}

+ 19 - 0
watero-rst-interface/src/main/java/com/iamberry/rst/faces/product/ProductAreaService.java

@@ -0,0 +1,19 @@
+package com.iamberry.rst.faces.product;
+
+import com.iamberry.rst.core.order.ProductArea;
+
+import java.util.List;
+
+/**
+ *  产品作用域接口
+ * @author Administrator
+ * @Date 2019-07-12
+ */
+public interface ProductAreaService {
+    /**
+     * 获取集合
+     * @param  productArea
+     * @return List
+     */
+    List<ProductArea>  getProductAreaList(ProductArea  productArea);
+}

+ 1 - 1
watero-rst-interface/src/main/java/com/iamberry/rst/faces/product/ProductColorService.java

@@ -51,5 +51,5 @@ public interface ProductColorService {
      * @param  ids
      * @return Integer
      */
-    Integer  deleteList(Integer[]  ids);
+    Integer  deleteList(String[] ids);
 }

+ 6 - 0
watero-rst-interface/src/main/java/com/iamberry/rst/faces/product/ProductService.java

@@ -136,6 +136,12 @@ public interface ProductService {
      */
     Integer  update(Product  product);
     /**
+     * 修改数据
+     * @param  product
+     * @return Integer
+     */
+    Integer  updateState(Product  product);
+    /**
      * 删除数据
      * @param  id
      * @return Integer

+ 57 - 0
watero-rst-service/src/main/java/com/iamberry/rst/service/product/ProductAreaRelaServiceImpl.java

@@ -0,0 +1,57 @@
+package com.iamberry.rst.service.product;
+
+import com.iamberry.rst.core.order.ProductAreaRela;
+import com.iamberry.rst.faces.product.ProductAreaRelaService;
+import com.iamberry.rst.service.product.mapper.ProductAreaRelaMapper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ *  产品作用域关联产品接口
+ * @author Administrator
+ * @Date 2019-07-12
+ */
+@Service
+public class ProductAreaRelaServiceImpl  implements ProductAreaRelaService {
+    @Autowired
+    private ProductAreaRelaMapper productAreaRelaMapper;
+    /**
+     * 获取集合
+     * @param  productAreaRela
+     * @return List
+     */
+    @Override
+    public List<ProductAreaRela> getProductAreaRelaList(ProductAreaRela productAreaRela){
+        return  productAreaRelaMapper.getProductAreaRelaList(productAreaRela);
+    }
+    /**
+     * 查询单条数据
+     * @param  id
+     * @return  productAreaRela
+     */
+    @Override
+    public  ProductAreaRela  getProductAreaRelaById(Integer  id){
+        return  productAreaRelaMapper.getProductAreaRelaById(id);
+    }
+    /**
+     * 增加数据 <集合>
+     * @param  productAreaRelaList
+     * @return Integer
+     */
+    @Override
+    public  Integer  saveList(List<ProductAreaRela>  productAreaRelaList){
+        return  productAreaRelaMapper.saveList(productAreaRelaList);
+    }
+    /**
+     * 修改数据 <集合>
+     * @param  productAreaRelaList
+     * @return Integer
+     */
+    @Override
+    public  Integer  updateList(List<ProductAreaRela>  productAreaRelaList){
+        return  productAreaRelaMapper.updateList(productAreaRelaList);
+    }
+
+}

+ 29 - 0
watero-rst-service/src/main/java/com/iamberry/rst/service/product/ProductAreaServiceImpl.java

@@ -0,0 +1,29 @@
+package com.iamberry.rst.service.product;
+
+import com.iamberry.rst.core.order.ProductArea;
+import com.iamberry.rst.faces.product.ProductAreaService;
+import com.iamberry.rst.service.product.mapper.ProductAreaMapper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ *  产品作用域接口
+ * @author Administrator
+ * @Date 2019-07-12
+ */
+@Service
+public class ProductAreaServiceImpl  implements ProductAreaService {
+    @Autowired
+    private ProductAreaMapper productAreaMapper;
+    /**
+     * 获取集合
+     * @param  productArea
+     * @return List
+     */
+    @Override
+    public List<ProductArea> getProductAreaList(ProductArea  productArea){
+        return  productAreaMapper.getProductAreaList(productArea);
+    }
+}

+ 1 - 1
watero-rst-service/src/main/java/com/iamberry/rst/service/product/ProductColorServiceImpl.java

@@ -78,7 +78,7 @@ public class ProductColorServiceImpl  implements ProductColorService {
      * @return Integer
      */
     @Override
-    public  Integer  deleteList(Integer[]  ids){
+    public  Integer  deleteList(String[] ids){
         return  productColorMapper.deleteList(ids);
     }
 }

+ 148 - 2
watero-rst-service/src/main/java/com/iamberry/rst/service/product/ProductServiceImpl.java

@@ -3,12 +3,14 @@ package com.iamberry.rst.service.product;
 import com.github.pagehelper.PageHelper;
 import com.iamberry.rst.core.cm.FittingsInfo;
 import com.iamberry.rst.core.order.Product;
+import com.iamberry.rst.core.order.ProductAreaRela;
 import com.iamberry.rst.core.order.ProductColor;
 import com.iamberry.rst.core.order.ProductType;
 import com.iamberry.rst.core.page.PagedResult;
 import com.iamberry.rst.core.product.Gift;
 import com.iamberry.rst.core.product.OrderGift;
 import com.iamberry.rst.faces.product.ProductService;
+import com.iamberry.rst.service.product.mapper.ProductAreaRelaMapper;
 import com.iamberry.rst.service.product.mapper.ProductColorMapper;
 import com.iamberry.rst.service.product.mapper.ProductMapper;
 import com.iamberry.rst.util.PageUtil;
@@ -31,6 +33,8 @@ public class ProductServiceImpl implements ProductService {
     private ProductMapper productMapper;
     @Autowired
     private ProductColorMapper productColorMapper;
+    @Autowired
+    private ProductAreaRelaMapper productAreaRelaMapper;
 
     @Override
     public List<OrderGift> listGift() {
@@ -194,12 +198,22 @@ public class ProductServiceImpl implements ProductService {
         List<ProductColor> productColorList = product.getColorList();
         for (ProductColor productColor : productColorList) {
             productColor.setColorProductId(product.getProductId());
-            productColor.setColorStatus(1);
         }
         flag = productColorMapper.saveList(productColorList);
         if(flag < 1){
             throw new RuntimeException("添加颜色集合失败");
         }
+
+        //添加产品区域使用
+        if(product.getProductAreaRelaList() != null && product.getProductAreaRelaList().size() > 0){
+            for (ProductAreaRela productAreaRela:product.getProductAreaRelaList()) {
+                productAreaRela.setProductId(product.getProductId());
+            }
+            flag = productAreaRelaMapper.saveList(product.getProductAreaRelaList());
+            if(flag < 1){
+                throw new RuntimeException("添加产品使用区域失败");
+            }
+        }
         return  flag;
     }
 
@@ -211,8 +225,140 @@ public class ProductServiceImpl implements ProductService {
      */
     @Override
     public  Integer  update(Product  product){
-        return  productMapper.update(product);
+        Integer flag = 0;
+        flag = productMapper.update(product);
+        if(flag < 1){
+            throw new RuntimeException("修改产品失败");
+        }
+
+        //删除颜色
+        ProductColor oldproductColor = new ProductColor();
+        oldproductColor.setColorProductId(product.getProductId());
+        List<ProductColor> oldProductColorList = productColorMapper.getProductColorList(oldproductColor);
+        String colors = "";
+        for (ProductColor oldpc:oldProductColorList) {
+            boolean isHaveColor = false;
+            for (ProductColor updatePc:product.getColorList()) {
+                if(Objects.equals(oldpc.getColorId(), updatePc.getColorId())){
+                    isHaveColor = true;
+                }
+            }
+            if(!isHaveColor){
+                if("".equals(colors)){
+                    colors += oldpc.getColorId();
+                }else{
+                    colors += ","+oldpc.getColorId();
+                }
+            }
+        }
+        if(!"".equals(colors)){
+            String[] colorDels = colors.split(",");
+            flag = productColorMapper.deleteList(colorDels);
+            if(flag < 1){
+                throw new RuntimeException("删除颜色失败");
+            }
+        }
+
+        List<ProductColor> addProductColorList = new ArrayList<>();
+        List<ProductColor> updateProductColorList = new ArrayList<>();
+        List<ProductColor> newProductColorList = product.getColorList();
+        for (ProductColor productColor : newProductColorList) {
+            if(productColor.getColorId() == null){
+                addProductColorList.add(productColor);
+            }else{
+                if(1 == productColor.getIsUpdate() ){
+                    updateProductColorList.add(productColor);
+                }
+            }
+        }
+        //添加的颜色 - begin
+        if(addProductColorList.size() > 0){
+            for (ProductColor productColor : addProductColorList) {
+                productColor.setColorProductId(product.getProductId());
+            }
+            flag = productColorMapper.saveList(addProductColorList);
+            if(flag < 1){
+                throw new RuntimeException("添加颜色集合失败");
+            }
+        }
+        //添加颜色 -end
+
+        //修改颜色
+        if(updateProductColorList.size() > 0){
+            flag = productColorMapper.updateList(updateProductColorList);
+            if(flag < 1){
+                throw new RuntimeException("添加颜色集合失败");
+            }
+        }
+
+
+
+        //存储以前的所属区域id
+        List<Integer> oldlist = new ArrayList<>();
+        //存储交集
+        List<Integer> retainList = new ArrayList<>();
+        ProductAreaRela oldproductAreaRela = new ProductAreaRela();
+        oldproductAreaRela.setProductId(product.getProductId());
+        List<ProductAreaRela> oldproductAreaRelaList = productAreaRelaMapper.getProductAreaRelaList(oldproductAreaRela);
+        for (ProductAreaRela par:oldproductAreaRelaList) {
+            oldlist.add(par.getProductAreaId());
+            retainList.add(par.getProductAreaId());
+        }
+        //存储当前的所属区域id
+        List<Integer> newlist = new ArrayList<>();
+        for (ProductAreaRela newproductAreaRela:product.getProductAreaRelaList()) {
+            newlist.add(newproductAreaRela.getProductAreaId());
+        }
+        //获取两个集合的交集
+        retainList.retainAll(newlist);
+
+        //获取过去所属区域的补集
+        oldlist.removeAll(retainList);
+        //获取当前所属区域的补集
+        newlist.removeAll(retainList);
+
+        //删除过去的补集
+        if(oldlist.size()>0){
+            for (Integer areaId:oldlist) {
+                flag = productAreaRelaMapper.delete(product.getProductId(),areaId);
+                if(flag < 1){
+                    throw new RuntimeException("删除所属区域失败");
+                }
+            }
+        }
+
+        //增加当前的所属区域的补集
+        if(newlist.size()>0){
+            List<ProductAreaRela> productAreaRelaList = new ArrayList<>();
+            for (Integer areaId:newlist) {
+                ProductAreaRela productAreaRela = new ProductAreaRela();
+                productAreaRela.setProductId(product.getProductId());
+                productAreaRela.setProductAreaId(areaId);
+                productAreaRelaList.add(productAreaRela);
+            }
+            flag = productAreaRelaMapper.saveList(productAreaRelaList);
+            if(flag < 1){
+                throw new RuntimeException("添加产品使用区域失败");
+            }
+        }
+        return  flag;
     }
+
+    /**
+     * 修改数据
+     * @param  product
+     * @return Integer
+     */
+    @Override
+    public Integer updateState(Product  product){
+        Integer flag = 0;
+        flag = productMapper.update(product);
+        if(flag < 1){
+            throw new RuntimeException("修改产品失败");
+        }
+        return  flag;
+    }
+
     /**
      * 删除数据
      * @param  id

+ 19 - 0
watero-rst-service/src/main/java/com/iamberry/rst/service/product/mapper/ProductAreaMapper.java

@@ -0,0 +1,19 @@
+package com.iamberry.rst.service.product.mapper;
+
+import com.iamberry.rst.core.order.ProductArea;
+
+import java.util.List;
+
+/**
+ *  产品作用域接口
+ * @author Administrator
+ * @Date 2019-07-12
+ */
+public interface ProductAreaMapper {
+    /**
+     * 获取集合
+     * @param  productArea
+     * @return List
+     */
+    List<ProductArea> getProductAreaList(ProductArea  productArea);
+}

+ 47 - 0
watero-rst-service/src/main/java/com/iamberry/rst/service/product/mapper/ProductAreaRelaMapper.java

@@ -0,0 +1,47 @@
+package com.iamberry.rst.service.product.mapper;
+
+import com.iamberry.rst.core.order.ProductAreaRela;
+
+import java.util.List;
+
+/**
+ *  产品作用域关联产品接口
+ * @author Administrator
+ * @Date 2019-07-12
+ */
+public interface ProductAreaRelaMapper {
+    /**
+     * 获取集合
+     * @param  productAreaRela
+     * @return List
+     */
+    List<ProductAreaRela>  getProductAreaRelaList(ProductAreaRela  productAreaRela);
+    /**
+     * 查询单条数据
+     * @param  id
+     * @return  productAreaRela
+     */
+    ProductAreaRela getProductAreaRelaById(Integer  id);
+    /**
+     * 增加数据 <集合>
+     * @param  productAreaRelaList
+     * @return Integer
+     */
+    Integer  saveList(List<ProductAreaRela> productAreaRelaList);
+    /**
+     * 修改数据 <集合>
+     * @param  productAreaRelaList
+     * @return Integer
+     */
+    Integer  updateList(List<ProductAreaRela>  productAreaRelaList);
+
+    /**
+     * 删除数据 <集合>
+     * @param  product
+     * @param  productAreaId
+     * @return Integer
+     */
+    Integer  delete(Integer product,Integer productAreaId);
+
+
+}

+ 9 - 1
watero-rst-service/src/main/java/com/iamberry/rst/service/product/mapper/ProductColorMapper.java

@@ -52,10 +52,18 @@ public interface ProductColorMapper {
      * @return Integer
      */
     Integer  saveList(List<ProductColor>  productColorList);
+
+    /**
+     * 修改数据 <集合>
+     * @param  productColorList
+     * @return Integer
+     */
+    Integer  updateList(List<ProductColor>  productColorList);
+
     /**
      * 删除数据 <集合>
      * @param  ids
      * @return Integer
      */
-    Integer  deleteList(Integer[]  ids);
+    Integer  deleteList(String[] ids);
 }

+ 34 - 0
watero-rst-service/src/main/java/com/iamberry/rst/service/product/mapper/productAreaMapper.xml

@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.iamberry.rst.service.product.mapper.ProductAreaMapper">
+    <resultMap  id="BaseResultMap" type="ProductArea" >
+        <result    column="product_area_id"    property="productAreaId" />
+        <result    column="product_area_name"    property="productAreaName" />
+        <result    column="product_area_status"    property="productAreaStatus" />
+        <result    column="product_area_remark"    property="productAreaRemark" />
+        <result    column="product_area_create_time"    property="productAreaCreateTime" />
+    </resultMap>
+    <sql    id="Base_List" >
+        t.product_area_id,
+        t.product_area_name,
+        t.product_area_status,
+        t.product_area_remark,
+        t.product_area_create_time
+    </sql>
+    <select id="getProductAreaList" resultMap="BaseResultMap" parameterType="ProductArea" >
+        select
+        <include refid="Base_List" />
+        from tb_rst_product_area t
+        <where>
+            <if test="productAreaId != null ">
+                AND t.product_area_id = #{productAreaId}
+            </if >
+            <if test="productAreaName != null and productAreaName != ''">
+                AND t.product_area_name  like  CONCAT ('%',#{productAreaName},'%')
+            </if >
+            <if test="productAreaStatus != null ">
+                AND t.product_area_status = #{productAreaStatus}
+            </if >
+        </where>
+    </select>
+</mapper>

+ 76 - 0
watero-rst-service/src/main/java/com/iamberry/rst/service/product/mapper/productAreaRelaMapper.xml

@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.iamberry.rst.service.product.mapper.ProductAreaRelaMapper">
+    <resultMap  id="BaseResultMap" type="ProductAreaRela" >
+        <result    column="area_rela_id"    property="areaRelaId" />
+        <result    column="product_id"    property="productId" />
+        <result    column="product_area_id"    property="productAreaId" />
+        <result    column="area_rela_create_time"    property="areaRelaCreateTime" />
+    </resultMap>
+    <sql    id="Base_List" >
+        t.area_rela_id,
+        t.product_id,
+        t.product_area_id,
+        t.area_rela_create_time
+    </sql>
+    <select id="getProductAreaRelaList" resultMap="BaseResultMap" parameterType="ProductAreaRela" >
+        select
+        <include refid="Base_List" />
+        from tb_rst_product_area_rela t
+        <where>
+            <if test="areaRelaId != null ">
+                AND t.area_rela_id = #{areaRelaId}
+            </if >
+            <if test="productId != null ">
+                AND t.product_id = #{productId}
+            </if >
+            <if test="productAreaId != null ">
+                AND t.product_area_id = #{productAreaId}
+            </if >
+        </where>
+    </select>
+    <select id="getProductAreaRelaById" resultMap="BaseResultMap" parameterType="Integer" >
+        select
+        <include refid="Base_List" />
+        from tb_rst_product_area_rela t
+        where t.area_rela_id= #{areaRelaId}
+    </select>
+    <insert id="saveList" parameterType="java.util.List" >
+        insert into
+        tb_rst_product_area_rela
+        (
+        product_id,
+        product_area_id
+        )
+        values
+        <foreach collection="list" item="node" index="index" separator="," open="" close="">
+            (
+            #{node.productId},
+            #{node.productAreaId}
+            )
+        </foreach >
+    </insert>
+    <update id="updateList" parameterType="java.util.List" >
+        <foreach collection="list" item="node" index="index" separator="," open="" close="">
+            update
+            tb_rst_product_area_rela
+            <set >
+                <if test="node.productId != null ">
+                    product_id = #{node.productId},
+                </if >
+                <if test="node.productAreaId != null ">
+                    product_area_id = #{node.productAreaId},
+                </if >
+            </set >
+            where area_rela_id= #{node.areaRelaId}
+        </foreach >
+    </update>
+
+    <delete id="delete" parameterType="Integer" >
+        delete FROM
+          tb_rst_product_area_rela
+        where product_id = #{0}
+        AND product_area_id = #{1}
+    </delete>
+
+</mapper>

+ 55 - 2
watero-rst-service/src/main/java/com/iamberry/rst/service/product/mapper/productColorMapper.xml

@@ -29,6 +29,8 @@
         t.color_cretae_time,
         t.color_update_time,
         t.color_is_machine,
+        t.color_mode,
+        t.color_jd_product_id,
         t.color_is_weight
     </sql>
     <select id="getProductColorList" resultMap="BaseResultMap" parameterType="ProductColor" >
@@ -158,6 +160,8 @@
         color_status,
         color_cretae_time,
         color_is_machine,
+        color_jd_product_id,
+        color_mode,
         color_is_weight
         )
         values
@@ -173,15 +177,64 @@
             #{node.colorStatus},
             #{node.colorCretaeTime},
             #{node.colorIsMachine},
+            #{node.colorJdProductId},
+            #{node.colorMode},
             #{node.colorIsWeight}
             )
         </foreach >
     </insert>
-    <delete id="deleteList" parameterType="String" >
+
+    <update id="updateList" parameterType="java.util.List" >
+        <foreach collection="list" item="node" index="index" separator=";" open="" close="">
+            update
+            tb_rst_product_color
+            <set >
+                <if test="node.colorProductId != null ">
+                    color_product_id = #{node.colorProductId},
+                </if >
+                <if test="node.colorName != null and node.colorName != ''">
+                    color_name = #{node.colorName},
+                </if >
+                <if test="node.colorAbbreviation != null and node.colorAbbreviation != ''">
+                    color_abbreviation = #{node.colorAbbreviation},
+                </if >
+                <if test="node.colorMode != null and node.colorMode != ''">
+                    color_mode = #{node.colorMode},
+                </if >
+                <if test="node.colorDiscount != null ">
+                    color_discount = #{node.colorDiscount},
+                </if >
+                <if test="node.colorPrice != null ">
+                    color_price = #{node.colorPrice},
+                </if >
+                <if test="node.colorBar != null and node.colorBar != ''">
+                    color_bar = #{node.colorBar},
+                </if >
+                <if test="node.colorPicture != null and node.colorPicture != ''">
+                    color_picture = #{node.colorPicture},
+                </if >
+                <if test="node.colorStatus != null ">
+                    color_status = #{node.colorStatus},
+                </if >
+                <if test="node.colorIsMachine != null ">
+                    color_is_machine = #{node.colorIsMachine},
+                </if >
+                <if test="node.colorIsWeight != null ">
+                    color_is_weight = #{node.colorIsWeight},
+                </if >
+                <if test="node.colorJdProductId != null and node.colorJdProductId != ''">
+                    color_jd_product_id = #{node.colorJdProductId}
+                </if >
+            </set >
+            where color_id= #{node.colorId}
+        </foreach >
+    </update>
+
+    <delete id="deleteList">
         delete FROM
         tb_rst_product_color
         where color_id  in
-        <foreach collection="ids" item="item" index="index" separator="," open="(" close=")">
+        <foreach collection="array" item="item" index="index" separator="," open="(" close=")">
             #{item}
         </foreach >
     </delete>

+ 9 - 1
watero-rst-service/src/main/java/com/iamberry/rst/service/product/mapper/productMapper.xml

@@ -302,6 +302,9 @@
             <if test="colorName != null and colorName != ''">
                 AND pc.color_name  like  CONCAT ('%',#{colorName},'%')
             </if >
+            <if test="colorBar != null and colorBar != ''">
+                AND pc.color_bar  = #{colorBar}
+            </if >
             <if test="productAbbreviation != null and productAbbreviation != ''">
                 AND t.product_abbreviation  like  CONCAT ('%',#{productAbbreviation},'%')
             </if >
@@ -337,6 +340,7 @@
         product_remark,
         product_type,
         product_number,
+        product_is_detection,
         product_wholesale
         )
         values
@@ -349,6 +353,7 @@
         #{productRemark},
         #{productType},
         #{productNumber},
+        #{productIsDetection},
         #{productWholesale}
         )
     </insert>
@@ -378,7 +383,10 @@
                 product_number = #{productNumber},
             </if >
             <if test="productWholesale != null ">
-                product_wholesale = #{productWholesale}
+                product_wholesale = #{productWholesale},
+            </if >
+            <if test="productIsDetection != null ">
+                product_is_detection = #{productIsDetection}
             </if >
         </set >
         where product_id= #{productId}

+ 192 - 26
watero-rst-web/src/main/java/com/iamberry/rst/controllers/product/AdminProductController.java

@@ -1,10 +1,10 @@
 package com.iamberry.rst.controllers.product;
 
 import com.iamberry.rst.controllers.sys.SysController;
-import com.iamberry.rst.core.order.Product;
-import com.iamberry.rst.core.order.ProductColor;
-import com.iamberry.rst.core.order.ProductType;
+import com.iamberry.rst.core.order.*;
 import com.iamberry.rst.core.page.PagedResult;
+import com.iamberry.rst.faces.product.ProductAreaRelaService;
+import com.iamberry.rst.faces.product.ProductAreaService;
 import com.iamberry.rst.faces.product.ProductColorService;
 import com.iamberry.rst.faces.product.ProductService;
 import com.iamberry.rst.utils.StitchAttrUtil;
@@ -29,6 +29,7 @@ import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServletRequest;
 import java.io.*;
 import java.text.SimpleDateFormat;
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -49,6 +50,10 @@ public class AdminProductController {
     @Autowired
     private ProductService productService;
     @Autowired
+    private ProductAreaService productAreaService;
+    @Autowired
+    private ProductAreaRelaService productAreaRelaService;
+    @Autowired
     private ProductColorService productColorService;
 
 
@@ -85,7 +90,7 @@ public class AdminProductController {
         mv.addObject("productTypeList",productTypeList);
 
         StitchAttrUtil.getSa()
-                .addNoPro("colorList","fittingsList")
+                .addNoPro("colorList","fittingsList","productAreaRelaList")
                 .setModelAndView(product, mv, "/admin/product/product_page", pagedResult);
         return mv;
     }
@@ -101,8 +106,13 @@ public class AdminProductController {
     public ModelAndView toAddProduct(HttpServletRequest request) {
         ModelAndView mv = new ModelAndView("product/add_product");
         ProductType productType = new ProductType();
+        productType.setTypeStatus(1);
         List<ProductType> productTypeList = productService.listProductType(productType);
         mv.addObject("productTypeList",productTypeList);
+        ProductArea productArea = new ProductArea();
+        productArea.setProductAreaStatus(1);
+        List<ProductArea> productAreaList = productAreaService.getProductAreaList(productArea);
+        mv.addObject("productAreaList",productAreaList);
         return mv;
     }
 
@@ -115,20 +125,48 @@ public class AdminProductController {
     @RequiresPermissions("salesOrder:save:product")
     @RequestMapping("/add_product")
     public ResponseJson addProduct(HttpServletRequest request,Product product,String colorListJson) {
-        ResponseJson rj = new ResponseJson();
+        ResponseJson rj = ResponseJson.getSUCCESS();
         if(product == null){
             rj = ResponseJson.getFAILURE();
+            return  rj;
         }
         product.setProductSalesnum(0);
         product.setProductStatus(1);
         JSONArray jsonArray = JSONArray.fromObject(colorListJson);
         List<ProductColor> productColorList =  (List) JSONArray.toCollection(jsonArray, ProductColor.class);
-
         product.setColorList(productColorList);
+        rj = verification(product);
+        if(rj.getReturnCode() == 500){
+            return rj;
+        }
 
-        productService.save(product);
+        List<ProductAreaRela> productAreaRelaList = new ArrayList<>();
+        if(product.getProductAreaRelaStr() != null && !"".equals(product.getProductAreaRelaStr())){
+            String areas[] = product.getProductAreaRelaStr().split(",");
+            for (String area : areas) {
+                ProductAreaRela productAreaRela = new ProductAreaRela();
+                productAreaRela.setProductAreaId(Integer.valueOf(area));
+                productAreaRelaList.add(productAreaRela);
+            }
+        }
+        product.setProductAreaRelaList(productAreaRelaList);
 
-        return rj;
+        Integer flag = 0;
+        try{
+            flag = productService.save(product);
+        }catch (RuntimeException e){
+            e.printStackTrace();
+            rj = ResponseJson.getFAILURE();
+            rj.setResultMsg("增加产品失败,失败原因:"+e.getMessage());
+            return  rj;
+        }
+        if(flag > 0){
+            rj.setResultMsg("添加成功");
+            return rj;
+        }else{
+            rj = ResponseJson.getFAILURE();
+            return  rj;
+        }
     }
 
     /**
@@ -136,27 +174,57 @@ public class AdminProductController {
      * @param product
      * @return
      */
-    private String verification(Product product){
-        String msg = "";
+    private ResponseJson verification(Product product){
+        ResponseJson rj = ResponseJson.getFAILURE();
         if(product.getProductName() == null ||  "".equals(product.getProductName())){
-            msg = "产品名称不能为空";
-            return msg;
+            rj.setResultMsg("产品名称不能为空");
+            return rj;
+        }
+        if(product.getProductAbbreviation() == null ||  "".equals(product.getProductAbbreviation())){
+            rj.setResultMsg("产品名称不能为空");
+            return rj;
         }
 
         List<ProductColor> productColorList = product.getColorList();
         for (ProductColor productColor:productColorList) {
-            ProductColor pc = new ProductColor();
-            pc.setColorBar(productColor.getColorBar());
-            List<ProductColor> pcList = productColorService.getProductColorList(pc);
-            if(pcList.size() > 0){
-                msg = "颜色69码重复";
-                return msg;
+            if(productColor.getColorName() == null || "".equals(productColor.getColorName())){
+                rj.setResultMsg("颜色名称为空,产品名称:"+product.getProductName());
+                return rj;
+            }
+            if(productColor.getColorAbbreviation() == null || "".equals(productColor.getColorAbbreviation())){
+                rj.setResultMsg("颜色简称为空,为空的颜色简称:"+productColor.getProductName());
+                return rj;
+            }
+            if(productColor.getColorBar() == null || "".equals(productColor.getColorBar())){
+                rj.setResultMsg("颜色69码为空,为空的颜色名称:"+productColor.getProductName());
+                return rj;
+            }
+            Integer flag = 0;
+            for (ProductColor productColorTwo:productColorList) {
+                if(productColorTwo.getColorBar().equals(productColor.getColorBar())){
+                    flag ++;
+                }
+            }
+            if(flag > 1){
+                rj.setResultMsg("颜色69码重复,重复颜色69码:"+productColor.getColorBar());
+                return rj;
+            }
+        }
+
+        for (ProductColor productColor:productColorList) {
+            if(productColor.getColorId() == null){
+                ProductColor pc = new ProductColor();
+                pc.setColorBar(productColor.getColorBar());
+                List<ProductColor> pcList = productColorService.getProductColorList(pc);
+                if(pcList.size() > 0){
+                    rj.setResultMsg("颜色69码重复,重复编码:"+productColor.getColorBar());
+                    return rj;
+                }
             }
         }
-        return msg;
+        return ResponseJson.getSUCCESS();
     }
 
-
     /**
      * 到修改页面产品
      * @param request
@@ -164,11 +232,36 @@ public class AdminProductController {
      */
     @RequiresPermissions("salesOrder:update:product")
     @RequestMapping("/to_update_product")
-    public ModelAndView toUpdateProduct(HttpServletRequest request) {
-        ModelAndView mv = new ModelAndView("product/product_list");
+    public ModelAndView toUpdateProduct(HttpServletRequest request,Integer productId) {
+        ModelAndView mv = new ModelAndView("product/update_product");
         ProductType productType = new ProductType();
         List<ProductType> productTypeList = productService.listProductType(productType);
         mv.addObject("productTypeList",productTypeList);
+
+        Product product = productService.getProduce(productId);
+        mv.addObject("product",product);
+
+        ProductArea productArea = new ProductArea();
+        productArea.setProductAreaStatus(1);
+        List<ProductArea> productAreaList = productAreaService.getProductAreaList(productArea);
+
+        ProductAreaRela productAreaRela = new ProductAreaRela();
+        productAreaRela.setProductId(productId);
+        List<ProductAreaRela> productAreaRelaList = productAreaRelaService.getProductAreaRelaList(productAreaRela);
+        for (ProductArea pa:productAreaList) {
+            pa.setIsUse(2);
+            for (ProductAreaRela par:productAreaRelaList) {
+                if(pa.getProductAreaId() == par.getProductAreaId()){
+                    pa.setIsUse(1);
+                }
+            }
+        }
+        mv.addObject("productAreaList",productAreaList);
+
+        ProductColor productColor = new ProductColor();
+        productColor.setColorProductId(productId);
+        List<ProductColor> productColorList = productColorService.getProductColorList(productColor);
+        mv.addObject("productColorList",productColorList);
         return mv;
     }
 
@@ -177,15 +270,88 @@ public class AdminProductController {
      * @param request
      * @return
      */
+    @ResponseBody
     @RequiresPermissions("salesOrder:update:product")
     @RequestMapping("/update_product")
-    public ModelAndView updateProduct(HttpServletRequest request) {
-        ModelAndView mv = new ModelAndView("product/product_list");
-        return mv;
+    public ResponseJson updateProduct(HttpServletRequest request,Product product,String colorListJson) {
+        ResponseJson rj = ResponseJson.getSUCCESS();
+        if(product == null){
+            rj = ResponseJson.getFAILURE();
+            return  rj;
+        }
+        product.setProductSalesnum(0);
+        product.setProductStatus(1);
+        JSONArray jsonArray = JSONArray.fromObject(colorListJson);
+        List<ProductColor> productColorList =  (List) JSONArray.toCollection(jsonArray, ProductColor.class);
+        product.setColorList(productColorList);
+        rj = verification(product);
+        if(rj.getReturnCode() == 500){
+            return rj;
+        }
+
+        List<ProductAreaRela> productAreaRelaList = new ArrayList<>();
+        if(product.getProductAreaRelaStr() != null && !"".equals(product.getProductAreaRelaStr())){
+            String areas[] = product.getProductAreaRelaStr().split(",");
+            for (String area : areas) {
+                ProductAreaRela productAreaRela = new ProductAreaRela();
+                productAreaRela.setProductAreaId(Integer.valueOf(area));
+                productAreaRelaList.add(productAreaRela);
+            }
+        }
+        product.setProductAreaRelaList(productAreaRelaList);
+
+        Integer flag = 0;
+        try{
+            flag = productService.update(product);
+        }catch (Exception e){
+            e.printStackTrace();
+            rj = ResponseJson.getFAILURE();
+            rj.setResultMsg("修改产品失败,失败原因:"+e.getMessage());
+            return  rj;
+        }
+        if(flag > 0){
+            rj.setResultMsg("修改成功");
+            return rj;
+        }else{
+            rj = ResponseJson.getFAILURE();
+            return  rj;
+        }
+    }
+
+
+    /**
+     * 修改产品 状态
+     * @param request
+     * @return
+     */
+    @ResponseBody
+    @RequiresPermissions("salesOrder:update:product")
+    @RequestMapping("/update_pro_state")
+    public ResponseJson updateProState(HttpServletRequest request,Integer productId,Integer productStatus) {
+        ResponseJson rj = ResponseJson.getFAILURE();
+        if(productId == null || productStatus ==null){
+            rj.setResultMsg("修改状态失败");
+            return rj;
+        }
+
+        Product product = new Product();
+        product.setProductId(productId);
+        product.setProductStatus(productStatus);
+        Integer flag = productService.updateState(product);
+
+        if(flag > 0){
+            rj = ResponseJson.getSUCCESS();
+            rj.setResultMsg("修改状态成功");
+            return rj;
+        }else{
+            rj.setResultMsg("修改状态失败");
+            rj = ResponseJson.getFAILURE();
+            return  rj;
+        }
     }
 
     /**
-     * 上传设计文件
+     * 图片
      * @RequestParam("file") 将name=file控件得到的文件封装成CommonsMultipartFile 对象
      */
     @ResponseBody

+ 4 - 0
watero-rst-web/src/main/resources/watero-rst-orm.xml

@@ -41,6 +41,8 @@
 		<typeAlias type="com.iamberry.rst.core.order.OrderCorrectItem" alias="OrderCorrectItem"/>
 		<typeAlias type="com.iamberry.rst.core.order.OrderWarehouse" alias="OrderWarehouse"/>
 		<typeAlias type="com.iamberry.rst.core.order.OrderWarehouseAdmin" alias="OrderWarehouseAdmin"/>
+		<typeAlias type="com.iamberry.rst.core.order.ProductAreaRela" alias="ProductAreaRela"/>
+		<typeAlias type="com.iamberry.rst.core.order.ProductArea" alias="ProductArea"/>
 
 		<typeAlias type="com.iamberry.rst.core.sms.SmsMessage" alias="SmsMessage"/>
 		<typeAlias type="com.iamberry.rst.core.sms.OrderMessage" alias="OrderMessage"/>
@@ -236,6 +238,8 @@
 
 		<mapper resource="com/iamberry/rst/service/product/mapper/productMapper.xml"/>
 		<mapper resource="com/iamberry/rst/service/product/mapper/productColorMapper.xml"/>
+		<mapper resource="com/iamberry/rst/service/product/mapper/productAreaRelaMapper.xml"/>
+		<mapper resource="com/iamberry/rst/service/product/mapper/productAreaMapper.xml"/>
 
 		<mapper resource="com/iamberry/rst/service/faq/mapper/faqMapper.xml"/>
 		<mapper resource="com/iamberry/rst/service/pts/mapper/produceMapper.xml"/>

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

@@ -99,7 +99,7 @@
             <table class="table table-border table-bordered table-bg table-hover table-sort">
                 <thead>
                 <tr class="text-c">
-                    <th width="10"><input type="checkbox" class="selectAll" id="selectAll" value="selectAll" ></th>
+                    <th width="10"><input type="checkbox" ></th>
                     <th width="50">产品名称</th>
                     <th width="50">产品颜色</th>
                     <#--<th width="50">产品原价</th>-->

+ 93 - 24
watero-rst-web/src/main/webapp/WEB-INF/views/product/add_product.ftl

@@ -87,12 +87,12 @@
 
                 <label class="form-label col-1 col-sm-1">产品型号:</label>
                 <div class="formControls col-2 col-sm-2">
-                    <input type="text" class="input-text" value="" placeholder="填写产品型号" id="productNumber" name="productNumber" datatype="*1-15" errormsg="产品型号格式不正确!">
+                    <input type="text" class="input-text" value="" placeholder="填写产品型号" id="productNumber" name="productNumber" datatype="*0-15" errormsg="产品型号格式不正确!">
                 </div>
             </div>
 
             <div class="row cl">
-                <label class="form-label col-1 col-sm-1"><span class="c-red">*</span>可批发:</label>
+                <#--<label class="form-label col-1 col-sm-1"><span class="c-red">*</span>可批发:</label>
                 <div class="formControls col-2 col-sm-2 skin-minimal">
                     <div class="radio-box">
                         <input type="radio" id="productWholesale-1" name="productWholesale" value="1" >
@@ -102,7 +102,7 @@
                         <input type="radio" id="productWholesale-2" name="productWholesale" value="2" checked>
                         <label for="productWholesale-2">不可批发</label>
                     </div>
-                </div>
+                </div>-->
 
                    <label class="form-label col-1 col-sm-1"><span class="c-red">*</span>售后检测:</label>
                    <div class="formControls col-2 col-sm-2 skin-minimal">
@@ -118,9 +118,27 @@
             </div>
 
             <div class="row cl">
+                <label class="form-label col-1 col-sm-1"><span class="c-red">*</span>使用区域:</label>
+                <div class="formControls col-9 col-sm-9 skin-minimal" >
+                    <div class="radio-box">
+                        <input type="checkbox" class="all_checkbox" id="productAreaRela-x" name="productAreaRela" value="0" checked >
+                        <label for="productAreaRela-x">全部</label>
+                    </div>
+                    <#if productAreaList??>
+                        <#list productAreaList as productArea>
+                            <div class="radio-box">
+                                <input type="checkbox" class="son_checkbox" id="productAreaRela-${productArea_index}" name="productAreaRela" value="${productArea.productAreaId}" checked >
+                                <label for="productAreaRela-${productArea_index}">${productArea.productAreaName}</label>
+                            </div>
+                        </#list>
+                    </#if>
+                </div>
+            </div>
+
+            <div class="row cl">
                 <label class="form-label col-1 col-sm-1">产品备注:</label>
-                <div class="formControls col-5 col-sm-5" style="width: 43.3%;">
-                    <input type="text" class="input-text" value="" placeholder="产品备注" id="productRemark" name="productRemark">
+                <div class="formControls col-9 col-sm-9" style="">
+                    <textarea id="productRemark" name="productRemark" style="width: 100%;"></textarea>
                 </div>
             </div>
 
@@ -134,6 +152,7 @@
 
             <div class="row cl" id="" style="margin-left: 25px;">
                 <div class="formControls col-11 col-sm-11">
+                    <input type="button" class="btn btn-primary" onclick="show_add_color()" value="添加颜色" >
 
                     <table class="table table-border table-bg table-bordered" style="margin-top: 10px;" id="all_add_product">
                         <thead>
@@ -147,60 +166,62 @@
                                 <th style="text-align: center;" width="10"><span class="c-red">*</span>重量(g)</th>
                                 <th style="text-align: center;" width="10">型号</th>
                                 <th style="text-align: center;" width="10"><span class="c-red">*</span>是否为水机</th>
+                                <th style="text-align: center;" width="10"><span class="c-red">*</span>状态</th>
                                 <th style="text-align: center;" width="20">图片</th>
                                 <th style="text-align: center;" width="5">操作</th>
                             </tr>
                         </thead>
-                        <tbody id="add_color">
-                            <tr><td colspan="11" class="td-manage text-c" >暂时没有颜色,请添加!</td></tr>
+                        <tbody id="add_color_id">
+                            <tr><td colspan="12" class="td-manage text-c" >暂时没有颜色,请添加!</td></tr>
                         </tbody>
                     </table>
 
                 </div>
             </div>
 
-            <div id="addColorHtml">
+            <div id="addColorHtml" style="display: none">
+                <input type="hidden" class="colorId" value="">
                 <div class="row cl" id="" style="">
                     <label class="form-label col-1 col-sm-1"><span class="c-red">*</span>颜色名称:</label>
                     <div class="formControls col-2 col-sm-2">
-                        <input type="text" class="input-text add_color colorName" value="" placeholder="填写颜色名称" id="" name="" myMinlength="1" myMaxlength="32" errormsg="颜色名称必填,只能填写1-32个字符!" >
+                        <input type="text" class="input-text add_color str colorName" value="" placeholder="填写颜色名称" id="" name="" myMinlength="1" myMaxlength="32" errormsg="颜色名称必填,只能填写1-32个字符!" >
                     </div>
                     <label class="form-label col-1 col-sm-1"><span class="c-red">*</span>产品简称:</label>
                     <div class="formControls col-2 col-sm-2">
-                        <input type="text" class="input-text add_color colorAbbreviation" value="" placeholder="填写颜色简称" id="" name="" myMinlength="1" myMaxlength="15"  errormsg="颜色简称必填,只能填写1-15个字符!">
+                        <input type="text" class="input-text add_color str colorAbbreviation" value="" placeholder="填写颜色简称" id="" name="" myMinlength="1" myMaxlength="15"  errormsg="颜色简称必填,只能填写1-15个字符!">
                     </div>
                 </div>
 
                 <div class="row cl" id="" style="">
                     <label class="form-label col-1 col-sm-1">售价:</label>
                     <div class="formControls col-2 col-sm-2">
-                        <input type="text" class="input-text add_color colorDiscount" value="0" placeholder="售价" id="" name="" onkeyup="keyFun($(this),9999,1)" onpaste="keyFun($(this),9999,1)">
+                        <input type="text" class="input-text add_color num colorDiscount" value="0" placeholder="售价" id="" name="" onkeyup="keyFun($(this),9999,1)" onpaste="keyFun($(this),9999,1)">
                     </div>
                     <label class="form-label col-1 col-sm-1">市场价:</label>
                     <div class="formControls col-2 col-sm-2">
-                        <input type="text" class="input-text add_color colorPrice" value="0" placeholder="市场价" id="" name="" onkeyup="keyFun($(this),9999,1)" onpaste="keyFun($(this),9999,1)">
+                        <input type="text" class="input-text add_color num colorPrice" value="0" placeholder="市场价" id="" name="" onkeyup="keyFun($(this),9999,1)" onpaste="keyFun($(this),9999,1)">
                     </div>
                 </div>
 
                 <div class="row cl" id="" style="">
                     <label class="form-label col-1 col-sm-1"><span class="c-red">*</span>69码:</label>
                     <div class="formControls col-2 col-sm-2">
-                        <input type="text" class="input-text add_color colorBar" value="" placeholder="69码" id="" name="" myMinlength="1"  myMaxlength="20" errormsg="69码必填,只能填写1-20个字符!" >
+                        <input type="text" class="input-text add_color str colorBar" value="" placeholder="69码" id="" name="" myMinlength="1"  myMaxlength="20" errormsg="69码必填,只能填写1-20个字符!" >
                     </div>
                     <label class="form-label col-1 col-sm-1">京东SKU:</label>
                     <div class="formControls col-2 col-sm-2">
-                        <input type="text" class="input-text add_color colorJdProductId" value="" placeholder="京东SKU" id="" name="" myMaxlength="20"  errormsg="京东SKU非必填,可填写1-20个字符!">
+                        <input type="text" class="input-text add_color str colorJdProductId" value="" placeholder="京东SKU" id="" name="" myMaxlength="20"  errormsg="京东SKU非必填,可填写1-20个字符!">
                     </div>
                 </div>
 
                 <div class="row cl" id="" style="">
                     <label class="form-label col-1 col-sm-1"><span class="c-red">*</span>重量:</label>
                     <div class="formControls col-2 col-sm-2">
-                        <input type="text" class="input-text add_color colorIsWeight" value="0" placeholder="重量" id="" name="" onkeyup="keyFun($(this),9999,1)" onpaste="keyFun($(this),9999,1)" >
+                        <input type="text" class="input-text add_color num colorIsWeight" value="0" placeholder="重量" id="" name="" onkeyup="keyFun($(this),9999,1)" onpaste="keyFun($(this),9999,1)" >
                     </div>
                     <label class="form-label col-1 col-sm-1">型号:</label>
                     <div class="formControls col-2 col-sm-2">
-                        <input type="text" class="input-text add_color colorMode" value="" placeholder="型号" id="" name=""  myMaxlength="30"  errormsg="型号非必填,可填写1-30个字符!">
+                        <input type="text" class="input-text add_color str colorMode" value="" placeholder="型号" id="" name=""  myMaxlength="30"  errormsg="型号非必填,可填写1-30个字符!">
                     </div>
                 </div>
 
@@ -209,7 +230,7 @@
                     <div class="formControls col-2 col-sm-2 upload_color_class">
                         <input type="file" class="color_file" name="file" id="upload_color_img" style="display: none">
                         <div class="download_file"><a href="javascript:void(0)" class="del_product all_down" onclick="fileOnclick(this)">上传图片</a></div>
-                        <input type="hidden" class="add_color colorPicture " name="" id="" value="" >
+                        <input type="hidden" class="add_color str colorPicture " name="" id="" value="" >
                     </div>
                 </div>
 
@@ -217,24 +238,39 @@
                     <label class="form-label col-1 col-sm-1"><span class="c-red">*</span>是否为水机:</label>
                     <div class="formControls col-5 col-sm-5 skin-minimal">
                         <div class="radio-box">
-                            <input type="radio" id="colorIsMachine-1" name="colorIsMachine" value="1" >
+                            <input type="radio" class="colorIsMachine" id="colorIsMachine-1" name="colorIsMachine" value="1" >
                             <label for="colorIsMachine-1">水机产品</label>
                         </div>
                         <div class="radio-box">
-                            <input type="radio" id="colorIsMachine-2" name="colorIsMachine" value="2" checked>
+                            <input type="radio" class="colorNoMachine" id="colorIsMachine-2" name="colorIsMachine" value="2" checked>
                             <label for="colorIsMachine-2">其他产品</label>
                         </div>
                     </div>
                 </div>
-            </div>
-
-            <div class="row cl" id="" style="margin-left: 25px;">
-                <div class="formControls col-2 col-sm-2">
-                    <input type="button" class="btn btn-primary add-order-button" onclick="add_color()" value="添加颜色" >
+                <div class="row cl" id="" style="">
+                    <label class="form-label col-1 col-sm-1"><span class="c-red">*</span>状态:</label>
+                    <div class="formControls col-5 col-sm-5 skin-minimal">
+                        <div class="radio-box">
+                            <input type="radio" class="colorIsStatus" id="colorStatus-1" name="colorStatus" value="1" checked>
+                            <label for="colorStatus-1">使用</label>
+                        </div>
+                        <div class="radio-box">
+                            <input type="radio" class="colorNoStatus" id="colorStatus-2" name="colorStatus" value="2" >
+                            <label for="colorStatus-2">停用</label>
+                        </div>
+                    </div>
+                </div>
+                <div class="row cl" id="" style="">
+                    <label class="form-label col-1 col-sm-1"></label>
+                    <div class="formControls col-2 col-sm-2">
+                        <input type="button" class="btn btn-primary add-color-button" onclick="add_color()" value="添加" >
+                        <input style="margin-left: 10px;" type="button" class="btn btn-default cancel-color-button" onclick="cancel_color()" value="取消" >
+                    </div>
                 </div>
             </div>
 
             <input type="hidden" id="colorListJson" name="colorListJson" value="" >
+            <input type="hidden" id="productAreaRelaStr" name="productAreaRelaStr" value="" >
 
             <div class="row cl" style="margin-bottom: 20px">
                 <div class="col-2 col-sm-2 col-offset-3">
@@ -259,6 +295,39 @@
         increaseArea: '20%'
     });
 
+
+    var isSonCh = false;
+    //选中
+    $('.all_checkbox').on('ifChecked', function(event){
+        isSonCh = false;
+        $(".son_checkbox").iCheck('check');
+    });
+    //取消
+    $('.all_checkbox').on('ifUnchecked', function (event) {
+        if(!isSonCh){
+            $(".son_checkbox").iCheck('uncheck');
+        }else{
+            isSonCh = false;
+        }
+    });
+    //选中
+    $('.son_checkbox').on('ifChecked', function(event){
+        var allCheck = true;
+        $(".son_checkbox").each(function () {
+            if(!$(this).is(':checked')){
+                allCheck = false;
+            }
+        });
+        if(allCheck){
+            $(".all_checkbox").iCheck('check');
+        }
+    });
+    //取消
+    $('.son_checkbox').on('ifUnchecked', function (event) {
+        isSonCh = true;
+        $(".all_checkbox").iCheck('uncheck');
+    });
+
     var isHaveColorList = 2; //是否已经有颜色   2没有  1 含有
 </script>
 

+ 45 - 12
watero-rst-web/src/main/webapp/WEB-INF/views/product/product_list.ftl

@@ -52,7 +52,7 @@
 
             <input type="text" class="my-input trim_input"  style="width:120px;margin-right: 0px; margin-bottom: 8px;" value="${product.productName!}" placeholder="产品名称" id="productName" name="productName">
             <input type="text" class="my-input trim_input"  style="width:120px;margin-right: 0px; margin-bottom: 8px;" value="${product.colorName!}" placeholder="颜色名称" id="colorName" name="colorName">
-
+            <input type="text" class="my-input trim_input"  style="width:120px;margin-right: 0px; margin-bottom: 8px;" value="${product.colorBar!}" placeholder="69码" id="colorBar" name="colorBar">
 
             <button type="submit" class="btn" style="background: #50a2ea;border: 1px solid #50a2ea;color: #fff;height: 35px;margin-top: -8px;"><i class="Hui-iconfont">&#xe665;</i> 查询</button>
 
@@ -66,7 +66,7 @@
                     <th width="50">类型</th>
                     <th width="100">名称</th>
                     <th width="50">颜色</th>
-                    <th width="50">可批发</th>
+                    <#--<th width="50">可批发</th>-->
                     <th width="50">售后检测</th>
                     <th width="50">状态</th>
                     <th width="80">创建时间</th>
@@ -80,13 +80,13 @@
                             <td>${product.typeName!''}</td>
                             <td>${product.productName!''}</td>
                             <td>${product.colorNameStr!''}</td>
-                            <td>
+                          <#--  <td>
                                 <#if product.productWholesale == 1>
                                     可批发
                                 <#elseif product.productWholesale == 2>
                                     不可批发
                                 </#if>
-                            </td>
+                            </td>-->
                             <td>
                                 <#if product.productIsDetection == 1>
                                     需要
@@ -103,10 +103,17 @@
                             </td>
                             <td>${(product.productCreateTime?string("yyyy-MM-dd HH:mm:ss"))!''}</td>
                             <td>
-                                <a style="text-decoration:none;color: #00E;" href="javascript:void(0);" title="禁用" onclick="product_disable('${product.productId!''}')">
-                                    禁用
-                                </a>
-                                <a style="text-decoration:none;color: #00E;" href="javascript:void(0);" title="修改" onclick="product_update('${product.productId!''}')">
+                                <#if product.productStatus == 1>
+                                    <a style="text-decoration:none;color: #00E;" href="javascript:void(0);" title="禁用" onclick="forbid('${product.productId!''}',2)">
+                                        禁用
+                                    </a>
+                                <#elseif product.productStatus == 2>
+                                    <a style="text-decoration:none;color: #00E;" href="javascript:void(0);" title="启用" onclick="forbid('${product.productId!''}',1)">
+                                        启用
+                                    </a>
+                                </#if>
+
+                                <a style="text-decoration:none;color: #00E;" href="javascript:void(0);" title="修改" onclick="to_update('${product.productId!''}')">
                                     修改
                                 </a>
                             </td>
@@ -125,7 +132,7 @@
 <script>
 
     /**
-     *跳转到客诉列表页面
+     *跳转到添加产品
      * @param employee
      */
     function to_add() {
@@ -133,11 +140,11 @@
     }
 
     /**
-     *下载
+     *跳转到修改产品
      * @param employee
      */
-    function download_order(batchId) {
-        window.location.href= "${path}/admin/order/download_order_excel?salesBatchId="+batchId;
+    function to_update(productId) {
+        window.location.href= "${path}/admin/product/to_update_product?productId="+productId;
     }
 
     /**
@@ -163,6 +170,32 @@
     function distribution_postFirm(title,url,w,h){
         layer_show(title,url,w,h);
     }
+
+    /**
+     * 禁用
+     * @param productId
+     * @param state
+     */
+    function forbid(productId,state) {
+        $.ajax({
+            type: "POST",
+            data: {
+                "productId" :productId,
+                "productStatus" :state
+            },
+            url: "${path}/admin/product/update_pro_state",
+            async: false,
+            success: function(data){
+                if (data.returnCode == 200) {
+                    location.replace(location.href);
+                }else{
+                    layer.msg("更改状态失败!", {icon: 5, time: 3000});
+                }
+            },
+            error: function(XmlHttpRequest, textStatus, errorThrown){
+            }
+        });
+    }
 </script>
 </body>
 </html>

+ 381 - 0
watero-rst-web/src/main/webapp/WEB-INF/views/product/update_product.ftl

@@ -0,0 +1,381 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+    <meta charset="utf-8">
+    <meta name="renderer" content="webkit|ie-comp|ie-stand">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+    <meta name="viewport"
+          content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
+    <meta http-equiv="Cache-Control" content="no-siteapp"/>
+<#include "/base/add_base.ftl">
+
+    <style>
+        .tit{position: relative;text-align: left;font-size: 16px;padding-left: 10px;}
+        .tit:after{content: '';position: absolute;left: 0;top: 20%;height: 60%;width: 3px;background-color: #32a3d8;}
+        .tit-2{position: relative;text-align: left;font-size: 16px;padding-left: 10px;color: #50a2ea;}
+        .tit-2:after{content: '';position: absolute;left: 0;top: 50%;height: 6px;width: 6px;border-radius: 6px;margin-top: -3px; background-color: #32a3d8;}
+        #province select{margin-right:10px; width:100px;height: 31px;-webkit-appearance:none !important;appearance:none;background: url(${path}/common/images/cm/select-1.png) right center no-repeat;background-size: auto 100%;padding-left:3px;padding-right: 25px;}
+        .ac_results li a {white-space: nowrap;text-decoration:none;display:block;color:#05a;padding:1px 3px}
+        .ac_results li {border:1px solid #fff}
+        .ac_results li a span {float:right}
+        .select-box{background: url(${path}/common/images/cm/select-1.png) right center no-repeat;background-size: auto 100%;}
+        .select-box select{-webkit-appearance:none !important;background-color: transparent; appearance:none;padding-right: 15px;}
+        .dalog-ask{position: absolute;left:60%;top:0;-webkit-transform: translateY(-30%);transform: translateY(-30%);display: none;background-color: #fff;z-index: 10;}
+        .tag{ width:300px; min-height:300px; border:1px solid #32a3d8; position:relative;background-color: #fff;line-height: 1.5;padding: 10px 12px;}
+        .tag em{display:block; border-width:15px; position:absolute; top:30%; left:-30px;border-style:solid dashed dashed; border-color:transparent  #32a3d8 transparent transparent;font-size:0; line-height:0;}
+        .time-line-list{list-style: none;width: 100%;margin-left: -20px;}
+        .time-line-list>li{position: relative;float: left; text-align: center;width: 100px;overflow: hidden;white-space: nowrap;word-break: break-all;padding: 2px 0;}
+        .time-line-list .number{display: inline-block; padding: 2px; background: #32a3d8;border: 2px solid #fff;box-shadow:0 0 0 1px #32a3d8;width: 20px;height: 20px;color: #fff;line-height: 20px;border-radius: 50%;}
+        .time-line-list>li:before{content:'';position: absolute;height: 1px;width: 30%;right:0;top: 15px; background-color: #32a3d8;}
+        .time-line-list>li:after{content: '';position: absolute;height: 1px;width: 30%;left: 0;top: 15px;background:#32a3d8;}
+        .time-line-list>li:first-child:after,.time-line-list>li:last-child:before{display: none;}
+        .time-line-list .arrow{border-width:7px; position:absolute; left:25%; top:9px;border-style:solid dashed dashed; border-color:transparent  transparent  transparent #32a3d8;font-size:0; line-height:0;}
+        .time-line-list>li:first-child .arrow{display: none;}
+        .table-bg th{background-color: #e2f6ff;}
+        .update-parts>span{margin-right: 10px;padding: 3px 4px;background-color: #effaff;border: 1px solid #32a3d8;}
+        .msg-phone{height: 35px;line-height: 35px;}
+        .col-sm-1{width: 10%;}
+        .all_down{text-decoration: underline;color: #00c;}
+    </style>
+    <title>添加产品 - 产品管理 - RST</title>
+</head>
+<body>
+<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页
+    <span class="c-gray en">/</span> 产品管理
+    <span class="c-gray en">/</span> 添加产品
+    <a class="btn radius r"
+       href="javascript:location.replace(location.href);" title="刷新"><i class="Hui-iconfont">&#xe68f;</i></a>
+    <a class="btn radius r"
+       href="javascript:history.back(-1);" title="后退"><i class="Hui-iconfont">&#xe6d4;</i></a>
+</nav>
+<article class="page-container" style="padding: 10px;">
+    <div class="pd-20 cl">
+        <form action="${path}/admin/product/update_product" method="post" class="form form-horizontal" id="form-order-add"  onkeydown="if(event.keyCode==13)return false;">
+
+            <div class="row cl">
+                <label class="form-label col-3">
+                    <div class="tit-2">产品基本信息</div>
+                </label>
+                <div class="formControls col-9">
+                </div>
+            </div>
+
+            <input type="hidden" id="productId" name="productId" value="${product.productId!''}">
+
+            <div class="row cl" id="" style="">
+                <label class="form-label col-1 col-sm-1"><span class="c-red">*</span>产品名称:</label>
+                <div class="formControls col-2 col-sm-2">
+                    <input type="text" class="input-text" value="${product.productName!''}" placeholder="填写产品名称" id="productName" name="productName" datatype="*1-32" errormsg="产品名称格式只支持1-32个字符!" >
+                </div>
+                <label class="form-label col-1 col-sm-1"><span class="c-red">*</span>产品简称:</label>
+                <div class="formControls col-2 col-sm-2">
+                    <input type="text" class="input-text" value="${product.productAbbreviation!''}" placeholder="填写产品简称" id="productAbbreviation" name="productAbbreviation" datatype="*1-17" errormsg="产品简称格式只支持1-17个字符!">
+                </div>
+            </div>
+
+            <div class="row cl">
+                <label class="form-label col-1 col-sm-1"><span class="c-red">*</span>产品类型:</label>
+                <div class="formControls col-2 col-sm-2" style="">
+                    <span class="select-box">
+                        <select class="select" id="productType" name="productType" >
+                        <#if productTypeList??>
+                            <#list productTypeList as productType>
+                                <option value="${productType.typeId}" <#if product.productType == productType.typeId>selected</#if>>${productType.typeName}</option>
+                            </#list>
+                        </#if>
+                        </select>
+				    </span>
+                </div>
+
+                <label class="form-label col-1 col-sm-1">产品型号:</label>
+                <div class="formControls col-2 col-sm-2">
+                    <input type="text" class="input-text" value="${product.productAbbreviation!''}" placeholder="填写产品型号" id="productNumber" name="productNumber" datatype="*0-15" errormsg="产品型号格式不正确!">
+                </div>
+            </div>
+
+            <div class="row cl">
+              <#--  <label class="form-label col-1 col-sm-1"><span class="c-red">*</span>可批发:</label>
+                <div class="formControls col-2 col-sm-2 skin-minimal">
+                    <div class="radio-box">
+                        <input type="radio" id="productWholesale-1" name="productWholesale" value="1" <#if product.productWholesale ==1 >checked</#if>>
+                        <label for="productWholesale-1">可批发</label>
+                    </div>
+                    <div class="radio-box">
+                        <input type="radio" id="productWholesale-2" name="productWholesale" value="2" <#if product.productWholesale ==2 >checked</#if>>
+                        <label for="productWholesale-2">不可批发</label>
+                    </div>
+                </div>-->
+
+                <label class="form-label col-1 col-sm-1"><span class="c-red">*</span>售后检测:</label>
+                <div class="formControls col-2 col-sm-2 skin-minimal">
+                    <div class="radio-box">
+                        <input type="radio" id="productIsDetection-1" name="productIsDetection" value="1" <#if product.productIsDetection ==1 >checked</#if>>
+                        <label for="productIsDetection-1">需要</label>
+                    </div>
+                    <div class="radio-box">
+                        <input type="radio" id="productIsDetection-2" name="productIsDetection" value="2" <#if product.productIsDetection ==2 >checked</#if>>
+                        <label for="productIsDetection-2">不需要</label>
+                    </div>
+                </div>
+            </div>
+
+            <div class="row cl">
+                <label class="form-label col-1 col-sm-1"><span class="c-red">*</span>使用区域:</label>
+                <div class="formControls col-9 col-sm-9 skin-minimal" >
+                    <div class="radio-box">
+                        <input type="checkbox" class="all_checkbox" id="productAreaRela-x" name="productAreaRela" value="0" >
+                        <label for="productAreaRela-x">全部</label>
+                    </div>
+                    <#if productAreaList??>
+                        <#list productAreaList as productArea>
+                            <div class="radio-box">
+                                <input type="checkbox" class="son_checkbox" id="productAreaRela-${productArea_index}" name="productAreaRela" value="${productArea.productAreaId}" <#if productArea.isUse == 1>checked</#if> >
+                                <label for="productAreaRela-${productArea_index}">${productArea.productAreaName}</label>
+                            </div>
+                        </#list>
+                    </#if>
+                </div>
+            </div>
+
+            <div class="row cl">
+                <label class="form-label col-1 col-sm-1">产品备注:</label>
+                <div class="formControls col-9 col-sm-9" style="">
+                    <textarea id="productRemark" name="productRemark" style="width: 100%;">${product.productRemark!''}</textarea>
+                </div>
+            </div>
+
+            <div class="row cl">
+                <label class="form-label col-3">
+                    <div class="tit-2">产品颜色信息</div>
+                </label>
+                <div class="formControls col-9">
+                </div>
+            </div>
+
+            <div class="row cl" id="" style="margin-left: 25px;">
+                <div class="formControls col-11 col-sm-11">
+                    <input type="button" class="btn btn-primary" onclick="show_add_color()" value="添加颜色" >
+
+                    <table class="table table-border table-bg table-bordered" style="margin-top: 10px;" id="all_add_product">
+                        <thead>
+                        <tr class="text-c" id="table1">
+                            <th  width="30" ><span class="c-red">*</span>颜色名称</th>
+                            <th  width="30" ><span class="c-red">*</span>颜色简称</th>
+                            <th  width="10">售价</th>
+                            <th  width="10">原价</th>
+                            <th  width="30"><span class="c-red">*</span>69码</th>
+                            <th  width="30">京东SKU</th>
+                            <th  width="10"><span class="c-red">*</span>重量(g)</th>
+                            <th  width="10">型号</th>
+                            <th  width="10"><span class="c-red">*</span>是否为水机</th>
+                            <th  width="10"><span class="c-red">*</span>状态</th>
+                            <th  width="20">图片</th>
+                            <th  width="5">操作</th>
+                        </tr>
+                        </thead>
+                        <tbody id="add_color_id">
+                            <#if productColorList?? && (productColorList?size > 0) >
+                                <#list productColorList as productColor>
+                                    <tr class="text-c">
+                                        <input type="hidden" class="colorId" value="${productColor.colorId!''}">
+                                        <input type="hidden" class="isUpdate" value="2">
+                                        <td width="30" class="colorName">${productColor.colorName!''}</td>
+                                        <td width="30" class="colorAbbreviation">${productColor.colorAbbreviation!''}</td>
+                                        <td width="10" class="colorDiscount">${productColor.colorDiscount!''}</td>
+                                        <td width="10" class="colorPrice">${productColor.colorPrice!''}</td>
+                                        <td width="30" class="colorBar">${productColor.colorBar!''}</td>
+                                        <td width="30" class="colorJdProductId">${productColor.colorJdProductId!''}</td>
+                                        <td width="10" class="colorIsWeight">${productColor.colorIsWeight!''}</td>
+                                        <td width="10" class="colorMode">${productColor.colorMode!''}</td>
+                                        <td width="10">
+                                            <span class="colorIsMachineMsg"><#if productColor.colorIsMachine==1>水机产品</#if><#if productColor.colorIsMachine==2>其他产品</#if></span>
+                                            <input type="hidden" class="colorIsMachine" value="${productColor.colorIsMachine!''}">
+                                        </td>
+                                        <td width="10" >
+                                            <span class="colorStatusMsg"><#if productColor.colorStatus==1>使用</#if><#if productColor.colorStatus==2>禁用</#if></span>
+                                            <input type="hidden" class="colorStatus" value="${productColor.colorStatus!''}">
+                                        </td>
+                                        <td width="20" >
+                                            <img style="width: 40px;" src="<#if productColor.colorPicture?? && productColor.colorPicture?length gt 0 >${path}/${productColor.colorPicture}</#if>"  class="colorPictureMsg" >
+                                            <input type="hidden"  class="colorPicture" value="${productColor.colorPicture}">
+                                        </td>
+                                        <td width="5">
+                                            <a href="javascript:void(0)" class="del_product all_down" onclick="updTr($(this))" >修改</a>&nbsp;&nbsp;
+                                            <a href="javascript:void(0)" class="del_product all_down" onclick="delTr($(this))" >删除</a>
+                                        </td>
+                                    </tr>
+                                </#list>
+                            </#if>
+                        </tbody>
+                    </table>
+                </div>
+            </div>
+
+            <div id="addColorHtml" style="display: none">
+                <input type="hidden" class="colorId" value="">
+                <div class="row cl" id="" style="">
+                    <label class="form-label col-1 col-sm-1"><span class="c-red">*</span>颜色名称:</label>
+                    <div class="formControls col-2 col-sm-2">
+                        <input type="text" class="input-text add_color str colorName" value="" placeholder="填写颜色名称" id="" name="" myMinlength="1" myMaxlength="32" errormsg="颜色名称必填,只能填写1-32个字符!" >
+                    </div>
+                    <label class="form-label col-1 col-sm-1"><span class="c-red">*</span>产品简称:</label>
+                    <div class="formControls col-2 col-sm-2">
+                        <input type="text" class="input-text add_color str colorAbbreviation" value="" placeholder="填写颜色简称" id="" name="" myMinlength="1" myMaxlength="15"  errormsg="颜色简称必填,只能填写1-15个字符!">
+                    </div>
+                </div>
+
+                <div class="row cl" id="" style="">
+                    <label class="form-label col-1 col-sm-1">售价:</label>
+                    <div class="formControls col-2 col-sm-2">
+                        <input type="text" class="input-text add_color num colorDiscount" value="0" placeholder="售价" id="" name="" onkeyup="keyFun($(this),9999,1)" onpaste="keyFun($(this),9999,1)">
+                    </div>
+                    <label class="form-label col-1 col-sm-1">市场价:</label>
+                    <div class="formControls col-2 col-sm-2">
+                        <input type="text" class="input-text add_color num colorPrice" value="0" placeholder="市场价" id="" name="" onkeyup="keyFun($(this),9999,1)" onpaste="keyFun($(this),9999,1)">
+                    </div>
+                </div>
+
+                <div class="row cl" id="" style="">
+                    <label class="form-label col-1 col-sm-1"><span class="c-red">*</span>69码:</label>
+                    <div class="formControls col-2 col-sm-2">
+                        <input type="text" class="input-text add_color str colorBar" value="" placeholder="69码" id="" name="" myMinlength="1"  myMaxlength="20" errormsg="69码必填,只能填写1-20个字符!" >
+                    </div>
+                    <label class="form-label col-1 col-sm-1">京东SKU:</label>
+                    <div class="formControls col-2 col-sm-2">
+                        <input type="text" class="input-text add_color str colorJdProductId" value="" placeholder="京东SKU" id="" name="" myMaxlength="20"  errormsg="京东SKU非必填,可填写1-20个字符!">
+                    </div>
+                </div>
+
+                <div class="row cl" id="" style="">
+                    <label class="form-label col-1 col-sm-1"><span class="c-red">*</span>重量:</label>
+                    <div class="formControls col-2 col-sm-2">
+                        <input type="text" class="input-text add_color num colorIsWeight" value="0" placeholder="重量" id="" name="" onkeyup="keyFun($(this),9999,1)" onpaste="keyFun($(this),9999,1)" >
+                    </div>
+                    <label class="form-label col-1 col-sm-1">型号:</label>
+                    <div class="formControls col-2 col-sm-2">
+                        <input type="text" class="input-text add_color str colorMode" value="" placeholder="型号" id="" name=""  myMaxlength="30"  errormsg="型号非必填,可填写1-30个字符!">
+                    </div>
+                </div>
+
+                <div class="row cl" id="" style="">
+                    <label class="form-label col-1 col-sm-1">介绍图:</label>
+                    <div class="formControls col-2 col-sm-2 upload_color_class">
+                        <input type="file" class="color_file" name="file" id="upload_color_img" style="display: none">
+                        <div class="download_file"><a href="javascript:void(0)" class="del_product all_down" onclick="fileOnclick(this)">上传图片</a></div>
+                        <input type="hidden" class="add_color str colorPicture " name="" id="" value="" >
+                    </div>
+                </div>
+
+                <div class="row cl" id="" style="">
+                    <label class="form-label col-1 col-sm-1"><span class="c-red">*</span>是否为水机:</label>
+                    <div class="formControls col-5 col-sm-5 skin-minimal">
+                        <div class="radio-box">
+                            <input type="radio" class="colorIsMachine" id="colorIsMachine-1" name="colorIsMachine" value="1" >
+                            <label for="colorIsMachine-1">水机产品</label>
+                        </div>
+                        <div class="radio-box">
+                            <input type="radio" class="colorNoMachine" id="colorIsMachine-2" name="colorIsMachine" value="2" checked>
+                            <label for="colorIsMachine-2">其他产品</label>
+                        </div>
+                    </div>
+                </div>
+                <div class="row cl" id="" style="">
+                    <label class="form-label col-1 col-sm-1"><span class="c-red">*</span>状态:</label>
+                    <div class="formControls col-5 col-sm-5 skin-minimal">
+                        <div class="radio-box">
+                            <input type="radio" class="colorIsStatus" id="colorStatus-1" name="colorStatus" value="1" checked>
+                            <label for="colorStatus-1">使用</label>
+                        </div>
+                        <div class="radio-box">
+                            <input type="radio" class="colorNoStatus" id="colorStatus-2" name="colorStatus" value="2" >
+                            <label for="colorStatus-2">停用</label>
+                        </div>
+                    </div>
+                </div>
+                <div class="row cl" id="" style="">
+                    <label class="form-label col-1 col-sm-1"></label>
+                    <div class="formControls col-2 col-sm-2">
+                        <input type="button" class="btn btn-primary add-color-button" onclick="add_color()" value="添加" >
+                        <input style="margin-left: 10px;" type="button" class="btn btn-default cancel-color-button" onclick="cancel_color()" value="取消" >
+                    </div>
+                </div>
+            </div>
+
+            <input type="hidden" id="colorListJson" name="colorListJson" value="" >
+            <input type="hidden" id="productAreaRelaStr" name="productAreaRelaStr" value="" >
+
+            <div class="row cl" style="margin-bottom: 20px">
+                <div class="col-2 col-sm-2 col-offset-3">
+                    <button class="btn btn-block btn-primary size-XL" type="submit">确认修改</button>
+                </div>
+            </div>
+        </form>
+    </div>
+</article>
+
+<script type="text/javascript">
+    var url_path = "${path}";
+</script>
+<#--时间控件-->
+<script type="text/javascript" src="${path}/common/lib/My97DatePicker/4.8/WdatePicker.js"></script>
+<script type="text/javascript" src="${path}/common/lib/jquery/1.9.1/ajaxfileupload.js"></script>
+
+<script type="text/javascript">
+    $('.skin-minimal input').iCheck({
+        checkboxClass: 'icheckbox-blue',
+        radioClass: 'iradio-blue',
+        increaseArea: '20%'
+    });
+
+
+    var isSonCh = false;
+    //选中
+    $('.all_checkbox').on('ifChecked', function(event){
+        isSonCh = false;
+        $(".son_checkbox").iCheck('check');
+    });
+    //取消
+    $('.all_checkbox').on('ifUnchecked', function (event) {
+        if(!isSonCh){
+            $(".son_checkbox").iCheck('uncheck');
+        }else{
+            isSonCh = false;
+        }
+    });
+    //选中
+    $('.son_checkbox').on('ifChecked', function(event){
+        var allCheck = true;
+        $(".son_checkbox").each(function () {
+            if(!$(this).is(':checked')){
+                allCheck = false;
+            }
+        });
+        if(allCheck){
+            $(".all_checkbox").iCheck('check');
+        }
+    });
+    //取消
+    $('.son_checkbox').on('ifUnchecked', function (event) {
+        isSonCh = true;
+        $(".all_checkbox").iCheck('uncheck');
+    });
+
+    $(function () {
+        var allCheck = true;
+        $(".son_checkbox").each(function () {
+            if(!$(this).is(':checked')){
+                allCheck = false;
+            }
+        });
+        if(allCheck){
+            $(".all_checkbox").iCheck('check');
+        }
+    })
+
+    var isHaveColorList = 1; //是否已经有颜色   2没有  1 含有
+</script>
+
+<script type="text/javascript" charset="utf-8" src="${path}/common/js/product/product.js"></script>
+
+</body>
+</html>

+ 264 - 57
watero-rst-web/src/main/webapp/common/js/product/product.js

@@ -1,49 +1,141 @@
-
+var update_color_id_suff = "X_";
+var update_color_id = "1";    //添加时的临时ID
+var color_is_update = 1;    //1是添加  2是修改
 /**
  * 添加颜色
  */
-function add_color(){
+function add_color(isUpdate){
     var $node = $("#addColorHtml");
     var flag = verificationColor();
     if(!flag){
         return false;
     }
-    var colorHtml = '<tr class="text-c">';
-    colorHtml += '<td width="40" class="colorName">'+$node.find(".colorName").val()+'</td>';
-    colorHtml += '<td width="40" class="colorAbbreviation">'+$node.find(".colorAbbreviation").val()+'</td>';
-    colorHtml += '<td width="40" class="colorDiscount">'+$node.find(".colorDiscount").val()+'</td>';
-    colorHtml += '<td width="40" class="colorPrice">'+$node.find(".colorPrice").val()+'</td>';
-    colorHtml += '<td width="40" class="colorBar">'+$node.find(".colorBar").val()+'</td>';
-    colorHtml += '<td width="40" class="colorJdProductId">'+$node.find(".colorJdProductId").val()+'</td>';
-    colorHtml += '<td width="40" class="colorIsWeight">'+$node.find(".colorIsWeight").val()+'</td>';
-    colorHtml += '<td width="40" class="colorMode">'+$node.find(".colorMode").val()+'</td>';
-
-    var colorIsMachine = $(':radio[name="colorIsMachine"]:checked').val();
-    if(colorIsMachine == 1){
-        colorIsMachine = '水机产品';
-    }else{
-        colorIsMachine = '其他产品';
-    }
-    colorHtml += '<td width="40" class="colorIsMachine">'+colorIsMachine+'</td>';
+    var colorId = $node.find(".colorId").val();
+    if(color_is_update == 1){
+        if(!isEmpty(isUpdate)){
+            isUpdate = 2;
+            colorId = update_color_id_suff+update_color_id;
+        }
+        update_color_id++;
+        var colorHtml = '<tr class="text-c">' +
+            '<input type="hidden" class="colorId" name="" id="" value="'+ colorId +'">'+
+            '<input type="hidden" class="isUpdate" name="" id="" value="'+ isUpdate +'">';
+        colorHtml += '<td width="40" class="colorName">'+$node.find(".colorName").val()+'</td>';
+        colorHtml += '<td width="40" class="colorAbbreviation">'+$node.find(".colorAbbreviation").val()+'</td>';
+        colorHtml += '<td width="40" class="colorDiscount">'+$node.find(".colorDiscount").val()+'</td>';
+        colorHtml += '<td width="40" class="colorPrice">'+$node.find(".colorPrice").val()+'</td>';
+        colorHtml += '<td width="40" class="colorBar">'+$node.find(".colorBar").val()+'</td>';
+        colorHtml += '<td width="40" class="colorJdProductId">'+$node.find(".colorJdProductId").val()+'</td>';
+        colorHtml += '<td width="40" class="colorIsWeight">'+$node.find(".colorIsWeight").val()+'</td>';
+        colorHtml += '<td width="40" class="colorMode">'+$node.find(".colorMode").val()+'</td>';
+        var colorIsMachine = $(':radio[name="colorIsMachine"]:checked').val();
+        var colorIsMachineStr = '';
+        if(colorIsMachine == 1){
+            colorIsMachineStr = '水机产品';
+        }else{
+            colorIsMachineStr = '其他产品';
+        }
+        colorHtml += '<td width="40" ><span class="colorIsMachineMsg">'+colorIsMachineStr+'</span><input type="hidden" class="colorIsMachine" name="colorIsMachine" id="colorIsMachine" value="'+ colorIsMachine +'"></td>';
 
-    var img = $node.find(".colorPicture").val();
-    var showImg = '';
-    if(isEmpty(img)){
-        showImg = url_path +"/"+ img;
-    }
-    colorHtml += '<td width="40" >'
-        + '<img style="width: 40px;" src="' + showImg + '"  class="del_product all_down" >'
-        + '<span style="display: none;" class="colorPicture">'+ img +'</span>'
-        + '</td>';
-    colorHtml += '<td width="40"><a href="javascript:void(0)" class="del_product all_down" onclick="delTr($(this))" >删除</a></td>';
-    colorHtml += '</tr>';
-
-    if(isHaveColorList == 2){
-        $("#add_color").html(colorHtml);
-        isHaveColorList = 1;
+        var colorStatus = $(':radio[name="colorStatus"]:checked').val();
+        var colorStatusStr = '';
+        if(colorStatus == 1){
+            colorStatusStr = '使用';
+        }else{
+            colorStatusStr = '禁用';
+        }
+        colorHtml += '<td width="40" ><span class="colorStatusMsg">'+colorStatusStr+'</span><input type="hidden" class="colorStatus"  value="'+ colorStatus +'"></td>';
+
+        var img = $node.find(".colorPicture").val();
+        var showImg = '';
+        if(isEmpty(img)){
+            showImg = url_path +"/"+ img;
+        }
+        colorHtml += '<td width="40" >'
+            + '<img style="width: 40px;" src="' + showImg + '"  class="colorPictureMsg" >'
+            + '<input type="hidden"  class="colorPicture" value="'+ img +'">'
+            + '</td>';
+        colorHtml += '<td width="40">' +
+            '<a href="javascript:void(0)" class="del_product all_down" onclick="updTr($(this))" >修改</a>&nbsp;&nbsp;' +
+            '<a href="javascript:void(0)" class="del_product all_down" onclick="delTr($(this))" >删除</a>' +
+            '</td>';
+        colorHtml += '</tr>';
+        if(isHaveColorList == 2){
+            $("#add_color_id").html(colorHtml);
+            isHaveColorList = 1;
+        }else{
+            $("#add_color_id").append(colorHtml);
+        }
     }else{
-        $("#add_color").append(colorHtml);
+        var noHaveColorId = true;
+        $("#add_color_id").find("tr").each(function () {
+            if($(this).find(".colorId").val() == colorId){
+                noHaveColorId = false;
+                $(this).find(".isUpdate").val(1);
+                $(this).find(".colorName").html($node.find(".colorName").val());
+                $(this).find(".colorAbbreviation").html($node.find(".colorAbbreviation").val());
+                $(this).find(".colorDiscount").html($node.find(".colorDiscount").val());
+                $(this).find(".colorPrice").html($node.find(".colorPrice").val());
+                $(this).find(".colorBar").html($node.find(".colorBar").val());
+                $(this).find(".colorJdProductId").html($node.find(".colorJdProductId").val());
+                $(this).find(".colorIsWeight").html($node.find(".colorIsWeight").val());
+                $(this).find(".colorMode").html($node.find(".colorMode").val());
+                $(this).find(".colorPicture").val($node.find(".colorPicture").val());
+
+                var colorIsMachine = $(':radio[name="colorIsMachine"]:checked').val();
+                $(this).find(".colorIsMachine").val(colorIsMachine);
+                var colorIsMachineStr = '';
+                if(colorIsMachine == 1){
+                    colorIsMachineStr = '水机产品';
+                }else{
+                    colorIsMachineStr = '其他产品';
+                }
+                $(this).find(".colorIsMachineMsg").html(colorIsMachineStr);
+
+                var colorStatus = $(':radio[name="colorStatus"]:checked').val();
+                $(this).find(".colorStatus").val(colorStatus);
+                var colorStatusStr = '';
+                if(colorStatus == 1){
+                    colorStatusStr = '使用';
+                }else{
+                    colorStatusStr = '禁用';
+                }
+                $(this).find(".colorStatusMsg").html(colorStatusStr);
+
+                var img = $node.find(".colorPicture").val();
+                var showImg = '';
+                if(isEmpty(img)){
+                    showImg = url_path +"/"+ img;
+                }
+                $(this).find(".colorPictureMsg").attr("src",showImg);
+            }
+        });
+        if(noHaveColorId){
+            var index = layer.confirm('该颜色已被删除,点击确认恢复。', {
+                btn: ['确认','取消'] //按钮
+            }, function(){
+                color_is_update = 1;
+                add_color(1);
+                layer.closeAll();
+            }, function(){
+                colorClear();
+                layer.closeAll();
+            });
+        }
     }
+    $("#addColorHtml").hide();
+}
+
+
+/**
+ * 取消颜色
+ */
+function cancel_color() {
+    $(".add-color-button").val("添加");
+    $("#addColorHtml").hide();
+    color_is_update = 1;
+    $("#addColorHtml").find(".colorId").val("");
+    colorClear();
 }
 
 /**
@@ -78,22 +170,22 @@ function verificationColor() {
     var colorAbbreviation = $("#addColorHtml").find(".colorAbbreviation").val();
     var colorBar = $("#addColorHtml").find(".colorBar").val();
     var colorJdProductId = $("#addColorHtml").find(".colorJdProductId").val();
-    $("#add_color").find("tr").each(function () {
+    $("#add_color_id").find("tr").each(function () {
         var tdcolorName = $(this).find(".colorName").html();
         var tdcolorAbbreviation = $(this).find(".colorAbbreviation").html();
         var tdcolorBar = $(this).find(".colorBar").html();
         var tdcolorJdProductId = $(this).find(".colorJdProductId").html();
-        if(colorName == tdcolorName && colorAbbreviation == tdcolorAbbreviation){
+        if(colorName == tdcolorName && colorAbbreviation == tdcolorAbbreviation && color_is_update == 1){
             vailErrorMsg_3($("#addColorHtml").find(".colorName"),"请勿重复添加");
             flag = false;
             return false;
         }
-        if(colorBar == tdcolorBar){
+        if(colorBar == tdcolorBar  && color_is_update == 1){
             vailErrorMsg_3($("#addColorHtml").find(".colorBar"),"69码重复");
             flag = false;
             return false;
         }
-        if(isEmpty(tdcolorJdProductId) && colorJdProductId == tdcolorJdProductId){
+        if(isEmpty(tdcolorJdProductId) && colorJdProductId == tdcolorJdProductId  && color_is_update == 1){
             vailErrorMsg_3($("#addColorHtml").find(".colorJdProductId"),"京东SKU重复");
             flag = false;
             return false;
@@ -131,23 +223,29 @@ $(function(){
         },
         beforeSubmit: function (curform) {  //验证通过之后执行的函数
 
-            var colorList = new Array();
-            $("#add_color").find(".color_list").each(function(){
-                var color = new Object();
-                $(this).find("input").each(function(){
-                    var inputName = $(this).attr("name");
-                    color[inputName] = $(this).val()
-                });
+           if(!$("#addColorHtml").is(':hidden')){//表示显示
+               vailErrorMsg_3($("#addColorHtml"),"操作未完成,请‘确定’或者‘取消’颜色的更改。");
+               return false;
+           }
 
-                $(this).find("select").each(function(){
-                    var inputName = $(this).attr("name");
-                    color[inputName] = $(this).val()
-                });
+            var colorList = getColorList();
+            if(colorList == null || colorList.length < 1){
+                vailErrorMsg_3($("#add_color_id"),"至少需要一个颜色");
+                return false;
+            }
+            $("#colorListJson").val(JSON.stringify(colorList));
 
-                colorList.push(color);
+            var productAreaRelaStr = '';
+            $(".son_checkbox").each(function () {
+                if($(this).is(':checked')){
+                    if(productAreaRelaStr == ''){
+                        productAreaRelaStr = $(this).val();
+                    }else{
+                        productAreaRelaStr += ','+$(this).val();
+                    }
+                }
             });
-
-            $("#colorListJson").val(JSON.stringify(colorList));
+            $("#productAreaRelaStr").val(productAreaRelaStr);
 
             loadIndex = layer.load(1, {
                 shade: [0.5,'#fff'] //0.1透明度的白色背景
@@ -156,8 +254,8 @@ $(function(){
         callback: function (data) {//异步回调函数
             if (data) {
                 var index = layer.alert(data.resultMsg, function (index) {
-                    if (data.resultCode == 200) {
-                        location.href = url_path + "/admin/salesOrder/list_order_page";
+                    if (data.returnCode == 200) {
+                        location.href = url_path + "/admin/product/product_page";
                     }else {
                         layer.close(index);
                     }
@@ -171,13 +269,122 @@ $(function(){
     });
 });
 
+/**
+ * 获取颜色集合
+ */
+function getColorList(){
+    var colorList = new Array();
+    $("#add_color_id").find("tr").each(function(){
+        var color = new Object();
+        if(!isEmpty($(this).find(".colorName").html()) || !isEmpty($(this).find(".colorBar").html())){
+            return false;
+        }
+        var colorId = $(this).find(".colorId").val();
+        if(colorId.indexOf(update_color_id_suff) > -1){ //新加的颜色
+            color.isUpdate=2;  //是否修改过   1:修改过   2:未曾修改
+        }else{
+            color.colorId = colorId;
+            color.isUpdate = $(this).find(".isUpdate").val();
+        }
+        color.colorName = $(this).find(".colorName").html();
+        color.colorAbbreviation = cufte($(this).find(".colorAbbreviation").html());
+        color.colorDiscount = cufte($(this).find(".colorDiscount").html());
+        color.colorPrice = cufte($(this).find(".colorPrice").html());
+        color.colorBar = cufte($(this).find(".colorBar").html());
+        color.colorJdProductId = cufte($(this).find(".colorJdProductId").html());
+        color.colorIsWeight = cufte($(this).find(".colorIsWeight").html());
+        color.colorMode = cufte($(this).find(".colorMode").html());
+        color.colorPicture = cufte($(this).find(".colorPicture").val());
+        color.colorIsMachine = cufte($(this).find('.colorIsMachine').val());
+        color.colorStatus = cufte($(this).find('.colorStatus').val());
+        colorList.push(color);
+    });
+    return colorList;
+}
+
+/**
+ * 展示出添加color
+ */
+function show_add_color() {
+    $(".add-color-button").val("添加");
+    $("#addColorHtml").show();
+    color_is_update = 1;
+    $("#addColorHtml").find(".colorId").val("");
+    colorClear();
+}
+
+/**
+ *  清除color
+ */
+function colorClear() {
+    $(".str").val("");
+    $(".num").val(0);
+    var uploadHtml = '<div class="download_file"><a href="javascript:void(0)" class="del_product all_down" onclick="fileOnclick(this)">上传图片</a></div>';
+    $("#addColorHtml").find(".download_file").html(uploadHtml);
+    $("#addColorHtml").find(".colorPicture").val("");
+    $("#upload_color_img").change(function() {
+        fileUpload("upload_color_img");
+    });
+    $(".colorNoMachine").iCheck('check');
+    $(".colorIsStatus").iCheck('check');
+}
+
+/**
+ * 修改
+ */
+function updTr($this) {
+    $this = $this.parents("tr");
+    var $addColor = $("#addColorHtml");
+    $addColor.find(".colorId").val($this.find(".colorId").val());
+    $addColor.find(".colorName").val($this.find(".colorName").html());
+    $addColor.find(".colorAbbreviation").val($this.find(".colorAbbreviation").html());
+    $addColor.find(".colorDiscount").val($this.find(".colorDiscount").html());
+    $addColor.find(".colorPrice").val($this.find(".colorPrice").html());
+    $addColor.find(".colorBar").val($this.find(".colorBar").html());
+    $addColor.find(".colorJdProductId").val($this.find(".colorJdProductId").html());
+    $addColor.find(".colorIsWeight").val($this.find(".colorIsWeight").html());
+    $addColor.find(".colorMode").val($this.find(".colorMode").html());
+    var colorPicture = $this.find(".colorPicture").val();
+    var html ='';
+    if(isEmpty(colorPicture)){
+        html = '<div class="download_file"><img style="width: 75px;" src="' + url_path +"/"+ colorPicture + '"  class="" >&nbsp;&nbsp;<a href="javascript:void(0)" onclick="fileOnclick(this)">重新上传</a></div>';
+    }else{
+        html = '<div class="download_file"><a href="javascript:void(0)" class="del_product all_down" onclick="fileOnclick(this)">上传图片</a></div>';
+    }
+    $(".download_file").html(html);
+    $(".upload_color_class").find(".colorPicture").val(colorPicture);
+    $("#upload_color_img").change(function() {
+        fileUpload("upload_color_img");
+    });
+    var colorIsMachine = $this.find('.colorIsMachine').val();
+    if(colorIsMachine == 1){
+        $(".colorIsMachine").iCheck('check');
+    }else{
+        $(".colorNoMachine").iCheck('check');
+    }
+
+    var colorStatus = $this.find('.colorStatus').val();
+    if(colorStatus == 1){
+        $(".colorIsStatus").iCheck('check');
+    }else{
+        $(".colorNoStatus").iCheck('check');
+    }
+
+    $(".add-color-button").val("修改");
+    $("#addColorHtml").show();
+    color_is_update = 2;
+}
 
 /**
  *  删除商品
  */
 function delTr($this){
-    color.num++;
-    $this.parents("tr").remove();
+    var length= $("#add_color_id").find("tr").length;
+    if(length < 2){
+        vailErrorMsg_3($("#add_color_id"),"必须要要有一个颜色");
+    }else{
+        $this.parents("tr").remove();
+    }
 }
 
 function fileUpload(idValue) {