|
@@ -15,44 +15,44 @@ type EChartsOption = echarts.EChartsOption;
|
|
|
|
|
|
@Component
|
|
@Component
|
|
export default class Line01 extends Vue {
|
|
export default class Line01 extends Vue {
|
|
- id=this.randomString();
|
|
|
|
|
|
+ id = this.randomString();
|
|
|
|
|
|
- mounted(){
|
|
|
|
|
|
+ mounted() {
|
|
this.getData()
|
|
this.getData()
|
|
}
|
|
}
|
|
|
|
|
|
- randomString(){
|
|
|
|
|
|
+ randomString() {
|
|
const str = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
const str = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
let result = '';
|
|
let result = '';
|
|
for (let i = 10; i > 0; --i)
|
|
for (let i = 10; i > 0; --i)
|
|
result += str[Math.floor(Math.random() * str.length)];
|
|
result += str[Math.floor(Math.random() * str.length)];
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
- initChart(list:Array<any>){
|
|
|
|
- if(!list) return
|
|
|
|
- let chartDom:any = document.getElementById(this.id);
|
|
|
|
|
|
+ initChart(list: Array<any>) {
|
|
|
|
+ if (!list) return
|
|
|
|
+ let chartDom: any = document.getElementById(this.id);
|
|
let myChart = echarts.init(chartDom);
|
|
let myChart = echarts.init(chartDom);
|
|
let option: EChartsOption;
|
|
let option: EChartsOption;
|
|
- let dataX:Array<any>=this.getDaysList()
|
|
|
|
- let dataY:Array<any>=[]
|
|
|
|
- for(const item of list) {
|
|
|
|
- let obj:any={
|
|
|
|
|
|
+ let dataX: Array<any> = this.getDaysList()
|
|
|
|
+ let dataY: Array<any> = []
|
|
|
|
+ for (const item of list) {
|
|
|
|
+ let obj: any = {
|
|
name: item[0].shop_name,
|
|
name: item[0].shop_name,
|
|
type: 'line',
|
|
type: 'line',
|
|
smooth: true,
|
|
smooth: true,
|
|
data: []
|
|
data: []
|
|
}
|
|
}
|
|
- if(item){
|
|
|
|
- for(const arr of dataX) {
|
|
|
|
|
|
+ if (item) {
|
|
|
|
+ for (const arr of dataX) {
|
|
let isAdd = false
|
|
let isAdd = false
|
|
- for(const item2 of item){
|
|
|
|
- if(arr == item2.day) {
|
|
|
|
|
|
+ for (const item2 of item) {
|
|
|
|
+ if (arr == item2.day) {
|
|
obj.data.push(item2.total)
|
|
obj.data.push(item2.total)
|
|
isAdd = true
|
|
isAdd = true
|
|
break
|
|
break
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if(!isAdd) {
|
|
|
|
|
|
+ if (!isAdd) {
|
|
obj.data.push(0)
|
|
obj.data.push(0)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -63,9 +63,9 @@ export default class Line01 extends Vue {
|
|
tooltip: {
|
|
tooltip: {
|
|
trigger: 'axis'
|
|
trigger: 'axis'
|
|
},
|
|
},
|
|
- legend:{
|
|
|
|
- show:true,
|
|
|
|
- top:0
|
|
|
|
|
|
+ legend: {
|
|
|
|
+ show: true,
|
|
|
|
+ top: 0
|
|
},
|
|
},
|
|
grid: {
|
|
grid: {
|
|
left: '3%',
|
|
left: '3%',
|
|
@@ -92,53 +92,57 @@ export default class Line01 extends Vue {
|
|
option && myChart.setOption(option);
|
|
option && myChart.setOption(option);
|
|
}
|
|
}
|
|
getDaysList() {
|
|
getDaysList() {
|
|
- let daysHandle = (n:number) => {
|
|
|
|
|
|
+ let daysHandle = (n: number) => {
|
|
let dy = new Date()
|
|
let dy = new Date()
|
|
dy.setTime(dy.getTime() - 3600 * 1000 * 24 * n)
|
|
dy.setTime(dy.getTime() - 3600 * 1000 * 24 * n)
|
|
let y = dy.getFullYear();
|
|
let y = dy.getFullYear();
|
|
- let m:any = dy.getMonth() + 1;
|
|
|
|
- let d:any = dy.getDate();
|
|
|
|
|
|
+ let m: any = dy.getMonth() + 1;
|
|
|
|
+ let d: any = dy.getDate();
|
|
m = m < 10 ? '0' + m : m;
|
|
m = m < 10 ? '0' + m : m;
|
|
d = d < 10 ? '0' + d : d;
|
|
d = d < 10 ? '0' + d : d;
|
|
return y + '-' + m + '-' + d;
|
|
return y + '-' + m + '-' + d;
|
|
}
|
|
}
|
|
- let data:Array<any> = []
|
|
|
|
- for(let i = 29; i >= 0; i--) {
|
|
|
|
|
|
+ let data: Array<any> = []
|
|
|
|
+ for (let i = 29; i >= 0; i--) {
|
|
data.push(daysHandle(i))
|
|
data.push(daysHandle(i))
|
|
}
|
|
}
|
|
return data;
|
|
return data;
|
|
}
|
|
}
|
|
getData() {
|
|
getData() {
|
|
(this as any).$request({
|
|
(this as any).$request({
|
|
- url:'/omsOrder/report/shopDailyCount',
|
|
|
|
|
|
+ //url:'/omsOrder/report/shopDailyCount',
|
|
|
|
+ url: '/omsOrder/orderReport/orderSourceByYear',
|
|
method: 'GET',
|
|
method: 'GET',
|
|
- }).then((res:any) => {
|
|
|
|
- if(res.data) {
|
|
|
|
|
|
+ }).then((res: any) => {
|
|
|
|
+ if (res.data) {
|
|
this.initChart(res.data)
|
|
this.initChart(res.data)
|
|
}
|
|
}
|
|
- }).catch(() =>{})
|
|
|
|
|
|
+ }).catch(() => { })
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
<style lang="scss" scoped>
|
|
-.chart-box{
|
|
|
|
|
|
+.chart-box {
|
|
height: 100%;
|
|
height: 100%;
|
|
width: 100%;
|
|
width: 100%;
|
|
- .title-top{
|
|
|
|
|
|
+
|
|
|
|
+ .title-top {
|
|
height: 40px;
|
|
height: 40px;
|
|
display: flex;
|
|
display: flex;
|
|
justify-content: center;
|
|
justify-content: center;
|
|
align-items: center;
|
|
align-items: center;
|
|
position: relative;
|
|
position: relative;
|
|
width: 100%;
|
|
width: 100%;
|
|
- >span{
|
|
|
|
|
|
+
|
|
|
|
+ >span {
|
|
font-size: 16px;
|
|
font-size: 16px;
|
|
font-weight: 700;
|
|
font-weight: 700;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-.chart{
|
|
|
|
|
|
+
|
|
|
|
+.chart {
|
|
height: calc(100% - 40px);
|
|
height: calc(100% - 40px);
|
|
width: 100%;
|
|
width: 100%;
|
|
}
|
|
}
|