import{D as I,u as U,n as B,E as g}from"./elementPlus.4833989a.js";import{S as y,W as O}from"./requestCode.a7f226d1.js";import{r as S}from"./index.ad3efb29.js";import{d as P,r as v,Z as F,ai as c,o as R,c as T,U as a,O as i,a as o,T as k,u as x,S as w,ac as W,ad as j}from"./vue.adf17aba.js";import"./echarts.72dc8373.js";const V="/api/searchterm/";function z(p){const n=new FormData;return n.append("file",p),S({url:V+"upload_file/",method:"POST",data:n,headers:{"Content-Type":"multipart/form-data"}})}function L(p){return S({url:V+"upload_file/",method:"POST",params:p})}const G={class:"py-2 px-2.5",style:{"background-color":"#f7f7f7"}},M={class:"flex flex-wrap gap-7"},Z=o("span",{class:"font-bold mr-2",style:{color:"#303133"}},"报告类型:",-1),q=o("span",{class:"font-bold mr-2",style:{color:"#303133"}},"报告日期:",-1),H=o("span",{class:"font-bold mr-2",style:{color:"#303133"}},"类型:",-1),J={class:"font-bold mr-2",style:{color:"#303133"}},K={class:"flex gap-3.5"},Q=o("div",{class:"text-xl font-bold text-center font-sans subpixel-antialiased"},"导入预览",-1),X=o("p",{class:"text-3xl w-full",style:{color:"red"}}," 该页面用来导入从后台下载的 Asin view 或 Brand view 数据 ",-1),Y=o("p",{class:"text-3xl w-full",style:{color:"red"}},"导入格式为csv格式!",-1),re=P({__name:"index",setup(p){const n=v(),f=v(!1),_=v("ASIN"),t=F({reportFilter:"",reportDateFilter:"",typeFilter:"",variableFilter:""}),d=F({loading:f,round:!0,stripe:!0,resizable:!0,height:900,toolbarConfig:{custom:!0},columns:[],data:[]});function D(e){n.value.clearFiles();const l=e[0];l.uid=B(),n.value.handleStart(l),n.value.submit()}function b(e){e.code===y?g.success({message:e.msg,plain:!0}):e.code===O?g.warning({message:e.msg,plain:!0}):g.error({message:e.msg,plain:!0})}async function N(e){f.value=!0;try{const{file:l}=e,r=await z(l);b(r),C(r.data),e.onSuccess(r)}catch(l){console.log("==Error==",l),e.onError(l)}finally{f.value=!1}}function C(e){const l=e.length>15?e.slice(0,15):e;e.length>0?(t.reportFilter=e[0].Reporting_Range||"",t.reportDateFilter=e[0].Reporting_Date||"",t.typeFilter=e[0].ASIN?"ASIN View":"Brand View",t.variableFilter=e[0].ASIN?e[0].ASIN:e[0].brand||""):(t.reportFilter="",t.reportDateFilter="",t.typeFilter="",t.variableFilter=""),d.columns=Object.keys(l[0]||{}).map(r=>{const u=r.replace(/_/g," ");let m=u.length*10;return(r==="ASIN"||r==="brand")&&(m=130),{field:r,title:u,minWidth:m}}),d.data=l,l[0].brand?_.value="Brand":_.value="ASIN"}async function E(){try{const e=await L({upload:!0});b(e),e.code===y&&(d.data=[],d.columns=[],t.reportFilter="",t.reportDateFilter="",t.typeFilter="",t.variableFilter="")}catch(e){console.error("==Error==",e)}}return(e,l)=>{const r=c("el-input"),u=c("el-button"),m=c("el-upload"),h=c("el-card"),A=c("vxe-grid");return R(),T("div",G,[a(h,{"body-class":"flex justify-between gap-3.5",shadow:"hover",style:{border:"none","margin-bottom":"10px"}},{default:i(()=>[o("div",M,[o("div",null,[Z,a(r,{modelValue:t.reportFilter,"onUpdate:modelValue":l[0]||(l[0]=s=>t.reportFilter=s),disabled:!0,style:{width:"200px"}},null,8,["modelValue"])]),o("div",null,[q,a(r,{modelValue:t.reportDateFilter,"onUpdate:modelValue":l[1]||(l[1]=s=>t.reportDateFilter=s),disabled:!0,style:{width:"200px"}},null,8,["modelValue"])]),o("div",null,[H,a(r,{modelValue:t.typeFilter,"onUpdate:modelValue":l[2]||(l[2]=s=>t.typeFilter=s),disabled:!0,style:{width:"200px"}},null,8,["modelValue"])]),o("div",null,[o("span",J,k(_.value)+":",1),a(r,{modelValue:t.variableFilter,"onUpdate:modelValue":l[3]||(l[3]=s=>t.variableFilter=s),disabled:!0,style:{width:"240px"}},null,8,["modelValue"])])]),o("div",K,[o("div",null,[a(m,{ref_key:"upload",ref:n,"auto-upload":!0,"http-request":N,limit:1,"on-exceed":D,"show-file-list":!1,action:"#"},{trigger:i(()=>[a(u,{icon:x(I),loading:f.value,color:"#6366f1",plain:""},{default:i(()=>[w("导入预览")]),_:1},8,["icon","loading"])]),_:1},512)]),a(u,{icon:x(U),plain:"",round:"",type:"warning",onClick:E},{default:i(()=>[w(" 确认导入")]),_:1},8,["icon"])])]),_:1}),a(h,{shadow:"hover",style:{border:"none"}},{default:i(()=>[Q,a(A,W(j(d)),{empty:i(()=>[X,Y]),_:1},16)]),_:1})])}}});export{re as default};
