import{r as e,L as a,o as l,K as t,b as r,d as s,e as o,f as u,w as d,g as i,v as m,l as n,j as f,z as c,ak as p,al as _,Y as h,y,p as v,am as b,a1 as g,aj as w,an as x}from"./index-DVkgSHpn.js";import{_ as $}from"./el-navbar.DVIyjZEN.js";import{_ as k,a as T}from"./el-layout._U-vZTft.js";const j=k({__name:"editor",setup(k){let j=e(!1),z=e({name:"",duty_number:"",drawer_phone:"",email:"",id:0});const P=a(),C=P.length>=2?P[P.length-2]:P[P.length-1];l((e=>{uni.$http.get("ucenter.invoice/detail",{id:e.id}).then((e=>{e.code&&!t(e.data)&&(z.value=e.data,B.value=e.data.header_type)}))}));const B=e(1),I=e=>{B.value=e},K=e=>{let a=e.detail.value;if(!j.value){if(t(a.name))return uni.$layer.showToast("请填写发票抬头"),!1;if(t(a.drawer_phone))return uni.$layer.showToast("请填写手机"),!1;if(!p(a.drawer_phone))return uni.$layer.showToast("您填写的手机号码不合法"),!1;if(t(a.email))return uni.$layer.showToast("请填写邮箱"),!1;if(!_(a.email))return uni.$layer.showToast("您填写的邮箱不正确"),!1;if(2==B.value&&t(a.duty_number))return uni.$layer.showToast("请填写税号"),!1;z.value.id>0&&(a.id=z.value.id),a.header_type=B.value,j.value=!0,uni.$http.post("ucenter.invoice/editor",a).then((e=>{j.value=!1,e.code?(C.$page.fullPath.includes("cart/confirm")?h(C.$page.fullPath):h("pages/ucenter/invoice/index"),uni.$layer.showToast(z.id>0?"编辑成功":"添加成功")):uni.$layer.showToast(e.msg)}))}};return(e,a)=>{const l=r(s("el-navbar"),$),t=y,p=v,_=b,h=g,k=w,P=x,C=r(s("el-layout"),T);return o(),u(C,null,{default:d((()=>[i(l,{placeholder:!0,fixed:!0,autoBack:!0,border:!0,title:"编辑发票"}),i(P,{onSubmit:K},{default:d((()=>[i(p,{class:"wrapper"},{default:d((()=>[i(p,{class:"content"},{default:d((()=>[i(p,{class:"form-item"},{default:d((()=>[i(p,{class:"form-item-body form-item-border"},{default:d((()=>[i(p,{class:"form-item-icon"},{default:d((()=>[i(t,{style:{"padding-right":"10rpx"}},{default:d((()=>[m("抬头类型")])),_:1})])),_:1}),i(p,{class:"form-item-input"},{default:d((()=>[i(p,{style:{"font-size":"28rpx"}},{default:d((()=>[i(_,{onClick:a[0]||(a[0]=e=>I(1)),name:"header_type",value:"1",checked:1===B.value,style:{transform:"scale(0.7)"}},null,8,["checked"]),m("个人")])),_:1}),i(p,{style:{"font-size":"28rpx"}},{default:d((()=>[i(_,{onClick:a[1]||(a[1]=e=>I(2)),name:"header_type",value:"2",checked:2===B.value,style:{transform:"scale(0.7)"}},null,8,["checked"]),m("企业")])),_:1})])),_:1})])),_:1})])),_:1}),i(p,{class:"form-item"},{default:d((()=>[i(p,{class:"form-item-body form-item-border"},{default:d((()=>[i(p,{class:"form-item-icon"},{default:d((()=>[i(t,{style:{"padding-right":"10rpx"}},{default:d((()=>[m("发票抬头")])),_:1})])),_:1}),i(p,{class:"form-item-input"},{default:d((()=>[i(h,{type:"text",name:"name",value:n(z).name,placeholder:"请输入发票抬头","placeholder-class":"form-item-placeholder"},null,8,["value"])])),_:1})])),_:1})])),_:1}),2==B.value?(o(),u(p,{key:0,class:"form-item"},{default:d((()=>[i(p,{class:"form-item-body form-item-border"},{default:d((()=>[i(p,{class:"form-item-icon"},{default:d((()=>[i(t,{style:{"padding-right":"10rpx"}},{default:d((()=>[m("企业税号")])),_:1})])),_:1}),i(p,{class:"form-item-input"},{default:d((()=>[i(h,{type:"text",name:"duty_number",value:n(z).duty_number,placeholder:"请输入税号","placeholder-class":"form-item-placeholder"},null,8,["value"])])),_:1})])),_:1})])),_:1})):f("",!0),i(p,{class:"form-item"},{default:d((()=>[i(p,{class:"form-item-body form-item-border"},{default:d((()=>[i(p,{class:"form-item-icon"},{default:d((()=>[i(t,{style:{"padding-right":"10rpx"}},{default:d((()=>[m("手机号码")])),_:1})])),_:1}),i(p,{class:"form-item-input"},{default:d((()=>[i(h,{type:"text",name:"drawer_phone",value:n(z).drawer_phone,placeholder:"请输入手机","placeholder-class":"form-item-placeholder"},null,8,["value"])])),_:1})])),_:1})])),_:1}),i(p,{class:"form-item"},{default:d((()=>[i(p,{class:"form-item-body form-item-border"},{default:d((()=>[i(p,{class:"form-item-icon"},{default:d((()=>[i(t,{style:{"padding-right":"10rpx"}},{default:d((()=>[m("接收邮箱")])),_:1})])),_:1}),i(p,{class:"form-item-input"},{default:d((()=>[i(h,{type:"text",name:"email",value:n(z).email,placeholder:"请输入邮箱","placeholder-class":"form-item-placeholder"},null,8,["value"])])),_:1})])),_:1})])),_:1})])),_:1}),i(p,{class:"form-submit"},{default:d((()=>[i(p,null,{default:d((()=>[i(k,{class:c({active:1==n(j)}),"form-type":"submit"},{default:d((()=>[m("确 定")])),_:1},8,["class"])])),_:1})])),_:1})])),_:1})])),_:1})])),_:1})}}},[["__scopeId","data-v-5ee5d89b"]]);export{j as default};
//# sourceMappingURL=pages-ucenter-invoice-editor.G1qbWwX0.js.map
