G.app.order.invoice={
	_tpl:{desc:['<ul class="list_info"><li><span class="tit">发票类型：</span>{typeChn}</li><li><span class="tit">发票抬头：</span>{title}</li><li><span class="tit">发票内容：</span>{invoiceContent}</li></ul>{specialTip}','<ul class="list_info"><li><span class="tit">发票类型：</span>{typeChn}</li><li><span class="tit">公司名称：</span>{name}</li><li><span class="tit">公司地址：</span>{addr}</li><li><span class="tit">公司电话：</span>{phone}</li><li><span class="tit">税　　号：</span>{taxno}</li><li><span class="tit">银行帐号：</span>{bankno}</li><li><span class="tit">开&nbsp;&nbsp;户&nbsp;&nbsp;行：</span>{bankname}</li></ul><div class="wrap_para zengzhi"><p class="para_inb"> <span class="para_tit">增值税专用发票将统一从上海进行快递，可能会在您收到商品之后到达，请您谅解。</span> </p></div>{specialTip}'],list:'<table class="table_nobor"><colgroup><col width="5%"><col width="95%"></colgroup><tbody><@list@><tr iid="{iid}"{toNone} t="{moreInvoice}"><td><input type="radio" name="sel_invoice" value="{iid}"/></td><td>[[item_desc]]</td></tr><@_list@>{showMore}<tr iid="-1"><td><input type="radio" name="sel_invoice" value="-1"></td><td>使用新发票</td></tr></tbody><tfoot><tr><td colspan="2"><span class="tit">发票内容：</span>{invoiceContentOption}</td></tr><tr><td colspan="2"><div class="wrap_btn"><a class="btn_strong" href="#" t="isave" onclick="return false">确认发票信息</a></div></td></tr></tfoot></table>',item_desc:'<div class="wrap_change"><div class="change_info">{typeChn} <span class="nor">(发票抬头：{title})</span></div><div class="modify"><a href="#" t="edit" onclick="return false">修改</a> | <a href="#" t="del" onclick="return false">删除</a></div></div>',edit:'<div class="list_info_wrap"><ul class="list_info"><li><span class="tit">发票类型：</span><label><input type="radio" name="iv_type_check" value="1" />商业零售发票</label> <label><input type="radio" name="iv_type_check" value="4" />普通发票</label> <label><input type="radio" name="iv_type_check" value="2" />增值税专用发票</label></li><li fe="1"><span class="tit"><span class="hot">*</span>发票抬头：</span><label><input type="radio" name="iv_ftype_check" value="1" hotname="I.ORDER.PERSONAL" />个人</label> <label><input type="radio" name="iv_ftype_check" value="2" hotname="I.ORDER.COMPANY"/>单位</label></li><li fe="1" ffe="1"><span class="tit"><span class="hot">*</span>个人姓名：</span><input type="text" class="input_long" name="title" value="{title}"/></li><li fe="1" class="normal_fe1"><div class="para_inb"><p>发票相关信息将被系统自动打印到发票上，请勿填写和发票无关的信息。</p></div></li><li fe="2"><span class="tit"><span class="hot">*</span>公司名称：</span><input type="text" class="input_long" name="name" value="{name}" /></li><li fe="2"><span class="tit"><span class="hot">*</span>公司地址：</span><input type="text" class="input_long" name="addr" value="{addr}" /></li><li fe="2"><span class="tit"><span class="hot">*</span>公司电话：</span><input type="text" class="input_long" name="phone" value="{phone}"/></li><li fe="2"><span class="tit"><span class="hot">*</span>税　　号：</span><input type="text" class="input_long" name="taxno" value="{taxno}"/></li><li fe="2"><span class="tit"><span class="hot">*</span>银行帐号：</span><input type="text" class="input_long" name="bankno" value="{bankno}"/></li><li fe="2"><span class="tit"><span class="hot">*</span>开&nbsp;&nbsp;户&nbsp;&nbsp;行：</span><input type="text" class="input_long" name="bankname" value="{bankname}"/></li><li fe="4"><span class="tit"><span class="hot">*</span>发票抬头：</span><input type="text" class="input_long" name="vat_normal_name" value="{title}" />（个人或单位名称）</li><li fe="4" class="normal_fe1"><div class="para_inb"><p>发票相关信息将被系统自动打印到发票上，请勿填写和发票无关的信息。</p></div></li></ul><div fe="2" class="wrap_para para_big"><div class="para_inb" id="addtax_fe2"><p>增值税专用发票将统一从上海进行快递，可能会在您收到商品之后到达，请您谅解。</p><p>发票相关信息将被系统自动打印到发票上，请勿填写和发票无关的信息。</p><p>请首次开具增值税专用发票的客户将营业执照、税务登记证副本、一般纳税人资格证书、开户许可证传真至 021-61831107。</p></div></div></div>',create:'<ul class="list_info"><li><span class="tit">发票内容：</span>{invoiceContentOption}</li></ul><table class="table_nobor"><tfoot><tr><td colspan="2"><div class="wrap_btn"><a href="#" onclick="return false" t="isave" class="btn_strong">确认发票信息</a></div></td></tr></tfoot></table>'},
	_dao:{
		_list:false,
		_filterExistInvoiceBySite:function(b){
			var a={};
			G.logic.constants.getWhId(function(d){
				if(d==1001){var c=0;$.each(b.data,function(f,e){if(e.type==2||e.type==4){a[c]=e;c++}})}else{if(-1!=$.inArray(parseInt(d),[1,2001,3001,4001])){var c=0;$.each(b.data,function(f,e){if(e.type==1||e.type==2||e.type==3){a[c]=e;c++}})}else{a=[]}}});return a
		},
		get:function(c,d){
				if(G.logic.login.ifLogin(this,arguments)===false){return}var a=G.app.order.invoice._dao,b=G.logic.login.getLoginUid();
				if(a._list!==false){return c()}
				G.util.post("http://"+G.DOMAIN.BASE_ICSON_COM+"/json.php?mod=invoice&act=get&uid="+b,{},function(g){if(g&&g.errno==0){var e=G.app.order.status.get("product");var f=a._filterExistInvoiceBySite(g);a._list={};$.each(f,function(i,h){if(!e.isCanVAT){if(h.type==2){return}}a._list[h.iid]=h});if($.isFunction(c)){c()}}else{if($.isFunction(d)){d(g)}}})
		},
		update:function(e,c,b,d){
				if(G.logic.login.ifLogin(this,arguments)===false){return}
				var a=G.logic.login.getLoginUid();
				c.iid=e;G.util.post("http://"+G.DOMAIN.BASE_ICSON_COM+"/json.php?mod=invoice&act=modify&uid="+a,c,function(g){if(g&&g.errno==0){var f=G.app.order.invoice._dao;if(c.type==2){c.title=c.name}$.extend(f._list[e],c);$.isFunction(b)&&b()}else{$.isFunction(d)&&d(g)}})
		},
		add:function(c,b,d){
					if(G.logic.login.ifLogin(this,arguments)===false){return}var a=G.logic.login.getLoginUid();G.util.post("http://"+G.DOMAIN.BASE_ICSON_COM+"/json.php?mod=invoice&act=add&uid="+a,c,function(f){if(f&&f.errno==0){var e=G.app.order.invoice._dao;c.iid=f.data;if(c.type==2){c.title=c.name}e._list[f.data]=c;$.isFunction(b)&&b(f.data)}else{$.isFunction(d)&&d(f)}})
		},
		del:function(d,b,c){
			if(G.logic.login.ifLogin(this,arguments)===false){return}var a=G.logic.login.getLoginUid();G.util.post("http://"+G.DOMAIN.BASE_ICSON_COM+"/json.php?mod=invoice&act=del&uid="+a,{iid:d},function(g){if(g&&g.errno==0){var f=G.app.order.status.get("invoice");if(f&&f.iid==d){G.app.order.status.set("invoice",null)}var e=G.app.order.invoice._dao;delete e._list[d];$.isFunction(b)&&b()}else{$.isFunction(c)&&c(g)}})
		}
	}
	,_mod:{get:function(d,c){var b=G.app.order.invoice,a=b._dao;a.get(function(){c(a._list[d])},function(e){G.ui.popup.showMsg("获取发票信息失败，请稍候重试")})},getAll:function(c){var b=G.app.order.invoice,a=b._dao;a.get(function(){c(a._list)},function(d){G.ui.popup.showMsg("获取发票信息失败，请稍候重试")})},add:function(d,c){var b=G.app.order.invoice,a=b._dao;a.add(d,function(e){c(e,a._list)},function(e){G.ui.popup.showMsg("添加发票信息失败，请稍候重试")})},del:function(d,c){var b=G.app.order.invoice,a=b._dao;a.del(d,function(){c(a._list)},function(e){G.ui.popup.showMsg("删除发票信息失败，请稍候重试")})},update:function(e,d,c){var b=G.app.order.invoice,a=b._dao;a.update(e,d,function(){c(a._list)},function(f){G.ui.popup.showMsg("修改发票信息失败，请稍候重试")})}}
	,_view:{_curId:0,_dom:false,getDom:function(){var b=G.app.order.invoice,a=b._view;if(!a._dom){a._dom=$("#invoice_box")}return a._dom},
		clear:function(){var c=G.app.order.invoice,a=c._view,b=c._mod;a.getDom().hide()},
		desc:function(){var g=G.app.order.invoice,c=g._view,e=g._mod,d=g._tpl,b=G.app.order.status.get("invoice"),a=G.app.order.status.get("product");if(b!=null){b=g._encode(b);b.invoiceContent=a.contentOpt[b.invoiceContentIdx]||"商品明细";var h="";if(a.hasNoteBook&&(b.type==2||b.type==3)){h=G.app.order._getYTipHtml("您选择开具的发票抬头是单位，后续保修将依照厂家售后政策进行，厂家售后政策可能会与三包条款相冲突，请您确认！")}b.specialTip=h;var f=$(".bd",c.getDom()).empty().html(G.ui.template.fillWithTPL(false,b,false,d.desc[b.type==2?1:0]));G.logic.constants.getWhId(function(i){if(i==2001){$("div .zengzhi").show()}else{$("div .zengzhi").hide()}})}else{var f=$(".bd",c.getDom()).empty().html('<div class="cont"><p><span class="nor">未选择</span></p><p><a href="#" onclick="return false" name="add">【选择发票】</a></p></div>');$("a[name=add]",f).click(c.list)}c.switchBtnStatus(1)},
		_addCreateListener:function(b){var c=G.app.order.invoice,a=c._view;$("a[t=save]",b).click(function(){var d=a._getEditData(b);if(d===false){return}c._mod.add(d,function(e,f){a._curId=e;a.list()})});$("a[t=isave]",b).click(function(){$("a[t=isave]",b).attr("enable",false);var d=a._getEditData(b);if(d===false){return}c._mod.add(d,function(e,f){a._curId=e;a.save()})})},
		list:function(){
			var d=G.app.order.invoice,a=d._view,c=d._mod,b=d._tpl;c.getAll(function(h){var j=$(".bd",a.getDom()),k={},e=[];var i=' checked="checked"';$.each(G.app.order.status.get("product").contentOpt,function(n,m){if(G.app.order._isES&&"商品明细"!=m){return}e.push('<label><input type="radio" name="iv_content_check" value="'+n+'"'+i+"/>"+m+"</label>");i=""});k.invoiceContentOption=e.join(" ");if(!h||$.isEmptyObject(h)){var l=b.edit+b.create;j.empty().html(G.ui.template.fillWithTPL(false,k,false,l));a._addCreateListener(j);G.app.form_ctrl.phone().attach($("input[name=phone]",j));a._filterCreateInvoiceBySite(j);a._filterCreateInvoiceByUser(j);a.ifKillVAT(j);a._setFormListener(j);a._setEditData(j);if(G.app.order._isES){j.find(".para_inb").append($("<p>参与节能补贴订单，普通用户发票抬头必须为身份证姓名，企事业单位发票抬头必须为企事业单位名称，否则将无法获得节能补贴。</p>"));j.find("input[name=title]").val(G.app.order._esInfo.es_name);j.find("input[name=name]").val(G.app.order._esInfo.es_name)}}else{k.list=[];$.each(h,function(m,n){if(G.app.order._isES&&G.app.order._esInfo.es_name==n.title){a._curId=n.iid}k.list.push(d._encode(n))});k.list.sort(function(n,m){if(n.sortfactor!=m.sortfactor){return m.sortfactor>n.sortfactor?1:-1}if(n.last_use_time!=m.last_use_time){return m.last_use_time>n.last_use_time?1:-1}if(n.updatetime!=m.updatetime){return m.updatetime>n.updatetime?1:-1}return n.createtime>m.createtime?1:-1});if(k.list.length>4){var g=false;$.each(k.list,function(m,n){if(n.iid==a._curId){g=m}k.list[m].toNone=' style="display:none"';k.list[m].moreInvoice="moreInvoice"});var f=[0,1,2,3];if(g){if(g>3){f[3]=g}}$.each(f,function(n,m){k.list[m].toNone="";k.list[m].moreInvoice=""})}k.showMore='<tr t="showMore"'+(k.list.length<=4?' style="display:none"':"")+'><td></td><td><div class="wrap_more"><a href="#" onclick="return false" count="'+k.list.length+'">显示全部'+k.list.length+'个发票信息<span class="arrow"></span></a></div></td></tr>';j.empty().html(G.ui.template.fillWithTPL(false,k,false,b.list.replace(/\[\[item_desc\]\]/g,b.item_desc)));a._addListListener(j);if(a._curId>0){a.select(a._curId)}else{if(G.app.order._isES){a.select(-1)}else{a.select($("tr[iid]:first",j).attr("iid"))}}}a.switchBtnStatus(2)})},
		_filterCreateInvoiceBySite:function(a){G.logic.constants.getWhId(function(c){var b={1:"<p>发票相关信息将被系统自动打印到发票上，请勿填写和发票无关的信息。</p><p>请首次开具增值税专用发票的客户将营业执照、税务登记证副本、一般纳税人资格证书、开户许可证传真至 021-61831107。</p>",1001:"<p>发票相关信息将被系统自动打印到发票上，请勿填写和发票无关的信息。</p><p>请首次开具增值税专用发票的客户将营业执照、税务登记证副本、一般纳税人资格证书、开户许可证传真至 0514-82930139。</p>",2001:"<p>增值税专用发票将统一从上海进行快递，可能会在您收到商品之后到达，请您谅解。</p><p>发票相关信息将被系统自动打印到发票上，请勿填写和发票无关的信息。</p><p>请首次开具增值税专用发票的客户将营业执照、税务登记证副本、一般纳税人资格证书、开户许可证传真至 021-61831107。</p>"};b[4001]=b[1];$("#addtax_fe2").empty().html((c in b)?b[c]:"");if(c==1001){$("input[name=iv_type_check][value=1]",a).parent().remove();$.each($("li[fe=1]",a),function(e,d){$(this).remove()});$.each($("div[fe=2],li[fe=2]",a),function(e,d){$(this).hide()});$("input[name=iv_type_check][value=4]",a).attr("checked",true)}else{if(-1!=$.inArray(parseInt(c),[1,2001,3001,4001])){$("input[name=iv_type_check][value=4]",a).parent().remove();$.each($("li[fe=4]",a),function(e,d){$(this).remove()});$.each($("div[fe=2],li[fe=2]",a),function(e,d){$(this).hide()});$("input[name=iv_type_check][value=1]",a).attr("checked",true)}}})},
		_filterCreateInvoiceByUser:function(a){if(G.app.order._user){if(G.app.order._user.icsonid.toString().toLowerCase().indexOf("login_shauto_")==0){$("input[name=iv_type_check][value=2]",a).parent().remove()}}else{G.logic.login.getLoginUser(function(b){if(b&&b.data&&b.data.icsonid.toString().toLowerCase().indexOf("login_shauto_")==0){$("input[name=iv_type_check][value=2]",a).parent().remove()}})}},
		ifKillVAT:function(b){var a=G.app.order.status.get("product");if(!a.isCanVAT){$("input[name=iv_type_check][value=2]",b).parent().remove()}},
		switchBtnStatus:function(a){var d=G.app.order.invoice,b=d._view,c=d._mod;$("#invoice_btn").show();if(a==1){if(G.app.order.status.get("invoice")){G.app.order.status.get("invoice").uediting=false}$("#invoice_btn").html("更改").unbind().click(b.list)}else{if(!G.app.order.status.get("invoice")){$("#invoice_btn").hide()}else{G.app.order.status.get("invoice").uediting=true;$("#invoice_btn").html("取消").unbind().click(b.desc)}}},
		_setFormListener:function(a){$("input[name=iv_type_check]",a).click(function(){G.app.order.invoice._view._switchInvoiceType.apply(this,[a])});$("input[name=iv_ftype_check]",a).click(function(){G.app.order.invoice._view._switchInvoiceFType.apply(this,[a])})},
		_setEditAndDelListener:function(a){if(!$("a[t=edit]",this).data("binded")){$("a[t=edit]",this).click({iid:a},function(b){G.app.order.invoice._view.edit(b.data.iid)}).data("binded",true)}if(!$("a[t=del]",this).data("binded")){$("a[t=del]",this).click({iid:a},function(b){G.app.order.invoice._view.del(b.data.iid)}).data("binded",true)}},
		_setSelectListener:function(a){if(!$("input[type=radio]",this).data("binded")){$("input[type=radio]",this).click({iid:a},function(b){G.app.order.invoice._view.select(b.data.iid)}).data("binded",true)}},
		_setItemListener:function(a){G.app.order.invoice._view._setEditAndDelListener.apply(this,[a]);G.app.order.invoice._view._setSelectListener.apply(this,[a])},
		_addListListener:function(a){$("tr[iid]",a).each(function(){G.app.order.invoice._view._setItemListener.apply(this,[$(this).attr("iid")])});$("tr[t=showMore] a",a).click(function(){if($(this).parent().hasClass("status_open")){$(this).parent().removeClass("status_open");$(this).html("显示全部"+$(this).attr("count")+'条发票信息<span class="arrow"></span>');$("tr[t=moreInvoice]",a).css("display","none")}else{$(this).parent().addClass("status_open");$(this).html('收起发票信息<span class="arrow"></span>');$("tr[t=moreInvoice]",a).css("display","")}});$("a[t=isave]",a).click(G.app.order.invoice._view.save)},
		_descItem:function(a){var b=a.attr("iid"),c=G.app.order.invoice;a.data("editing",false);if(b==-1){$("td:eq(1)",a).empty().html("使用新发票")}else{c._mod.get(b,function(d){d=c._encode(d);$("td:eq(0) input[type=radio]",a).val(b);$("td:eq(1)",a).empty().html(G.ui.template.fillWithTPL(false,d,false,c._tpl.item_desc));G.app.order.invoice._view._setItemListener.apply(a,[b])})}},
		select:function(d,c){var a=G.app.order.invoice._view;var b=$(".bd tr[iid]",a.getDom()).removeClass("status_on").filter("[iid="+d+"]").addClass("status_on").find("input[name=sel_invoice]");if(b.length>0){b[0].checked=true}$(".bd tr[iid]",a.getDom()).filter("[iid!="+d+"]").each(function(){if($(this).data("editing")){a._descItem($(this))}});a._curId=d;if(d!=-1){G.app.order.invoice._mod.get(d,function(f){if(f.invoiceContentIdx==null){return}var e=$(".bd input[name=iv_content_check][value="+f.invoiceContentIdx+"]",a.getDom());if(e.length>0){e[0].checked=true}})}if(c===false){return}if(d==-1){a.edit(d)}},
		edit:function(c){var b=G.app.order,d=b.invoice,a=d._view;d._mod.get(c,function(e){a._edit(c,e)})},
		_edit:function(g,f){var e=G.app.order,h=e.invoice,b=h._view,d=$(".bd tr[iid="+g+"]",b.getDom()),a={};d.data("editing",true);b.select(g,false);$("td:eq(1)",d).empty().html(G.ui.template.fillWithTPL(false,a,false,h._tpl.edit));var c;if(g!=-1){if(f.type==1||f.type==3){c=1}else{c=f.type}$.each($("input[name=iv_type_check][value!="+c+"]",d),function(){$(this).parent().remove()})}if(G.app.order._isES&&!f){f={name:G.app.order._esInfo.es_name,title:G.app.order._esInfo.es_name}}G.app.form_ctrl.phone().attach($("input[name=phone]",d));b._filterCreateInvoiceBySite(d);b._filterCreateInvoiceByUser(d);b.ifKillVAT(d);b._setFormListener(d);b._setEditData(d,f);if(G.app.order._isES){$("tr[iid="+g+"] .para_inb").append($("<p>参与节能补贴订单，普通用户发票抬头必须为身份证姓名，企事业单位发票抬头必须为企事业单位名称，否则将无法获得节能补贴。</p>"))}$("td:eq(1) a[t=save]",d).click(function(i){b._saveItem(g)})},
		_switchInvoiceFType:function(c){var d=G.app.order,e=d.invoice,b=e._view,a=$(this).val();$(".list_info li[fe=1][ffe=1] .tit",c).empty().html('<span class="hot">*</span>'+(a==1?"个人姓名":"单位名称")+"：")},
		_switchInvoiceType:function(c){var d=G.app.order,e=d.invoice,b=e._view,a=$(this).val();$(".list_info li[fe="+a+"]",c).show();if(a==2){$(".list_info_wrap div[fe=2]",c).show()}else{$(".list_info_wrap div[fe=2]",c).hide()}$(".list_info li[fe]",c).filter("[fe!="+a+"]").hide();$(".list_info input[name=iv_ftype_check]:first",c).click()},
		_setEditData:function(e,d){var c=G.app.order,g=c.invoice,a=g._view,d=d||{},f=1,b=1;if(d.type==2){f=2}else{if(d.type==1||d.type==3){if(d.type==3){b=2}}else{if(d.type==4){f=4;d.vat_normal_name=d.title}else{}}}$("input[name=iv_type_check][value="+f+"]",e).click();if(f==1){$("input[name=iv_ftype_check][value="+b+"]",e).click()}$.each(["title","name","addr","phone","taxno","bankno","bankname","vat_normal_name"],function(h,i){if(i=="phone"){$("input[name=phone]",e).data("phone").val(d[i]||"")}else{$("input[name="+i+"]",e).val(d[i]||"")}})},
		_getEditData:function(d){var c={},e=$("input[name=iv_type_check]:checked",d).val(),a=$("input[name=iv_ftype_check]:checked",d).val(),b=1;if(e==1){if(a==2){b=3}}else{if(e==2){b=2}else{if(e==4){b=4}}}c.type=b;$.each(["title","name","addr","phone","taxno","bankno","bankname","vat_normal_name"],function(g,h){if(h=="phone"){c[h]=$("input[name=phone]",d).data("phone").val()}else{c[h]=$("input[name="+h+"]",d).val()}c[h]=$.trim(c[h])});if(b==1||b==3){$.each(c,function(g,f){if(g!="title"&&g!="type"){delete c[g]}});if(!c.title){G.ui.popup.showMsg((b==1?"个人姓名":"单位名称")+"不能为空，请填写");return false}if($.strlen(c.title)>100){G.ui.popup.showMsg((b==1?"个人姓名":"单位名称")+"不能超过50个汉字或100个字母，请重新填写");return false}}else{if(b==2){$.each(c,function(g,f){if(g=="title"){delete c[g]}});if(!c.name){G.ui.popup.showMsg("公司名称不能为空，请填写");return false}if($.strlen(c.name)>100){G.ui.popup.showMsg("公司名称不能超过50个汉字或100个字母，请重新填写");return false}if(!c.addr){G.ui.popup.showMsg("公司地址不能为空，请填写");return false}if($.strlen(c.addr)>100){G.ui.popup.showMsg("公司地址不能超过50个汉字或100个字母，请重新填写");return false}if(!c.phone){G.ui.popup.showMsg("电话号码不能为空，请填写");return false}if(!G.logic.validate.checkTelephone(c.phone)){G.ui.popup.showMsg("电话号码填写有误，格式：021-83161107，请重新填写");return false}if(!c.taxno){G.ui.popup.showMsg("税号不能为空，请填写");return false}if($.strlen(c.taxno)>25){G.ui.popup.showMsg("税号不能超过25位，请重新填写");return false}if(!G.logic.validate.checkChars(c.taxno,2|4)){G.ui.popup.showMsg("税号只能包含英文或数字，请重新填写");return false}if(!c.bankno){G.ui.popup.showMsg("银行帐号不能为空，请填写");return false}if($.strlen(c.bankno)>25){G.ui.popup.showMsg("银行帐号不能超过25位，请重新填写");return false}if(!/^[a-zA-Z0-9\-]+$/.test(c.bankno)){G.ui.popup.showMsg("银行帐号只能包含英文或数字或-，请重新填写");return false}if(!c.bankname){G.ui.popup.showMsg("开户行名称不能为空，请填写");return false}if($.strlen(c.bankname)>100){G.ui.popup.showMsg("开户行名称不能超过50个汉字或100个字母，请重新填写");return false}c.title=c.name}else{if(b==4){if($.strlen(c.vat_normal_name)>50){G.ui.popup.showMsg("发票抬头不能超过25个汉字或50个字母，请重新填写");return false}c.title=c.vat_normal_name}}}return c},
		clear:function(){G.app.order.status.reset("invoice")},
		save:function(){var d=G.app.order.invoice,a=d._view,c=d._mod,e=a._curId,b=$(".bd tr[iid="+e+"]",a.getDom());if(b&&b.data("editing")){a._saveItem(e,function(){e=a._curId,b=$(".bd tr[iid="+e+"]",a.getDom());a._save(e)})}else{a._save(e)}},
		_save:function(d,e){var c=G.app.order.invoice,a=c._view,b=c._mod;b.get(d,function(g){if(!g){return}var f=$(".bd input[name=iv_content_check]:checked",a.getDom()).val();g.invoiceContentIdx=f;G.app.order.status.set("invoice",g);a.desc();G.app.order.status.saveIds();$.isFunction(e)&&e()})},
		_saveItem:function(f,h){var g=G.app.order.invoice,a=g._view,c=g._mod,b=g._tpl,e=$(".bd tr[iid="+f+"]",a.getDom());if(e.length<=0){return}var d=a._getEditData(e);if(d===false){return}c.getAll(function(i){var j=false;$.each(i,function(m,l){var n=true;$.each(d,function(o,k){if(o=="iid"){return}if(k!=l[o]){n=false;return false}});if(n&&m!=f){j=true;return false}});if(j){G.ui.popup.showMsg("发票信息重复，无法保存！");return}if(f==-1){g._mod.add(d,function(l,m){var k=$(".bd tr[t=showMore]",a.getDom());a._descItem(e);e.find("input[name=sel_invoice]").removeAttr("checked");e=e.clone().insertBefore(k.length>0?k:e);e.attr("iid",l);a._descItem(e);a.select(l,false);$.isFunction(h)&&h()})}else{g._mod.update(f,d,function(k){a._descItem(e);$.isFunction(h)&&h()})}})},
		del:function(c){var b=G.app.order,d=b.invoice,a=d._view;if(c==-1){return}d._mod.del(c,function(){d._mod.getAll(function(f){var e=0;$.each(f,function(){e++});if(e==0){a.list()}else{setTimeout(function(){var g=$(".bd tr[iid="+c+"]",a.getDom());if(a._curId==c){$(".bd tr[aid] input[name=sel_invoice]",a.getDom()).first().click()}g.remove();if(e<=4){$(".bd tr[t=showMore]",a.getDom()).css("display","none")}},0)}})})},
		init:function(){var d=G.app.order.invoice,b=d._view,c=d._mod,a=G.app.order.status.get("address");c.getAll(function(e){if(!e||$.isEmptyObject(e)){b.list()}else{var f=G.app.order.status.getSavedId("invoice")||0;if(f!=0){G.app.order.status.delSavedId("invoice")}f=f||(a?a.iid:0);if(f>0&&e[f]&&!G.app.order._isES){b._curId=f;b.save()}else{b.list()}}})}
		},
		init:function(){this._view.init()},
		getInvoiceTypeChn:function(a){if(a==1){return"商业零售发票(个人)"}else{if(a==2){return"增值税专用发票"}else{if(a==3){return"商业零售发票(单位)"}else{if(a==4){return"普通发票"}else{return""}}}}},
		hide:function(){
			$(".bd",this._view.getDom()).empty().html('<div class="cont"><p><span class="nor">未选择</span></p><p>&nbsp;</p></div>');
		},
		_encode:function(a){a=G.app.order._encode(a);a.typeChn=this.getInvoiceTypeChn(a.type);return a}}