import{aU as R,ac as M,_ as j,d as Y,aV as z,Z as K,x as X,A as $,z as H,r as m,aD as Q,o as w,G as y,D as l,l as e,M as T,L as B,H as V,h as q,c as G,F as k,E as I,m as E,bK as W,bO as Z,b4 as D,ar as J,bP as ee,bQ as ue,b7 as oe}from"./index.js";import{I as S}from"./InvoiceTitle.199e3c.js";const{VITE_PROXY_DOMAIN_REAL:ce,VITE_PROXY_USER_REAL:le,VITE_WORKORDER_REAL:me}=M(),L=le+"/admin/",te=f=>R.request("post",`${L}orderquery`,{data:f}),ae=f=>R.request("post",`${L}orderinvadd`,{data:{...f,noLogout:!0}}),re={class:"flex flex-col w-full"},ne={class:"flex flex-col w-full"},se=Y({__name:"ProcessModal",props:{data:{type:Array,required:!0},visible:{type:Boolean,required:!0},companyNo:{type:String,required:!0},sellerInvoiceTitle:{type:null,required:!0},purchaserInvoiceTitle:{type:null,required:!0}},emits:["updateGroup","updateSequenceNo","download","refresh"],setup(f,{emit:v}){const x=f,h=z(x,"visible"),O=()=>({email:"",invtype:"",platform_type:"",orderArr:[],remark:""}),a=K({tableloading:!1,formloading:!1,orderData:[],currentGroup:1,groupCount:0}),o=X({...O()});async function U(p){o.value={email:p[0].email,invtype:ee[p[0].invtype],platform_type:ue[p[0].platform_type],remark:p.map(({poCode:t})=>t).join(""),orderArr:[]};const r={};for(const t of p){const{sequenceNo:s,inv_fee:c}=t;r[s]?r[s].push({inv_fee:c}):(r[s]=[],r[s].push({inv_fee:c}))}for(const t of Object.keys(r))o.value.orderArr.push({sequenceNo:t,platform_type:o.value.platform_type,inv_fee:r[t].reduce((s,c)=>Number(D(s,c.inv_fee)).toFixed(2),0)});const _={inv_is:"1",status:"3",is_comon:"1",cat_status:"2",inv_status:"0",companyNo:x.companyNo,customerNo:"GS2404151642335170",platform_type:o.value.platform_type,sequenceNo:o.value.orderArr.map(({sequenceNo:t})=>t).join(",")};try{a.tableloading=!0;const t=await te(_);if(a.tableloading=!1,t.code==0){if(t.data.length!==o.value.orderArr.length){const d=t.data.map(({sequenceNo:i})=>i),b=o.value.orderArr.map(({sequenceNo:i})=>i),n=b.filter(i=>!d.includes(i));b.filter(i=>!d.includes(i)).forEach(i=>{v("updateSequenceNo",{sequenceNo:i,remark:"\u67E5\u8BE2\u4E0D\u5230\u8BE5\u8BA2\u5355",status:3})}),n.forEach(i=>{o.value.orderArr=o.value.orderArr.filter(F=>F.sequenceNo!==i)})}const s=[];if(t.data.forEach(d=>{const b=o.value.orderArr.findIndex(({sequenceNo:P})=>P===d.sequenceNo),n=o.value.orderArr[b];d.current_inv_fee=n.inv_fee,d.current_inv_num=Number(oe(n.inv_fee,d.goodPrice)).toFixed(8),o.value.orderArr[b].num=d.current_inv_num;const{current_inv_fee:i,ainv_fee:F,inv_fee:C,apay_fee:A,sequenceNo:u}=d;Number(i)+Number(F)+Number(C)>A&&(v("updateSequenceNo",{sequenceNo:u,remark:"\u8BA2\u5355\u5DF2\u5F00\u7968\u91D1\u989D+\u672A\u5F00\u7968\u91D1\u989D+\u672C\u6B21\u5F00\u7968\u91D1\u989D\u5FC5\u987B\u5C0F\u4E8E\u6216\u7B49\u4E8E\u5DF2\u8BA4\u6B3E\u91D1\u989D",status:3}),s.push(u))}),o.value.orderArr=o.value.orderArr.filter(({sequenceNo:d})=>!s.includes(d)),o.value.orderArr.length===0){g();return}a.orderData=t.data,a.formloading=!0;const{code:c,message:N}=await ae({...o.value,companyType:"01",buyNo:"GS2404151642335170",companyNo:x.companyNo,is_comon:"1",exam_remark:""});a.formloading=!1,c==0?(v("updateGroup",{group:a.currentGroup,remark:"\u521B\u5EFA\u6210\u529F",status:2}),g()):(v("updateGroup",{group:a.currentGroup,remark:N,status:3}),g())}else v("updateGroup",{group:a.currentGroup,remark:t.message,status:3}),g()}catch(t){a.tableloading=!1,v("updateGroup",{group:a.currentGroup,remark:t.message,status:3}),g()}}function g(){const p=a.currentGroup+1;if(p>a.groupCount){h.value=!1,v("download"),v("refresh");return}else v("updateGroup",{group:p,status:1,remark:""});a.currentGroup=p;const r=x.data.filter(({group:_})=>_==a.currentGroup);U(r)}return $(()=>h.value,()=>{!h.value||H(()=>{const p=[...new Set(x.data.map(({group:_})=>_))],r=Number(p[p.length-1]);a.groupCount=r,a.currentGroup=0,g()})},{immediate:!0}),(p,r)=>{const _=m("ElTag"),t=m("ElInput"),s=m("ElFormItem"),c=m("ElCol"),N=m("ElOption"),d=m("ElSelect"),b=m("ElRow"),n=m("ElTableColumn"),i=m("ElTable"),F=m("ElForm"),C=m("ElDialog"),A=Q("loading");return w(),y(C,{width:"1200px",modelValue:E(h),"onUpdate:modelValue":r[4]||(r[4]=u=>J(h)?h.value=u:null),title:"\u5F00\u7968\u7533\u8BF7\u521B\u5EFA",center:"",top:"10px"},{default:l(()=>[e(_,{class:"font-bold mb-[10px]"},{default:l(()=>[T("\u5F53\u524D\u7B2C "+B(a.currentGroup)+" \u7EC4 , \u5171 "+B(a.groupCount)+" \u7EC4",1)]),_:1}),V((w(),y(F,null,{default:l(()=>[e(b,{gutter:10},{default:l(()=>[e(c,{span:12},{default:l(()=>[e(s,{label:"\u9500\u552E\u65B9\u516C\u53F8\u62AC\u5934"},{default:l(()=>[q("div",re,[e(t,{modelValue:(f.sellerInvoiceTitle||{}).invoice_title,class:"mb-[10px]",disabled:""},null,8,["modelValue"]),e(S,{detail:f.sellerInvoiceTitle||{}},null,8,["detail"])])]),_:1})]),_:1}),e(c,{span:12},{default:l(()=>[e(s,{label:"\u8D2D\u4E70\u65B9\u516C\u53F8\u62AC\u5934"},{default:l(()=>[q("div",ne,[e(t,{modelValue:(f.purchaserInvoiceTitle||{}).invoice_title,class:"mb-[10px]",disabled:""},null,8,["modelValue"]),e(S,{detail:f.purchaserInvoiceTitle||{}},null,8,["detail"])])]),_:1})]),_:1}),e(c,{span:8},{default:l(()=>[e(s,{label:"\u53D1\u7968\u7C7B\u578B"},{default:l(()=>[e(d,{modelValue:o.value.invtype,"onUpdate:modelValue":r[0]||(r[0]=u=>o.value.invtype=u),class:"w-full",disabled:""},{default:l(()=>[(w(!0),G(k,null,I(E(W),u=>(w(),y(N,{value:u.value,label:u.label,key:u.value},null,8,["value","label"]))),128))]),_:1},8,["modelValue"])]),_:1})]),_:1}),e(c,{span:8},{default:l(()=>[e(s,{label:"\u7535\u5B50\u90AE\u7BB1"},{default:l(()=>[e(t,{modelValue:o.value.email,"onUpdate:modelValue":r[1]||(r[1]=u=>o.value.email=u),disabled:""},null,8,["modelValue"])]),_:1})]),_:1}),e(c,{span:8},{default:l(()=>[e(s,{label:"\u5E73\u53F0\u7C7B\u578B"},{default:l(()=>[e(d,{modelValue:o.value.platform_type,"onUpdate:modelValue":r[2]||(r[2]=u=>o.value.platform_type=u),class:"w-full",disabled:""},{default:l(()=>[(w(!0),G(k,null,I(E(Z),u=>(w(),y(N,{value:u.value,label:u.label,key:u.value},null,8,["value","label"]))),128))]),_:1},8,["modelValue"])]),_:1})]),_:1}),e(c,{span:24},{default:l(()=>[e(s,{label:"\u53D1\u7968\u5907\u6CE8"},{default:l(()=>[e(t,{modelValue:o.value.remark,"onUpdate:modelValue":r[3]||(r[3]=u=>o.value.remark=u),disabled:""},null,8,["modelValue"])]),_:1})]),_:1})]),_:1}),V((w(),y(i,{border:"",size:"small",data:a.orderData},{default:l(()=>[e(n,{label:"\u4EA7\u54C1\u7F16\u53F7",width:"120px",prop:"goodNo","show-overflow-tooltip":""}),e(n,{label:"\u5546\u54C1\u540D\u79F0",width:"120px",prop:"goodName","show-overflow-tooltip":""}),e(n,{label:"\u5F00\u7968\u5546\u54C1\u540D\u79F0","show-overflow-tooltip":"",prop:"inv_good_name",width:"140px"}),e(n,{label:"\u54C1\u724C",width:"60px",prop:"goodBrand","show-overflow-tooltip":""}),e(n,{label:"\u5355\u4F4D",width:"60px",prop:"goodUnit","show-overflow-tooltip":""}),e(n,{label:"\u5355\u4EF7",width:"60px",prop:"goodPrice","show-overflow-tooltip":""}),e(n,{label:"\u6570\u91CF",align:"center"},{default:l(()=>[e(n,{label:"\u603B\u8BA1",width:"80px","show-overflow-tooltip":""},{default:l(({row:u})=>[T(B(Number(E(D)(Number(E(D)(u.inv_num,u.winv_num)).toFixed(2),u.current_inv_num)).toFixed(8)),1)]),_:1}),e(n,{label:"\u5DF2\u6838\u9500",prop:"inv_num",width:"80px","show-overflow-tooltip":""}),e(n,{label:"\u672A\u6838\u9500",prop:"winv_num",width:"80px","show-overflow-tooltip":""}),e(n,{label:"\u6B64\u6B21\u6838\u9500",prop:"current_inv_num",width:"80px","show-overflow-tooltip":""})]),_:1}),e(n,{label:"\u603B\u4EF7",width:"80px","show-overflow-tooltip":""},{default:l(({row:u})=>[T(B(Number(E(D)(Number(E(D)(u.inv_fee,u.winv_fee)).toFixed(2),u.current_inv_fee)).toFixed(2)),1)]),_:1}),e(n,{label:"\u5173\u8054\u53D1\u7968\u4FE1\u606F",align:"center"},{default:l(()=>[e(n,{label:"\u5DF2\u6838\u9500\u91D1\u989D",prop:"inv_fee",width:"100px","show-overflow-tooltip":""}),e(n,{label:"\u672A\u6838\u9500\u91D1\u989D",prop:"winv_fee",width:"100px","show-overflow-tooltip":""}),e(n,{label:"\u6B64\u6B21\u6838\u9500\u91D1\u989D",prop:"current_inv_fee",width:"100px","show-overflow-tooltip":""})]),_:1})]),_:1},8,["data"])),[[A,a.tableloading]])]),_:1})),[[A,a.formloading]])]),_:1},8,["modelValue"])}}});var fe=j(se,[["__file","C:/Users/63107/Desktop/mine/settle-vue3/src/views/InvoiceSales/batchImportYunlong/ProcessModal.vue"]]);export{fe as default};