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