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