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