diff --git a/back/src/views/modules/workBench/api.js b/back/src/views/modules/workBench/api.js index 9e3bf5de..da7c16a2 100644 --- a/back/src/views/modules/workBench/api.js +++ b/back/src/views/modules/workBench/api.js @@ -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) diff --git a/back/src/views/modules/workBench/components/lineOption.js b/back/src/views/modules/workBench/components/lineOption.js index 75c33e08..cc9a5142 100644 --- a/back/src/views/modules/workBench/components/lineOption.js +++ b/back/src/views/modules/workBench/components/lineOption.js @@ -67,7 +67,7 @@ export const trendLineChart = (id, chartData, _option) => { }, }], series: [{ - name: '合格数据百分比', + name: '使用量', type: 'line', showAllSymbol: true, symbolSize: 0, diff --git a/back/src/views/modules/workBench/components/trend-view.vue b/back/src/views/modules/workBench/components/trend-view.vue index 9b644e34..3ccaf9c1 100644 --- a/back/src/views/modules/workBench/components/trend-view.vue +++ b/back/src/views/modules/workBench/components/trend-view.vue @@ -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; } } };