import{a as R,b as A}from"./api.DGelHC0B.js";import{D as w,z as N,h as O}from"./elementPlus.CXoFsoPv.js";/* empty css                   */import{d as j,Z as B,r as _,w as E,j as I,ai as r,o as c,c as v,U as d,O as m,a as n,u as f,D as h,K as L,am as P,F as K,M as x,R as T,T as H}from"./vue.1RczIYhx.js";import{_ as Z}from"./_plugin-vue_export-helper.DlAUqK2U.js";import"./index.fM6cvGYs.js";const q=[{field:"asin",title:"ASIN",minWidth:"auto"},{field:"sku",title:"SKU",minWidth:"auto"},{field:"reviews1",title:"一星评分个数",align:"center",minWidth:"auto"},{field:"reviews2",title:"二星评分个数",align:"center",minWidth:"auto"},{field:"reviews3",title:"三星评分个数",align:"center",minWidth:"auto"},{field:"reviews4",title:"四星评分个数",align:"center",minWidth:"auto"},{field:"reviews5",title:"五星评分个数",align:"center",minWidth:"auto"},{field:"is_new_sku",title:"是否新品",align:"center",formatter:({cellValue:y})=>y===!0?"是":"否",minWidth:"auto"},{field:"review_date",title:"评论日期",minWidth:"auto"},{field:"launch_date",title:"发布日期",minWidth:"auto"},{field:"avg_score",title:"平均评分",minWidth:120,slots:{default:"avg_score"}}],G={class:"mb-1",style:{display:"flex","align-items":"baseline","justify-content":"space-between"}},J={style:{display:"flex",gap:"25px","margin-bottom":"10px"}},Q={key:1},X={key:1},$=j({__name:"MonthlyRating",setup(y){const o=B({border:"inner",loading:!1,height:700,pagerConfig:{enabled:!0,total:20,currentPage:1,pageSize:20,pageSizes:[10,20,30]},rowConfig:{height:38},columns:q,data:[]}),l=_(w().subtract(1,"month").startOf("month").format("YYYY-MM-DD")),k=t=>{const e=new Date,i=e.getFullYear(),s=e.getMonth()+1;return t.getFullYear()>i||t.getFullYear()===i&&t.getMonth()+2>s},u=_(""),p=_("");_([]);const C={pageChange({pageSize:t,currentPage:e}){o.pagerConfig.currentPage=e,o.pagerConfig.pageSize=t,g()}};async function g(){o.loading=!0;try{const t={limit:o.pagerConfig.pageSize,page:o.pagerConfig.currentPage,review_date:l.value,asin:u.value,sku:p.value},e=await R(t);o.data=e.data,o.pagerConfig.total=e.total}catch(t){console.log(t)}finally{o.loading=!1}}async function S(){o.loading=!0;try{const t={review_date:l.value,asin:u.value,sku:p.value},e=await A(t),i=window.URL.createObjectURL(e.data),s=document.createElement("a");s.href=i,s.setAttribute("download",l.value+"平均评分.xlsx"),document.body.appendChild(s),s.click(),document.body.removeChild(s),window.URL.revokeObjectURL(i),o.loading=!1,O.success("下载成功！")}catch(t){console.log(t)}finally{o.loading=!1}}function V(){return{fontSize:"13px",fontWeight:"500"}}function D(){return{fontSize:"13px",backgroundColor:"#f0f1f3",height:10}}return E(l,t=>{const e=w(t).startOf("month").format("YYYY-MM-DD");e!==l.value&&(l.value=e,g())}),I(()=>{g()}),(t,e)=>{const i=r("el-input"),s=r("el-date-picker"),M=r("el-button"),U=r("el-rate"),W=r("el-tooltip"),Y=r("el-empty"),z=r("vxe-grid"),b=r("el-card");return c(),v("div",null,[d(b,{shadow:"hover",class:"border-none"},{default:m(()=>[e[6]||(e[6]=n("span",{class:"title"},"监控ASIN每月平均评分",-1)),n("div",G,[n("div",J,[n("div",null,[e[3]||(e[3]=n("span",{style:{"font-size":"14px","padding-right":"4px"}},"ASIN ",-1)),d(i,{modelValue:f(u),"onUpdate:modelValue":e[0]||(e[0]=a=>h(u)?u.value=a:null),clearable:"",style:{width:"180px"},onChange:g},null,8,["modelValue"])]),n("div",null,[e[4]||(e[4]=n("span",{style:{"font-size":"14px","padding-right":"4px"}},"SKU ",-1)),d(i,{modelValue:f(p),"onUpdate:modelValue":e[1]||(e[1]=a=>h(p)?p.value=a:null),clearable:"",style:{width:"180px"},onChange:g},null,8,["modelValue"])]),n("div",null,[e[5]||(e[5]=n("span",{class:"mr-1",style:{"font-size":"14px"}},"时间选择 ",-1)),d(s,{modelValue:f(l),"onUpdate:modelValue":e[2]||(e[2]=a=>h(l)?l.value=a:null),clearable:!1,"disabled-date":k,placeholder:"选择月",style:{width:"170px"},type:"month"},null,8,["modelValue"])])]),n("div",null,[d(M,{icon:f(N),circle:"",plain:"",onClick:S},null,8,["icon"])])]),d(b,{"body-style":"padding: 0",shadow:"never"},{default:m(()=>[d(z,L({"cell-style":V,"header-cell-style":D,"show-overflow":"tooltip"},f(o),P(C)),{avg_score:m(({row:a})=>[a.avg_score!==null&&a.avg_score!==void 0&&a.avg_score!==""?(c(),v(K,{key:0},[a.avg_score>0?(c(),x(W,{key:0,content:a.avg_score,placement:"top","show-after":300},{default:m(()=>[a.avg_score>0?(c(),x(U,{key:0,modelValue:a.avg_score,"onUpdate:modelValue":F=>a.avg_score=F,colors:["#FF0000","#FF9900","#67C23A"],disabled:"","text-color":"#1e293b"},null,8,["modelValue","onUpdate:modelValue"])):T("",!0)]),_:2},1032,["content"])):(c(),v("span",Q,H(a.avg_score),1))],64)):(c(),v("span",X,"-"))]),empty:m(()=>[d(Y,{description:"暂无数据"})]),_:1},16)]),_:1})]),_:1})])}}}),se=Z($,[["__scopeId","data-v-aa78d517"]]);export{se as default};
