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