123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647 |
- //添加信息框
- $(".packing .exptj").click(function() {
- layx.iframe('resize-ct','添加产品信息','/choice/1',{skin:'default',icon:false,border:false,minMenu:false,maxMenu:false,maxwidth:840,maxheight:375,closeMenu:false,shadable:true,shadable:0.1});
- layx.restore('layx');
- });
- //查找信息单价
- $(".exp .ckrows input").click(function() {
- var num = $(this).index();
- if ($(this).is(":checked"))
- {
- var f = "";
- $(".exp .datalist .select").each(function() {
- if($(this).prop("name") != "hairtype")
- {
- f = f + $(this).children("option:selected").val() + "-";
- }
- else
- {
- f = f + 0 + "-";
- }
- });
- $(".exp .post .select").each(function() {
- f = f + $(this).children("option:selected").val() + "-";
- });
- f = f + $(this).val();
- $.ajax({
- url: "/fullorder/price/",
- data: "data="+f,
- type: "POST",
- dataType: "json",
- success: function(a) {
- if (a && a.success) {
- var ma = $(".exp input[name='money']").val()*1;
- var mx = a.msg['salesprice']*1;
- var n = $(".exp .num font").text()*1;
- $(".exp input[name='money']").val(mx.toFixed(2));
- $(".exp .tm font").html((mx*n).toFixed(2));
- //$(".exp input[name='money']").val((ma+mx).toFixed(2));//多条数叠加计算价格
- //$(".exp .tm font").html(((ma+mx)*n).toFixed(2));//多条数叠加计算价格
- $(".zm").append("<font class='z"+a.n+"'>"+mx.toFixed(2)+"</span>");
- $(".exp .purchase").text((a.msg['purchase']*1*n).toFixed(2));
- $(".exp .cost").text((a.msg['cost']*1*n).toFixed(2));
- } else {
- $('.exp .'+a.n).prop("checked",false);
- $(".ts p").html(a.msg);
- $(".ts").fadeIn();
- setTimeout('$(".ts").fadeOut()', 600);
- }
- }
- });
- }
- /** 单选用不上,这个无成本计算
- else
- {
- var cname = $(this).prop("className");
- var ma = $(".exp input[name='money']").val()*1;
- var mx = $(".z"+cname).text()*1;
- var n = $(".exp .num font").text()*1;
- $(".exp input[name='money']").val((ma-mx).toFixed(2));
- $(".exp .tm font").html(((ma-mx)*n).toFixed(2));
- $(".z"+cname).remove();
- }
- **/
- });
- //关闭添加信息框
- function choicegb() {
- var id;
- if (self != top && self.frameElement && self.frameElement.tagName == "IFRAME") {
- var layxWindow = $(self.frameElement).parents(".layx-window");
- id = layxWindow.attr("id").substr(5);
- }
- parent.layx.destroy(id);
- }
- //提交时tr增加data信息
- $(".exp").on('click',".packingtj",function() {
- var f = "";var e = "";var o = "";var checkid = "";
- $(".exp .datalist .select").each(function() {
- if($(this).children("option:selected").val() != 0 || $(this).children("option:selected").val() != '')
- {
- f = f + $(this).children("option:selected").val() + "-";
- e = e + $(this).children("option:selected").text() + " ";
- }
- });
- $(".exp .post .select").each(function() {
- if($(this).children("option:selected").val() != 0 || $(this).children("option:selected").val() != '')
- {
- f = f + $(this).children("option:selected").val() + "-";
- e = e + $(this).children("option:selected").text() + " ";
- }
- });
-
-
- var checkname = "";
- $(".datalist .checkbox .ckrows input:checked").each(function(){
- checkname = $(this).attr("name");
- checkid = checkid + $(this).val()+",";
- o = o + $(this).next('font').text()+" ";
- });
- if(checkname == "")
- {
- $(".ts p").text($(".datalist .checkbox").prevAll("em").text()+"为必填项");
- $(".ts").show();
- setTimeout('$(".ts").fadeOut()', 600);
- return false;
- }
- else
- {
- f = checkid + "-" + f;
- e = e + o;
- }
- var ab = 0;
- $(".datalist .must").each(function() {
- if ($.trim($(this).val()).length == 0) {
- $(this).css("border", "1px solid #F66");
- ab = ab + 1;
- }
- });
- if (ab > 0) {
- $(".ts p").text("红框为必填项");
- $(".ts").show();
- setTimeout('$(".ts").fadeOut()', 600);
- return false;
- }
- var x = 0
- $(".datatext tr",window.parent.document).each(function() {
- if($(this).data("list") == f)
- {
- x++;
- }
- });
- if(x > 0)
- {
- $(".ts p").text("已有相同信息!");
- $(".ts").show();
- setTimeout('$(".ts").fadeOut()', 700);
- return false;
- }
- else
- {
- var ts = $(".exp .num font").text()*1
- var dj = $(".exp input[name='money']").val()*1;
- var purchasemy = $(".exp .purchase").text()*1;
- var costmy = $(".exp .cost").text()*1;
- var inch = $(".datalist .checkbox .ckrows input:checked").next("font").text();//针对单选尺寸,多选需要修改
- $(".datatext",window.parent.document).append("<tr data-list='"+f+"'><td>"+e+"</td><td>"+ts+"</td><td>"+(dj).toFixed(2)+"</td><td>"+(ts*dj).toFixed(2)+"</td><td>CNY</td><td class='none'>"+inch.replace("inch","")+"</td><td class='none'>"+(ts*purchasemy).toFixed(2)+"</td><td class='none'>"+(ts*costmy).toFixed(2)+"</td></tr>");
- }
- //$("input[name='shouldmoney']").val(($("input[name='shouldmoney']").val()*1+(sl*dj)).toFixed(2));//应收价格加上新增价格
- //et();
- cost();//计算成本价
- window.parent.custom();
- choicegb();
-
- });
- //修改tr-data信息
- $(".exp").on('click',".packingxg",function() {
- var f = "";var e = "";var o = "";var checkid = "";
- $(".exp .datalist .select").each(function() {
-
- if($(this).children("option:selected").val() != 0 || $(this).children("option:selected").val() != '')
- {
- f = f + $(this).children("option:selected").val() + "-";
- e = e + $(this).children("option:selected").text() + " ";
- }
- });
- $(".exp .post .select").each(function() {
- if($(this).children("option:selected").val() != 0 || $(this).children("option:selected").val() != '')
- {
- f = f + $(this).children("option:selected").val() + "-";
- e = e + $(this).children("option:selected").text() + " ";
- }
- });
-
-
- var checkname = "";
- $(".datalist .checkbox .ckrows input:checked").each(function(){
- checkname = $(this).attr("name");
- checkid = checkid + $(this).val()+",";
- o = o + $(this).next('font').text()+" ";
- });
- if(checkname == "")
- {
- $(".ts p").text($(".datalist .checkbox").prevAll("em").text()+"为必填项");
- $(".ts").show();
- setTimeout('$(".ts").fadeOut()', 600);
- return false;
- }
- else
- {
- f = checkid + "-" + f;
- e = e + o;
- }
- var ab = 0;
- $(".datalist .must").each(function() {
- if ($.trim($(this).val()).length == 0) {
- $(this).css("border", "1px solid #F66");
- ab = ab + 1;
- }
- });
- if (ab > 0) {
- $(".ts p").text("红框为必填项");
- $(".ts").show();
- setTimeout('$(".ts").fadeOut()', 600);
- return false;
- }
- //var ts = $(".datalist .checkbox .ckrows input:checked").length*1;
- var ts = $(".exp .num font").text()*1
- var dj = $(".exp input[name='money']").val()*1;
- var purchasemy = $(".exp .purchase").text()*1;
- var costmy = $(".exp .cost").text()*1;
- $(".datatext tr.on",window.parent.document).attr("data-list",f);
- //var xg = $(".datatext tr.on td:eq(8)").text()*1;
- // $("input[name='shouldmoney']").val(($("input[name='shouldmoney']").val()*1+((sl*dj)-xg)).toFixed(2));
- // et();
- var inch = $(".datalist .checkbox .ckrows input:checked").next("font").text();//针对单选尺寸,多选需要修改
- $(".datatext tr.on",window.parent.document).html("<td>"+e+"</td><td>"+ts+"</td><td>"+(dj).toFixed(2)+"</td><td>"+(ts*dj).toFixed(2)+"</td><td>CNY</td><td class='none'>"+inch.replace("inch","")+"</td><td class='none'>"+(ts*purchasemy).toFixed(2)+"</td><td class='none'>"+(ts*costmy).toFixed(2)+"</td>");
- cost();//计算成本价
- window.parent.custom();
- choicegb();
- });
- //修改数量
- $(".exp .lengththree .gz").click(function() {
- var num = $(".exp .num font").text()*1;
- var dj = $(".exp input[name='money']").val()*1;
- $(".exp .num font").text(num+1);
- if(dj > 0)
- {
- $(".exp .tm font").text((dj*(num+1)).toFixed(2));
- }
- });
- $(".exp .lengththree .gj").click(function() {
- var num = $(".exp .num font").text()*1;
- var dj = $(".exp input[name='money']").val()*1;
- if(num > 1)
- {
- $(".exp .num font").text(num-1)*1;
- if(dj > 0)
- {
- $(".exp .tm font").text((dj*(num-1)).toFixed(2));
- }
- }
- });
- //点击增加信息是增加标记
- $(".datatext").on('click',"tr",function() {
- $(".datatext tr").removeClass("on");
- $(this).addClass("on");
- });
- //删除信息
- $(".packing .expsc").click(function() {
- var b = 0;
- $(".packing .datatext .on").each(function() {
- b = b+1;
- });
- if (b>1)
- {
- $(".ts p").html("每次只可删除一条内容");
- $(".ts").show();
- setTimeout('$(".ts").fadeOut()', 1000);
- }
- else if(b<1)
- {
- $(".ts p").html("请选择需要删除的内容");
- $(".ts").show();
- setTimeout('$(".ts").fadeOut()', 1000);
- }
- else
- {
- // var xg = $(".datatext tr.on td:eq(8)").text()*1;
- //$("input[name='shouldmoney']").val(($("input[name='shouldmoney']").val()*1-xg).toFixed(2));et();
- $(".packing .datatext .on").remove();
- }
- costz();//计算成本价
- window.parent.custom();
- });
- //统一修改币种
- $("#currency").change(function(){
- var index = $(this).find("option:selected").text();
- var va = $(this).find("option:selected").val();
- $(".currency").text(index);
- $(".datatext tr").each(function() {
- //$(this).find("td:eq(9)").text(index);
- });
-
- });
- //fullorder 数据库增加currency币种 考虑更改币种是否需要ajax获取美元汇率更改金额
-
- $(".packing .expxg").click(function() {
- var b = 0;
- $(".packing .datatext .on").each(function() {
- b = b+1;
- });
- if (b>1)
- {
- $(".ts p").html("每次只可修改一条内容");
- $(".ts").show();
- setTimeout('$(".ts").fadeOut()', 1000);
- }
- else if(b<1)
- {
- $(".ts p").html("请选择需要修改的内容");
- $(".ts").show();
- setTimeout('$(".ts").fadeOut()', 1000);
- }
- else
- {
- layx.iframe('topiframe','修改产品信息','/choice/2',{skin:'default',icon:false,border:false,minMenu:false,maxMenu:false,width:840,minheight:375,closeMenu:false,shadable:true,shadable:0.1});
- layx.restore('layx');
- }
- });
- //自动显示option
- function option() {
- var index = $(".cike select").find("option:selected").index();
- $(".pttab li").hide(); $(".pttab li").removeClass("post");
- $("."+index).show();$("."+index).addClass("post");
- $('.pttab select option:eq(0)').prop('selected','selected');
- if(index == 1)
- {
- $(".pttab .a1").show();$(".pttab .a2").hide();
- }
- var indexb = $(".cikeb.post select").find("option:selected").index();
- $(".pttab .a1").hide();$(".pttab .a2").hide();$(".pttab .a1").removeClass("post");$(".pttab .a2").removeClass("post");
- if(indexb == 0 || indexb == 4)
- {
- $(".pttab .a1").show();$(".pttab .a1").addClass("post");
- }
- else if(indexb == 2)
- {
- $(".pttab .a2").show();$(".pttab .a2").addClass("post");
- }
- }
- $("select[name='country']").change(function() {
- $("select[name=productdescription]").html("");
- $("input[name=customs]").val("0");
- //express() 暂时固定运费为20USD 不在查找设置价格
- printtype();
- });
- $("select[name='express']").change(function() {
- $("select[name=productdescription]").html("");
- $("input[name=customs]").val("0");
- //express() 暂时固定运费为20USD 不在查找设置价格
- printtype();
- type();
- });
- $("select[name='printtype']").change(function() {
- $("select[name=productdescription]").html("");
- $("input[name=customs]").val("0");
- printtype();
- });
-
- //打印类型
- function printtype() {
- var index = $("select[name='printtype']").find("option:selected").index();
- if(index == 0)
- {
- var e = $("select[name=express]").find("option:selected").val();
- var c = $("select[name=country]").find("option:selected").val();
- $.ajax({
- url: "/fullorder/customs/",
- data: "e="+e+"&c="+c,
- type: "POST",
- dataType: "json",
- success: function(a) {
- if (a && a.success) {
- $("input[name=customs]").val(a.money);
- for(i=0;i<a.msg.length;i++)
- {
- $("select[name=productdescription]").append("<option value='"+a.msg[i]['id']+"'>"+a.msg[i]['title']+"</option>");
- }
- $(".productdescription").show();
- $(".customs").show();
- } else {
- $(".productdescription").hide();
- $(".customs").hide();
- $(".ts p").html(a.msg);
- $(".ts").fadeIn();
- setTimeout('$(".ts").fadeOut()', 800);
- }
- }
- });
-
- }else
- {
- $(".productdescription").hide();
- $(".customs").hide();
- }
- }
- $("select[name='warehouse']").change(function() {
- type()
- });
- function express() {
- var e = $("select[name=express]").find("option:selected").val();
- var c = $("select[name=country]").find("option:selected").val();
- $.ajax({
- url: "/fullorder/express/",
- data: "e="+e+"&c="+c,
- type: "POST",
- dataType: "json",
- success: function(a) {
- if (a && a.success) {
- $("input[name=expressmoney]").val(a.money);//?这里或许需要根据币种美元转换
- } else {
- $("input[name=expressmoney]").val("0.00");
- }
- }
- });
- }
- function type() {
- var t = $("select[name=express]").find("option:selected").val();
- var c = $("select[name=warehouse]").find("option:selected").val();
- /** 如果仓库不是1的话,执行不打印操作
- if(c!=1)
- {
- $("select[name=printtype]").find("option[value='3']").prop("selected","selected");return false;
- }
- **/
- $.ajax({
- url: "/fullorder/expresstype/",
- data: "id="+t,
- type: "POST",
- dataType: "json",
- success: function(a) {
- if (a && a.success) {
- $("select[name=printtype]").find("option[value='"+a.msg+"']").prop("selected","selected");
- }
- }
- });
- }
- $(".lengththree input[name='money']").bind("change",function(){
- var ma= $(this).val();
- var n = $(".exp .num font").text()*1;
- $(".exp .tm font").html((ma*n).toFixed(2));
- });
-
- //整体提交数据
- $(".fullorderdata").click(function() {
- var f = "";
- var e = "";
- var w = "";
- $(".need .select").each(function() {
- f = f + $(this).attr("name") + "=" + $(this).children("option:selected").val() + "&";
- });
- $(".need input:text").each(function() {
- var str = $(this).val().replace(/\+/g,"%2B");
- var str = str.replace(/&/g,"%26");
- f = f + $(this).attr("name") + "=" + str + "&";
- });
- $(".need input:hidden").each(function() {
- f = f + $(this).attr("name") + "=" + $(this).val() + "&";
- });
- $(".need textarea").each(function() {
- var str2 = $(this).val().replace(/\+/g,"%2B");
- f = f + $(this).attr("name") + "=" + str2 + "&";
- });
-
- $(".datatext tr").each(function() {
- var cc = "";var listqc = "";var data = "";var t = "";
- e = e + $(this).data("list")+ "|" + $(this).find("td:eq(0)").text() + "|" + $(this).find("td:eq(1)").text() + "|" + $(this).find("td:eq(2)").text() + "|" + $(this).find("td:eq(3)").text() + "|" + $(this).find("td:eq(5)").text() + "|" + $(this).find("td:eq(6)").text() + "|" + $(this).find("td:eq(7)").text() + ";";
- var list = $(this).data("list").replace(/\-(0|163|164|165|166)\-/,'-');
- cc = list.split(",");
- listqc = list.replace(/\d{1,3}\,/,'');
- listqc = listqc.substring(0,listqc.length-1);
- data = listqc.split("-");
- for(i=1;i<data.length;i++)
- {
- if(i == 2)
- {
- t = t +data[i] + cc[0]
- }
- else
- {
- t = t +data[i]
- }
- }
- w = w + t + '-' + $(this).find("td:eq(1)").text() + '|';
- });
- f = f + "whlabel=|" + w + "&fpdata=" + encodeURI(e) + "&";
-
- f = f + "budget=" + $(".budget").text() + "&";
- var ab = 0;
- $(".need .must").each(function() {
- if ($.trim($(this).val()).length == 0) {
- $(this).css("border", "1px solid #F66");
- ab = ab + 1;
- }
- });
- if (ab > 0) {
- $(".ts p").text("红框为必填项");
- $(".ts").show();
- setTimeout('$(".ts").fadeOut()', 600);
- return false;
- }
- //限制必须提交产品详细列表
- if (e == '') {
- $(".ts p").text("必须添加订单详细信息!");
- $(".ts").show();
- setTimeout('$(".ts").fadeOut()', 800);
- return false;
- }
- layx.load('loadId','数据提交中,请稍后');
- $.ajax({
- url: addedit,
- data: f,
- type: "POST",
- dataType: "json",
- success: function(a) {
- if (a && a.success) {
- layx.destroy('loadId');
- $(".express p:eq(0)").html(a.msg);
- $(".express p:eq(1)").html("<font class='fh'>确 定</font>");
- $(".express").show();
- } else {
- layx.destroy('loadId');
- $(".ts p").html(a.msg);
- $(".ts").fadeIn();
- setTimeout('$(".ts").fadeOut()', 600);
- }
- }
- });
- });
- //关联总金额换算穿预计到帐金额
- $("input[name='shouldmoney']").bind("change",function(){
- et();
- });
- function et(){
- var ma= $("input[name='shouldmoney']").val();
- if(ma > 0)
- {
- var n= $("input[name='et']").val();
- $(".currencymoney").text(eval(ma+n).toFixed(2));
- }
- else
- {
- $(".currencymoney").text(0);
- }
- }
- //计算成本金额,子页面用
- function cost(){
- var purchasemoney = 0;var costmoney = 0;
- $(".datatext tr",window.parent.document).each(function() {
- purchasemoney = purchasemoney+$(this).find("td:eq(6)").text()*1;
- costmoney = costmoney+$(this).find("td:eq(7)").text()*1;
- });
- $("input[name='purchase']",window.parent.document).val(purchasemoney.toFixed(2));
- $("input[name='cost']",window.parent.document).val(costmoney.toFixed(2));
- //$("li b .zlr").html(($("li .budget").html()*1-money).toFixed(2));//总利润
- }
- //计算成本金额,自页面用
- function costz(){
- var purchasemoney = 0;var costmoney = 0;
- $(".datatext tr").each(function() {
- purchasemoney = purchasemoney+$(this).find("td:eq(6)").text()*1;
- costmoney = costmoney+$(this).find("td:eq(7)").text()*1;
- });
- $("input[name='purchase']").val(purchasemoney.toFixed(2));
- $("input[name='cost']").val(costmoney.toFixed(2));
- //$("li b .zlr").html(($("li .budget").html()*1-money).toFixed(2));//总利润
- }
- $(".power").click(function() {
- layx.confirm('重置选择','确定重置此订单?',function(id){
- $.ajax({
- url: "/fullorder/power/",
- data: "id="+$("input[name='id']").val(),
- type: "POST",
- dataType: "json",
- success: function(a) {
- layx.destroy(id);
- if (a && a.success) {
- $(".express p:eq(0)").html(a.msg);
- $(".express p:eq(1)").html("<font class='fh'>确 定</font>");
- $(".express").show();
- } else {
- $(".ts p").html(a.msg);
- $(".ts").fadeIn();
- setTimeout('$(".ts").fadeOut()', 800);
- }
- }
- });
- layx.destroy(id);
- },{shadable:0.6,dialogIcon:'help'});
- });
-
- //验证库存
- $("select[name=warehouse]").change(function(){
- if($(this).find("option:selected").val() == "5")
- {
- var w = "";
- $(".datatext tr").each(function() {
- var cc = "";var listqc = "";var data = "";var t = "";
- var list = $(this).data("list").replace(/\-(0|163|164|165|166)\-/,'-');
- cc = list.split(",");
- listqc = list.replace(/\d{1,3}\,/,'');
- listqc = listqc.substring(0,listqc.length-1);
- data = listqc.split("-");
- for(i=1;i<data.length;i++)
- {
- if(i == 2)
- {
- t = t +data[i] + cc[0]
- }
- else
- {
- t = t +data[i]
- }
- }
- w = w + t + '-' + $(this).find("td:eq(1)").text() + '|';
- });
- var yzdata = {
- warehouse: $(this).find("option:selected").val(),
- whlabel: "|" + w
-
- };
- $.ajax({
- url: "/whlabel/kcyz/",
- data: yzdata,
- type: "POST",
- dataType: "json",
- success: function(a) {
- if (a && a.success) {
-
- } else {
- $("select[name=warehouse] option:eq(0)").prop('selected','selected');
- if(a.t == 1)
- {
- layx.alert('错误',a.msg,function(id,button){
- },{dialogIcon:'error'});
- }
- else
- {
- layx.alert('错误',a.msg,function(id,button){
- },{dialogIcon:'error'});
- for(i=0;i<a.error.length;i++)
- {
- $(".datatext tr:eq("+a.error[i]+") td:eq(0)").css("color","red");
- }
- }
- }
- }
- });
- }
-
- });
|