import{_ as re,d as te,E as i,af as q,bh as ne,a6 as se,H as j,x as m,o as n,N as v,K as s,y as p,a as D,u as t,c1 as H,b4 as M,c as h,M as R,L as w,b as ie,aE as pe,W as Y,aS as _,ah as de,bi as ce,bj as me}from"./index.1417328f.js";import{a as ve}from"./_details.019d6a4a.js";import{I as S}from"./global.9ad647c8.js";import{h as _e}from"./status.727086c1.js";const ke={payNo:{trigger:"change",required:!0,message:"\u8BF7\u9009\u62E9\u8BA2\u5355"},invArr:{required:!0,message:"\u8BF7\u4E0A\u4F20\u53D1\u7968",validator(L,V){return V.length!==0}}},fe={payNo:[{trigger:"blur",message:"\u8BF7\u9009\u62E9\u8BA2\u5355",required:!0}],invoiceType:[{trigger:"blur",message:"\u8BF7\u9009\u62E9\u53D1\u7968\u7C7B\u578B",required:!0}],invType:[{trigger:"blur",message:"\u8BF7\u9009\u62E9\u7533\u8BF7\u65B9\u5F0F",required:!0}],invNumber:[{trigger:"blur",message:"\u8BF7\u8F93\u5165\u53D1\u7968\u4EE3\u7801",required:!0}],invCode:[{trigger:"blur",message:"\u8BF7\u9009\u62E9\u53D1\u7968\u7F16\u7801",required:!0}],open_time:[{trigger:"blur",message:"\u8BF7\u9009\u62E9\u5F00\u7968\u65F6\u95F4",required:!0}],subtotal_amount:[{trigger:"blur",message:"\u8BF7\u8F93\u5165\u91D1\u989D",required:!0}],invName:[{trigger:"blur",message:"\u8BF7\u8F93\u5165\u53D1\u7968\u540D\u79F0",required:!0}],gold:[{trigger:"blur",message:"\u8BF7\u9009\u62E9\u91D1\u989D",required:!0}]};const Fe={key:1,"w-full":""},ge=Y("\u4E0A\u4F20\u56FE\u7247"),Be={class:"justify-end flex w-full"},be=Y("\u4FDD\u5B58"),ye=te({__name:"invoice-form",emits:["change"],setup(L,{expose:V,emit:P}){const y=i(!1),E=i([]),f=i([]),d=i("1"),K=i(!1),O=["png","jpg","bmp","jpeg"].map(l=>"image/"+l),C=i({...fe}),x=i(null),$=q(()=>d.value==="1"),F=i(""),a=i({currentValue:""}),z=ne(),G=se(),W=["invCode","checkNumber"],I=q(()=>ve[d.value]||[]),X=({type:l,size:u})=>{if(!O.includes(l))return _.error("\u8BF7\u4E0A\u4F20jpg.png.bmp.jpeg\u7C7B\u578B\u56FE\u7247"),!1;if(u/1024/1024>1)return _.error("\u56FE\u7247\u5927\u5C0F\u8D85\u8FC71M"),!1};function J(){f.value=[],E.value=[],a.value={}}function Q(){x.value.validate(async l=>{if(!!l){if(!d.value)return _.error("\u8BF7\u9009\u62E9\u7533\u8BF7\u7C7B\u578B");if(d.value==="2"){if(!f.value.length)return _.error("\u8BF7\u9009\u62E9\u4E0A\u4F20\u7684\u56FE\u7247");if(f.value.length>100)return _.error("\u4E0A\u4F20\u56FE\u7247\u4E0D\u80FD\u8D85\u8FC7100\u5F20")}P("change",d.value==="2"?f.value:{...t(a),invType:t(d)}),y.value=!1}})}function Z(l){const{keyCode:u}=l;if(u!==13)return;if(F.value.indexOf("\uFF0C")>=0)return _.error("\u4E0D\u80FD\u5305\u542B\u4E2D\u6587\u9017\u53F7"),F.value="";const o=F.value.split(",");if(o.length!==8&&o.length!==9){_.error("\u626B\u7801\u67AA\u8BC6\u522B\u6570\u636E\u683C\u5F0F\u4E0D\u6B63\u786E,\u8BF7\u91CD\u65B0\u626B\u63CF\u3002");return}let[B,c,...g]=o;const[b,A,N,e,U]=g;let r="";if(e){const T=e.slice(0,4),ae=e.slice(4,6),oe=e.slice(6);r=de(`${T}-${ae}-${oe}`).format("YYYY-MM-DD HH:mm:ss")}a.value={invoiceType:c,invCode:b,subtotal_amount:N,open_time:r,invNumber:A,checkNumber:U},F.value=""}const k=q(()=>{const{invoiceType:l}=a.value;return l==="32"||l==="31"}),ee=async({file:l})=>{const u=new FormData;u.append("img",l),u.append("token",z.token);const{message:o,code:B,data:c}=await ce(u);G({message:o,code:B,handler:()=>{c.forEach(({url:g,name:b})=>{f.value.push({inv_img:me+"/"+g,invName:b,invType:"2"})})}})},ue=l=>{const u=E.value.findIndex(({uid:o})=>o===l.uid);return f.value.splice(u,1),!0};j(()=>I.value,l=>{const u={};u.payNo=a.value.payNo,l.forEach(o=>{o.prop!=="payNo"&&(u[o.prop]="")}),a.value=u}),j(()=>a.value.invoiceType,()=>{C.value.checkNumber&&(C.value.checkNumber[0].required=["04","10"].includes(a.value.invoiceType))});const le=l=>l.getTime()>Date.now();return V({onDisplay:()=>y.value=!0}),(l,u)=>{const o=m("el-option"),B=m("el-select"),c=m("el-form-item"),g=m("el-button"),b=m("el-upload"),A=m("el-date-picker"),N=m("el-dialog");return n(),v(N,{modelValue:y.value,"onUpdate:modelValue":u[3]||(u[3]=e=>y.value=e),onClose:J,title:"\u4E0A\u4F20\u53D1\u7968",center:""},{default:s(()=>[p(t(pe),{"label-width":"100px",model:a.value,rules:C.value,ref_key:"formRef",ref:x,size:"small"},{default:s(()=>[p(c,{label:"\u53D1\u7968\u4E0A\u4F20\u65B9\u5F0F"},{default:s(()=>[p(B,{modelValue:d.value,"onUpdate:modelValue":u[0]||(u[0]=e=>d.value=e),disabled:""},{default:s(()=>[p(o,{label:"\u624B\u5DE5\u6DFB\u52A0",value:"1"}),D(' ')]),_:1},8,["modelValue"])]),_:1}),D(" \u626B\u7801\u67AA\u8BC6\u522B "),t($)?(n(),v(c,{key:0,label:"\u626B\u7801\u67AA"},{default:s(()=>[p(t(H),M({type:"textarea",placeholder:"\u8BF7\u5728\u626B\u7801\u5B8C\u6210\u540E\u624B\u52A8\u56DE\u8F66",onKeydown:Z,modelValue:F.value,"onUpdate:modelValue":u[1]||(u[1]=e=>F.value=e)},t(S)),null,16,["modelValue"])]),_:1})):D("v-if",!0),(n(!0),h(w,null,R(t(I),(e,U)=>(n(),h(w,{key:U},[!t(k)||t(k)&&!W.includes(e.prop)?(n(),v(c,{key:0,label:t(k)&&e.prop==="subtotal_amount"?"\u7A0E\u540E\u91D1\u989D":e.label,prop:e.prop},{default:s(()=>[e.prop==="invoiceType"?(n(),v(B,{key:0,modelValue:a.value[e.prop],"onUpdate:modelValue":r=>a.value[e.prop]=r,placeholder:"\u8BF7\u9009\u62E9\u53D1\u7968\u7C7B\u578B","w-750px":""},{default:s(()=>[(n(!0),h(w,null,R(t(_e),(r,T)=>(n(),v(o,{label:r.label,value:r.scanValue,key:T},null,8,["label","value"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue"])):e.prop==="inv_img"?(n(),h("div",Fe,[p(b,{class:"upload-demo","file-list":E.value,"onUpdate:file-list":u[2]||(u[2]=r=>E.value=r),"before-upload":X,"before-remove":ue,"http-request":ee,multiple:""},{default:s(()=>[p(g,{type:"primary"},{default:s(()=>[ge]),_:1})]),_:1},8,["file-list"])])):e.prop==="open_time"?(n(),v(A,{key:2,modelValue:a.value[e.prop],"onUpdate:modelValue":r=>a.value[e.prop]=r,"disabled-date":le,"value-format":"YYYY-MM-DD HH:mm:ss",placeholder:"\u8BF7\u8F93\u5165\u5F00\u7968\u65E5\u671F"},null,8,["modelValue","onUpdate:modelValue"])):(n(),v(t(H),M({key:3,modelValue:a.value[e.prop],"onUpdate:modelValue":r=>a.value[e.prop]=r},t(S)),null,16,["modelValue","onUpdate:modelValue"]))]),_:2},1032,["label","prop"])):D("v-if",!0)],64))),128)),p(c,null,{default:s(()=>[ie("div",Be,[p(g,{type:"primary",loading:K.value,onClick:Q},{default:s(()=>[be]),_:1},8,["loading"])])]),_:1})]),_:1},8,["model","rules"])]),_:1},8,["modelValue"])}}});var Ee=re(ye,[["__scopeId","data-v-7c68f4ae"],["__file","/Users/apple/Desktop/Company Projects/accout-vue3-ui/src/views/purchase/ticketReturn/components/invoice-form.vue"]]),Ae=Object.freeze(Object.defineProperty({__proto__:null,default:Ee},Symbol.toStringTag,{value:"Module"}));export{Ee as I,ke as c,Ae as i};