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