batchImportSendOrder.d023ca.js 3.9 KB

1
  1. import{aZ as i,be as O,am as x,_ as $,d as I,x as P,p as V,bG as T,W as L,r as F,aD as M,H as j,m as h,o as g,c as B,l as D,D as b,G as w,a as y,F as q,E as G,bJ as R,M as A}from"./index.js";import{e as U}from"./execl-upload.7c83427b.js";import{c as m}from"./template.140ed259.js";import{h as z}from"./index.b3c071be.js";import"./xlsx.ed122d16.js";function H(u,e){if(u.length!==e.length)return i.warning("\u5BFC\u5165\u7684\u6A21\u677F\u683C\u5F0F\u4E0D\u6B63\u786E"),!1;for(const t in u)if(u[t].label!==e[t])return i.warning("\u5BFC\u5165\u7684\u6A21\u677F\u683C\u5F0F\u4E0D\u6B63\u786E"),!1;return!0}const J=m.reduce((u,e)=>({...u,[e.label]:e.prop}),{});function W(u){const e=[];for(const t of u){const n={};for(const o in t)n[J[o]]=t[o];e.push(n)}return e}const C=m.reduce((u,e)=>({...u,[e.prop]:e.label}),{}),Z=m.filter(u=>u.required).map(u=>u.prop),K=m.filter(u=>u.number).map(u=>u.prop),Q=u=>u===""||u.trim()==="",X=/^\d+(\.\d+)?$/,Y=/[^\w\s]/g;function S(u){let e=[];for(const t in u){let n=[];const o=u[t];for(const r in o){let s=String(o[r]);Z.includes(r)&&Q(s)&&n.push(`${C[r]}\u4E0D\u80FD\u4E3A\u7A7A`),K.includes(r)&&X.test(s)===!1&&n.push(`${C[r]}\u5FC5\u987B\u4E3A\u6570\u5B57`),r==="remark"&&(s=s.replace(/[\s\r\n]+/g,""),o[r]=s,Y.test(s)&&n.push(`${C[r]}\u4E0D\u80FD\u5305\u542B\u6807\u70B9\u7B26\u53F7`))}n.length!==0&&e.push({index:Number(t)+1,error:n.join(",")})}return{errorSet:e,isValid:e.length===0}}function k(u){const e=u.map(t=>`\u7B2C ${t.index} \u884C\uFF1A${t.error}`);O({title:"\u6570\u636E\u6821\u9A8C\u5931\u8D25",type:"warning",message:x("div",null,e.map(t=>x("p",null,t)))})}const ee={class:"padding-container bg-white"},ue={key:1,class:"flex my-[10px]"},te=I({__name:"batchImportSendOrder",setup(u){const e=P([]),{push:t}=V(),{run:n,loading:o}=T({success:()=>t("/supplierOrder/supSendOrder")}),{currentCompany:r}=L();function s({results:d,header:p}){if(!H(m,p))return;const l=W(d),c=[...new Set(l.map(E=>E.supplierNo))];if(c.length>1){i.warning("\u4E0A\u4F20\u591A\u6761\u6570\u636E\u4F9B\u5E94\u5546\u5FC5\u987B\u4E00\u81F4");return}if(c[0]!==r.value.companyNo){i.warning("\u4E0A\u4F20\u6570\u636E\u7684\u4F9B\u5E94\u5546\u4E0E\u9009\u4E2D\u7684\u4F9B\u5E94\u5546\u4E0D\u4E00\u81F4");return}const{errorSet:a,isValid:f}=S(l);f||k(a),e.value=l}function N(){if(e.value.length>100){i.warning("\u5BFC\u5165\u53D1\u8D27\u8FD0\u5355\u4E0D\u80FD\u8D85\u8FC7100\u6761");return}const d=[...new Set(e.value.map(a=>a.supplierNo))];if(d.length>1){i.warning("\u4E0A\u4F20\u591A\u6761\u6570\u636E\u4F9B\u5E94\u5546\u5FC5\u987B\u4E00\u81F4");return}if(d[0]!==r.value.companyNo){i.warning("\u4E0A\u4F20\u6570\u636E\u7684\u4F9B\u5E94\u5546\u4E0E\u9009\u4E2D\u7684\u4F9B\u5E94\u5546\u4E0D\u4E00\u81F4");return}const{errorSet:p,isValid:l}=S(e.value);if(!l){k(p);return}const c=e.value.map(({outChildCode:a,supplierNo:f,companyNo:E,post_fee:v,remark:_})=>({outChildCode:a,supplierNo:f,companyNo:E,remark:_,post_fee:Number(v).toFixed(2)}));n(z({list:c}))}return(d,p)=>{const l=F("el-table-column"),c=F("el-table"),a=F("el-button"),f=F("el-tab-pane"),E=F("el-tabs"),v=M("loading");return j((g(),B("div",ee,[D(E,{class:"px-[10px]"},{default:b(()=>[D(f,{label:"\u6279\u91CF\u5BFC\u5165\u53D1\u8D27\u8FD0\u5355"},{default:b(()=>[e.value.length===0?(g(),w(h(U),{key:0,style:{width:"100%"},onOnSuccess:s})):y("v-if",!0),D(c,{border:"",size:"mini",class:"my-[10px]",data:e.value},{default:b(()=>[(g(!0),B(q,null,G(h(m),_=>(g(),w(l,R(_,{key:_.prop,"show-overflow-tooltip":""}),null,16))),128))]),_:1},8,["data"]),e.value.length!==0?(g(),B("div",ue,[D(a,{class:"ml-auto",onClick:p[0]||(p[0]=_=>e.value=[])},{default:b(()=>[A("\u53D6\u6D88")]),_:1}),D(a,{type:"primary",class:"ml-auto",onClick:N},{default:b(()=>[A("\u4FDD\u5B58")]),_:1})])):y("v-if",!0)]),_:1})]),_:1})])),[[v,h(o)]])}}});var le=$(te,[["__file","C:/Users/89793/Desktop/projects/settle-vue3/src/views/supplierOrder/sendOrder/batchImportSendOrder.vue"]]);export{le as default};