趋势接口修改

This commit is contained in:
hucongqian 2022-06-30 16:50:01 +08:00
parent c4b6faaa6d
commit 5ead4f085b
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:获取当前登录用户所在部门发布的资源 // /resource/getByDept:获取当前登录用户所在部门发布的资源
@ -125,9 +139,9 @@ export const getApplyByDept = (data, success, fail) => {
} }
// 部门发布能力被调用趋势 // 部门发布能力被调用趋势
export const getByDept = (data, success, fail) => { export const getByDept = (data, success, fail) => {
Request({ RequestPost({
methods: 'get', methods: 'post',
url: '/resource/getByDept', url: '/resource/trafficDeptResource',
data data
}).then(res => { }).then(res => {
success && success(res) success && success(res)

View File

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

View File

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