Compare commits

...

2 Commits

3 changed files with 70 additions and 16 deletions

View File

@ -15,6 +15,20 @@ function Request({
})
})
}
function RequestPost({
methods, url, data, success, fali
}) {
return new Promise((resolve, reject) => {
http[methods](url,
data
).then(res => {
resolve(res)
}, err => {
reject(err)
})
})
}
// /resource/getByDept:获取当前登录用户所在部门发布的资源
@ -125,9 +139,9 @@ export const getApplyByDept = (data, success, fail) => {
}
// 部门发布能力被调用趋势
export const getByDept = (data, success, fail) => {
Request({
methods: 'get',
url: '/resource/getByDept',
RequestPost({
methods: 'post',
url: '/resource/trafficDeptResource',
data
}).then(res => {
success && success(res)

View File

@ -67,7 +67,7 @@ export const trendLineChart = (id, chartData, _option) => {
},
}],
series: [{
name: '合格数据百分比',
name: '使用量',
type: 'line',
showAllSymbol: true,
symbolSize: 0,

View File

@ -23,7 +23,14 @@ export default {
return {
titles: ["近七日", "月度"],
selectedTitle: 0,
trendChartData:{}
trendChartData: {},
startDate: "",
endDate:
new Date().getFullYear() +
"-" +
(new Date().getMonth() + 1) +
"-" +
new Date().getDate()
};
},
components: {
@ -32,25 +39,38 @@ export default {
mounted() {
this.initChart();
},
watch: {
selectedTitle: {
handler: function(newVal, oldVal) {
this.startDate = this.getData(newVal == 0 ? 7 : 30);
},
deep: true,
immediate: true
}
},
methods: {
//
initChart() {
let data = {
limit: 10,
page: 1
};
Apis.getByDept(
data,
{
startDate: this.startDate,
endDate: this.endDate
},
res => {
if (res.data.code !== 0) {
return;
}
this.data = res.data.data.records || [];
let xaxis=[],ydata=[]
this.data.forEach(v=>{
xaxis.push(v.createDate)
ydata.push(v.visits)
})
this.data = res.data.data.browseDayList || [];
let xaxis = [],
ydata = [];
this.data.forEach(v => {
Object.keys(v).map((key, value) => {
xaxis.push(key);
ydata.push(value);
});
});
console.log(xaxis)
console.log(ydata)
this.trendChartData = {
xaxis: xaxis,
ydata: ydata
@ -66,7 +86,27 @@ export default {
},
handleTitleSwitch(idx) {
this.selectedTitle = idx;
this.startDate = this.getData(this.selectedTitle == 0 ? 7 : 30);
console.log(this.startDate);
this.initChart();
},
getData(aa) {
let date1 = new Date(),
time1 =
date1.getFullYear() +
"-" +
(date1.getMonth() + 1) +
"-" +
date1.getDate(); //time1
let date2 = new Date(date1);
date2.setDate(date1.getDate() - aa);
let time2 =
date2.getFullYear() +
"-" +
(date2.getMonth() + 1) +
"-" +
date2.getDate();
return time2;
}
}
};