diff --git a/package.json b/package.json index 430f367..aee15fd 100644 --- a/package.json +++ b/package.json @@ -65,10 +65,7 @@ "not ie <= 8" ], "lint-staged": { - "src/**/*.{js,vue}": [ - "eslint --fix", - "git add" - ] + }, "husky": { "hooks": { diff --git a/src/api/index.js b/src/api/index.js index fbd387d..ea1922a 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -32,7 +32,9 @@ api.interceptors.request.use( * 以下代码为示例,在登录状态下,分别对 post 和 get 请求加上 token 参数 */ if (store.getters['user/isLogin']) { - request.headers.token = store.state.user.token + request.headers.token = store.state.user.token + // request.headers.token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJhcHAiOiJnb3YiLCJjbGllbnQiOiJ3ZWIiLCJleHAiOjE2MzI5NjYwODEsInVzZXJJZCI6Ijg0ODg3ZDQzMjEzN2EzMGI3YWJhYWM1MDY5ODZkNDYxIiwiaWF0IjoxNjMyMzYxMjgxfQ.CDYJNfuF7gRRDwwmB9dJQjVOj_t_3xdrgwMqxHNAleZuQHkPMu9fI32at2aPjprhN4yBc_KT_3_Yhh30SF7YzA' + // request.headers.Authorization = store.state.user.token } signRequest(request) return request diff --git a/src/views/form/statistics/analysis.vue b/src/views/form/statistics/analysis.vue index ba73c12..2b84ca0 100644 --- a/src/views/form/statistics/analysis.vue +++ b/src/views/form/statistics/analysis.vue @@ -5,29 +5,67 @@ :key="index">
- Q:{{ item.label }}({{ item.type }}) + Q{{ index + 1 }} :{{ item.label }}({{ item.type }}) -
- 图表类型: - - - + +
+ +
+ 共收集 {{ item.detail.collectionTotal }} 条, + 有效 {{ item.detail.validTotal }} 条 + ,总计 {{ item.detail.sumTotal }} + ,开 {{ item.detail.openTotal }} 条,关 {{ item.detail.closedTotal }} 条 +
+ +
+
+
{{ n.label }}
+
+
+ +
+
+ {{ computedPercent(n.currentCount, item.detail.totalCount).toFixed(2) }}% +
+
{{ n.currentCount }}次
+
-
- + + + + + @@ -116,76 +154,70 @@ export default { this.list = res.data }) }, - getCharData (data) { - const config = { - tooltip: { - backgroundColor: 'rgba(255,255,255,0.8)', // 通过设置rgba调节背景颜色与透明度 - color: 'black', - borderWidth: '1', - borderColor: 'rgb(156,209,255)', - textStyle: { - color: 'black' + mounted () { + this.getData() + }, + methods: { + getData () { + // `${process.env.VUE_APP_API_ROOT_TDUCK}/user/project/report/analysis` + // params: { projectKey: this.$route.query.key } + this.$api + .post('/data/aggregator/questionnaire/analysisreport', { + projectKey: this.$route.query.key + }) + .then(res => { + this.list = res.data + }) + }, + grid: { + left: '3%', + right: '4%', + bottom: '3%', + containLabel: true + }, + xAxis: [ + { + type: 'category', + axisTick: { + alignWithLabel: true } + return config }, - grid: { - left: '3%', - right: '4%', - bottom: '3%', - containLabel: true + computedCount(type) { + const arr = ['PROVINCE_CITY', 'NUMBER_INPUT', 'SWITCH', 'INPUT', 'TEXTAREA', 'INPUT_MAP', 'TIME', 'DATE_RANGE', 'DATE', 'TIME_RANGE'] + return arr.includes(type) }, - xAxis: [ - { - type: 'category', - axisTick: { - alignWithLabel: true - } - } - ], - yAxis: [ - { - type: 'value' - } - ], - series: [ - { - name: '数量', - type: 'pie', - barWidth: '40%' - } - ] - } - if (['bar', 'line'].includes(data.chartType)) { - config.tooltip.axisPointer = { - type: 'line' + computedPercent(num, count) { + return ((num * 100) / count) } config.tooltip.trigger = 'axis' config.xAxis[0].data = data.fieldName config.series[0].data = data.data config.series[0].type = data.chartType - } else { - // 环形图暂时不用 无法切换到饼图 - /* if ("ring" === data.chartType) { - config.series[0].radius = ["40%", "70%"]; - - config.series[0].emphasis = { - label: { - show: true, - fontSize: '25', - fontWeight: 'bold' - } + } else { + // 环形图暂时不用 无法切换到饼图 + /* if ("ring" === data.chartType) { +config.series[0].radius = ["40%", "70%"]; + +config.series[0].emphasis = { + label: { + show: true, + fontSize: '25', + fontWeight: 'bold' } +} }else{ - delete config.series[0].radius - delete config.series[0].label +delete config.series[0].radius +delete config.series[0].label } */ - config.series[0].data = [] + config.series[0].data = [] Object.keys(data.map).forEach(key => { - config.series[0].data.push({ name: key, value: data.map[key] }) - }) - // config.series[0].data = data.map - } + config.series[0].data.push({ name: key, value: data.map[key] }) + }) + // config.series[0].data = data.map + } return config - } +} } } @@ -199,7 +231,7 @@ export default { width: 100%; .title { font-size: 14px; - padding: 0 30px; + // padding: 0 30px; height: 54px; line-height: 54px; width: 100%; @@ -211,4 +243,51 @@ export default { } } } - \ No newline at end of file + + + + diff --git a/src/views/form/statistics/chart.vue b/src/views/form/statistics/chart.vue index f5e29ff..2f596f3 100644 --- a/src/views/form/statistics/chart.vue +++ b/src/views/form/statistics/chart.vue @@ -186,130 +186,88 @@ export default { type: 'shadow' } }, - grid: { - left: '3%', - right: '4%', - bottom: '3%', - containLabel: true + getProjectStats () { + this.$api.get(`${process.env.VUE_APP_API_ROOT_TDUCK}/user/project/report/stats`, { params: { projectKey: this.activeProjectKey } }).then(res => { + this.projectStats = res.data + if (this.projectStats.completeCount) { + let rate = this.projectStats.completeCount / this.projectStats.viewCount + this.projectStats.completeRate = rate > 1 ? 100 : rate * 100 + this.projectStats.avgCompleteFormatStr = timeFormat(this.projectStats.avgCompleteTime) + } else { + this.projectStats.completeRate = 0 + this.projectStats.avgCompleteFormatStr = 0 + } + }) }, - xAxis: { - type: 'value', - interval: 1, - boundaryGap: [0, 0.01] + getProjectSituation () { + this.$api.get(`${process.env.VUE_APP_API_ROOT_TDUCK}/user/project/report/situation`, { params: { projectKey: this.activeProjectKey } }).then(res => { + this.lineChartOptionData.xAxis.data = res.data.map(item => { + return item.createdTime + }) + this.lineChartOptionData.series = [{ + data: res.data.map(item => { + return item.count + }), + name: '回收数', + stack: '总量', + type: 'line', + areaStyle: {} + }] + }) }, - yAxis: { - type: 'category', - data: [0] + // 项目提交地址 + getProjectSubmitPosition () { + this.$api.get(`${process.env.VUE_APP_API_ROOT_TDUCK}/user/project/report/position`, { params: { projectKey: this.activeProjectKey } }).then(res => { + this.mapChartOptionData.series = [ + { + name: '提交数', + type: 'map', + mapType: 'china', + zoom: 1.2, + roam: false, + label: { + show: false, + color: 'rgb(0,0,0)' + }, + data: Object.keys(res.data).map(key => { + return { name: key.replace(/省(s?)|市(s?)|\//ig, ''), value: res.data[key] } + }) + } + ] + }) }, - series: [ - { - barWidth: 30, - name: '数量', - type: 'bar', - data: [0] - } - ] - }, - pieChartOptionData: { - tooltip: { - trigger: 'item', - backgroundColor: 'rgba(255,255,255,0.8)', // 通过设置rgba调节背景颜色与透明度 - color: 'black', - borderWidth: '1', - borderColor: 'rgb(156,209,255)', - textStyle: { - color: 'black' - } + getProjectSubmitSource () { + this.$api.get(`${process.env.VUE_APP_API_ROOT_TDUCK}/user/project/report/source`, { params: { projectKey: this.activeProjectKey } }).then(res => { + if (res.data && res.data.length) { + this.barChartOptionData.yAxis.data = res.data.map(item => { + return item.browserName ? item.browserName : '其他' + }) + this.barChartOptionData.series = [ + { + barWidth: 30, + name: '数量', + type: 'bar', + data: res.data.map(item => { + return item.count + }) + } + ] + } + }) }, - series: [ - { - name: '设备类型', - type: 'pie', - radius: ['50%', '70%'], - avoidLabelOverlap: false, - label: { - show: false, - position: 'center' - }, - emphasis: { - label: { - show: true, - fontSize: '30', - fontWeight: 'bold' - } - }, - labelLine: { - show: false - }, - data: [0] - } - ] - } - } - }, - created () { - this.activeProjectKey = this.$route.query.key - this.projectChangeHandle() - - }, methods: { - projectChangeHandle () { - this.getProjectStats() - this.getProjectSituation() - this.getProjectSubmitPosition() - this.getProjectSubmitDevice() - this.getProjectSubmitSource() - }, - getProjectStats () { - this.$api.get(`${process.env.VUE_APP_API_ROOT_TDUCK}/user/project/report/stats`, { params: { projectKey: this.activeProjectKey } }).then(res => { - this.projectStats = res.data - if (this.projectStats.completeCount) { - let rate = this.projectStats.completeCount / this.projectStats.viewCount - this.projectStats.completeRate = rate > 1 ? 100 : rate * 100 - this.projectStats.avgCompleteFormatStr = timeFormat(this.projectStats.avgCompleteTime) - } else { - this.projectStats.completeRate = 0 - this.projectStats.avgCompleteFormatStr = 0 + getProjectSubmitDevice () { + this.$api.get(`${process.env.VUE_APP_API_ROOT_TDUCK}/user/project/report/device`, { params: { projectKey: this.activeProjectKey } }).then(res => { + if (res.data && res.data.length) { + this.pieChartOptionData.series[0].data = res.data.map(item => { + return { value: item.count, name: item.osName ? item.osName : '其他' } + }) + } + }) } - }) - }, - getProjectSituation () { - this.$api.get(`${process.env.VUE_APP_API_ROOT_TDUCK}/user/project/report/situation`, { params: { projectKey: this.activeProjectKey } }).then(res => { - this.lineChartOptionData.xAxis.data = res.data.map(item => { - return item.createdTime - }) - this.lineChartOptionData.series = [{ - data: res.data.map(item => { - return item.count - }), - name: '回收数', - stack: '总量', - type: 'line', - areaStyle: {} - }] - }) - }, - // 项目提交地址 - getProjectSubmitPosition () { - this.$api.get(`${process.env.VUE_APP_API_ROOT_TDUCK}/user/project/report/position`, { params: { projectKey: this.activeProjectKey } }).then(res => { - this.mapChartOptionData.series = [ - { - name: '提交数', - type: 'map', - mapType: 'china', - zoom: 1.2, - roam: false, - label: { - show: false, - color: 'rgb(0,0,0)' - }, - data: Object.keys(res.data).map(key => { - return { name: key.replace(/省(s?)|市(s?)|\//ig, ''), value: res.data[key] } - }) - } ] }) }, - getProjectSubmitSource () { + getProjectSubmitSource() { this.$api.get(`${process.env.VUE_APP_API_ROOT_TDUCK}/user/project/report/source`, { params: { projectKey: this.activeProjectKey } }).then(res => { if (res.data && res.data.length) { this.barChartOptionData.yAxis.data = res.data.map(item => { @@ -328,7 +286,7 @@ export default { } }) }, - getProjectSubmitDevice () { + getProjectSubmitDevice() { this.$api.get(`${process.env.VUE_APP_API_ROOT_TDUCK}/user/project/report/device'`, { params: { projectKey: this.activeProjectKey } }).then(res => { if (res.data && res.data.length) { this.pieChartOptionData.series[0].data = res.data.map(item => { diff --git a/src/views/form/statistics/index.vue b/src/views/form/statistics/index.vue index 71d0d6e..60600bf 100644 --- a/src/views/form/statistics/index.vue +++ b/src/views/form/statistics/index.vue @@ -4,9 +4,9 @@ - + diff --git a/src/views/form/statistics/list.vue b/src/views/form/statistics/list.vue index db083b6..1a02ab8 100644 --- a/src/views/form/statistics/list.vue +++ b/src/views/form/statistics/list.vue @@ -45,6 +45,14 @@ + + + + + - - +