import{q as V,j as L,a8 as F,B as M,d as N,a0 as O,X as q,C as P,D as U,l as $,o,a as l,u as t,N as r,O as i,M as H,J as d,b as s,L as b,m as u,w as h,a9 as J,c as W,aa as X,ab as Z,Z as K,$ as Q,_ as Y}from"./__uno-D1Fc7LNY.js";import{I as ee}from"./icon-dolphin-empty-grRn4AQf.js";import{b as te,c as se,R as B,s as T,d as ae}from"./popup-B0Dhd1u8.js";import{D as oe}from"./detect-header-BNsCGAid.js";import{A as z}from"./amazon-DrWpsM1q.js";import"./modulepreload-polyfill-B5Qt9EMX.js";const ne=()=>{const a=V(),m=te(),_=se(),x=L([]),k=async()=>{const{taskList:S,taskProcessingList:e,taskFinishList:D}=await T({fn:"getTaskList",val:["taskList","taskProcessingList","taskFinishList"]});x.value=[...e.map(v=>j(v,!1)),...S.map(v=>j(v,!1)),...D.map(v=>j(v,!0))]};let p;const y=L(!1),f=L(0),g=L(!1),R=async(S=!0)=>{if(!(f.value>0)){g.value=S,f.value=5,p=setInterval(()=>{f.value-=1,f.value<=0&&clearInterval(p)},1e3);try{y.value=!0;const e=await T({fn:"Tasks.getTaskList",cb:!0});e&&!(e!=null&&e.isSuccess)&&(e.code>0||e.msg==="验证token出错"?a.logout():M.GjMessage.error(e.msg))}catch(e){console.error(e)}finally{y.value=!1}}};return k(),m.on(B,k),_.query.refreshTaskList&&setTimeout(()=>{R(!1)},500),F(()=>{m.off(B)}),{taskList:x,refreshLoading:y,refreshCounter:f,showRefreshAlert:g,refreshTaskList:R}};function j(a,m){const _={0:"获取中...",1:"等待获取",2:"获取成功",3:"获取失败"},x={0:"#ff5c5c",1:"#E4A33D",2:"#6BC63B",3:"#F3666C"};return{id:a.id,name:a.documentFile,stateText:_[a.reportStatus],stateColor:x[a.reportStatus],rangeStartDate:a.rangeStartDate,rangeEndDate:a.rangeEndDate,createTime:a.createTime,finishTime:m?a.createTime:"",isFinish:m}}const le=a=>(K("data-v-4661dccd"),a=a(),Q(),a),re=le(()=>s("div",null,"自定义获取报告：",-1)),ce={key:0},ie={class:"u-flex u-flex-justify-between"},ue={key:0},pe={key:1},de={class:"u-mt-26px u-line-height-16px"},me={key:0,class:"u-text-14px u-color-#86909c"},fe={key:1,class:"u-text-14px u-color-#86909c"},ve={key:2,class:"u-text-16px"},n="task-list",_e=N({__name:"index",setup(a){const m=ae(),_=O().platform(q.Amazon),x=P(),{taskList:k,refreshCounter:p,refreshTaskList:y,refreshLoading:f,showRefreshAlert:g}=ne(),{taskSyncEnable:R}=U(x),S=[{label:"日期范围报告",value:z.CustomGetReportType.DateRangeReport},{label:"业务报告",value:z.CustomGetReportType.BusinessReport}],e=L(z.CustomGetReportType.DateRangeReport),D=()=>{m.push({path:"/amazon/custom-report",query:{customGetReportType:e.value}})},v=async()=>{_.info("手动暂停任务同步"),await T({fn:"TipsOperate.SetSyncStatusClose"})},A=async()=>{_.info("手动开启任务同步"),await T({fn:"TipsOperate.ExecGrabData"}),T({fn:"Tasks.getTaskList",cb:!1})};return(xe,w)=>{const C=$("gj-link"),E=$("gj-select"),I=$("gj-space");return o(),l("div",{class:r(n)},[t(p)>0&&t(g)?(o(),l("div",{key:0,class:r(`${n}-refresh-counter`)},i(t(p))+"秒后再点击获取哦~ ",3)):H("",!0),d(t(oe)),s("div",{class:r(`${n}-content`)},[s("div",{class:r(`${n}-row`)},[t(R)?(o(),l(b,{key:0},[s("div",null,[u(" 同步任务：开启中 "),d(C,{class:"u-ml-4px u-text-14px",onClick:v},{default:h(()=>[u("立即暂停")]),_:1})]),s("div",{class:r(`${n}-text0`)}," 注：插件在有报表需要同步时会进行同步 ",2)],64)):(o(),l(b,{key:1},[s("div",null,[u(" 同步任务：同步任务已暂停 "),d(C,{class:"u-ml-4px u-text-14px",onClick:A},{default:h(()=>[u("立即开启")]),_:1})]),s("div",{class:r(`${n}-text0`)}," 注：已暂停的任务不会进行同步，如需再次同步，请点击立即开启 ",2)],64))],2),s("div",{class:r(`${n}-row`)},[d(I,{size:0},{default:h(()=>[re,d(E,{modelValue:t(e),"onUpdate:modelValue":w[0]||(w[0]=c=>J(e)?e.value=c:null),options:S,size:"small",style:{width:"128px"}},null,8,["modelValue"]),d(C,{class:"u-ml-6px",onClick:D},{default:h(()=>[u("获取")]),_:1})]),_:1}),s("div",{class:r(`${n}-text0`)},[u(" 注：当前服务器下发任务时间为每晚9:00至早上8:00，请卖家中心保持登录状态。如需立即获取点击【"),t(p)>0&&!t(g)?(o(),l("span",ce,i(t(p)),1)):(o(),W(C,{key:1,onClick:w[1]||(w[1]=c=>t(y)(!1))},{default:h(()=>[u("刷新")]),_:1})),u("】 ")],2)],2),t(k).length>0?(o(!0),l(b,{key:0},X(t(k),(c,G)=>(o(),l("div",{key:G,class:r([`${n}-row`,`${n}-task`])},[s("div",ie,[s("div",null,i(c.name),1),s("div",{class:r(`${n}-task-state`),style:Z({color:c.stateColor})},i(c.stateText),7)]),s("div",{class:r(`${n}-text1`)}," 报告范围："+i(c.rangeStartDate)+" 至 "+i(c.rangeEndDate),3),s("div",{class:r(["u-flex u-flex-justify-between",`${n}-text1`])},[c.isFinish?(o(),l("div",ue,"完成时间："+i(c.finishTime),1)):(o(),l("div",pe,"生成时间："+i(c.createTime),1)),s("div",null,"任务编号："+i(c.id),1)],2)],2))),128)):(o(),l("div",{key:1,class:r(`${n}-empty`)},[d(t(ee),{class:"u-text-100px u-mt-40px"}),s("div",de,[t(f)?(o(),l("div",me," 获取中... ")):t(p)<=0?(o(),l("div",fe," 暂无记录 ")):(o(),l("div",ve,"暂时没有可以获取的报告哦~"))]),d(C,{class:"u-text-16px u-mt-36px",onClick:t(y)},{default:h(()=>[u("立即获取")]),_:1},8,["onClick"])],2))],2)])}}}),Le=Y(_e,[["__scopeId","data-v-4661dccd"]]);export{Le as default};
