import{c as B,d as I,e as z,f as N}from"./popup-CUqQDM27.js";import{j as v,ah as T,v as A,E,q as M,d as O,f as X,k as K,l as d,o as b,a as R,J as s,u as e,w as o,b as f,N as p,L as S,m as h,M as L,B as C,_ as F}from"./__uno-CP0Q6RG2.js";import{A as l}from"./amazon-DrWpsM1q.js";import"./modulepreload-polyfill-B5Qt9EMX.js";const H=()=>{const i=v("2018-01-01"),_=u=>T(u).isAfter(T().subtract(1,"day"))||T(u).isBefore(i.value);return(async()=>{const{dateTimeStartDate:u}=await A.storage.local.get(["dateTimeStartDate"]);i.value=u||"2018-01-01"})(),{disabledDate:_}};async function J(i){return M().isX?`/plugin/assistant${i}`:`/amz/assistant${i}`}async function Q(i){return E.post(await J("/generateTask"),i)}const m="custom-report",W=O({__name:"index",setup(i){const _=B(),D=I(),{countryOptions:u}=z(),{disabledDate:V}=H(),y=_.query.customGetReportType,w=[{label:"Detail Page Sales and Traffic by SKU",value:l.ReportType._Detail_Page_Sales_and_Traffic_by_SKU_},{label:"Detail Page Sales and Traffic by Child Item",value:l.ReportType._Detail_Page_Sales_and_Traffic_by_Child_Item_},{label:"Detail Page Sales and Traffic by Time",value:l.ReportType._Detail_Page_Sales_and_Traffic_by_Time_},{label:"Detail Page Sales and Traffic by Parent Item",value:l.ReportType._Detail_Page_Sales_and_Traffic_by_Parent_Item_}],j=v(),t=X({countries:[],reportType:"",month:"",dates:[]});K(()=>_.query,()=>{y===l.CustomGetReportType.DateRangeReport?t.reportType=l.ReportType._Date_Range_:y===l.CustomGetReportType.BusinessReport&&(t.reportType=l.ReportType._Detail_Page_Sales_and_Traffic_by_Child_Item_)},{immediate:!0});const g=v(!1),P=()=>{j.value.validate(async k=>{var a,c;if(!k){g.value=!0;try{const r=await Q({marketIds:t.countries,reportType:t.reportType,rangeStartDate:(a=t.dates)==null?void 0:a[0],rangeEndDate:(c=t.dates)==null?void 0:c[1],month:t.month});r.isSuccess?D.replace("/amazon/task-list?refreshTaskList=true"):C.GjMessage.error(r.msg)}catch(r){C.GjMessage.error(`${r}`)}finally{g.value=!1}}})};return(k,a)=>{const c=d("gj-select"),r=d("gj-form-item"),x=d("gj-radio"),$=d("gj-month-picker"),q=d("gj-range-picker"),G=d("gj-button"),U=d("gj-form");return b(),R("div",{class:p(m)},[s(e(N)),s(U,{ref_key:"formRef",ref:j,model:e(t),layout:"vertical",class:"u-mt-16px"},{default:o(()=>[s(r,{field:"countries",rules:[{required:!0,message:"请选择国家店铺"}]},{label:o(()=>[f("div",{class:p(`${m}-label`)},"国家店铺筛选",2)]),default:o(()=>[s(c,{modelValue:e(t).countries,"onUpdate:modelValue":a[0]||(a[0]=n=>e(t).countries=n),options:e(u),"allow-search":"","allow-clear":"",multiple:"",placeholder:"请选择国家店铺",style:{width:"100%"}},null,8,["modelValue","options"])]),_:1}),e(y)===e(l).CustomGetReportType.DateRangeReport?(b(),R(S,{key:0},[s(r,{field:"reportType",rules:[{required:!0,message:"请选择报告类型"}]},{label:o(()=>[f("div",{class:p(`${m}-label`)},"报告类型",2)]),default:o(()=>[s(x,{modelValue:e(t).reportType,"onUpdate:modelValue":a[1]||(a[1]=n=>e(t).reportType=n),value:e(l).ReportType._Date_Range_},{default:o(()=>[h("Date-Range Reports")]),_:1},8,["modelValue","value"])]),_:1}),s(r,{field:"month",rules:[{required:!0,message:"请选择月份"}]},{label:o(()=>[f("div",{class:p(`${m}-label`)},"时间范围(按月)",2)]),default:o(()=>[s($,{modelValue:e(t).month,"onUpdate:modelValue":a[2]||(a[2]=n=>e(t).month=n),"disabled-date":e(V),style:{width:"100%"}},null,8,["modelValue","disabled-date"])]),_:1})],64)):e(y)===e(l).CustomGetReportType.BusinessReport?(b(),R(S,{key:1},[s(r,{field:"reportType","hide-asterisk":"",rules:[{required:!0,message:"请选择报告类型"}]},{label:o(()=>[f("div",{class:p(`${m}-label`)},"报告类型",2)]),default:o(()=>[s(c,{modelValue:e(t).reportType,"onUpdate:modelValue":a[3]||(a[3]=n=>e(t).reportType=n),options:w,placeholder:"请选择报告类型",style:{width:"100%"}},null,8,["modelValue"])]),_:1}),s(r,{field:"dates",rules:[{required:!0,message:"请选择日期范围"}]},{label:o(()=>[f("div",{class:p(`${m}-label`)},"时间范围(按日期范围)",2)]),default:o(()=>[s(q,{modelValue:e(t).dates,"onUpdate:modelValue":a[4]||(a[4]=n=>e(t).dates=n),"disabled-date":e(V),style:{width:"100%"}},null,8,["modelValue","disabled-date"])]),_:1})],64)):L("",!0),s(G,{type:"primary",class:"u-mt-16px",loading:e(g),onClick:P},{default:o(()=>[h("获取报告")]),_:1},8,["loading"])]),_:1},8,["model"])])}}}),ae=F(W,[["__scopeId","data-v-35a85d18"]]);export{ae as default};
