wangxiaoming hace 5 años
padre
commit
c87c812f2f

+ 23 - 1
watero-rst-core/src/main/java/com.iamberry.rst.core/order/Product.java

@@ -27,7 +27,7 @@ public class Product implements Serializable {
 
     private Integer productSalesnum;    //已售数量
 
-    private Integer productStatus;      //商品状态
+    private Integer productStatus;      //商品状态 1使用  2禁用
 
     private Date productCreateTime;     //创建时间
 
@@ -39,11 +39,17 @@ public class Product implements Serializable {
 
     private String typeName;            //产品类型名称
 
+    private String colorNameStr;            //颜色集合名称
+    private String colorName;            //颜色名称
+
     private Integer productIsDetection;  //是否需要售后检测 1 需要 2不需要
 
     //是否可批发 1:可批发 2:不可批发'
     private Integer productWholesale;
 
+    //应用场景
+//    private Integer productApplied; // 1,销售产品  2,维修产品
+
     private List<ProductColor> colorList = new ArrayList<ProductColor>();   //产品颜色集合
 
     private List<FittingsInfo> fittingsList = new ArrayList<FittingsInfo>();   //产品配件集合
@@ -160,6 +166,22 @@ public class Product implements Serializable {
         this.productIsDetection = productIsDetection;
     }
 
+    public String getColorNameStr() {
+        return colorNameStr;
+    }
+
+    public void setColorNameStr(String colorNameStr) {
+        this.colorNameStr = colorNameStr;
+    }
+
+    public String getColorName() {
+        return colorName;
+    }
+
+    public void setColorName(String colorName) {
+        this.colorName = colorName;
+    }
+
     @Override
     public String toString() {
         return "Product{" +

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

@@ -45,6 +45,8 @@ public class ProductColor implements Serializable {
 
     private Integer colorIsWeight;    //重量
 
+    private String colorMode;       //型号
+
     private String colorJdProductId;    //京东的sku
 
     private Integer colorIsMachine; //是否是水机 1:水机 2;其它产品
@@ -205,6 +207,14 @@ public class ProductColor implements Serializable {
         this.typeCompany = typeCompany;
     }
 
+    public String getColorMode() {
+        return colorMode;
+    }
+
+    public void setColorMode(String colorMode) {
+        this.colorMode = colorMode;
+    }
+
     @Override
     public String toString() {
         return "ProductColor{" +

+ 1 - 1
watero-rst-core/src/main/java/com.iamberry.rst.core/order/ProductType.java

@@ -25,7 +25,7 @@ public class ProductType implements Serializable {
 
     private Date typeUpdateTime;    //修改时间
 
-    private Integer typeStatus;     //状态
+    private Integer typeStatus;     //状态 1:可用;2:禁用',
 
     private Integer typeCompany;    // 所属商城
 

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

@@ -285,8 +285,13 @@
             t.product_remark,
             t.product_type,
             t.product_number,
-            t.product_wholesale
+            t.product_wholesale,
+            t.product_is_detection,
+            pt.type_name,
+            concat (GROUP_CONCAT(color_name)) AS colorNameStr
         from tb_rst_product_info t
+        LEFT JOIN tb_rst_product_type pt ON t.product_type = pt.type_id
+        LEFT JOIN tb_rst_product_color pc ON t.product_id = pc.color_product_id
         <where>
             <if test="productId != null ">
                 AND t.product_id = #{productId}
@@ -294,6 +299,9 @@
             <if test="productName != null and productName != ''">
                 AND t.product_name  like  CONCAT ('%',#{productName},'%')
             </if >
+            <if test="colorName != null and colorName != ''">
+                AND pc.color_name  like  CONCAT ('%',#{colorName},'%')
+            </if >
             <if test="productAbbreviation != null and productAbbreviation != ''">
                 AND t.product_abbreviation  like  CONCAT ('%',#{productAbbreviation},'%')
             </if >
@@ -309,7 +317,12 @@
             <if test="productWholesale != null ">
                 AND t.product_wholesale = #{productWholesale}
             </if >
+            <if test="productIsDetection != null ">
+                AND t.product_is_detection = #{productIsDetection}
+            </if >
         </where>
+        GROUP BY t.product_id
+        ORDER BY t.product_id DESC
     </select>
 
     <insert id="save" parameterType="Product"   useGeneratedKeys="true"  keyProperty="productId" >

+ 27 - 33
watero-rst-web/src/main/java/com/iamberry/rst/controllers/product/AdminProductController.java

@@ -8,6 +8,7 @@ import com.iamberry.rst.core.page.PagedResult;
 import com.iamberry.rst.faces.product.ProductColorService;
 import com.iamberry.rst.faces.product.ProductService;
 import com.iamberry.rst.utils.StitchAttrUtil;
+import com.iamberry.rst.utils.UploadFileUtils;
 import com.iamberry.wechat.tools.ResponseJson;
 import com.iamberry.wechat.tools.ResultInfo;
 import net.sf.json.JSONArray;
@@ -78,7 +79,13 @@ public class AdminProductController {
             pagedResult.setTotal(totalNum);
         }
 
+        ProductType productType = new ProductType();
+        productType.setTypeStatus(1);
+        List<ProductType> productTypeList = productService.listProductType(productType);
+        mv.addObject("productTypeList",productTypeList);
+
         StitchAttrUtil.getSa()
+                .addNoPro("colorList","fittingsList")
                 .setModelAndView(product, mv, "/admin/product/product_page", pagedResult);
         return mv;
     }
@@ -177,51 +184,38 @@ public class AdminProductController {
         return mv;
     }
 
-
     /**
-     * 上传零件图片
-     * 通过流的方式上传文件
+     * 上传设计文件
      * @RequestParam("file") 将name=file控件得到的文件封装成CommonsMultipartFile 对象
      */
     @ResponseBody
     @RequestMapping("/fileUpload")
-    public ResponseJson  fileUpload(HttpServletRequest request,@RequestParam("file") CommonsMultipartFile file) throws IOException {
+    public ResponseJson fileUpload(HttpServletRequest request, @RequestParam("file") CommonsMultipartFile file) throws IOException {
         ResponseJson responseJson = new ResponseJson();
         System.out.println("fileName:"+file.getOriginalFilename());
-        //获取项目根目录
-        WebApplicationContext webApplicationContext = ContextLoader.getCurrentWebApplicationContext();
-        ServletContext servletContext = webApplicationContext.getServletContext();
-        String realPath = servletContext.getRealPath(ResultInfo.COLOR_IMAGE)+"/";
-        String suffix = file.getOriginalFilename().substring(file.getOriginalFilename().toString().lastIndexOf("."));
-        String imgUrl = System.currentTimeMillis()+suffix;
-        try {
 
-            File targetFile = new File(realPath);
-            if (!targetFile.exists()) {
-                targetFile.mkdirs();
-            }
+        String realPath = request.getSession().getServletContext().getRealPath("/");
 
-            //获取输出流
-            OutputStream os=new FileOutputStream(realPath+imgUrl);
+        if(file.getOriginalFilename() == null || "".equals(file.getOriginalFilename())){
+            responseJson.setReturnCode(500);
+            return responseJson;
+        }
 
-            //获取输入流 CommonsMultipartFile 中可以直接得到文件的流
-            InputStream is=file.getInputStream();
-            byte[] bts = new byte[1024];
-            //一个一个字节的读取并写入
-            while(is.read(bts)!=-1)
-            {
-                os.write(bts);
-            }
-            os.flush();
-            os.close();
-            is.close();
+        String oldName = file.getOriginalFilename();
+
+        //名称
+        String suffix = file.getOriginalFilename().substring(file.getOriginalFilename().toString().lastIndexOf("."));
+        String name = System.currentTimeMillis()+suffix;
+
+        String path = UploadFileUtils.productImgUploadFile(realPath,name,file);
+
+        String url = request.getScheme()+"://"+ request.getServerName();
 
-        } catch (FileNotFoundException e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
-        }
         responseJson.setReturnCode(200);
-        responseJson.addResponseKeyValue("imgUrl",ResultInfo.COLOR_IMAGE+"/"+imgUrl);
+        responseJson.addResponseKeyValue("allImgUrl",url + "/" + path);
+        responseJson.addResponseKeyValue("imgUrl",path);
+        responseJson.addResponseKeyValue("oldName",oldName);
+        responseJson.addResponseKeyValue("name",name);
         return responseJson;
     }
 

+ 14 - 0
watero-rst-web/src/main/java/com/iamberry/rst/utils/UploadFileUtils.java

@@ -21,6 +21,7 @@ public class UploadFileUtils {
         map.put("scmOrder","scmOrder");
         map.put("eiInvo","eiInvo");
         map.put("cm","cm");
+        map.put("product","product");
     };
 
     /**
@@ -127,5 +128,18 @@ public class UploadFileUtils {
         return path;
     }
 
+    /**
+     * 订单-产品管理-产品图片
+     * path  : common/upload/yyyyMMdd/
+     * @param name
+     * @param file
+     * @return
+     */
+    public static String productImgUploadFile(String rootPathh, String name, CommonsMultipartFile file){
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
+        String soonPath = "/color/"+ sdf.format(new Date()) + "/";
+        String path = UploadFileUtils.getUf().upload("product",rootPathh,soonPath,name,file);
+        return path;
+    }
 
 }

+ 2 - 2
watero-rst-web/src/main/webapp/WEB-INF/views/cm/question/question_list.ftl

@@ -75,9 +75,9 @@
             </select>
 
 
-            <input type="text" class="my-input trim_input"  style="width:120px;margin-right: 0px; margin-bottom: 10px;" value="${complaintQuestionInfo.questionName!}" placeholder="问题名称" id="questionName" name="questionName">
+            <input type="text" class="my-input trim_input"  style="width:120px;margin-right: 0px; margin-bottom: 8px;" value="${complaintQuestionInfo.questionName!}" placeholder="问题名称" id="questionName" name="questionName">
 
-            <button type="submit" class="btn" style="background: #50a2ea;border: 1px solid #50a2ea;color: #fff;height: 35px;margin-top: -8px;margin-bottom: 3px;"><i class="Hui-iconfont">&#xe665;</i> 查询</button>
+            <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>
 
         </form>
     </div>

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

@@ -34,8 +34,7 @@
         .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: 150px;}
-
+        .col-sm-1{width: 10%;}
         .all_down{text-decoration: underline;color: #00c;}
     </style>
     <title>添加产品 - 产品管理 - RST</title>
@@ -62,18 +61,18 @@
             </div>
 
             <div class="row cl" id="" style="">
-                <label class="form-label col-1 col-sm-1">产品名称:</label>
+                <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="" placeholder="填写产品名称" id="productName" name="productName" datatype="*1-32" errormsg="产品名称格式不正确!" >
+                    <input type="text" class="input-text" value="" placeholder="填写产品名称" id="productName" name="productName" datatype="*1-32" errormsg="产品名称格式只支持1-32个字符!" >
                 </div>
-                <label class="form-label col-1 col-sm-1">产品简称:</label>
+                <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="" placeholder="填写产品简称" id="productAbbreviation" name="productAbbreviation" datatype="*1-15" errormsg="产品简称格式不正确!">
+                    <input type="text" class="input-text" value="" 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">产品类型:</label>
+                <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" >
@@ -93,18 +92,34 @@
             </div>
 
             <div class="row cl">
-                <label class="form-label col-1 col-sm-1">是否可批发:</label>
-                <div class="formControls col-2 col-sm-2" style="">
-                    <span class="select-box">
-                        <select class="select" id="productWholesale" name="productWholesale" >
-                            <option value="1" >可批发</option>
-                            <option value="2" >不可批发</option>
-                        </select>
-				    </span>
+                <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" >
+                        <label for="productWholesale-1">可批发</label>
+                    </div>
+                    <div class="radio-box">
+                        <input type="radio" id="productWholesale-2" name="productWholesale" value="2" checked>
+                        <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" >
+                           <label for="productIsDetection-1">需要</label>
+                       </div>
+                       <div class="radio-box">
+                           <input type="radio" id="productIsDetection-2" name="productIsDetection" value="2" checked>
+                           <label for="productIsDetection-2">不需要</label>
+                       </div>
+                   </div>
+            </div>
+
+            <div class="row cl">
                 <label class="form-label col-1 col-sm-1">产品备注:</label>
-                <div class="formControls col-2 col-sm-2" style="">
+                <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>
             </div>
@@ -117,34 +132,111 @@
                 </div>
             </div>
 
-            <div class="row cl" id="" style="">
-                <label class="form-label col-1 col-sm-1">颜色信息:</label>
-                <div class="formControls col-8 col-sm-8">
-                    <input type="button" class="btn btn-primary add-order-button" onclick="add_color()" value="添加商品" >
+            <div class="row cl" id="" style="margin-left: 25px;">
+                <div class="formControls col-11 col-sm-11">
+
                     <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 style="text-align: center;" width="30" >颜色名称</th>
-                                <th style="text-align: center;" width="25" >颜色简称</th>
+                                <th style="text-align: center;" width="30" ><span class="c-red">*</span>颜色名称</th>
+                                <th style="text-align: center;" width="30" ><span class="c-red">*</span>颜色简称</th>
                                 <th style="text-align: center;" width="10">售价</th>
                                 <th style="text-align: center;" width="10">原价</th>
-                                <th style="text-align: center;" width="10">69码</th>
-                                <th style="text-align: center;" width="10">重量(g)</th>
-                                <th style="text-align: center;" width="10">是否为水机</th>
-                                <th style="text-align: center;" width="10">图片</th>
-                                <th style="text-align: center;" width="10">操作</th>
+                                <th style="text-align: center;" width="30"><span class="c-red">*</span>69码</th>
+                                <th style="text-align: center;" width="30">京东SKU</th>
+                                <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="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>
                     </table>
-                    <input type="hidden" id="colorListJson" name="colorListJson" value="" >
+
                 </div>
             </div>
 
+            <div id="addColorHtml">
+                <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个字符!" >
+                    </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个字符!">
+                    </div>
+                </div>
 
-            <div class="row cl">
+                <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)">
+                    </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)">
+                    </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个字符!" >
+                    </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个字符!">
+                    </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)" >
+                    </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个字符!">
+                    </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 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" 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>
+                            <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>
+            </div>
+
+            <input type="hidden" id="colorListJson" name="colorListJson" 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>
@@ -166,6 +258,8 @@
         radioClass: 'iradio-blue',
         increaseArea: '20%'
     });
+
+    var isHaveColorList = 2; //是否已经有颜色   2没有  1 含有
 </script>
 
 <script type="text/javascript" charset="utf-8" src="${path}/common/js/product/product.js"></script>

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

@@ -31,15 +31,30 @@
 </nav>
 <div class="page-container">
     <div class="text-c">
-        <form action="${path}/admin/order_batch/batch_list" method="post">
+        <form action="${path}/admin/product/product_page" method="post">
 
             <div style="position: relative;float: left;display: block;width: 110px;height: 30px;" id="addOrderDiv" >
                 <button type="button" style="cursor:pointer" class="my-btn-search my-order" id="addProduct" onclick="to_add()" >添加产品</button>
             </div>
 
-            <#--<input type="text" class="my-input trim_input"  style="margin-top: -3px;width:118px;margin-right: 0px;height: 28px;padding: 0px;" value="${orderBatch.batchId!}" placeholder="批次编号" name="batchId" id="batchId">-->
+            <select class="my-select" name="productType" id="productType" style="height: 36px;width: 132px;margin: 0px;padding: 12px 10px 6px 15px;margin-bottom: 10px;">
+                <option value="">产品分类</option>
+                <#list productTypeList as productType>
+                    <option value="${productType.typeId}"  <#if product.productType??><#if product.productType == productType.typeId >selected="selected"</#if></#if> >${productType.typeName}</option>
+                </#list>
+            </select>
 
-             <button type="submit" class="my-btn-search" style="" id="" name=""><i class="Hui-iconfont">&#xe665;</i> 搜索</button>
+            <select class="my-select" name="productStatus" id="productStatus" style="height: 36px;width: 132px;margin: 0px;padding: 12px 10px 6px 15px;margin-bottom: 10px;">
+                <option value="">状态</option>
+                <option value="1" <#if product.productStatus??><#if product.productStatus == 1 >selected="selected"</#if></#if>>使用</option>
+                <option value="2" <#if product.productStatus??><#if product.productStatus == 2 >selected="selected"</#if></#if>>禁用</option>
+            </select>
+
+            <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">
+
+
+            <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>
 
         </form>
     </div>
@@ -48,13 +63,12 @@
         <table class="table table-border table-bordered table-bg table-hover table-sort">
             <thead>
                 <tr class="text-c">
+                    <th width="50">类型</th>
                     <th width="100">名称</th>
-                    <th width="80">简称</th>
-                    <th width="50">状态</th>
                     <th width="50">颜色</th>
-                    <th width="50">类型</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>
                     <th width="80">操作</th>
                 </tr>
@@ -63,16 +77,36 @@
             <#if page.dataList?? &&  (page.dataList?size > 0) >
                     <#list page.dataList as product>
                         <tr class="text-c">
+                            <td>${product.typeName!''}</td>
                             <td>${product.productName!''}</td>
-                            <td>${product.productAbbreviation!''}</td>
-                            <td>${product.productStatus!''}</td>
-                            <td></td>
-                            <td>${product.productType!''}</td>
-                            <td>${product.productNumber!''}</td>
-                            <td>${product.productRemark!''}</td>
+                            <td>${product.colorNameStr!''}</td>
+                            <td>
+                                <#if product.productWholesale == 1>
+                                    可批发
+                                <#elseif product.productWholesale == 2>
+                                    不可批发
+                                </#if>
+                            </td>
+                            <td>
+                                <#if product.productIsDetection == 1>
+                                    需要
+                                <#elseif product.productIsDetection == 2>
+                                    不需要
+                                </#if>
+                            </td>
+                            <td>
+                                <#if product.productStatus == 1>
+                                    使用
+                                <#elseif product.productStatus == 2>
+                                    禁用
+                                </#if>
+                            </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="update('${product.productId!''}')">
+                                <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!''}')">
                                     修改
                                 </a>
                             </td>

+ 7 - 0
watero-rst-web/src/main/webapp/common/js/common/common.js

@@ -199,6 +199,13 @@ function vailErrorMsg_1(node,msg){
     vailErrorMsg(node,msg,1000);
 }
 /**
+ * 1000毫秒的提示信息
+ * 用于展示错误信息,并让该节点得到焦点
+ */
+function vailErrorMsg_3(node,msg){
+    vailErrorMsg(node,msg,3000);
+}
+/**
  * 5000表的提示信息
  * 用于展示错误信息,并让该节点得到焦点
  */

+ 107 - 41
watero-rst-web/src/main/webapp/common/js/product/product.js

@@ -1,50 +1,114 @@
 
-var colorNum = "COLOR_NUM";
-
-var color = new Object();
-color.num = 0;  //标志颜色数量
-color.html = '<tr class="color_list">'
-            + '<td style="text-align: center;" width="30" > <input type="text" class="input-text input-number item-num" value="" name="colorName" id="" placeholder="颜色名称"  datatype="*1-32" errormsg="颜色名称格式不正确!"></td>'
-            + '<td style="text-align: center;" width="25" ><input type="text" class="input-text input-number item-num" value="" name="colorAbbreviation" id="" placeholder="颜色简称"  datatype="*1-15" errormsg="颜色简称格式不正确!"></td>'
-            + '<td style="text-align: center;" width="10"><input type="text" class="input-text input-number item-num" value="0" name="colorDiscount" id=""  style="width: 100%;text-align: center;" placeholder="售价" onkeyup="keyFun($(this),9999,1)" onpaste="keyFun($(this),9999,1)"></td>'
-            + '<td style="text-align: center;" width="10"><input type="text" class="input-text input-number item-num" value="0" name="colorPrice" id=""  style="width: 100%;text-align: center;" placeholder="原价" onkeyup="keyFun($(this),9999,1)" onpaste="keyFun($(this),9999,1)"></td>'
-            + '<td style="text-align: center;" width="10"><input type="text" class="input-text input-number item-num" value="" name="colorBar" id="" placeholder="69码"  datatype="*1-20" errormsg="69码格式不正确!"></td>'
-            + '<td style="text-align: center;" width="10"><input type="text" class="input-text input-number item-num" value="0" name="colorIsWeight" id=""  style="width: 100%;text-align: center;"  placeholder="重量" onkeyup="keyFun($(this),9999,1)" onpaste="keyFun($(this),9999,1)"></td>'
-            + '<td style="text-align: center;" width="10"><select class="select" id="" name="colorIsMachine" ><option value="2" >否</option><option value="1" >是</option></select></td>'
-            + '<td style="text-align: center;" width=""><input type="file" class="color_file" name="file" id="fileId_'+ colorNum +'" style="display: none">'
-            + '<div class="download_file"><a href="javascript:void(0)" class="del_product all_down" num="'+ num +'" onclick="fileOnclick(this)">上传图片</a></div>'
-            + '<input class="colorPicture" name="colorPicture" id="xxx" value="" style="display: none;"></td>'
-            + '<td style="text-align: center;" width="10">&nbsp;&nbsp;<a href="javascript:void(0)" class="del_product all_down" onclick="delTr($(this))" >删除</a></td>'
-            + '</tr>';
-
 /**
- *
+ * 添加颜色
  */
-function getColorHtml(){
-    return color.html.replace(colorNum,color.num);
+function add_color(){
+    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 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;
+    }else{
+        $("#add_color").append(colorHtml);
+    }
 }
 
 /**
- * 添加颜色
+ * 验证
  */
-function add_color(){
-    color.num++;
-    $("#add_color").append(getColorHtml());
+function verificationColor() {
+    var flag = true;
+    $("#addColorHtml").find(".add_color").each(function () {
+        var $node = $(this);
+        var myValue = $node.val();
+        var myMinlength = $node.attr("myMinlength");
+        if(!isEmpty(myMinlength)){
+            myMinlength = 0;
+        }
+        if(!isEmpty(myValue) && myMinlength != 0){
+            vailErrorMsg_3($(this),$(this).attr("errormsg"));
+            flag = false;
+            return false;
+        }
+        var myMaxlength = $node.attr("myMaxlength");
+        if(isEmpty(myMaxlength)){
+            if(myValue.length > myMaxlength){
+                vailErrorMsg_3($(this),$(this).attr("errormsg"));
+                flag = false;
+                return false;
+            }
+        }
+    });
 
-    $("#fileId_"+color.num).change(function() {
-        fileUpload("fileId_"+color.num);
+    //判断是否有sku相等,京东69码相等,名称与简称相等
+    var colorName = $("#addColorHtml").find(".colorName").val();
+    var colorAbbreviation = $("#addColorHtml").find(".colorAbbreviation").val();
+    var colorBar = $("#addColorHtml").find(".colorBar").val();
+    var colorJdProductId = $("#addColorHtml").find(".colorJdProductId").val();
+    $("#add_color").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){
+            vailErrorMsg_3($("#addColorHtml").find(".colorName"),"请勿重复添加");
+            flag = false;
+            return false;
+        }
+        if(colorBar == tdcolorBar){
+            vailErrorMsg_3($("#addColorHtml").find(".colorBar"),"69码重复");
+            flag = false;
+            return false;
+        }
+        if(isEmpty(tdcolorJdProductId) && colorJdProductId == tdcolorJdProductId){
+            vailErrorMsg_3($("#addColorHtml").find(".colorJdProductId"),"京东SKU重复");
+            flag = false;
+            return false;
+        }
     });
+    return flag;
 }
 
 function fileOnclick(node){
-    $(node).parent().siblings('.color_file').click();
+    $(node).parents(".upload_color_class").find('.color_file').click();
 }
 
 $(function(){
-    $("#add_color").append(getColorHtml());
-
-    $("#fileId_0").change(function() {
-        fileUpload("fileId_0");
+    $("#upload_color_img").change(function() {
+        fileUpload("upload_color_img");
     });
 });
 
@@ -118,19 +182,21 @@ function delTr($this){
 
 function fileUpload(idValue) {
     $.ajaxFileUpload({
-        url:"/admin/product/fileUpload",
-        secureuri:false,
-        fileElementId : idValue,//文件选择框的id属性/名称
+        url: url_path + "/admin/product/fileUpload",
+        secureuri: false,
+        fileElementId: idValue,//文件选择框的id属性/名称
         dataType: 'json',   //json
         success: function (data) {
-            if(data.returnCode == 200){
-                var html = '<img style="width: 75px;" src="'+ url_path + data.returnMsg.imgUrl +'"  class="del_product all_down" onclick="fileOnclick(this)">';
-                $("#"+idValue).parent().find(".download_file").html(html);
-                // $("#"+idValue).parent().find(".colorPicture").val(data.returnMsg.imgUrl);
-
-            }             $("#xxx").val(data.returnMsg.imgUrl);
+            if (data.returnCode == 200) {
+                var html = '<div><img style="width: 75px;" src="' + url_path +"/"+ data.returnMsg.imgUrl + '"  class="del_product all_down " >&nbsp;&nbsp;<a href="javascript:void(0)" onclick="fileOnclick(this)">重新上传</a></div>';
+                $("#" + idValue).parent().find(".download_file").html(html);
+                $("#"+idValue).parent().find(".colorPicture").val(data.returnMsg.imgUrl);
+                $("#upload_color_img").change(function() {
+                    fileUpload("upload_color_img");
+                });
             }else{
                 layer.msg('上传失败,请重试!',{icon: 5,time:2000});
             }
         }
     });
+}