import{cm as p,cD as O,af as w,_ as $,d as I,n as P,k as V,d3 as T,O as L,r as _,aw as j,B as q,i as v,o as g,c as b,h as D,y as A,A as B,a as x,F as z,z as M,d6 as R,H as y}from"./index.js";import{e as H}from"./execl-upload.d28cb458.js";import{c as m}from"./template.1fabfb8e.js";import{h as U}from"./index.3e69b0f4.js";import"./xlsx.ed122d16.js";function G(e,u){if(e.length!==u.length)return p.warning("\u5BFC\u5165\u7684\u6A21\u677F\u683C\u5F0F\u4E0D\u6B63\u786E"),!1;for(const t in e)if(e[t].label!==u[t])return p.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 K(e){const u=[];for(const t of e){const r={};for(const s in t)r[J[s]]=t[s];u.push(r)}return u}const h=m.reduce((e,u)=>({...e,[u.prop]:u.label}),{}),Q=m.filter(e=>e.required).map(e=>e.prop),W=m.filter(e=>e.number).map(e=>e.prop),X=e=>e===""||e.trim()==="",Y=/^\d+(\.\d+)?$/,Z=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 s=e[t];for(const n in s){let a=String(s[n]);Q.includes(n)&&X(a)&&r.push(`${h[n]}\u4E0D\u80FD\u4E3A\u7A7A`),W.includes(n)&&Y.test(a)===!1&&r.push(`${h[n]}\u5FC5\u987B\u4E3A\u6570\u5B57`),n==="remark"&&(a=a.replace(/[\s\r\n]+/g,""),s[n]=a,Z.test(a)&&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:w("div",null,u.map(t=>w("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:s}=T({success:()=>t("/postSupplierOrder/sendOrder")}),{currentCompany:n}=L();function a({results:d,header:o}){if(!G(m,o))return;const i=K(d),c=[...new Set(i.map(f=>f.companyNo))];if(c.length>1){p.warning("\u4E0A\u4F20\u591A\u6761\u6570\u636E\u4E1A\u52A1\u516C\u53F8\u5FC5\u987B\u4E00\u81F4");return}if(c[0]!==n.value.companyNo){p.warning("\u4E0A\u4F20\u6570\u636E\u7684\u4E1A\u52A1\u516C\u53F8\u4E0E\u9009\u4E2D\u7684\u4E1A\u52A1\u516C\u53F8\u4E0D\u4E00\u81F4");return}const{errorSet:l,isValid:F}=S(i);F||k(l),u.value=i}function N(){if(u.value.length>100){p.warning("\u5BFC\u5165\u53D1\u8D27\u8FD0\u5355\u4E0D\u80FD\u8D85\u8FC7100\u6761");return}const d=[...new Set(u.value.map(l=>l.companyNo))];if(d.length>1){p.warning("\u4E0A\u4F20\u591A\u6761\u6570\u636E\u4E1A\u52A1\u516C\u53F8\u5FC5\u987B\u4E00\u81F4");return}if(d[0]!==n.value.companyNo){p.warning("\u4E0A\u4F20\u6570\u636E\u7684\u4E1A\u52A1\u516C\u53F8\u4E0E\u9009\u4E2D\u7684\u4E1A\u52A1\u516C\u53F8\u4E0D\u4E00\u81F4");return}const{errorSet:o,isValid:i}=S(u.value);if(!i){k(o);return}const c=u.value.map(({outChildCode:l,supplierNo:F,companyNo:f,post_fee:C,remark:E})=>({outChildCode:l,supplierNo:F,companyNo:f,remark:E,post_fee:Number(C).toFixed(2)}));r(U({list:c}))}return(d,o)=>{const i=_("el-table-column"),c=_("el-table"),l=_("el-button"),F=_("el-tab-pane"),f=_("el-tabs"),C=j("loading");return q((g(),b("div",uu,[D(f,{class:"px-[10px]"},{default:A(()=>[D(F,{label:"\u6279\u91CF\u5BFC\u5165\u53D1\u8D27\u8FD0\u5355"},{default:A(()=>[u.value.length===0?(g(),B(v(H),{key:0,style:{width:"100%"},onOnSuccess:a})):x("v-if",!0),D(c,{border:"",size:"mini",class:"my-[10px]",data:u.value},{default:A(()=>[(g(!0),b(z,null,M(v(m),E=>(g(),B(i,R({ref_for:!0},E,{key:E.prop,"show-overflow-tooltip":""}),null,16))),128))]),_:1},8,["data"]),u.value.length!==0?(g(),b("div",eu,[D(l,{class:"ml-auto",onClick:o[0]||(o[0]=E=>u.value=[])},{default:A(()=>o[1]||(o[1]=[y("\u53D6\u6D88")])),_:1}),D(l,{type:"primary",class:"ml-auto",onClick:N},{default:A(()=>o[2]||(o[2]=[y("\u4FDD\u5B58")])),_:1})])):x("v-if",!0)]),_:1})]),_:1})])),[[C,v(s)]])}}});var lu=$(tu,[["__file","D:/work/jiesuan/settle-vue3/src/views/postSupplierOrder/sendOrder/batchImportSendOrder.vue"]]);export{lu as default};
