import{aJ as S,aK as $,b as j,p as h,o as d,h as D,A as v,c as k,E as w,f as N,bk as z,bl as I,aL as p,_ as q,k as B,j as A,l as V,r as K,aM as P,F as H,bm as T}from"./index.4d3e3847.js";import{r as W}from"./responseHandle.db1518c7.js";import{a as J}from"./useNav.afbe69e0.js";import{r as X,u as g}from"./xlsx.ed122d16.js";const{VITE_PROXY_DOMAIN_REAL:L}=$();async function le(){return S.request("post",`${L}admin/orderList`,{data:{}})}async function ne(c={}){return S.request("post",`${L}admin/orderRead`,{data:c})}async function Y(c={}){return S.request("post",`${L}admin/orderDeliver`,{data:c})}const R=["\u8BA2\u5355ID","\u4E3B\u8BA2\u5355\u7F16\u53F7","\u8BA2\u5355\u7F16\u53F7","\u8BA2\u5355\u7C7B\u578B","\u4E1A\u52A1\u516C\u53F8","\u5361\u7C7B\u578B","\u8D2D\u4E70\u7528\u6237\u540D","\u8D2D\u4E70\u8D26\u53F7","\u8D2D\u4E70\u6570\u91CF","\u6536\u8D27\u8054\u7CFB\u4EBA","\u6536\u8D27\u8054\u7CFB\u7535\u8BDD","\u72B6\u6001","\u7269\u6D41\u516C\u53F8","\u7269\u6D41\u5355\u53F7","\u521B\u5EFA\u65F6\u95F4","\u6536\u8D27\u5730\u5740","\u5546\u54C1\u7F16\u7801","\u5546\u54C1(\u670D\u52A1)\u540D\u79F0"],G=()=>{const c=[{type:"index",width:"50",fixed:"left",label:"\u5E8F\u53F7"}];return R.forEach((_,m)=>{c.push({prop:"value"+m,label:_,minWidth:"100px"})}),c},Q={key:0,class:"el-upload__text"},Z=j({__name:"execl-upload",emits:["onSuccess"],setup(c,{expose:_,emit:m}){const f=h(null),a=h(null),r=o=>{const t=o.raw;!t||C(t)},C=o=>{E(o)&&x(o)},x=async o=>{const t=I.service({lock:!0,text:"Loading",background:"rgba(0, 0, 0, 0.7)"});return new Promise((s,e)=>{const l=new FileReader;l.onload=u=>{const n=u.target.result,i=X(n,{type:"array"}),F=i.SheetNames[0],U=i.Sheets[F],M=b(U),O=g.sheet_to_json(U,{defval:""});m("onSuccess",{header:M,results:O}),t.close(),s({isok:!0})},l.readAsArrayBuffer(o)})},b=o=>{const t=[],s=g.decode_range(o["!ref"]);let e;const l=s.s.r;for(e=s.s.c;e<=s.e.c;++e){const u=o[g.encode_cell({c:e,r:l})];let n="UNKNOWN "+e;u&&u.t&&(n=g.format_cell(u)),t.push(n)}return t},E=async o=>o.size/1024<500?!0:(p.warning("\u8BF7\u4E0D\u8981\u4E0A\u4F20\u5927\u4E8E500KB\u7684\u6587\u4EF6"),!1),y=()=>a.value=null;return _({onDisplay:()=>a.value=null}),(o,t)=>(d(),D(N(z),{ref_key:"uploadRef",ref:f,action:"#",accept:".xls,.xlsx",drag:"","auto-upload":!1,onChange:r,onRemove:y,onBeforeUpload:E,multiple:""},{default:v(()=>[a.value?w("",!0):(d(),k("div",Q,"\u70B9\u51FB\u6B64\u5904,\u4E0A\u4F20\u6587\u4EF6"))]),_:1},512))}});const ee=q(Z,[["__scopeId","data-v-332e4a30"]]),ue={key:1,flex:"","justify-end":"","gap-2":""},re=j({__name:"index",emits:["onSuccess"],setup(c,{expose:_,emit:m}){const f=h(!1),a=h(!1),r=h([]),C=G(),{logout:x}=J(),b=()=>{},E=({results:t,header:s})=>{if(a.value=!0,t.length===0){p.error("\u8868\u683C\u65E0\u6709\u6548\u6570\u636E\uFF01"),a.value=!1;return}let e=!0;if(s.length!==R.length?e=!1:R.forEach((l,u)=>{l!==s[u]&&(e=!1)}),!e){p.error("\u8868\u5934\u4E0E\u5BFC\u5165\u6A21\u677F\u4E0D\u5339\u914D\uFF01"),a.value=!1;return}r.value=[];try{t.forEach(l=>{const u=Object.values(l);let n={};u.forEach((i,F)=>{n["value"+F]=i+""}),r.value.push(n)}),a.value=!1}catch{p.error("\u5BFC\u5165\u6570\u636E\u62FC\u63A5\u6709\u8BEF\uFF01"),a.value=!1}},y=async()=>{if(a.value)return;a.value=!0;let t=!0,s=[];if(r.value.forEach(u=>{let n={orderCode:u.value2||"",post_name:u.value12||"",post_code:u.value13||""};(u.value2===""||u.value13==="")&&(t=!1),s.push(n)}),!t){T({title:"\u5FC5\u586B\u5B57\u6BB5\u7F3A\u5931\uFF01",message:"\u8BA2\u5355\u7F16\u53F7\u548C\u7269\u6D41\u5355\u53F7\u4E3A\u5FC5\u586B\u9879\uFF01",type:"error"}),a.value=!1;return}const{code:e,message:l}=await Y({list:s});e===1005||e===1006?(a.value=!1,p.error(l)):W({code:e,message:l,logout:x,handler:()=>{a.value=!1,p.success("\u6570\u636E\u5BFC\u5165\u6210\u529F\uFF01"),m("onSuccess"),f.value=!1}})},o=()=>{r.value=[]};return _({onDisplay:()=>(f.value=!0,r.value=[])}),(t,s)=>{const e=B("el-button"),l=B("el-table-column"),u=B("el-table"),n=B("el-dialog");return d(),D(n,{modelValue:f.value,"onUpdate:modelValue":s[0]||(s[0]=i=>f.value=i),title:"\u5BFC\u5165\u8868\u683C\u6570\u636E",width:"1040px",top:"8vh",center:"",onClose:b},{default:v(()=>[r.value.length===0?(d(),D(N(ee),{key:0,onOnSuccess:E})):w("",!0),r.value.length!==0?(d(),k("div",ue,[A(e,{size:"small",onClick:o},{default:v(()=>[V("\u53D6\u6D88")]),_:1}),A(e,{size:"small",type:"primary",loading:a.value,onClick:y},{default:v(()=>[V("\u4FDD\u5B58")]),_:1},8,["loading"])])):w("",!0),A(u,{data:r.value,stripe:"",border:"","max-height":"500px",size:"small",style:{width:"100%",padding:"10px 0 0 0"}},{default:v(()=>[(d(!0),k(H,null,K(N(C),(i,F)=>(d(),D(l,P(i,{key:F,"show-overflow-tooltip":""}),null,16))),128))]),_:1},8,["data"])]),_:1},8,["modelValue"])}}});export{re as _,ne as a,le as h};
