mirror of
https://gitee.com/hzchunfen/erp.git
synced 2025-12-01 06:30:49 +00:00
2 lines
6.3 KiB
JavaScript
Vendored
2 lines
6.3 KiB
JavaScript
Vendored
"use strict";(self["webpackChunkerp"]=self["webpackChunkerp"]||[]).push([[121],{372:function(t,e,a){a.r(e),a.d(e,{default:function(){return y}});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:"type_name"}}),e("el-table-column",{attrs:{label:"库存",prop:"stock"}}),e("el-table-column",{attrs:{label:"可售库存",prop:"sale_stock"}}),"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:"goods_total"}}),e("el-table-column",{attrs:{label:"总销售金额",prop:"goods_total_amount"}})],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:"",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.fetchData()},fetchData(){this.loading=!0;let t={type:"day"==this.time_type?1:2,start_day:this.startTime,end_day:this.endTime};(0,l.E0)(t).then((t=>{this.saleList=t.data.data,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.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()},handleExport(){this.saleList.length?(this.downloadLoading=!0,Promise.all([a.e(560),a.e(283)]).then(a.bind(a,6283)).then((t=>{const e=["类型名称","库存","可售库存","总销量","总销售金额"],a=["type_name","stock","sale_stock","goods_total","goods_total_amount"];"day"==this.time_type&&(e.splice(3,0,"已发货数","未发货数"),a.splice(3,0,"shipping_num","unshipping_num"));const i=this.saleList;let s=this.startTime==this.endTime?this.startTime:this.startTime+"-"+this.endTime;const l=this.formatJson(a,i);t.export_json_to_excel({header:e,data:l,filename:"sku销售统计数据【"+this.TIMETYPE[this.time_type]+s+"】",autoWidth:this.autoWidth,bookType:this.bookType}),this.downloadLoading=!1})).catch((()=>{this.downloadLoading=!1}))):this.$message({message:"暂无数据",type:"error"})},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,"0bbd0026",null),y=d.exports}}]);
|
|
//# sourceMappingURL=121.5d0c0fba.js.map
|