import{_ as ne,d as se,x as f,ah as H,c_ as ie,X as pe,A as $,r as F,o as i,G as g,D as p,l as _,m as r,aQ as de,a as V,co as L,bJ as G,c as k,F as R,E as K,df as ce,M as N,h as me,aZ as s,ae as d,c$ as ve,d0 as fe}from"./index.js";import{t as Fe}from"./_details.f1560125.js";import{I as P}from"./global.9ad647c8.js";const _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",required:!0,validator(T,c,a){c===""?a(new Error("\u53D1\u7968\u53F7\u7801\u4E0D\u80FD\u4E3A\u7A7A!")):/^\d+(\.\d+)?$/.test(c)?a():a(new Error("\u53D1\u7968\u53F7\u7801\u5FC5\u987B\u4E3A\u6570\u5B57"))}}],invCode:[{required:!0,validator(T,c,a){c===""?a(new Error("\u53D1\u7968\u4EE3\u7801\u4E0D\u80FD\u4E3A\u7A7A!")):/^\d+(\.\d+)?$/.test(c)?a():a(new Error("\u53D1\u7968\u4EE3\u7801\u5FC5\u987B\u4E3A\u6570\u5B57"))}}],open_time:[{trigger:"blur",message:"\u8BF7\u9009\u62E9\u5F00\u7968\u65F6\u95F4",required:!0}],subtotal_amount:[{trigger:"blur",required:!0,validator(T,c,a){c===""?a(new Error("\u7A0E\u524D\u91D1\u989D\u4E0D\u80FD\u4E3A\u7A7A!")):/^\d+(\.\d+)?$/.test(c)?a():a(new Error("\u7A0E\u524D\u91D1\u989D\u5FC5\u987B\u4E3A\u6570\u5B57\u4E14\u4E0D\u80FD\u4E3A\u8D1F\u6570!"))}}],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 Ee={key:1,"w-full":""},De={class:"justify-end flex w-full"},ge=se({__name:"invoice-form",emits:["change"],setup(T,{expose:c,emit:a}){const E=f(!1),b=f([]),v=f([]),m=f("1"),S=f(!1),X=["png","jpg","bmp","jpeg"].map(l=>"image/"+l),Y=f({..._e}),x=f(null),z=H(()=>m.value==="1"),B=f(""),u=f({currentValue:""}),J=ie(),O=pe(),Q=["invCode","checkNumber"],j=H(()=>Fe[m.value]||[]),Z=({type:l,size:e})=>{if(!X.includes(l))return s.error("\u8BF7\u4E0A\u4F20jpg.png.bmp.jpeg\u7C7B\u578B\u56FE\u7247"),!1;if(e/1024/1024>1)return s.error("\u56FE\u7247\u5927\u5C0F\u8D85\u8FC71M"),!1};function W(){v.value=[],b.value=[],u.value={}}function ee(){x.value.validate(async l=>{if(!l)return;if(!m.value)return s.error("\u8BF7\u9009\u62E9\u7533\u8BF7\u7C7B\u578B");if(m.value==="2"){if(!v.value.length)return s.error("\u8BF7\u9009\u62E9\u4E0A\u4F20\u7684\u56FE\u7247");if(v.value.length>100)return s.error("\u4E0A\u4F20\u56FE\u7247\u4E0D\u80FD\u8D85\u8FC7100\u5F20")}const e=d(new Date).format("YYYY-MM-DD");if(u.value.open_time&&!d(u.value.open_time).isSame(d(e))&&!d(u.value.open_time).isBefore(d(e)))return s.error("\u5F00\u7968\u65E5\u671F\u4E0D\u80FD\u8D85\u8FC7\u5F53\u524D\u65E5\u671F");a("change",m.value==="2"?v.value:{...r(u),invType:r(m)}),E.value=!1})}function ue(){x.value.validate(async l=>{if(!l)return;if(!m.value)return s.error("\u8BF7\u9009\u62E9\u7533\u8BF7\u7C7B\u578B");if(m.value==="2"){if(!v.value.length)return s.error("\u8BF7\u9009\u62E9\u4E0A\u4F20\u7684\u56FE\u7247");if(v.value.length>100)return s.error("\u4E0A\u4F20\u56FE\u7247\u4E0D\u80FD\u8D85\u8FC7100\u5F20")}const e=d(new Date).format("YYYY-MM-DD");if(u.value.open_time&&!d(u.value.open_time).isSame(d(e))&&!d(u.value.open_time).isBefore(d(e)))return s.error("\u5F00\u7968\u65E5\u671F\u4E0D\u80FD\u8D85\u8FC7\u5F53\u524D\u65E5\u671F");a("change",m.value==="2"?v.value:{...r(u),invType:r(m)}),u.value={}})}function le(l){const{keyCode:e}=l;if(e!==13)return;if(B.value.indexOf("\uFF0C")>=0)return s.error("\u4E0D\u80FD\u5305\u542B\u4E2D\u6587\u9017\u53F7"),B.value="";const t=B.value.split(",");if(t.length!==8&&t.length!==9){s.error("\u626B\u7801\u67AA\u8BC6\u522B\u6570\u636E\u683C\u5F0F\u4E0D\u6B63\u786E,\u8BF7\u91CD\u65B0\u626B\u63CF\u3002");return}let[h,A,...D]=t;const[C,I,q,y,o]=D;let w="";if(y){const n=y.slice(0,4),M=y.slice(4,6),te=y.slice(6);w=d(`${n}-${M}-${te}`).format("YYYY-MM-DD HH:mm:ss")}u.value={invoiceType:A,invCode:C,subtotal_amount:q,open_time:w,invNumber:I,checkNumber:o},B.value=""}const U=H(()=>{const{invoiceType:l}=u.value;return l==="32"||l==="31"}),oe=async({file:l})=>{const e=new FormData;e.append("img",l),e.append("token",J.token);const{message:t,code:h,data:A}=await ve(e);O({message:t,code:h,handler:()=>{A.forEach(({url:D,name:C})=>{v.value.push({inv_img:fe+"/"+D,invName:C,invType:"2"})})}})},re=l=>{const e=b.value.findIndex(({uid:t})=>t===l.uid);return v.value.splice(e,1),!0};$(()=>j.value,l=>{const e={};e.payNo=u.value.payNo,l.forEach(t=>{t.prop!=="payNo"&&(e[t.prop]="")}),u.value=e}),$(()=>u.value.invoiceType,()=>{Y.value.checkNumber&&(Y.value.checkNumber[0].required=["04","10"].includes(u.value.invoiceType))});const ae=l=>l.getTime()>Date.now();return c({onDisplay:()=>E.value=!0}),(l,e)=>{const t=F("el-form-item"),h=F("el-option"),A=F("el-select"),D=F("el-button"),C=F("el-upload"),I=F("el-date-picker"),q=F("ElTag"),y=F("el-dialog");return i(),g(y,{modelValue:E.value,"onUpdate:modelValue":e[2]||(e[2]=o=>E.value=o),onClose:W,title:"\u4E0A\u4F20\u53D1\u7968",center:"","close-on-click-modal":!1,"close-on-press-escape":!1},{default:p(()=>[_(r(de),{"label-width":"100px",model:u.value,rules:Y.value,ref_key:"formRef",ref:x,size:"small"},{default:p(()=>[V(` \r \r \r \r \r `),V(" \u626B\u7801\u67AA\u8BC6\u522B "),r(z)?(i(),g(t,{key:0,label:"\u626B\u7801\u67AA"},{default:p(()=>[_(r(L),G({type:"textarea",placeholder:"\u8BF7\u5728\u626B\u7801\u5B8C\u6210\u540E\u624B\u52A8\u56DE\u8F66",onKeydown:le,modelValue:B.value,"onUpdate:modelValue":e[0]||(e[0]=o=>B.value=o)},r(P)),null,16,["modelValue"])]),_:1})):V("v-if",!0),(i(!0),k(R,null,K(r(j),(o,w)=>(i(),k(R,{key:w},[!r(U)||r(U)&&!Q.includes(o.prop)?(i(),g(t,{key:0,label:r(U)&&o.prop==="subtotal_amount"?"\u7A0E\u540E\u91D1\u989D":o.label,prop:o.prop},{default:p(()=>[o.prop==="invoiceType"?(i(),g(A,{key:0,modelValue:u.value[o.prop],"onUpdate:modelValue":n=>u.value[o.prop]=n,placeholder:"\u8BF7\u9009\u62E9\u53D1\u7968\u7C7B\u578B","w-750px":""},{default:p(()=>[(i(!0),k(R,null,K(r(ce),(n,M)=>(i(),g(h,{label:n.label,value:n.scanValue,key:M},null,8,["label","value"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue"])):o.prop==="inv_img"?(i(),k("div",Ee,[_(C,{class:"upload-demo","file-list":b.value,"onUpdate:fileList":e[1]||(e[1]=n=>b.value=n),"before-upload":Z,"before-remove":re,"http-request":oe,multiple:""},{default:p(()=>[_(D,{type:"primary"},{default:p(()=>[N("\u4E0A\u4F20\u56FE\u7247")]),_:1})]),_:1},8,["file-list"])])):o.prop==="open_time"?(i(),g(I,{key:2,modelValue:u.value[o.prop],"onUpdate:modelValue":n=>u.value[o.prop]=n,disabledDate:ae,"value-format":"YYYY-MM-DD HH:mm:ss",placeholder:"\u8BF7\u8F93\u5165\u5F00\u7968\u65E5\u671F"},null,8,["modelValue","onUpdate:modelValue"])):(i(),g(r(L),G({key:3,modelValue:u.value[o.prop],"onUpdate:modelValue":n=>u.value[o.prop]=n},r(P)),null,16,["modelValue","onUpdate:modelValue"]))]),_:2},1032,["label","prop"])):V("v-if",!0)],64))),128)),_(t,null,{default:p(()=>[_(q,{type:"warning",style:{"margin-left":"30px"}},{default:p(()=>[N("\u6682\u4E0D\u652F\u6301\u4E0A\u4F20\u8D1F\u6570\u53D1\u7968")]),_:1}),me("div",De,[_(D,{type:"primary",loading:S.value,onClick:ue},{default:p(()=>[N("\u4FDD\u5B58\u5F53\u524D\u53D1\u7968")]),_:1},8,["loading"]),_(D,{type:"primary",loading:S.value,onClick:ee},{default:p(()=>[N("\u4FDD\u5B58\u5E76\u5173\u95ED")]),_:1},8,["loading"])])]),_:1})]),_:1},8,["model","rules"])]),_:1},8,["modelValue"])}}});var Ce=ne(ge,[["__scopeId","data-v-f4e4f622"],["__file","C:/Users/89793/Desktop/projects/settle-vue3/src/views/supplyNew/invoiceRelation/components/invoice-form.vue"]]);export{Ce as default};