mirror of
https://gitee.com/hzchunfen/erp.git
synced 2025-11-30 22:20:45 +00:00
2 lines
7.1 KiB
JavaScript
Vendored
2 lines
7.1 KiB
JavaScript
Vendored
"use strict";(self["webpackChunkerp"]=self["webpackChunkerp"]||[]).push([[806],{1618:function(t,e,a){a.r(e),a.d(e,{default:function(){return c}});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",staticStyle:{width:"100%"}},[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),"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"}}):"day"==t.time_type?e("el-time-picker",{staticStyle:{width:"200px"},attrs:{"is-range":"","value-format":"HH:mm:ss",format:"HH:mm:ss","range-separator":"至",clearable:!1,"start-placeholder":"开始时间","end-placeholder":"结束时间",placeholder:"选择时间范围"},on:{change:t.changeTimePicker},model:{value:t.dayTimeList,callback:function(e){t.dayTimeList=e},expression:"dayTimeList"}}):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("div",{staticClass:"row"},[e("span",[t._v("规格:")]),e("el-select",{attrs:{filterable:"",remote:"",clearable:"","reserve-keyword":"",placeholder:"请选择具体规格","remote-method":t.remoteMethod,loading:t.remoteLoading},model:{value:t.sku_id,callback:function(e){t.sku_id=e},expression:"sku_id"}},t._l(t.skusList,(function(t){return e("el-option",{key:t.id,attrs:{label:t.title,value:t.id}})})),1)],1),e("div",{staticClass:"row"},[e("el-button",{attrs:{type:"primary",icon:"el-icon-search"},on:{click:function(e){return t.handleSearch()}}},[t._v("筛选")])],1)])]),e("el-card",[e("div",{staticClass:"echartBox",attrs:{id:"myEchart"}})])],1)},s=[],h=(a(560),a(1808)),l=a(9036),o=a(7484),r=a.n(o),m=a(2092),n={data(){return{loading:!1,time_type:"thirty",timeTypeList:[{label:"今日",value:"day"},{label:"自然周",value:"week"},{label:"自然月",value:"month"},{label:"近7天",value:"seven"},{label:"近30天",value:"thirty"},{label:"自定义",value:"custom"}],dayValue:"",monthValue:"",customValue:[],startTime:"",endTime:"",dateList:[],Sales:[],SaleCount:[],myChart:null,dayTimeList:[],sku_id:"",skusList:[],remoteLoading:!1}},mounted(){this.getInitList(),window.onresize=()=>{this.myChart&&this.myChart.resize()}},methods:{getInitList(){this.dayValue=this.endTime=r()().format("YYYY-MM-DD"),this.startTime=r()().subtract(30,"day").format("YYYY-MM-DD"),this.fetchData()},changeTimeType(){if("day"==this.time_type){let t=this.getDayTime();this.startTime=t+" 00:00:00",this.endTime=t+" 23:59:59",this.dayTimeList=["00:00:00","23:59:59"]}else"week"==this.time_type?(this.dayValue=this.endTime=r()().format("YYYY-MM-DD"),this.startTime=r()(this.getFirstDay(this.dayValue)).format("YYYY-MM-DD")):"month"==this.time_type?(this.monthValue=r()().format("YYYY-MM"),this.startTime=this.monthValue+"-01",this.endTime=this.monthValue+"-"+this.getDaysInMonth(this.monthValue)):"seven"==this.time_type?(this.dayValue=this.endTime=r()().format("YYYY-MM-DD"),this.startTime=r()().subtract(7,"day").format("YYYY-MM-DD")):"thirty"==this.time_type?(this.dayValue=this.endTime=r()().format("YYYY-MM-DD"),this.startTime=r()().subtract(30,"day").format("YYYY-MM-DD")):"custom"==this.time_type&&(this.startTime=this.endTime=r()().format("YYYY-MM-DD"),this.customValue=[this.startTime,this.startTime]);this.fetchData()},fetchData(){this.loading=!0;let t={};t="day"==this.time_type?{type:1,interval:60,start_time:this.startTime,end_time:this.endTime,sku_id:this.sku_id||0}:{type:2,start_day:this.startTime,end_day:this.endTime,sku_id:this.sku_id||0},(0,h.sF)(t).then((t=>{this.dateList=[],this.Sales=[],this.SaleCount=[];let e=t.data.data;if("day"==this.time_type){e=[];for(let a=0;a<24;a++){let i={goods_total:0,goods_total_amount:0,day:a};for(let e=0;e<t.data.data.length;e++){let s=t.data.data[e];a==s.sort_key&&(i.goods_total=s.goods_total,i.goods_total_amount=s.goods_total_amount)}i.day+=":00",e.push(i)}}e.forEach((t=>{this.dateList.push(t.day),this.Sales.push(t.goods_total),this.SaleCount.push(t.goods_total_amount)})),this.renderChart()})).catch((()=>{this.loading=!1}))},renderChart(){this.myChart=m.S1(document.getElementById("myEchart")),this.myChart.setOption({grid:{left:"1%",bottom:"2%",containLabel:!0},color:["#3cd08f","#f89f34"],tooltip:{trigger:"axis"},legend:{icon:"rect",left:30,data:["总销量","总销售额"]},xAxis:{type:"category",data:this.dateList},yAxis:{type:"value"},series:[{name:"总销量",type:"line",smooth:!0,data:this.Sales},{name:"总销售额",type:"line",smooth:!0,data:this.SaleCount}]}),this.loading=!1},getDayTime(){let t=r()().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=r()(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=r()(this.getFirstDay(this.dayValue)).format("YYYY-MM-DD")):"seven"==this.time_type?(this.endTime=this.dayValue,this.startTime=r()(this.dayValue).subtract(7,"day").format("YYYY-MM-DD")):"thirty"==this.time_type&&(this.endTime=this.dayValue,this.startTime=r()(this.dayValue).subtract(30,"day").format("YYYY-MM-DD")),this.fetchData()},changeMonthTime(){this.startTime=this.monthValue+"-01",this.endTime=this.monthValue+"-"+this.getDaysInMonth(this.monthValue),this.fetchData()},changeCustomTime(){this.startTime=this.customValue[0],this.endTime=this.customValue[1],this.fetchData()},changeTimePicker(){let t=this.getDayTime();this.startTime=t+" "+this.dayTimeList[0],this.endTime=t+" "+this.dayTimeList[1],this.fetchData()},handleSearch(){this.fetchData()},remoteMethod(t){t?(this.remoteLoading=!0,(0,l.no)(t).then((t=>{this.skusList=t.data.data,this.remoteLoading=!1}))):this.skusList=[]}},beforeDestroy(){this.myChart&&(this.myChart.dispose(),this.myChart=null)}},d=n,y=a(1001),u=(0,y.Z)(d,i,s,!1,null,"6517090e",null),c=u.exports}}]);
|
|
//# sourceMappingURL=806.6fa0f083.js.map
|