invoice-form.951f1a.js 4.8 KB

1
  1. import{_ as W,d as ee,x as p,ah as A,c_ as le,X as ue,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 R,c as U,F as w,E as T,e7 as te,h as ne,M,aZ as B,ae as se,c$ as re,d0 as pe}from"./index.js";import{t as de}from"./_details.05947f76.js";import{i as ce}from"./_rules.da2e4e6a.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(u=>"image/"+u),x=A(()=>de[d.value]||[]),$=p({...ce}),I=p(null),q=A(()=>d.value==="1"),_=p(""),a=p({currentValue:""}),G=le(),K=ue(),P=({type:u,size:e})=>{if(!L.includes(u))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 u=>{if(!!u){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(u){const{keyCode:e}=u;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,l]=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:l},_.value=""}const O=async({file:u})=>{const e=new FormData;e.append("img",u),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=u=>{const e=V.value.findIndex(({uid:t})=>t===u.uid);return f.value.splice(e,1),!0};ae(()=>x.value,u=>{const e={};e.payNo=a.value.payNo,u.forEach(t=>{t.prop!=="payNo"&&(e[t.prop]="")}),a.value=e});const Z=u=>u.getTime()>Date.now();return j({onDisplay:()=>D.value=!0}),(u,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]=l=>D.value=l),onClose:X,"close-on-click-modal":!1,"close-on-press-escape":!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]=l=>d.value=l)},{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),R({type:"textarea",placeholder:"\u8BF7\u5728\u626B\u7801\u5B8C\u6210\u540E\u624B\u52A8\u56DE\u8F66",onKeydown:J,modelValue:_.value,"onUpdate:modelValue":e[1]||(e[1]=l=>_.value=l)},i(Y)),null,16,["modelValue"])]),_:1})):C("v-if",!0),(s(!0),U(w,null,T(i(x),(l,h)=>(s(),v(c,{label:l.label,prop:l.prop,key:h},{default:n(()=>[l.prop==="invoiceType"?(s(),v(F,{key:0,modelValue:a.value[l.prop],"onUpdate:modelValue":o=>a.value[l.prop]=o,placeholder:"\u8BF7\u9009\u62E9\u53D1\u7968\u7C7B\u578B","w-750px":""},{default:n(()=>[(s(!0),U(w,null,T(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"])):l.prop==="inv_img"?(s(),U(w,{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(()=>[M("\u4E0A\u4F20\u56FE\u7247")]),_:1})]),_:1},8,["file-list"])])],64)):l.prop==="open_time"?(s(),v(b,{key:2,modelValue:a.value[l.prop],"onUpdate:modelValue":o=>a.value[l.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),R({key:3,modelValue:a.value[l.prop],"onUpdate:modelValue":o=>a.value[l.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(()=>[M("\u4FDD\u5B58")]),_:1},8,["loading"])]),_:1})]),_:1},8,["model","rules"])]),_:1},8,["modelValue"])}}});var Be=W(me,[["__scopeId","data-v-3f57436f"],["__file","C:/Users/89793/Desktop/projects/settle-vue3/src/views/InvoiceSales/supplierReturnRelive/components/invoice-form.vue"]]);export{Be as default};