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