import{_ as W,d as ee,x as p,ah as A,c_ as ue,X as le,A as ae,r as m,o as s,G as v,D as n,l as r,m as i,aQ as oe,a as C,co as N,bJ as T,c as w,F as U,E as M,e4 as te,h as ne,M as R,aZ as B,ae as se,c$ as re,d0 as pe}from"./index.js";import{t as de}from"./_details.215a1c33.js";import{i as ce}from"./_rules.aa11c031.js";import{I as Y}from"./global.9ad647c8.js";const ie={"w-full":""},me=ee({__name:"invoice-form",emits:["change"],setup(ve,{expose:j,emit:H}){const D=p(!1),V=p([]),f=p([]),d=p("1"),S=p(!1),L=["png","jpg","bmp","jpeg"].map(l=>"image/"+l),x=A(()=>de[d.value]||[]),$=p({...ce}),I=p(null),q=A(()=>d.value==="1"),_=p(""),a=p({currentValue:""}),G=ue(),K=le(),P=({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 X(){f.value=[],V.value=[],a.value={}}function z(){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(!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")}H("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,g,b,E,u]=c,h=E.slice(0,4),o=E.slice(4,6),k=E.slice(6);a.value={invoiceType:F,invCode:y,subtotal_amount:b,open_time:se(`${h}-${o}-${k}`).format("YYYY-MM-DD HH:mm:ss"),invNumber:g,checkNumber:u},_.value=""}const O=async({file:l})=>{const e=new FormData;e.append("img",l),e.append("token",G.token);const{message:t,code:F,data:c}=await re(e);K({message:t,code:F,handler:()=>{c.forEach(({url:y,name:g})=>{f.value.push({inv_img:pe+"/"+y,invName:g,invType:"2"})})}})},Q=l=>{const e=V.value.findIndex(({uid:t})=>t===l.uid);return f.value.splice(e,1),!0};ae(()=>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:()=>D.value=!0}),(l,e)=>{const t=m("el-option"),F=m("el-select"),c=m("el-form-item"),y=m("el-button"),g=m("el-upload"),b=m("el-date-picker"),E=m("el-dialog");return s(),v(E,{modelValue:D.value,"onUpdate:modelValue":e[3]||(e[3]=u=>D.value=u),onClose:X,"close-on-click-modal":!1},{default:n(()=>[r(i(oe),{"label-width":"100px",model:a.value,rules:$.value,ref_key:"formRef",ref:I,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}),C(" \u626B\u7801\u67AA\u8BC6\u522B "),i(q)?(s(),v(c,{key:0,label:"\u626B\u7801\u67AA"},{default:n(()=>[r(i(N),T({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(Y)),null,16,["modelValue"])]),_:1})):C("v-if",!0),(s(!0),w(U,null,M(i(x),(u,h)=>(s(),v(c,{label:u.label,prop:u.prop,key:h},{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,M(i(te),(o,k)=>(s(),v(t,{label:o.label,value:o.hwy_value,key:k},null,8,["label","value"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue"])):u.prop==="inv_img"?(s(),w(U,{key:1},[C(' list-type="picture" '),ne("div",ie,[r(g,{class:"upload-demo","file-list":V.value,"onUpdate:fileList":e[2]||(e[2]=o=>V.value=o),"before-upload":P,"before-remove":Q,"http-request":O,multiple:""},{default:n(()=>[r(y,{type:"primary"},{default:n(()=>[R("\u4E0A\u4F20\u56FE\u7247")]),_:1})]),_:1},8,["file-list"])])],64)):u.prop==="open_time"?(s(),v(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(),v(i(N),T({key:3,modelValue:a.value[u.prop],"onUpdate:modelValue":o=>a.value[u.prop]=o},i(Y)),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:z},{default:n(()=>[R("\u4FDD\u5B58")]),_:1},8,["loading"])]),_:1})]),_:1},8,["model","rules"])]),_:1},8,["modelValue"])}}});var Be=W(me,[["__scopeId","data-v-48894978"],["__file","C:/Users/89793/Desktop/projects/settle-vue3/src/views/purchaseNew/unInvoiceRelation/components/invoice-form.vue"]]);export{Be as default};
