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