view={api:new ec.api("cart"),datas:[],init:function(){this.btn=$("#btn_confirm")},lineHtml:function(j){var html="";var line=$("#cart_line").html();for(var i=0;i100)item.Amount=1});return list},getInfo:function(info){if(info)this.datas=info;else this.datas=this.data();if(this.datas.length>0){ec.loading();this.api.put("orderbatch/get",this.datas,function(r){ec.unLoading();view.render(r)},function(r){ec.unLoading()})}else ec.notifyQ(L.G("请输入一个产品编号"))},hasErroe:function(r){var t=false;r.forEach(function(d){if(d.ErrorMsg!=null)t=true});return t},render:function(r){ec.unLoading();var html="";var length=$("#batch_line tr").length;html=ke.template.get("result_line").renderForeach(r);html+=this.lineHtml(length-r.length);$("#batch_line").html(html);$("#btn_confirm").toggleClass("btn-disable",this.hasErroe(r)||r.length==0);ke.ui.render();ke.ui.findControls("batch_line","combobox").forEach(function(con){con.change(function(){view.calculate(this)})})},remove:function(productNum){var index=this.datas.get({ProductNum:productNum},true);this.datas.splice(index,1);if(this.datas.length>0)this.getInfo();else window.location.reload()},calculate:function(el){var rid=$(el).find("input[type=hidden]").val();$(el).parents("tr").find("span").hide();$(el).parents("tr").find("span").each(function(){if($(this).attr("data-value")==rid)$(this).show()})},addCart:function(){var info=[];var items=$("#batch_line .active");var msg="";items.each(function(){var proItem={};var name=$(this).find(".product-num input").val();var num=$(this).find(".product-amount input").val();if(num>0&&num<=100){proItem.PriceRID=$(this).find(".product-priceRid input[type=hidden]").val();proItem.Amount=num;info.push(proItem)}else{msg=L.G("请为 '")+name+L.G("' 输入1-100之间的产品数量");return false}});if(msg){ec.notifyQ(msg)}else{ec.btnLoading(view.btn,L.G("添加中..."));this.api.put("insert",info,function(r){$.removeCookie("cart_batch",{path:"/"});window.location.href=L.route+"/cart"})}}};L.push(["请输入一个产品编号","Please enter a product number","请为 '","Please enter the number of products between 1-100 for '","' 输入1-100之间的产品数量","'","添加中...","Adding..."]);