invoice-form.b6a27e.js 8.1 KB

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