index.c289d8.js 6.5 KB

1
  1. import{_ as Z,d as J,x as D,df as k,W as K,aO as Q,r as B,o as E,G as $,D as g,m as b,a as M,l as T,c as N,F as X,E as Y,L as H,M as V,h as w,aZ as l}from"./index.js";import{e as ee}from"./execl-upload.7c83427b.js";import{c as ue}from"./index.26d6ac45.js";import"./xlsx.ed122d16.js";const U=["\u4E70\u65B9\u516C\u53F8\u7F16\u7801","\u4E70\u65B9\u516C\u53F8\u540D\u79F0","\u5356\u65B9\u516C\u53F8\u7F16\u7801","\u5356\u65B9\u516C\u53F8\u540D\u79F0","\u5BF9\u8D26\u7F16\u7801","\u53D1\u7968\u7C7B\u578B","\u53D1\u7968\u4EE3\u7801","\u53D1\u7968\u53F7\u7801","\u53D1\u7968\u7A0E\u524D\u91D1\u989D","\u5F00\u7968\u65E5\u671F","\u6821\u9A8C\u7801"],O={value0:"companyNo",value1:"companyName",value2:"supplierNo",value3:"supplierName",value4:"payNo",value5:"invoiceType",value6:"invoiceCode",value7:"invoiceNumber",value8:"inv_subtotal_amount",value9:"open_time",value10:"checkNumber"},te=[],oe=()=>{const A=[{type:"index",width:"50",fixed:"left",label:"\u5E8F\u53F7"}];return U.forEach((x,F)=>{A.push({prop:"value"+F,label:x,minWidth:F===0||F===1?"120px":"90px"})}),A},ae={key:0},se={key:1},le=w("span",{style:{color:"#f56c6c","font-size":"14px"}},"* ",-1),ne={key:1,flex:"","justify-end":"","gap-2":"",style:{padding:"10px 0 0 0"}},re=J({__name:"index",emits:["onSuccess"],setup(A,{expose:x,emit:F}){const y=D(!1),u=D(!1),n=D([]),I=oe(),L=k.map(({label:s})=>s),W=D(1),z=s=>`\u5BFC\u5165\u6570\u636E\u7B2C ${s} \u884C \u53D1\u7968\u7C7B\u578B\u683C\u5F0F\u4E0D\u6B63\u786E,\u53D1\u7968\u7C7B\u578B\u5FC5\u987B\u4E3A${L.join(",")}`,{currentCompany:S}=K(),q=Q(),G=({results:s,header:v})=>{if(u.value=!0,s.length===0){l.error("\u8868\u683C\u65E0\u6709\u6548\u6570\u636E\uFF01"),u.value=!1;return}let f=!0;if(v.length!==U.length?f=!1:U.forEach((o,r)=>{o!==v[r]&&(f=!1)}),!f){l.error("\u8868\u5934\u4E0E\u5BFC\u5165\u6A21\u677F\u4E0D\u5339\u914D\uFF01"),u.value=!1;return}n.value=[];for(const o of s){const r=Object.values(o);let e={};r.forEach((a,c)=>{e["value"+c]=a+""}),n.value.push(e),W.value=W.value+1}const d=[];n.value.forEach((o,r)=>{const e={};for(let a in o){const c=O[a],i=o[a];e[c]=i}d.push(e)});const p=[],m=[],t=[],h=[],_=[];if(d.forEach((o,r)=>{const e=o.invoiceType.trim(),a=k.find(({label:i})=>i===e);a?(o.invoiceType=a.value,(a.value==="normal"||a.value==="electronic")&&!o.checkNumber&&m.push(String(r+1))):p.push(String(r+1));const c=/^\d+(\.\d+)?$/;c.test(o.invoiceCode)||t.push(String(r+1)),c.test(o.invoiceNumber)||h.push(String(r+1)),(!c.test(o.inv_subtotal_amount)||Number(o.inv_subtotal_amount)<0)&&_.push(String(r+1))}),p.length>0){l({type:"error",message:z(p.join(","))}),u.value=!1;return}if(m.length>0){l({type:"error",message:`\u7B2C ${m.join(",")} \u884C,\u6821\u9A8C\u7801\u4E0D\u80FD\u4E3A\u7A7A\u3002`}),u.value=!1,n.value=[];return}if(t.length>0){l({type:"error",message:`\u7B2C ${t.join(",")} \u884C,\u53D1\u7968\u4EE3\u7801\u5FC5\u987B\u4E3A\u6570\u5B57\u3002`}),u.value=!1,n.value=[];return}if(h.length>0){l({type:"error",message:`\u7B2C ${h.join(",")} \u884C,\u53D1\u7968\u53F7\u7801\u5FC5\u987B\u4E3A\u6570\u5B57\u3002`}),u.value=!1,n.value=[];return}if(_.length>0){l({type:"error",message:`\u7B2C ${_.join(",")} \u884C,\u53D1\u7968\u7A0E\u524D\u91D1\u989D\u5FC5\u987B\u4E3A\u6570\u5B57\u4E14\u4E0D\u80FD\u662F\u8D1F\u6570`}),u.value=!1,n.value=[];return}u.value=!1},P=async()=>{try{if(u.value)return;u.value=!0;const s=[];n.value.forEach((e,a)=>{const c={};for(let i in e){const C=O[i],j=e[i];c[C]=j}s.push(c)});const v=[],f=[],d=[],p=[],m=[];if(s.forEach((e,a)=>{const c=e.invoiceType.trim(),i=k.find(({label:j})=>j===c);i?(e.invoiceType=i.value,(i.value==="normal"||i.value==="electronic")&&!e.checkNumber&&f.push(String(a+1))):v.push(String(a+1));const C=/^\d+(\.\d+)?$/;C.test(e.invoiceCode)||d.push(String(a+1)),C.test(e.invoiceNumber)||p.push(String(a+1)),(!C.test(e.inv_subtotal_amount)||Number(e.inv_subtotal_amount)<0)&&m.push(String(a+1))}),v.length>0){l({type:"error",message:z(v.join(","))}),u.value=!1;return}if(f.length>0){l({type:"error",message:`\u7B2C ${f.join(",")} \u884C,\u6821\u9A8C\u7801\u4E0D\u80FD\u4E3A\u7A7A\u3002`}),u.value=!1;return}if(d.length>0){l({type:"error",message:`\u7B2C ${d.join(",")} \u884C,\u53D1\u7968\u4EE3\u7801\u5FC5\u987B\u4E3A\u6570\u5B57\u3002`}),u.value=!1;return}if(p.length>0){l({type:"error",message:`\u7B2C ${p.join(",")} \u884C,\u53D1\u7968\u53F7\u7801\u5FC5\u987B\u4E3A\u6570\u5B57\u3002`}),u.value=!1;return}if(m.length>0){l({type:"error",message:`\u7B2C ${m.join(",")} \u884C,\u53D1\u7968\u7A0E\u524D\u91D1\u989D\u5FC5\u987B\u4E3A\u6570\u5B57\u4E14\u4E0D\u80FD\u662F\u8D1F\u6570`}),u.value=!1;return}const t=s.map(({companyNo:e})=>e);if([...new Set(t)].length>1){l.error("\u4E70\u65B9\u516C\u53F8\u7F16\u7801\u4E0D\u4E00\u81F4"),u.value=!1;return}if(s[0].companyNo!=S.value.companyNo){l.error("\u4E70\u65B9\u516C\u53F8\u7F16\u7801\u4E0E\u5F53\u524D\u9009\u4E2D\u7684\u516C\u53F8\u4E0D\u4E00\u81F4"),u.value=!1;return}s.forEach(e=>{delete e.supplierNo,delete e.supplierName,delete e.companyName,delete e.companyNo});const{code:o,message:r}=await ue({list:s,companyNo:S.value.companyNo,relaComNo:S.value.companyNo});u.value=!1,q({code:o,message:r,noMessage:!1,handler:()=>{l.success("\u6570\u636E\u5BFC\u5165\u6210\u529F\uFF01"),F("onSuccess"),y.value=!1}})}catch{}},R=()=>{n.value=[]};return x({onDisplay:()=>(y.value=!0,n.value=[])}),(s,v)=>{const f=B("el-table-column"),d=B("el-table"),p=B("el-button"),m=B("el-dialog");return E(),$(m,{"close-on-click-modal":!1,modelValue:y.value,"onUpdate:modelValue":v[0]||(v[0]=t=>y.value=t),title:"\u6279\u91CF\u5BFC\u5165\u5F00\u7968\u6570\u636E",width:"1040px",top:"8vh",center:""},{default:g(()=>[n.value.length===0?(E(),$(b(ee),{key:0,onOnSuccess:G})):M("v-if",!0),T(d,{data:n.value,stripe:"",border:"","max-height":"500px",size:"small",style:{width:"100%"}},{default:g(()=>[(E(!0),N(X,null,Y(b(I),(t,h)=>(E(),$(f,{type:t.type,minWidth:t.minWidth,fixed:t.fixed,key:h,prop:t.prop,"show-overflow-tooltip":""},{header:g(()=>[!b(te).includes(b(O)[t.prop])||t.label==="\u5E8F\u53F7"?(E(),N("span",ae,H(t.label),1)):(E(),N("p",se,[le,V(" "+H(t.label),1)]))]),_:2},1032,["type","minWidth","fixed","prop"]))),128))]),_:1},8,["data"]),n.value.length!==0?(E(),N("div",ne,[T(p,{size:"small",onClick:R},{default:g(()=>[V("\u53D6\u6D88")]),_:1}),T(p,{size:"small",type:"primary",loading:u.value,onClick:P},{default:g(()=>[V("\u4FDD\u5B58")]),_:1},8,["loading"])])):M("v-if",!0)]),_:1},8,["modelValue"])}}});var fe=Z(re,[["__file","C:/Users/89793/Desktop/projects/settle-vue3/src/views/supplierOrder/sendOrderInvoice/components/execl-files-upload-inv/index.vue"]]);export{fe as default};