1 |
- import{w as A,u as U,k as B,j as g}from"./elementPlus.346c766a.js";import{S as h,W as O}from"./requestCode.a7f226d1.js";import{r as V}from"./index.3f76f4e0.js";import{d as P,r as b,Q as y,a9 as u,o as R,c as k,M as a,G as p,a as r,L as T,u as x,K as w,a3 as j,a4 as L}from"./vue.6daa721c.js";import"./echarts.72dc8373.js";const S="/api/searchterm/";function W(c){const n=new FormData;return n.append("file",c),V({url:S+"upload_file/",method:"POST",data:n,headers:{"Content-Type":"multipart/form-data"}})}function z(c){return V({url:S+"upload_file/",method:"POST",params:c})}const G={class:"py-2 px-2.5",style:{"background-color":"#f7f7f7"}},M={class:"flex flex-wrap gap-7"},K=r("span",{class:"font-bold mr-2",style:{color:"#303133"}},"报告类型:",-1),Q=r("span",{class:"font-bold mr-2",style:{color:"#303133"}},"报告日期:",-1),q=r("span",{class:"font-bold mr-2",style:{color:"#303133"}},"类型:",-1),H={class:"font-bold mr-2",style:{color:"#303133"}},J={class:"flex gap-3.5"},X=r("div",{class:"text-xl font-bold text-center font-sans subpixel-antialiased"},"导入预览",-1),le=P({__name:"index",setup(c){const n=b(),f=b(!1),_=b("ASIN"),t=y({reportFilter:"",reportDateFilter:"",typeFilter:"",variableFilter:""}),i=y({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 v(e){e.code===h?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,o=await W(l);v(o),C(o.data),e.onSuccess(o)}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=""),i.columns=Object.keys(l[0]||{}).map(o=>{const d=o.replace(/_/g," ");let m=d.length*10;return(o==="ASIN"||o==="brand")&&(m=130),{field:o,title:d,minWidth:m}}),i.data=l,l[0].brand?_.value="Brand":_.value="ASIN"}async function E(){try{const e=await z({upload:!0});v(e),e.code===h&&(i.data=[],i.columns=[],t.reportFilter="",t.reportDateFilter="",t.typeFilter="",t.variableFilter="")}catch(e){console.error("==Error==",e)}}return(e,l)=>{const o=u("el-input"),d=u("el-button"),m=u("el-upload"),F=u("el-card"),I=u("vxe-grid");return R(),k("div",G,[a(F,{"body-class":"flex justify-between gap-3.5",shadow:"hover",style:{border:"none","margin-bottom":"10px"}},{default:p(()=>[r("div",M,[r("div",null,[K,a(o,{modelValue:t.reportFilter,"onUpdate:modelValue":l[0]||(l[0]=s=>t.reportFilter=s),disabled:!0,style:{width:"200px"}},null,8,["modelValue"])]),r("div",null,[Q,a(o,{modelValue:t.reportDateFilter,"onUpdate:modelValue":l[1]||(l[1]=s=>t.reportDateFilter=s),disabled:!0,style:{width:"200px"}},null,8,["modelValue"])]),r("div",null,[q,a(o,{modelValue:t.typeFilter,"onUpdate:modelValue":l[2]||(l[2]=s=>t.typeFilter=s),disabled:!0,style:{width:"200px"}},null,8,["modelValue"])]),r("div",null,[r("span",H,T(_.value)+":",1),a(o,{modelValue:t.variableFilter,"onUpdate:modelValue":l[3]||(l[3]=s=>t.variableFilter=s),disabled:!0,style:{width:"240px"}},null,8,["modelValue"])])]),r("div",J,[r("div",null,[a(m,{ref_key:"upload",ref:n,action:"#",limit:1,"show-file-list":!1,"auto-upload":!0,"on-exceed":D,"http-request":N},{trigger:p(()=>[a(d,{loading:f.value,plain:"",color:"#6366f1",icon:x(A)},{default:p(()=>[w("导入预览")]),_:1},8,["loading","icon"])]),_:1},512)]),a(d,{plain:"",round:"",type:"warning",icon:x(U),onClick:E},{default:p(()=>[w(" 确认导入 ")]),_:1},8,["icon"])])]),_:1}),a(F,{shadow:"hover",style:{border:"none"}},{default:p(()=>[X,a(I,j(L(i)),null,16)]),_:1})])}}});export{le as default};
|