create-modal.fd3052.js 6.0 KB

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