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