Selaa lähdekoodia

sku商品编辑

zhijiezhao 2 vuotta sitten
vanhempi
commit
8d45dd535f

+ 96 - 1
src/main/java/com/caimei/modules/product/entity/CmLadderPrice.java

@@ -10,7 +10,6 @@ import java.util.Date;
  * @author zzj
  */
 @Data
-@SuppressWarnings("all")
 @Accessors(fluent = true)
 public class CmLadderPrice implements Serializable{
     private static final long serialVersionUID = 1L;
@@ -29,4 +28,100 @@ public class CmLadderPrice implements Serializable{
     private String updateBy; //  最后更新人ID(用户ID)
     private Date updateDate; // 最后更新时间
     private String delFlag; // 删除标记 0正常 其它为已删除(使用时间戳记录) 默认值 = 0
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getSkuId() {
+        return skuId;
+    }
+
+    public void setSkuId(Integer skuId) {
+        this.skuId = skuId;
+    }
+
+    public Integer getProductId() {
+        return productId;
+    }
+
+    public void setProductId(Integer productId) {
+        this.productId = productId;
+    }
+
+    public Integer getUserType() {
+        return userType;
+    }
+
+    public void setUserType(Integer userType) {
+        this.userType = userType;
+    }
+
+    public Integer getLadderNum() {
+        return ladderNum;
+    }
+
+    public void setLadderNum(Integer ladderNum) {
+        this.ladderNum = ladderNum;
+    }
+
+    public Integer getBuyNum() {
+        return buyNum;
+    }
+
+    public void setBuyNum(Integer buyNum) {
+        this.buyNum = buyNum;
+    }
+
+    public Double getBuyPrice() {
+        return buyPrice;
+    }
+
+    public void setBuyPrice(Double buyPrice) {
+        this.buyPrice = buyPrice;
+    }
+
+    public String getCreateBy() {
+        return createBy;
+    }
+
+    public void setCreateBy(String createBy) {
+        this.createBy = createBy;
+    }
+
+    public Date getCreateDate() {
+        return createDate;
+    }
+
+    public void setCreateDate(Date createDate) {
+        this.createDate = createDate;
+    }
+
+    public String getUpdateBy() {
+        return updateBy;
+    }
+
+    public void setUpdateBy(String updateBy) {
+        this.updateBy = updateBy;
+    }
+
+    public Date getUpdateDate() {
+        return updateDate;
+    }
+
+    public void setUpdateDate(Date updateDate) {
+        this.updateDate = updateDate;
+    }
+
+    public String getDelFlag() {
+        return delFlag;
+    }
+
+    public void setDelFlag(String delFlag) {
+        this.delFlag = delFlag;
+    }
 }

+ 1 - 1
src/main/resources/mappings/modules/product/ProductMapper.xml

@@ -2044,7 +2044,7 @@
         where productId = #{productID}
     </select>
     <select id="findLadderPriceBySku" resultType="com.caimei.modules.product.entity.CmLadderPrice">
-        select skuId,productId,userType,ladderNum,buyNum,buyPrice
+        select skuId,productId,userType,ladderNum,buyNum,buyPrice,delFlag
         FROM product_ladder_price
         WHERE productId = #{productId}
           AND userType = 3

+ 21 - 12
src/main/webapp/WEB-INF/views/modules/product-new/productEdit.jsp

@@ -1806,11 +1806,12 @@
     })
 
     function insertDefaultSkuRow() {
-        var skuTemplate = $('#skuTemplate').html();
-        $("#skus").append(skuTemplate).show();
-        var current = $("#skus").find('.sku').eq(-1);
+        console.log('skyList', skuList);
         if (skuList) {
             for (var i = 0; i < skuList.length; i++) {
+                var skuTemplate = $('#skuTemplate').html();
+                $("#skus").append(skuTemplate).show();
+                var current = $("#skus").find('.sku').eq(-1);
                 var product = skuList[i];
                 product.skuIndex = i;
                 setSkuPrototypeValues(current, product);
@@ -1868,7 +1869,7 @@
         // 机构价
         var price = el.find('input[name$="price"]');
         price.val(product.price)
-        price.attr('name', 'skuList[0].price');
+        price.attr('name', 'skuList[' + skuIndex + '].price');
         // 商品展示阶梯价格
         var ladderPriceFlag = el.find('input[name$="ladderPriceFlag"]');
         // 起订量
@@ -1891,25 +1892,26 @@
         ladderPriceBox.find('.ladderPrice').each(function (index, item) {
             var ladderPrice = {}
             if (product.ladderPriceList && product.ladderPriceList.length > 0) {
-                ladderPrice = product.ladderPriceList[index];
+                ladderPrice = product.ladderPriceList[index] || {};
             }
 
+            console.log('ladderPrice---', ladderPrice)
             // 起订量
             var buyNum = $(item).find('[name$="buyNum"]');
             buyNum.val(ladderPrice.buyNum);
-            buyNum.attr('name', 'skuList[' + skuIndex + '].ladderPriceList[0].buyNum');
+            buyNum.attr('name', 'skuList[' + skuIndex + '].ladderPriceList[' + index + '].buyNum');
             // 价格
             var buyPrice = $(item).find('[name$="buyPrice"]');
             buyPrice.val(ladderPrice.buyPrice);
-            buyPrice.attr('name', 'skuList[' + skuIndex + '].ladderPriceList[0].buyPrice');
+            buyPrice.attr('name', 'skuList[' + skuIndex + '].ladderPriceList[' + index + '].buyPrice');
             // 阶梯价id
             var id = $(item).find('[name$="id"]');
             id.val(ladderPrice.id);
-            id.attr('name', 'skuList[' + skuIndex + '].ladderPriceList[0].id');
+            id.attr('name', 'skuList[' + skuIndex + '].ladderPriceList[' + index + '].id');
             // 阶梯价delFlag
             var delFlag = $(item).find('[name$="delFlag"]');
             delFlag.val(ladderPrice.delFlag || 1);
-            delFlag.attr('name', 'skuList[' + skuIndex + '].ladderPriceList[0].delFlag');
+            delFlag.attr('name', 'skuList[' + skuIndex + '].ladderPriceList[' + index + '].delFlag');
         });
 
         skuIndex++;
@@ -1960,11 +1962,18 @@
         })
 
         ladderPriceBox.find('.ladderPrice').each(function (index, item) {
-            var delFlag = index.delFlag;
-            if (index != 0 && (delFlag != 0 || product && product.ladderPriceFlag != 1)) {
+            var ladderPrice = product.ladderPriceList[index]
+            var delFlag = 1
+            if (ladderPrice) {
+                delFlag = ladderPrice.delFlag
+            }
+            console.log(delFlag)
+            if (index != 0) {
                 $(item).hide();
             }
-            ;
+            if (delFlag == 0 && product.ladderPriceFlag == 1) {
+                $(item).show()
+            }
         })
 
         costCheckFlag.on('change', function () {