浏览代码

产品管理

wangxiaoming 6 年之前
父节点
当前提交
6ea6170c36

+ 5 - 0
watero-common-tool/src/main/java/com/iamberry/wechat/tools/ResultInfo.java

@@ -89,6 +89,11 @@ public class ResultInfo {
 	public static String PARTS_IMAGE = "/common/images/uploadimages";
 
 	/**
+	 * 颜色图片保存路径
+	 */
+	public static String COLOR_IMAGE = "/common/images/productUpload/";
+
+	/**
 	 * 上传审批合同图片保存路径
 	 */
 	public static String CONTRACT_IMAGE = "/common/images/contractimages/";

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

@@ -21,6 +21,8 @@ public class ProductColor implements Serializable {
 
     private String colorName;       //颜色名称
 
+    private String colorAbbreviation;   //颜色简称
+
     private Integer colorDiscount;  //产品折扣价
 
     private Integer colorPrice;     //产品市场价
@@ -165,6 +167,14 @@ public class ProductColor implements Serializable {
         this.colorIsMachine = colorIsMachine;
     }
 
+    public String getColorAbbreviation() {
+        return colorAbbreviation;
+    }
+
+    public void setColorAbbreviation(String colorAbbreviation) {
+        this.colorAbbreviation = colorAbbreviation;
+    }
+
     @Override
     public String toString() {
         return "ProductColor{" +

+ 24 - 20
watero-rst-service/src/main/java/com/iamberry/rst/service/cm/CustomerServiceImpl.java

@@ -1416,27 +1416,31 @@ public class CustomerServiceImpl implements CustomerService {
                 break;
         }
 
-        RelationOrder relationOrder = new RelationOrder();
-        relationOrder.setRelationType(customerCommon.getCustomerIsSolve());
-        relationOrder.setRelationId(customerCommon.getRelationId());
-        List<RelationOrder> relationOrderList = relationOrderService.getRelationOrderList(relationOrder);
-        if(relationOrderList != null && relationOrderList.size() > 0){
-            String[] salesIds = new String[relationOrderList.size()];
-            for (int k=0; k<relationOrderList.size();k++){
-                salesIds[k] = String.valueOf(relationOrderList.get(k).getSalesId());
-            }
-            SalesOrder so = new SalesOrder();
-            so.setSalesIds(salesIds);
-            List<SalesOrder> orderList = salesOrderMapper.listSalesOrder(so);
-            if (orderList != null && orderList.size() > 0) {
-                SalesOrder order = orderList.get(0);
-                SalesOrderItem salesOrderItem = new SalesOrderItem();
-                salesOrderItem.setItemOrderId(order.getSalesId());
-                order.setSalesOrderItemList(salesOrderMapper.listSalesOrderItem(salesOrderItem));
-            } else {
-                map.put("orderList",null);
+        if(customerCommon != null && customer.getCustomerIsSolve() != null && (customer.getCustomerIsSolve() == 3 || customer.getCustomerIsSolve() == 4 ||
+        customer.getCustomerIsSolve() == 5 || customer.getCustomerIsSolve() == 6 || customer.getCustomerIsSolve() == 7)
+                ){
+            RelationOrder relationOrder = new RelationOrder();
+            relationOrder.setRelationType(customerCommon.getCustomerIsSolve());
+            relationOrder.setRelationId(customerCommon.getRelationId());
+            List<RelationOrder> relationOrderList = relationOrderService.getRelationOrderList(relationOrder);
+            if(relationOrderList != null && relationOrderList.size() > 0){
+                String[] salesIds = new String[relationOrderList.size()];
+                for (int k=0; k<relationOrderList.size();k++){
+                    salesIds[k] = String.valueOf(relationOrderList.get(k).getSalesId());
+                }
+                SalesOrder so = new SalesOrder();
+                so.setSalesIds(salesIds);
+                List<SalesOrder> orderList = salesOrderMapper.listSalesOrder(so);
+                if (orderList != null && orderList.size() > 0) {
+                    SalesOrder order = orderList.get(0);
+                    SalesOrderItem salesOrderItem = new SalesOrderItem();
+                    salesOrderItem.setItemOrderId(order.getSalesId());
+                    order.setSalesOrderItemList(salesOrderMapper.listSalesOrderItem(salesOrderItem));
+                } else {
+                    map.put("orderList",null);
+                }
+                map.put("orderList",orderList);
             }
-            map.put("orderList",orderList);
         }
         map.put("customerCommon",customerCommon);
         return map;

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

@@ -864,7 +864,10 @@
         sales_add_type = #{salesAddType},
       </if >
       <if test="salesAdminId != null ">
-        sales_admin_id = #{salesAdminId}
+        sales_admin_id = #{salesAdminId},
+      </if >
+      <if test="salesCustomerId != null ">
+          sales_customer_id = #{salesCustomerId}
       </if >
     </set >
     where sales_id= #{salesId}

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

@@ -9,10 +9,12 @@ 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.ProductColorMapper;
 import com.iamberry.rst.service.product.mapper.ProductMapper;
 import com.iamberry.rst.util.PageUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.*;
 
@@ -27,6 +29,8 @@ import java.util.*;
 public class ProductServiceImpl implements ProductService {
     @Autowired
     private ProductMapper productMapper;
+    @Autowired
+    private ProductColorMapper productColorMapper;
 
     @Override
     public List<OrderGift> listGift() {
@@ -179,9 +183,26 @@ public class ProductServiceImpl implements ProductService {
      * @return Integer
      */
     @Override
+    @Transactional
     public  Integer  save(Product  product){
-        return  productMapper.save(product);
+        Integer flag = 0;
+        flag = productMapper.save(product);
+        if(flag < 1){
+            throw new RuntimeException("添加产品失败");
+        }
+
+        List<ProductColor> productColorList = product.getColorList();
+        for (ProductColor productColor : productColorList) {
+            productColor.setColorProductId(product.getProductId());
+        }
+        flag = productColorMapper.saveList(productColorList);
+        if(flag < 1){
+            throw new RuntimeException("添加颜色集合失败");
+        }
+        return  flag;
     }
+
+
     /**
      * 修改数据
      * @param  product

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

@@ -294,10 +294,11 @@
         </where>
     </select>
 
-    <insert id="save" parameterType="Product" >
+    <insert id="save" parameterType="Product"   useGeneratedKeys="true"  keyProperty="productId" >
         insert into
         tb_rst_product_info
         (
+        product_id,
         product_name,
         product_abbreviation,
         product_salesnum,
@@ -309,6 +310,7 @@
         )
         values
         (
+        #{productId},
         #{productName},
         #{productAbbreviation},
         #{productSalesnum},

+ 96 - 5
watero-rst-web/src/main/java/com/iamberry/rst/controllers/product/AdminProductController.java

@@ -3,10 +3,14 @@ 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.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.wechat.tools.ResponseJson;
+import com.iamberry.wechat.tools.ResultInfo;
+import net.sf.json.JSONArray;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -15,9 +19,14 @@ import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.context.ContextLoader;
+import org.springframework.web.context.WebApplicationContext;
+import org.springframework.web.multipart.commons.CommonsMultipartFile;
 import org.springframework.web.servlet.ModelAndView;
 
+import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServletRequest;
+import java.io.*;
 import java.text.SimpleDateFormat;
 import java.util.List;
 
@@ -38,6 +47,8 @@ public class AdminProductController {
 
     @Autowired
     private ProductService productService;
+    @Autowired
+    private ProductColorService productColorService;
 
 
     @ResponseBody
@@ -81,7 +92,7 @@ public class AdminProductController {
     @RequiresPermissions("salesOrder:save:product")
     @RequestMapping("/to_add_product")
     public ModelAndView toAddProduct(HttpServletRequest request) {
-        ModelAndView mv = new ModelAndView("product/product_list");
+        ModelAndView mv = new ModelAndView("product/add_product");
 
         return mv;
     }
@@ -91,12 +102,49 @@ public class AdminProductController {
      * @param request
      * @return
      */
+    @ResponseBody
     @RequiresPermissions("salesOrder:save:product")
     @RequestMapping("/add_product")
-    public ModelAndView addProduct(HttpServletRequest request) {
-        ModelAndView mv = new ModelAndView("product/product_list");
+    public ResponseJson addProduct(HttpServletRequest request,Product product,String colorListJson) {
+        ResponseJson rj = new ResponseJson();
+        if(product == null){
+            rj = ResponseJson.getFAILURE();
+        }
+        product.setProductSalesnum(0);
+        product.setProductStatus(1);
+        JSONArray jsonArray = JSONArray.fromObject(colorListJson);
+        List<ProductColor> productColorList =  (List) JSONArray.toCollection(jsonArray, ProductColor.class);
 
-        return mv;
+        product.setColorList(productColorList);
+
+        productService.save(product);
+
+        return rj;
+    }
+
+    /**
+     * 验证产品信息
+     * @param product
+     * @return
+     */
+    private String verification(Product product){
+        String msg = "";
+        if(product.getProductName() == null ||  "".equals(product.getProductName())){
+            msg = "产品名称不能为空";
+            return msg;
+        }
+
+        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;
+            }
+        }
+        return msg;
     }
 
 
@@ -109,7 +157,9 @@ public class AdminProductController {
     @RequestMapping("/to_update_product")
     public ModelAndView toUpdateProduct(HttpServletRequest request) {
         ModelAndView mv = new ModelAndView("product/product_list");
-
+        ProductType productType = new ProductType();
+        List<ProductType> productTypeList = productService.listProductType(productType);
+        mv.addObject("productTypeList",productTypeList);
         return mv;
     }
 
@@ -125,4 +175,45 @@ public class AdminProductController {
         return mv;
     }
 
+
+    /**
+     * 上传零件图片
+     * 通过流的方式上传文件
+     * @RequestParam("file") 将name=file控件得到的文件封装成CommonsMultipartFile 对象
+     */
+    @ResponseBody
+    @RequestMapping("/fileUpload")
+    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 imgUrl = System.currentTimeMillis() + file.getOriginalFilename();
+        try {
+            //获取输出流
+            OutputStream os=new FileOutputStream(realPath+imgUrl);
+
+            //获取输入流 CommonsMultipartFile 中可以直接得到文件的流
+            InputStream is=file.getInputStream();
+            byte[] bts = new byte[1024];
+            //一个一个字节的读取并写入
+            while(is.read(bts)!=-1)
+            {
+                os.write(bts);
+            }
+            os.flush();
+            os.close();
+            is.close();
+
+        } catch (FileNotFoundException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        responseJson.setReturnCode(200);
+        responseJson.addResponseKeyValue("imgUrl",ResultInfo.COLOR_IMAGE+imgUrl);
+        return responseJson;
+    }
+
 }

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

@@ -124,7 +124,7 @@
                             + ' <td width="100">'
                             + ' <table class="table table-border table-bg table-bordered">'
                             + ' <tbody id="">'
-                            + ' <tr class="text-c"><td width="16">产品名称</td><td width="16">总数</td><td width="16">已发货</td><td width="16">已出库</td><td width="16">未出库</td></tr>';
+                            + ' <tr class="text-c"><td width="16">产品名称</td><td width="16">总数</td><td width="16">已打单</td><td width="16">已出库</td><td width="16">未出库</td></tr>';
                     if(list.length < 1 ){
                         html += '<tr class="text-c">'
                                 + '<td width="16" colspan="5">暂无数据</td>'

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

@@ -115,7 +115,9 @@
             <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">
+                    ${order.salesBatchId!''}
+                    <input type="hidden" id="salesBatchId" name="salesBatchId" value="${order.salesBatchId!''}">
+                    <#--<span class="select-box">
                         <select class="select" id="salesBatchId" name="salesBatchId" >
                             <option value="1" >新增批次</option>
                                 <#if order.salesBatchId??>
@@ -124,7 +126,7 @@
                                     </#list>
                                 </#if>
                         </select>
-				    </span>
+				    </span>-->
                 </div>
             </div>
 

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

@@ -63,142 +63,77 @@
                 </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="">
-                    <span class="select-box">
-                        <select class="select" id="salesBatchId" name="salesBatchId" >
-                            <option value="1" >新增批次</option>
-                        <#--<#list orderBatchs as orderBatch>-->
-                            <#--<option value="${orderBatch.batchId}" >${orderBatch.batchId}</option>-->
-                        <#--</#list>-->
-                        </select>
-				    </span>
-                </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" value="" placeholder="填写产品名称" id="productName" name="productName" datatype="*1-32" errormsg="产品名称格式不正确!" >
                 </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" value="" placeholder="填写产品简称" id="productAbbreviation" name="productAbbreviation" datatype="*1-15" errormsg="产品简称格式不正确!">
                 </div>
             </div>
 
-
-            <div class="row cl" id="recipientAddressText" style="">
-                <label class="form-label col-1 col-sm-1"></label>
-                <div class="formControls col-6 col-sm-6">
-                    <textarea name="addressDesc" style="height: 50px;" id="addressDesc" cols="" rows="2" datatype="*" errormsg="收货地址不正确!" class="textarea" placeholder="请填写详细地址,最多支持50字符" onKeyUp="$.Huitextarealength(this,50)"></textarea>
-                    <span id="addrssMsg"></span>
-                </div>
-                <input type="hidden" name="salesAddressInfo" id="salesAddressInfo" value="">
-            </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" placeholder="购买日期" id="salesPayTime"  name="salesPayTime" datatype="*" class="input-text Wdate" onclick="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd HH:mm:ss',maxDate: '%y-%M-%d'})"  readonly="readonly">
-                </div>
-                <label class="form-label col-2 col-sm-2">支付方式:</label>
+            <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="salesPayType" name="salesPayType">
-                            <#--1:微信支付 2:现金支付3:已支付定金¥99 4:刷卡支付 5:支付宝支付-->
-                                <option value="1">微信支付</option>
-                            <option value="2">现金支付</option>
-                            <option value="4">刷卡支付</option>
-                            <option value="5">支付宝支付</option>
+                        <select class="select" id="salesBatchId" name="salesBatchId" >
+                            <#list productTypeList as productType>
+                                <option value="${productType.typeId}" >${productType.typeName}</option>
+                            </#list>
                         </select>
 				    </span>
                 </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="">
-                <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_product()" value="添加商品" >
-                    <table class="table table-border table-bg table-bordered" style="margin-top: 10px;display: none" 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="10">售价</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>
-                        </tr>
-                        </thead>
-                        <tbody id="add_product">
-                        </tbody>
-                    </table>
-                    <input type="hidden" id="orderItemString" name="orderItemString" value="" >
+                <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="产品型号格式不正确!">
                 </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" value="" placeholder="总金额" datatype="*" errormsg="必须要输入总金额!" id="salesAmount" name="salesAmount"  >
-                </div>
-                <label class="form-label col-2 col-sm-2">实付金额:</label>
-                <div class="formControls col-2 col-sm-2">
-                    <input type="text" class="input-text" value="0" placeholder="实付金额" datatype="*" errormsg="必须要输入总金额!" id="salesPayMoney" name="salesPayMoney"  >
-                </div>
-                <div class="formControls col-2 col-sm-2" style="display: none">
-                    <input type="text" class="input-text" value="0" placeholder="优惠金额" datatype="*" errormsg="必须要输入总金额!" id="salesDiscountMoney" name="salesDiscountMoney"  >
-                </div>
-
-                <div class="formControls col-2 col-sm-2">
-                    <input type="button" style="width: 100%;" class="btn btn-primary add-order-button" onclick="calculatePrice()" value="计算商品总价" >
+                <label class="form-label col-1 col-sm-1">备注:</label>
+                <div class="formControls col-6 col-sm-6" style="">
+                    <input type="text" class="input-text" value="" placeholder="填写产品型号" id="productRemark" name="productRemark" datatype="*1-15" errormsg="产品型号格式不正确!">
                 </div>
             </div>
 
-            <input type="hidden" class="input-text" value="0" placeholder="待付金额" id="salesWaitMoney" name="salesWaitMoney"  >
-            <input type="hidden" class="input-text" value="0" placeholder="本次支付金额" id="salesLastMoney" name="salesLastMoney"  >
-            <input type="hidden" class="input-text" value="0" placeholder="邮费" id="salesShippingFee" name="salesShippingFee"  >
-
             <div class="row cl">
                 <label class="form-label col-3">
-                    <div class="tit-2">备注信息</div>
+                    <div class="tit-2">产品颜色信息</div>
                 </label>
                 <div class="formControls col-9">
                 </div>
             </div>
 
             <div class="row cl" id="" style="">
-                <label class="form-label col-1 col-sm-1">用户备注:</label>
-                <div class="formControls col-6 col-sm-6">
-                    <textarea name="salesUserRemark" id="salesUserRemark" cols="" rows="2"  class="textarea" placeholder="请填写用户备注,最多支持100字符" onKeyUp="$.Huitextarealength(this,100)"></textarea>
-                <#--<span id="addrssMsg"></span>-->
-                </div>
-            </div>
+                <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="添加商品" >
+                    <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="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>
+                            </tr>
+                        </thead>
+                        <tbody id="add_color">
 
-            <div class="row cl" id="" style="">
-                <label class="form-label col-1 col-sm-1">后台备注:</label>
-                <div class="formControls col-6 col-sm-6">
-                    <textarea name="salesAdminRemark" id="salesAdminRemark" cols="" rows="2" class="textarea" placeholder="请填写后台备注,最多支持100字符" onKeyUp="$.Huitextarealength(this,100)"></textarea>
-                <#--<span id="addrssMsg"></span>-->
+                        </tbody>
+                    </table>
+                    <input type="hidden" id="colorListJson" name="colorListJson" value="" >
                 </div>
             </div>
 
+
             <div class="row cl">
                 <div class="col-2 col-sm-2 col-offset-3">
                     <button class="btn btn-block btn-primary size-XL" type="submit">确认录入</button>
@@ -213,6 +148,7 @@
 </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({

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

@@ -95,7 +95,7 @@
      * @param employee
      */
     function to_add() {
-        window.location.href= "${path}/admin/salesOrder/list_order_page?salesBatchId="+batchId + "&salesShippingStatus=0";
+        window.location.href= "${path}/admin/product/to_add_product";
     }
 
     /**

+ 61 - 165
watero-rst-web/src/main/webapp/common/js/product/product.js

@@ -1,35 +1,50 @@
 
-var allCustomerId = "";
-
+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="1" >是</option><option value="1" >否</option></select></td>'
+            + '<td style="text-align: center;" width="10"><input type="file" class="color_file" name="file" id="fileId_'+ colorNum +'" style="display: none">'
+            + '<a href="javascript:void(0)" class="del_product all_down" onclick="fileOnclick(this)">上传图片</a>'
+            + '<input name="colorPicture" 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 add_product() {
-    layer_show("商品列表",url_path + "/admin/salesOrder/to_add_product","1000","500");
+function getColorHtml(){
+    return color.html.replace(colorNum,color.num);
 }
 
 /**
- * 打开客诉列表
+ * 添加颜色
  */
-function add_customer() {
-    layer_show("客诉列表",url_path + "/admin/customer/to_add_customer_list","1000","500");
+function add_color(){
+    color.num++;
+    $("#add_color").append(getColorHtml());
+
+    $("#fileId_"+color.num).change(function() {
+        fileUpload();
+    });
+}
+
+function fileOnclick(node){
+    $(node).siblings('.color_file').click();
+    $("#fileId_"+color.num).change(function() {
+        fileUpload("fileId_" + color.num);
+    });
 }
 
 $(function(){
-    $("#salesOrderStatus").change(function(){
-        var status = $(this).val();
-        if(status == 1){    //正常订单
-            $("#selectCustomer").hide();
-            $("#salesCustomer").hide();
-            $("#salesCustomerIdHtml").html("");
-            $("#salesCustomerId").val("");
-        }else{
-            $("#selectCustomer").show();
-            $("#salesCustomer").show();
-            $("#salesCustomerIdHtml").html("未选择客诉编号!");
-        }
-    })
+    $("#add_color").append(getColorHtml());
 })
 
 $(function(){
@@ -50,29 +65,18 @@ $(function(){
             var flag = false;
         },
         beforeSubmit: function (curform) {  //验证通过之后执行的函数
-            var addressProvince = $("#addressProvince").find("option:selected").text();
-            var addressCity = $("#addressCity").find("option:selected").text();
-            var addressCountry = $("#addressCountry").find("option:selected").text();
-            var addressDesc = $("#addressDesc").val();
-            var salesAddressInfo = addressProvince + " " + addressCity + " " + addressCountry + " " + addressDesc
-            $("#salesAddressInfo").val(salesAddressInfo);
 
-            var flag = false;
-            /*封装订单项*/
-            var orderItemArray = new Array();
-            $("#add_product").find("tr").each(function(){
-                var orderItem = new Object();
-                orderItem.itemColorId = $(this).find(".color_id").val();
-                orderItem.itemNum = $(this).find(".item-num").val();
-                orderItemArray.push(orderItem);
-                flag = true;
+            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()
+                })
+                colorList.push(color);
             })
-            if(!flag){
-                vailErrorMsg($(".add-order-button"),"必须要有一个产品");
-                return false;
-            }
 
-            $("#orderItemString").val(JSON.stringify(orderItemArray));
+            $("#colorListJson").val(JSON.stringify(colorList));
 
             loadIndex = layer.load(1, {
                 shade: [0.5,'#fff'] //0.1透明度的白色背景
@@ -98,134 +102,26 @@ $(function(){
 
 
 /**
- * 客诉回调
- * @param colorIds
+ *  删除商品
  */
-function setSelectCustomer(customerId){
-    var index = layer.load(1, {
-        shade: [0.5,'#fff'] //0.1透明度的白色背景
-    });
-
-    $.ajax({
-        type: "POST",
-        data: { customerId : customerId},
-        url: url_path +"/admin/customer/get_customer_info",
-        success: function(data){
-            if (data.returnCode == 200 && data.returnMsg.customer != null ) {
-                var customer = data.returnMsg.customer;
-                $("#salesCustomerIdHtml").html("已经选择客诉记录:"+customer.customerId);
-                $("#salesCustomerId").val(customer.customerId);
-                sc.setCompanyId(customer.companyId);
-                sc.setStoreId(customer.storeId);
-                /*设置用户姓名、电话*/
-                $("#salesAddressName").val(customer.customerName);
-                $("#salesAddressTel").val(customer.customerTel);
-                /* 售后订单的支付时间、支付方式默认 */
-                $("#salesPayTime").val(customer.salesTime);
+function delTr($this){
+    color.num++;
+    $this.parents("tr").remove();
+}
 
+function fileUpload(nodo) {
+    $.ajaxFileUpload({
+        url:"/admin/product/fileUpload",
+        secureuri:false,
+        fileElementId : nodo,//文件选择框的id属性
+        dataType: 'json',   //json
+        success: function (data) {
+            if(data.returnCode == 200){
+                $("#"+nodo)
+                $("#fileDiv").prepend('<input type="file" name="file" id="fileid" style="opacity: 0; position: absolute; width: 90px;height: 80px;" onchange="fileUpload()">');
             }else{
+                layer.msg('上传失败,请重试!',{icon: 5,time:2000});
             }
-            $("#salesCustomer").show();
         }
     });
-    layer.close(index);
 }
-
-
-/**
- * 选择商品回调
- * @param colorIds
- */
-function setSelectProduct(colorIds){
-    var index = layer.load(1, {
-        shade: [0.5,'#fff'] //0.1透明度的白色背景
-    });
-
-    $("#all_add_product").show();
-
-    var colorIdArray = colorIds.split("_");
-    for(var i=0;i<colorIdArray.length;i++){
-        var colorId = colorIdArray[i];
-        if(colorId == ""){
-            break;
-        }
-
-        var flag = true;
-        $("#add_product").find("tr").each(function (){
-            var colId = $(this).find(".color_id").eq(0).val();
-            if(colId == colorId){
-                flag  = false;
-            }
-        })
-        if(!flag){
-            continue;
-        }
-        $.ajax({
-            type: "POST",
-            data: { colorId : colorId},
-            url: url_path +"/admin/product/get_product",
-            success: function(data){
-                var html = "";
-                if (data.returnCode == 200 && data.returnMsg.productColorList.length > 0 ) {
-                    for(var i=0;i<data.returnMsg.productColorList.length;i++){
-                        var productColor = data.returnMsg.productColorList[i];
-                        html += '<tr class="text-c">' +
-                            '<input type="hidden" class="color_id" id="" value="'+ productColor.colorId +'" >' +
-                            '<input type="hidden" class="color_price" id="" value="'+ productColor.colorPrice +'" >' +
-                            '<input type="hidden" class="color_discount" id="" value="'+ productColor.colorDiscount +'" >' +
-                            ' <td>'+ cufte(productColor.productName) +'</td>' +
-                            ' <td>'+ cufte(productColor.colorName) +'</td>' +
-                            ' <td>'+ cufte(productColor.colorPrice)/100 +'</td>' +
-                            ' <td>'+ cufte(productColor.colorBar) +'</td>' +
-                            ' <td><input type="text" class="input-text input-number item-num" value="1"  style="width: 100%;border: none;text-align: center;" name="" id="" placeholder="产品数量" onkeyup="keyFun($(this),999,1)" onpaste="keyFun($(this),999,1)"></td>' +
-                            ' <td><a href="javascript:void(0)" class="del_product all_down" onclick="delProduct($(this))" >删除</a></td>' +
-                            ' </tr>';
-                    }
-                }else{
-                    html = '<tr class="text-c"><td colspan="12">没有搜索到商品,请重试!</td></tr>';
-                }
-                $("#add_product").append(html);
-                /*计算价格*/
-                calculatePrice();
-            }
-        });
-    }
-    layer.close(index);
-}
-
-/**
- *  删除商品
- */
-function delProduct($this){
-    $this.parents("tr").remove();
-}
-
-/**
- * 计算价格
- */
-function calculatePrice(){
-    /*总价,折扣价,优惠金额*/
-    var colorDiscountAll = 0,colorPriceAll = 0,salesPayMoneyAll=0;
-    $("#add_product").find("tr").each(function(){
-        var colorDiscount = 0,colorPrice = 0,salesPayMoney=0,itemNum=0;
-        colorDiscount = parseInt($(this).find(".color_discount").val())/100;
-        colorPrice = parseInt($(this).find(".color_price").val())/100;
-        itemNum = $(this).find(".item-num").val();
-        if(!isEmpty(itemNum)){
-            return;
-        }
-        itemNum = parseInt(itemNum);
-        salesPayMoney = colorPrice -colorDiscount;
-        if(salesPayMoney < 0){
-            salesPayMoney = 0;
-        }
-        colorDiscountAll += colorDiscount*itemNum;
-        colorPriceAll += colorPrice*itemNum;
-        salesPayMoneyAll += salesPayMoney*itemNum;
-    })
-    $("#salesAmount").val(colorPriceAll);
-    $("#salesPayMoney").val(colorDiscountAll);
-    $("#salesDiscountMoney").val(salesPayMoneyAll);
-
-    $("#salesLastMoney").val(colorDiscountAll);
-}

+ 2 - 2
watero-rst-web/src/main/webapp/common/js/salesOrder/salesOrder.js

@@ -115,8 +115,8 @@ function setSelectCustomer(customerId){
                 var customer = data.returnMsg.customer;
                 $("#salesCustomerIdHtml").html("已经选择客诉记录:"+customer.customerId);
                 $("#salesCustomerId").val(customer.customerId);
-                sc.setCompanyId(customer.companyId);
-                sc.setStoreId(customer.storeId);
+                // sc.setCompanyId(customer.companyId);
+                // sc.setStoreId(customer.storeId);
                 /*设置用户姓名、电话*/
                 $("#salesAddressName").val(customer.customerName);
                 $("#salesAddressTel").val(customer.customerTel);