mirror of
https://gitee.com/hzchunfen/erp.git
synced 2025-12-01 06:30:49 +00:00
2 lines
7.7 KiB
JavaScript
Vendored
2 lines
7.7 KiB
JavaScript
Vendored
"use strict";(self["webpackChunkerp"]=self["webpackChunkerp"]||[]).push([[162],{9361:function(t,e,a){a.r(e),a.d(e,{default:function(){return p}});var i=function(){var t=this,e=t._self._c;return e("div",[e("div",{staticClass:"cardBox"},[e("div",{staticClass:"searchBox"},[e("div",{staticClass:"row"},[e("span",[t._v("统计时间:")]),e("el-select",{staticStyle:{width:"100px","margin-right":"5px"},on:{change:t.changeTimeType},model:{value:t.time_type,callback:function(e){t.time_type=e},expression:"time_type"}},t._l(t.timeTypeList,(function(t){return e("el-option",{key:t.value,attrs:{label:t.label,value:t.value}})})),1),"day"==t.time_type||"week"==t.time_type||"seven"==t.time_type||"thirty"==t.time_type?e("el-date-picker",{attrs:{clearable:!1,type:"date",placeholder:"选择日期",format:"yyyy-MM-dd","value-format":"yyyy-MM-dd"},on:{change:t.changeDayTime},model:{value:t.dayValue,callback:function(e){t.dayValue=e},expression:"dayValue"}}):"month"==t.time_type?e("el-date-picker",{attrs:{type:"month",clearable:!1,format:"yyyy-MM","value-format":"yyyy-MM",placeholder:"选择月"},on:{change:t.changeMonthTime},model:{value:t.monthValue,callback:function(e){t.monthValue=e},expression:"monthValue"}}):"custom"==t.time_type?e("el-date-picker",{staticStyle:{width:"250px"},attrs:{type:"datetimerange","range-separator":"-","start-placeholder":"开始时间","end-placeholder":"结束时间",format:"yyyy-MM-dd","value-format":"yyyy-MM-dd",clearable:!1},on:{change:t.changeCustomTime},model:{value:t.customValue,callback:function(e){t.customValue=e},expression:"customValue"}}):t._e(),e("div",{staticClass:"time"},[e("span",[t._v("当前统计时间:")]),t.startTime==t.endTime?e("span",[t._v(t._s(t.startTime))]):e("span",[t._v(t._s(t.startTime)+"~"+t._s(t.endTime))])])],1)])]),e("el-card",[e("div",{staticClass:"opaBox"},[e("el-button",{attrs:{type:"success",icon:"el-icon-download",loading:t.downloadLoading},on:{click:t.handleExport}},[t._v("导出")])],1),e("el-table",{directives:[{name:"loading",rawName:"v-loading",value:t.loading,expression:"loading"}],attrs:{border:"",data:t.saleList}},[e("el-table-column",{attrs:{label:"商品名称",prop:"name"}}),e("el-table-column",{attrs:{label:"sku规格",prop:"title"}}),e("el-table-column",{attrs:{label:"规格编码",prop:"external_sku_id"}}),e("el-table-column",{attrs:{label:"销量",prop:"goods_total"}}),e("el-table-column",{attrs:{label:"销售额",prop:"goods_total_amount"}}),"day"==t.time_type?e("el-table-column",{attrs:{label:"昨日销量",prop:"yesterday_avg_num"}}):t._e(),"day"==t.time_type?e("el-table-column",{attrs:{label:"3日内销量",prop:"three_day_avg_num"}}):t._e(),"day"==t.time_type?e("el-table-column",{attrs:{label:"7日内销量",prop:"seven_day_avg_num"}}):t._e(),"day"==t.time_type?e("el-table-column",{attrs:{label:"已发货数",prop:"shipping_num"}}):t._e(),"day"==t.time_type?e("el-table-column",{attrs:{label:"未发货数",prop:"unshipping_num"}}):t._e(),e("el-table-column",{attrs:{label:"库存",prop:"stock"}}),e("el-table-column",{attrs:{label:"可售库存",prop:"sale_stock"}}),e("el-table-column",{attrs:{label:"状态",prop:"status"}})],1),e("div",{staticClass:"page-pagination"},[e("el-pagination",{attrs:{"current-page":t.page,"page-sizes":[10,20,50,100],"page-size":t.pageSize,layout:"prev, pager, next, jumper, sizes, total",total:t.total},on:{"size-change":t.handleSizeChange,"current-change":t.handleCurrentChange}})],1)],1)],1)},s=[],l=a(1808),n=a(7484),o=a.n(n),h={data(){return{loading:!1,time_type:"day",timeTypeList:[{label:"自然日",value:"day"},{label:"自然周",value:"week"},{label:"自然月",value:"month"},{label:"近7天",value:"seven"},{label:"近30天",value:"thirty"},{label:"自定义",value:"custom"}],TIMETYPE:{day:"自然日",week:"自然周",month:"自然月",seven:"近7天",thirty:"近30天",custom:"自定义"},dayValue:"",monthValue:"",customValue:[],startTime:"",endTime:"",page:1,pageSize:10,total:0,saleList:[],downloadLoading:!1,autoWidth:!0,bookType:"xlsx"}},mounted(){this.getInitList()},methods:{getInitList(){let t=this.getDayTime();this.dayValue=this.startTime=this.endTime=t,this.fetchData()},changeTimeType(){if("day"==this.time_type){let t=this.getDayTime();this.dayValue=this.startTime=this.endTime=t}else"week"==this.time_type?(this.dayValue=this.endTime=o()().format("YYYY-MM-DD"),this.startTime=o()(this.getFirstDay(this.dayValue)).format("YYYY-MM-DD")):"month"==this.time_type?(this.monthValue=o()().format("YYYY-MM"),this.startTime=this.monthValue+"-01",this.endTime=this.monthValue+"-"+this.getDaysInMonth(this.monthValue)):"seven"==this.time_type?(this.dayValue=this.endTime=o()().format("YYYY-MM-DD"),this.startTime=o()().subtract(7,"day").format("YYYY-MM-DD")):"thirty"==this.time_type?(this.dayValue=this.endTime=o()().format("YYYY-MM-DD"),this.startTime=o()().subtract(30,"day").format("YYYY-MM-DD")):"custom"==this.time_type&&(this.startTime=this.endTime=o()().format("YYYY-MM-DD"),this.customValue=[this.startTime,this.startTime]);this.page=1,this.fetchData()},fetchData(){this.loading=!0;let t={type:"day"==this.time_type?1:2,start_day:this.startTime,end_day:this.endTime,page:this.page,per_page:this.pageSize};(0,l.E4)(t).then((t=>{this.saleList=t.data.data.data,this.total=t.data.data.total,this.loading=!1})).catch((()=>{this.loading=!1}))},getDayTime(){let t=o()().format("YYYY-MM-DD");return t},getFirstDay(t){let e=new Date(t).getDay()||7;return new Date(new Date(t).getFullYear(),new Date(t).getMonth(),new Date(t).getDate()+1-e)},getDaysInMonth(t){let e=1*t.split("-")[0],a=1*t.split("-")[1];const i=o()(new Date(e,a-1,1)),s=i.endOf("month");return s.date()},changeDayTime(){"day"==this.time_type?this.startTime=this.endTime=this.dayValue:"week"==this.time_type?(this.endTime=this.dayValue,this.startTime=o()(this.getFirstDay(this.dayValue)).format("YYYY-MM-DD")):"seven"==this.time_type?(this.endTime=this.dayValue,this.startTime=o()().subtract(7,"day").format("YYYY-MM-DD")):"thirty"==this.time_type&&(this.endTime=this.dayValue,this.startTime=o()().subtract(30,"day").format("YYYY-MM-DD")),this.page=1,this.fetchData()},changeMonthTime(){this.startTime=this.monthValue+"-01",this.endTime=this.monthValue+"-"+this.getDaysInMonth(this.monthValue),this.page=1,this.fetchData()},changeCustomTime(){this.startTime=this.customValue[0],this.endTime=this.customValue[1],this.page=1,this.fetchData()},handleSizeChange(t){this.page=1,this.pageSize=t,this.fetchData()},handleCurrentChange(t){this.page=t,this.fetchData()},handleExport(){this.downloadLoading=!0;let t={type:"day"==this.time_type?1:2,start_day:this.startTime,end_day:this.endTime,page:1,per_page:this.total};(0,l.E4)(t).then((t=>{if(!t.data.data.data.length)return this.$message({message:"暂无数据",type:"error"}),void(this.downloadLoading=!1);Promise.all([a.e(560),a.e(283)]).then(a.bind(a,6283)).then((e=>{const a=["商品名称","sku规格","规格编码","销量","销售额","库存","可售库存","状态"],i=["name","title","external_sku_id","goods_total","goods_total_amount","stock","sale_stock","status"];"day"==this.time_type&&(a.splice(5,0,"昨日销量","3日内销量","7日内销量","已发货数","未发货数"),i.splice(5,0,"yesterday_avg_num","three_day_avg_num","seven_day_avg_num","shipping_num","unshipping_num"));const s=t.data.data.data,l=this.formatJson(i,s);let n=this.startTime==this.endTime?this.startTime:this.startTime+"-"+this.endTime;e.export_json_to_excel({header:a,data:l,filename:"sku销售统计数据【"+this.TIMETYPE[this.time_type]+n+"】",autoWidth:this.autoWidth,bookType:this.bookType}),this.downloadLoading=!1})).catch((()=>{this.downloadLoading=!1}))})).catch((()=>{this.downloadLoading=!1}))},formatJson(t,e){return e.map((e=>t.map((t=>e[t]))))}}},m=h,r=a(1001),d=(0,r.Z)(m,i,s,!1,null,"0fa06413",null),p=d.exports}}]);
|
|
//# sourceMappingURL=162.e44cb03d.js.map
|