import{aY as p,b4 as O,al as B,_ 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 C,o as E,c as D,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}from"./template.f1513dc2.js";import{h as H}from"./index.1e0c26b5.js";import"./xlsx.ed122d16.js";function R(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 W=c.reduce((e,u)=>({...e,[u.label]:u.prop}),{});function Y(e){const u=[];for(const t of e){const n={};for(const s in t)n[W[s]]=t[s];u.push(n)}return u}const A=c.reduce((e,u)=>({...e,[u.prop]:u.label}),{}),J=c.filter(e=>e.required).map(e=>e.prop),K=c.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 s=e[t];for(const r in s){const v=String(s[r]);J.includes(r)&&Q(v)&&n.push(`${A[r]}\u4E0D\u80FD\u4E3A\u7A7A`),K.includes(r)&&X.test(v)===!1&&n.push(`${A[r]}\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:B("div",null,u.map(t=>B("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:s}=T({success:()=>t("/supplierOrder/supSendOrder")}),{currentCompany:r}=L();function v({results:m,header:l}){if(!R(c,l))return;const a=Y(m),i=[...new Set(a.map(f=>f.supplierNo))];if(i.length>1){p.warning("\u4E0A\u4F20\u591A\u6761\u6570\u636E\u4F9B\u5E94\u5546\u5FC5\u987B\u4E00\u81F4");return}if(i[0]!==r.value.companyNo){p.warning("\u4E0A\u4F20\u6570\u636E\u7684\u4F9B\u5E94\u5546\u4E0E\u9009\u4E2D\u7684\u4F9B\u5E94\u5546\u4E0D\u4E00\u81F4");return}const{errorSet:o,isValid:d}=S(a);d||k(o),u.value=a}function N(){const m=[...new Set(u.value.map(o=>o.supplierNo))];if(m.length>1){p.warning("\u4E0A\u4F20\u591A\u6761\u6570\u636E\u4F9B\u5E94\u5546\u5FC5\u987B\u4E00\u81F4");return}if(m[0]!==r.value.companyNo){p.warning("\u4E0A\u4F20\u6570\u636E\u7684\u4F9B\u5E94\u5546\u4E0E\u9009\u4E2D\u7684\u4F9B\u5E94\u5546\u4E0D\u4E00\u81F4");return}const{errorSet:l,isValid:a}=S(u.value);if(!a){k(l);return}const i=u.value.map(({outChildCode:o,supplierNo:d,companyNo:f,post_fee:g})=>({outChildCode:o,supplierNo:d,companyNo:f,post_fee:Number(g).toFixed(2)}));n(H({list:i}))}return(m,l)=>{const a=_("el-table-column"),i=_("el-table"),o=_("el-button"),d=_("el-tab-pane"),f=_("el-tabs"),g=M("loading");return j((E(),D("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(C(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),D(q,null,U(C(c),h=>(E(),w(a,z(h,{key:h.prop,"show-overflow-tooltip":""}),null,16))),128))]),_:1},8,["data"]),u.value.length!==0?(E(),D("div",ee,[F(o,{class:"ml-auto",onClick:l[0]||(l[0]=h=>u.value=[])},{default:b(()=>[y("\u53D6\u6D88")]),_:1}),F(o,{type:"primary",class:"ml-auto",onClick:N},{default:b(()=>[y("\u4FDD\u5B58")]),_:1})])):x("v-if",!0)]),_:1})]),_:1})])),[[g,C(s)]])}}});var ae=I(ue,[["__file","C:/Users/63107/Desktop/projects/accout-vue3-ui/src/views/supplierOrder/sendOrder/batchImportSendOrder.vue"]]);export{ae as default};
