diff --git a/src/views/index.vue b/src/views/index.vue index d714192..f48bd24 100644 --- a/src/views/index.vue +++ b/src/views/index.vue @@ -209,6 +209,10 @@ export default { }, methods: { btgetdata() { + let that = this; + that.proportionData = []; + that.groupNameData = []; + that.dataP = []; // console.log(type) let rqtp; switch (this.klselt) { @@ -222,50 +226,106 @@ export default { } // allTygGroupTimeNum homeApi.allGroupTimeNum(reqp).then(res => { - const kldata = res.data.data.allTimeData - // 对应的键名 - let kltd = new Array; - let tmpkvd = new Array; + // const kldata = res.data.data.allTimeData + // // 对应的键名 + // let kltd = new Array; + // let tmpkvd = new Array; + // const dkeys = res.data.data.dkeys + // dkeys.forEach(function (item, idx) { + // kltd.push(item) + // tmpkvd.push(kldata[item].num) + // }) + // this.kltdata = kltd + // this.klvdata = tmpkvd; + + // 以上的不知道是什么,以下是新的 + const tmpdata = res.data.data.allTimeData const dkeys = res.data.data.dkeys - dkeys.forEach(function (item, idx) { - kltd.push(item) - tmpkvd.push(kldata[item].num) + const groupsData = res.data.data.groupsData + + let datas = [] + Object.values(tmpdata).forEach((value) => { + datas.push(value.num); + }); + + that.klqsDatas = datas; + that.klqsXDatas = dkeys; + + that.proportionData = [];that.groupNameData=[];that.dataP=[]; + groupsData.forEach((item) => { + that.proportionData.push(item.proportion); + that.groupNameData.push(item.groupName); + that.dataP.push({ + name:item.groupName, + value:item.proportion.split('%')[0] + }) }) - this.kltdata = kltd - this.klvdata = tmpkvd + + this.home_bar(); }); }, btgetdata2() { // + let that = this; + that.proportionData = []; + that.groupNameData = []; + that.dataP = []; homeApi.allGroupTimeNum2().then(res => { - const kldata = res.data.data.allTimeData - // 对应的键名 - let kltd = new Array; - let tmpkvd = new Array; + const tmpdata = res.data.data.allTimeData const dkeys = res.data.data.dkeys - dkeys.forEach(function (item, idx) { - kltd.push(item) - tmpkvd.push(kldata[item].num) + const groupsData = res.data.data.groupsData + + let datas = [] + Object.values(tmpdata).forEach((value) => { + datas.push(value.num); + }); + + that.klqsDatas = datas; + that.klqsXDatas = dkeys; + + that.proportionData = [];that.groupNameData=[];that.dataP=[]; + groupsData.forEach((item) => { + that.proportionData.push(item.proportion); + that.groupNameData.push(item.groupName); + that.dataP.push({ + name:item.groupName, + value:item.proportion.split('%')[0] + }) }) - this.kltdata = kltd - this.klvdata = tmpkvd + + this.home_bar(); }); }, btgetdata3() { // + let that = this; + that.proportionData = []; + that.groupNameData = []; + that.dataP = []; homeApi.allGroupTimeNum3().then(res => { - const kldata = res.data.data.allTimeData - // 对应的键名 - let kltd = new Array; - let tmpkvd = new Array; + const tmpdata = res.data.data.allTimeData const dkeys = res.data.data.dkeys - dkeys.forEach(function (item, idx) { - kltd.push(item) - tmpkvd.push(kldata[item].num) + const groupsData = res.data.data.groupsData + + let datas = [] + Object.values(tmpdata).forEach((value) => { + datas.push(value.num); + }); + + that.klqsDatas = datas; + that.klqsXDatas = dkeys; + + that.proportionData = [];that.groupNameData=[];that.dataP=[]; + groupsData.forEach((item) => { + that.proportionData.push(item.proportion); + that.groupNameData.push(item.groupName); + that.dataP.push({ + name:item.groupName, + value:item.proportion.split('%')[0] + }) }) - this.kltdata = kltd - this.klvdata = tmpkvd + this.home_bar(); }); }, //选择年月日中的某个 @@ -293,8 +353,6 @@ export default { var myChart = echarts.init(chartDom); var option; - // var xData = ['09:00', '10:00', '11:00','12:00', '13:00', '14:00','15:00', '16:00', '17:00','18:00', '20:00', '21:00', '22:00']; - // var data = [100, 200, 100, 200, 100, 200, 250, 50, 30, 130, 150, 110, 120] let xData = this.klqsXDatas.slice(-8,this.klqsXDatas.length); var data = this.klqsDatas.slice(-8,this.klqsDatas.length); let max=data[0]; @@ -511,11 +569,11 @@ export default { ] }); } - that.timer1 = setInterval(function () { - myChart.clear(); - option && myChart.setOption(option); - run(myChart); - }, 5000); + // that.timer1 = setInterval(function () { + // myChart.clear(); + // option && myChart.setOption(option); + // run(myChart); + // }, 5000); }, // 今日各场馆服务人次趋势 @@ -784,8 +842,12 @@ export default { }, getHomeBarData() { - let that = this + let that = this; + that.proportionData = []; + that.groupNameData = []; + that.dataP = []; homeApi.homeBarData().then(res => { + // /pass.passcc/allGroupTimeNum&granularity=daily // get allTimeData const tmpdata = res.data.data.allTimeData const dkeys = res.data.data.dkeys @@ -793,16 +855,15 @@ export default { let datas = [] Object.values(tmpdata).forEach((value) => { - datas.push(value.num) - + datas.push(value.num); }); - that.klqsDatas = datas + that.klqsDatas = datas; that.klqsXDatas = dkeys; that.proportionData = [];that.groupNameData=[];that.dataP=[]; groupsData.forEach((item) => { - that.proportionData.push(item.proportion) + that.proportionData.push(item.proportion); that.groupNameData.push(item.groupName); that.dataP.push({ name:item.groupName, @@ -840,7 +901,7 @@ export default { this.rsqsDataName = []; that.rsqsData_z = []; homeApi.allGcgNumDatas().then(res => { - ///pass.passcc/toDayGroupsEnterNum' + // /pass.passcc/toDayGroupsEnterNum' const tmpdata = res.data.data tmpdata.forEach((item) => { this.rsqsDataName.push(item.groupName);