mainData.af497c7c.js 6.0 KB

1
  1. import{e as V,g as ee,u as te}from"./columns.185e998c.js";import{a as ae}from"./elementPlus.97569cdd.js";import{f as oe,r as s,Q as ne,w as _,d as se,a7 as $,h as re,E as le,G as v,j as N,M as de,L as F,K as ie,B as ce,aa as ue}from"./vue.9083513e.js";import{_ as fe}from"./_plugin-vue_export-helper.c27b6911.js";import"./index.136f97e1.js";import"./echarts.594b4072.js";const me={class:"mx-3.5"},ge={class:"font-semibold"},pe={class:"font-semibold",style:{color:"#164285"}},_e=oe({__name:"mainData",props:{dayDate:Object,weekDate:Object,monthDate:Object,taskIds:Object},setup(K){const c=K,B=s(null),j=s([]),T=s([]),h=s(null),S=s(null),C=s(null),b=s(null),w=s(null),x=s(null),f=s(""),m=s(""),g=s(""),D=s(null),y=s(null),P=s(!0),n=ne({border:"inner",height:900,align:null,round:!0,loading:!1,id:"mainDataCustomStorage",columnConfig:{resizable:!0},rowConfig:{isHover:!0},pagerConfig:{enabled:!0,total:20,currentPage:1,pageSize:20,pageSizes:[10,20,30]},sortConfig:{remote:!0,defaultSort:{field:y,order:D}},customConfig:{storage:{visible:!0}},toolbarConfig:{custom:!0,zoom:{iconIn:"vxe-icon-fullscreen",iconOut:"vxe-icon-minimize"},slots:{tools:"toolbar_buttons"}},columns:j,data:T}),W=()=>{localStorage.setItem("sortField",f.value),localStorage.setItem("sortOrder",m.value),localStorage.setItem("salesOrder",D.value),localStorage.setItem("salesField",y.value)},G=()=>{f.value=localStorage.getItem("sortField")||"",m.value=localStorage.getItem("sortOrder")||"",n.sortConfig.defaultSort.order=localStorage.getItem("salesOrder")||"",n.sortConfig.defaultSort.field=localStorage.getItem("salesField")||""},Q={pageChange({currentPage:e,pageSize:a}){n.pagerConfig&&(n.pagerConfig.currentPage=e,n.pagerConfig.pageSize=a,p(c.taskIds))}};async function p(e,a=!1){a&&(n.pagerConfig.currentPage=1);try{n.loading=!0;const o=await ee({page:n.pagerConfig.currentPage,limit:n.pagerConfig.pageSize,task_ids:e,day_start_date:h.value,day_end_date:S.value,week_start_date:C.value,week_end_date:b.value,month_start_date:w.value,month_end_date:x.value,sort:m.value,order_date:f.value,date_type:g.value});if(n.data=o.data,n.pagerConfig.total=o.total,P.value&&o.data&&o.data.length>0){const r=[],l=/\d{2}-\d{2}/,M=/\d{4}-\d{2}-\d{2}/,k=/\d{4}-\d{2}/,I=/\d{4}-\d{2}-\d{2}~\d{4}-\d{2}-\d{2}/,A=["~","截止","近90天平台退货率","余额"],H=new Set;o.data.forEach(t=>{for(const d in t)(l.test(d)||A.some(i=>d.includes(i)))&&H.add(d)});const z=[],E=[],O=[];H.forEach(t=>{let d=!1;t.includes("的销售额")&&!t.includes("广告销售额")&&!t.includes("增长率")&&(d=!0);const i={field:t,title:t,minWidth:t.includes("~")||t.includes("截止")?94:M.test(t)?95:/\d{4}-\d{2}的销售额/.test(t)?127:76,align:"center",formatter:Z,sortable:d};A.some(u=>t.includes(u))?E.push(i):k.test(t)&&!M.test(t)?O.push(i):l.test(t)&&z.push(i)});const L=z.filter(t=>t.field.includes("的销售额")&&!t.field.includes("增长率"));L.sort((t,d)=>{const i=t.field.match(/\d{4}-\d{2}-\d{2}/),u=d.field.match(/\d{4}-\d{2}-\d{2}/);return i&&u?new Date(i[0])-new Date(u[0]):0});const R=E.filter(t=>t.field.includes("的销售额")&&!t.field.includes("增长率"));R.sort((t,d)=>{const i=t.field.match(I)[0].split("~")[0],u=d.field.match(I)[0].split("~")[0];return new Date(i)-new Date(u)});const U=O.filter(t=>t.field.includes("的销售额"));U.sort((t,d)=>{const i=`${t.field.match(k)[0]}-01`,u=`${d.field.match(k)[0]}-01`;return new Date(i)-new Date(u)}),r.push(...L,...z.filter(t=>!t.field.includes("的销售额")),...R,...E.filter(t=>!I.test(t.field)),...U,...O.filter(t=>!t.field.includes("的销售额"))),j.value=[...te,...r]}W()}catch(o){console.error("Error fetching task data:",o)}finally{n.loading=!1}}function q({field:e,order:a}){if(D.value=a,y.value=e,m.value=a==="asc"?"smallfirst":"bigfirst",e){const o=e.match(/(\d{4}-\d{2}-\d{2})的销售额/),r=e.match(/(\d{4}-\d{2}-\d{2})~(\d{4}-\d{2}-\d{2})的销售额/),l=e.match(/(\d{4}-\d{2})的销售额/);r?(f.value=r[1],g.value="week"):o?(f.value=o[1],g.value="day"):l&&(f.value=`${l[1]}-01`,g.value="month")}n.sortConfig.defaultSort.order=a,n.sortConfig.defaultSort.field=e,P.value=!1,p(c.taskIds,!0)}async function J(){try{n.loading=!0;const e={page:n.pagerConfig.currentPage,limit:n.pagerConfig.pageSize,task_ids:c.taskIds,day_start_date:h.value,day_end_date:S.value,week_start_date:C.value,week_end_date:b.value,month_start_date:w.value,month_end_date:x.value},a=await V(e),o=window.URL.createObjectURL(new Blob([a.data])),r=document.createElement("a");r.href=o,r.setAttribute("download","合并数据展示.xlsx"),document.body.appendChild(r),r.click(),n.loading=!1,ae.success("导出数据成功")}catch(e){console.error("导出数据失败:",e)}}_(()=>c.taskIds,e=>{B.value=e,p(e,!0)}),_(()=>c.dayDate,e=>{if(e){const{dailyStartDate:a,dailyTime:o}=e;h.value=a,S.value=o}}),_(()=>c.weekDate,e=>{if(e){const{weekStartDate:a,weekEndDate:o}=e;C.value=a,b.value=o}}),_(()=>c.monthDate,e=>{if(e){const{startDate:a,endDate:o}=e;w.value=a,x.value=o}B.value&&p(c.taskIds,!0)});const X=({columnIndex:e})=>e<6?{fontSize:"12px",fontWeight:"500"}:{fontSize:"12px",fontWeight:"500"},Y=({column:e})=>{const a=e.field,o=/\d{2}-\d{2}/,r=/\d{4}-\d{2}-\d{2}/,l=/\d{4}-\d{2}/;return a.includes("~")||a.includes("截止")||a.includes("近90天平台退货率")||a.includes("余额")?{fontSize:"12px",backgroundColor:"#b3ced7"}:l.test(a)&&!r.test(a)?{fontSize:"12px",backgroundColor:"#8cbacc"}:o.test(a)?{fontSize:"12px",backgroundColor:"#d0dadf"}:{fontSize:"12px"}};function Z({cellValue:e}){return e==null||e===""?"--":typeof e=="number"?new Intl.NumberFormat("en-US",{minimumFractionDigits:0}).format(e):e}return se(()=>{G()}),(e,a)=>{const o=$("vxe-button"),r=$("vxe-grid");return re(),le(r,ce({"cell-style":X,"header-cell-style":Y},n,ue(Q),{onSortChange:q}),{toolbar_buttons:v(()=>[N("div",me,[de(o,{circle:"",icon:"vxe-icon-download",onClick:J})])]),platformNumber_default:v(({row:l})=>[N("div",ge,F(l.platformNumber),1)]),platformName_default:v(({row:l})=>[N("div",pe,F(l.platformName),1)]),brandName_default:v(({row:l})=>[ie(F(l.brandName),1)]),_:1},16)}}});const xe=fe(_e,[["__scopeId","data-v-1055dbae"]]);export{xe as default};