123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554 |
- //添加信息框
- $(".packing .exptj").click(function() {
- if($("select[name=purchase]").children("option:selected").val() < 1)
- {
- $(".ts p").html("请选择供应商!");
- $(".ts").fadeIn();
- setTimeout('$(".ts").fadeOut()', 800);
- return false;
- }
- if($("select[name=price]").children("option:selected").val() < 1)
- {
- $(".ts p").html("请选择供应商价格表!");
- $(".ts").fadeIn();
- setTimeout('$(".ts").fadeOut()', 800);
- return false;
- }
- $(".exp .title").text("添加信息");
- $(".exp .setting").addClass("packing");
- $(".expwp .button").html("<font class='datasave packingtj'>提 交</font> <font class='fh'>关 闭</font>");
- $(".exp .select").each(function() {
- if($(this).children("option:selected").val() != 0)
- {
- $(this).children("option:selected").prop("selected",false);
- }
- });
- $(".exp .checkbox .ckrows input:checked").each(function(){
- $(this).prop("checked",false);
-
- });
- $(".exp input[name='money']").val("");
- $(".exp .num font").text("1");
- $(".exp .tm font").html("");
- option();
- $(".exp").show();
- });
- //查找信息单价
- $(".exp .ckrows input").click(function() {
- $(".exp .tm font").html("0.00");
- $(".exp input[name='money']").val("0.00");
- $(".exp .num font").text("1");
- var num = $(this).index();
- var f = "";
- $(".exp .datalist .select").each(function() {
- f = f + $(this).children("option:selected").val() + "-";
- });
- $(".exp .post .select").each(function() {
- f = f + $(this).children("option:selected").val() + "-";
- });
- f = f + $(this).val();
- $.ajax({
- url: "/purchaseorder/describe/",
- data: "data="+f+"&priceid="+$("select[name=price]").children("option:selected").val(),
- type: "POST",
- dataType: "json",
- success: function(a) {
- if (a && a.success) {
- var ma = $(".exp input[name='money']").val()*1;
- var mb = a.msg['purchase']*1;
- var n = $(".exp .num font").text()*1;
- $(".exp input[name='money']").val((ma+mb).toFixed(2));
- $(".exp .tm font").html(((ma+mb)*n).toFixed(2));
- $(".zm").append("<font class='z"+a.n+"'>"+mb.toFixed(2)+"</span>");
- } else {
- $('.exp .'+a.n).prop("checked",false);
- $(".ts p").html($("select[name=price]").children("option:selected").text()+"供应商"+a.msg);
- $(".ts").fadeIn();
- setTimeout('$(".ts").fadeOut()', 900);
- }
- }
- });
-
- });
- //修改信息时清除原有信息
- $(".exp select").click(function() {
- $(".zm").html("");
- $(".exp .ckrows input").prop("checked",false);
- $(".exp .tm font").html("0.00");
- $(".exp input[name='money']").val("0.00");
- $(".exp .num font").text("1");
- });
- //关闭添加信息框
- $(".exp").on('click',".fh",function() {
- $(".exp").hide();
- });
- //提交时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)
- {
- f = f + $(this).children("option:selected").val() + "-";
- e = e + $(this).children("option:selected").text() + " ";
- }
- });
- $(".exp .post .select").each(function() {
- 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").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 = $(".datalist .checkbox .ckrows input:checked").length*1;
- var sl = $(".exp .num font").text()*1
- var dj = $(".exp input[name='money']").val()*1;
- $(".datatext").append("<tr data-list='"+f+"'><td>"+e+"</td><td>"+ts+"</td><td>"+sl+"</td><td>"+(dj).toFixed(2)+"</td><td>"+ts*sl+"</td><td>"+(sl*dj).toFixed(2)+"</td><td>"+$(".exp .currency").text()+"</td></tr>");
- }
- //$("input[name='shouldmoney']").val(($("input[name='shouldmoney']").val()*1+(sl*dj)).toFixed(2));//应收价格加上新增价格
- //et();
- datasort();
- $(".exp").hide();
- cost();//计算成本价
- });
- //修改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)
- {
- f = f + $(this).children("option:selected").val() + "-";
- e = e + $(this).children("option:selected").text() + " ";
- }
- });
- $(".exp .post .select").each(function() {
- 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 sl = $(".exp .num font").text()*1
- var dj = $(".exp input[name='money']").val()*1;
- $(".datatext tr.on").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();
- $(".datatext tr.on").html("<td>"+e+"</td><td>"+ts+"</td><td>"+sl+"</td><td>"+(dj).toFixed(2)+"</td><td>"+ts*sl+"</td><td>"+(sl*dj).toFixed(2)+"</td><td>"+$(".exp .currency").text()+"</td>");
- datasort();
- $(".exp").hide();
- cost();//计算成本价
- });
- //修改数量
- $(".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();
- }
- cost();//计算成本价
- });
- //统一修改币种
- $("#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
- {
- $(".exp .select").each(function() {
- if($(this).children("option:selected").val() != 0)
- {
- $(this).children("option:selected").prop("selected",false);
- }
- });
- $(".exp .checkbox .ckrows input:checked").each(function(){
- $(this).prop("checked",false);
-
- });
- $(".exp input[name='money']").val($(".packing .datatext .on td:eq(3)").text());
- $(".exp .num font").text($(".packing .datatext .on td:eq(2)").text());
- $(".exp .tm font").text($(".packing .datatext .on td:eq(5)").text());
- $(".exp .title").text("修改信息");
- $(".exp .setting").addClass("packing");
- var list = $(".packing .datatext .on").data("list");
- list = list.substring(0,list.length-1);
- var data = list.split("-");
- var ckrows = data[0].substring(0,data[0].length-1);
- ckrows = ckrows.split(",");
- for(i=0;i<ckrows.length;i++)
- {
- $(".exp .ckrows input[type='radio']").each(function() {
-
- if($(this).val() == ckrows[i])
- {
- $(this).prop("checked",true);
- }
- });
- }
- for(i=1;i<data.length+1;i++)
- {
- $(".exp .select").each(function() {
- $(this).find("option[value='"+data[i]+"']").prop("selected","selected");
- });
- }
- option();
- $(".expwp .button").html("<font class='datasave packingxg'>提 交</font> <font class='fh'>关 闭</font>");
- $(".exp").show();
- }
- });
- //自动显示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");
- $("input[name=expressmoney]").val("0.00");
- express()
- printtype();
- });
- $("select[name='express']").change(function() {
- $("select[name=productdescription]").html("");
- $("input[name=customs]").val("0");
- $("input[name=expressmoney]").val("0.00");
- express()
- printtype();
- });
- $("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();
- }
- }
- 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");
- }
- }
- });
- }
- $(".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() {
- $(".ts p").html("<i class='fa fa-2x fa-cog fa-spin'></i> 正在添加中,请稍后...");
- $(".ts").show();
- var f = "";
- var e = "";
- $(".need .select").each(function() {
- f = f + $(this).attr("name") + "=" + $(this).children("option:selected").val() + "&";
- });
- $(".need input:text").each(function() {
- f = f + $(this).attr("name") + "=" + $(this).val() + "&";
- });
- $(".need input:hidden").each(function() {
- f = f + $(this).attr("name") + "=" + $(this).val() + "&";
- });
- $(".need textarea").each(function() {
- f = f + $(this).attr("name") + "=" + $(this).val() + "&";
- });
-
- $(".datatext tr").each(function() {
- 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(4)").text() + "|" + $(this).find("td:eq(5)").text() + "|" + "*";
- });
- f = f + "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;
- }
- $.ajax({
- url: addedit,
- data: f,
- type: "POST",
- dataType: "json",
- success: function(a) {
- if (a && a.success) {
- $(".ts").hide();
- $(".express p:eq(0)").html(a.msg+"是否关闭?");
- $(".express p:eq(1)").html("<font class='fh'>确 定</font><font class='esc'>取 消</font>");
- $(".express").show();
- } else {
- $(".ts").hide();
- $(".ts p").html("添加失败,请重试");
- $(".ts").fadeIn();
- setTimeout('$(".ts").fadeOut()', 600);
- }
- }
- });
- });
- //关联总金额换算穿预计到帐金额
- $("input[name='shouldmoney']").bind("change",function(){
- et();
- });
- function et(){
- var ma= $("input[name='shouldmoney']").val();
- var n= $("input[name='et']").val();
- $(".currencymoney").text((ma*n).toFixed(2));
- }
- //计算成本金额
- function cost(){
- var money = 0;
- $(".datatext tr").each(function() {
- money = money+$(this).find("td:eq(8)").text()*1;
- });
-
- $("input[name='cost']").val(money);
- }
- //选择供应商
- $("select[name='purchase']").change(function() {
- if($(this).find("option:selected").index() == 0)
- {
- $("select[name='price']").html("<option value=''>需先选择供应商</option>");
- return false;
- }
- $("select[name='price']").html("<option value=''>需先选择供应商</option>");
- var id = $(this).children("option:selected").val();
- $.ajax({
- url: "/purchaseorder/price/",
- data: "id="+id,
- type: "POST",
- dataType: "json",
- success: function(a) {
- if (a && a.success) {
- for(i=0;i<(a.msg).length;i++)
- {
- $("select[name=price]").append("<option value='"+a.msg[i]['id']+"'>"+a.msg[i]['title']+"</option>");
- }
- $("select[name=price]").find("option:eq(1)").attr("selected","selected");
- } else {
- $(".ts p").html("供应商价格表获取失败,请重试");
- $(".ts").fadeIn();
- setTimeout('$(".ts").fadeOut()', 800);
- }
- }
- });
- });
|