Browse Source

修改统计

old
13176889840 4 years ago
parent
commit
e040251279
  1. 5
      package.json
  2. 2
      src/api/index.js
  3. 95
      src/views/form/statistics/analysis.vue
  4. 10
      src/views/form/statistics/chart.vue
  5. 4
      src/views/form/statistics/index.vue
  6. 24
      src/views/form/statistics/list.vue
  7. 4
      vue.config.js

5
package.json

@ -65,10 +65,7 @@
"not ie <= 8" "not ie <= 8"
], ],
"lint-staged": { "lint-staged": {
"src/**/*.{js,vue}": [
"eslint --fix",
"git add"
]
}, },
"husky": { "husky": {
"hooks": { "hooks": {

2
src/api/index.js

@ -33,6 +33,8 @@ api.interceptors.request.use(
*/ */
if (store.getters['user/isLogin']) { 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) signRequest(request)
return request return request

95
src/views/form/statistics/analysis.vue

@ -4,9 +4,9 @@
<div v-for="(item, index) in list" :key="index"> <div v-for="(item, index) in list" :key="index">
<div class="content"> <div class="content">
<div class="title"> <div class="title">
<span style="font-size: 16px">Q{{ item.label }}{{ item.type }}</span> <span style="font-size: 16px; font-weight: bold;">Q{{ index + 1 }} {{ item.label }}{{ item.type }}</span>
<div> <!-- <div>
<span>图表类型</span> <span>图表类型</span>
<el-select v-model="item.chartType" placeholder="请选择"> <el-select v-model="item.chartType" placeholder="请选择">
<el-option <el-option
@ -16,18 +16,39 @@
:value="subItem.value" :value="subItem.value"
/> />
</el-select> </el-select>
</div> </div> -->
</div> </div>
<line-chart <!-- <line-chart
class="chart" class="chart"
:chart-option="getCharData(item)" :chart-option="getCharData(item)"
:width="'90vw'" :width="'90vw'"
/> /> -->
<div v-if="computedCount(item.type)" class="cell-type">
<span>共收集 {{ item.detail.collectionTotal }} </span>
<span>有效 {{ item.detail.validTotal }} </span>
<span v-if="item.type === 'NUMBER_INPUT'">总计 {{ item.detail.sumTotal }} </span>
<span v-if="item.type === 'SWITCH'"> {{ item.detail.openTotal }} {{ item.detail.closedTotal }} </span>
</div>
<div v-else-if="item.type === 'RADIO' || item.type === 'CHECKBOX' || item.type === 'SELECT'" class="cell-wrapper">
<div v-for="(n, i) in item.detail.options" :key="i" class="cell">
<div class="cell-label">{{ n.label }}</div>
<div class="cell-value">
<div class="cell-progress">
<el-progress :stroke-width="20" :show-text="false" :percentage="computedPercent(n.currentCount, item.detail.totalCount)" />
</div>
<div class="cell-percent">
{{ computedPercent(n.currentCount, item.detail.totalCount).toFixed(2) }}%
</div>
<div class="cell-num">{{ n.currentCount }}</div>
</div>
</div>
</div>
</div> </div>
<el-divider /> <el-divider />
</div> </div>
</div> </div>
<data-empty v-else style="padding: 20px" desc="只有单选、多选、下拉框组件可以生成图表" /> <data-empty v-else style="padding: 20px" desc="暂无数据分析" />
</div> </div>
</template> </template>
@ -108,9 +129,11 @@ export default {
}, },
methods: { methods: {
getData() { getData() {
// `${process.env.VUE_APP_API_ROOT_TDUCK}/user/project/report/analysis`
// params: { projectKey: this.$route.query.key }
this.$api this.$api
.get('/user/project/report/analysis', { .post('/data/aggregator/questionnaire/analysisreport', {
params: { projectKey: this.$route.query.key } projectKey: this.$route.query.key
}) })
.then(res => { .then(res => {
this.list = res.data this.list = res.data
@ -185,6 +208,13 @@ export default {
// config.series[0].data = data.map // config.series[0].data = data.map
} }
return config return config
},
computedCount(type) {
const arr = ['PROVINCE_CITY', 'NUMBER_INPUT', 'SWITCH', 'INPUT', 'TEXTAREA', 'INPUT_MAP', 'TIME', 'DATE_RANGE', 'DATE', 'TIME_RANGE']
return arr.includes(type)
},
computedPercent(num, count) {
return ((num * 100) / count)
} }
} }
} }
@ -199,7 +229,7 @@ export default {
width: 100%; width: 100%;
.title { .title {
font-size: 14px; font-size: 14px;
padding: 0 30px; // padding: 0 30px;
height: 54px; height: 54px;
line-height: 54px; line-height: 54px;
width: 100%; width: 100%;
@ -212,3 +242,50 @@ export default {
} }
} }
</style> </style>
<style lang="scss" scoped>
.cell-type {
padding-left: 10px;
font-size: 14px;
}
.cell-wrapper {
width: 100%;
border: 1px solid #eee;
.cell, .cell-value {
widows: 100%;
display: flex;
align-items: center;
}
.cell {
justify-content: space-between;
padding: 10px 0;
font-size: 14px;
border-bottom: 1px solid #eee;
.cell-label {
width: 60%;
box-sizing: border-box;
padding-left: 10px;
}
.cell-value {
width: 40%;
.cell-progress {
// flex: 1;
width: 180px;
}
.cell-percent {
margin-left: 10px;
}
.cell-num {
width: 40%;
flex-shrink: 0;
text-align: center;
}
}
}
.cell:last-child {
border-bottom: 0;
}
}
</style>

10
src/views/form/statistics/chart.vue

@ -252,7 +252,7 @@ export default {
this.getProjectSubmitSource() this.getProjectSubmitSource()
}, },
getProjectStats() { getProjectStats() {
this.$api.get('/user/project/report/stats', {params: {projectKey: this.activeProjectKey}}).then(res => { this.$api.get(`${process.env.VUE_APP_API_ROOT_TDUCK}/user/project/report/stats`, {params: {projectKey: this.activeProjectKey}}).then(res => {
this.projectStats = res.data this.projectStats = res.data
if (this.projectStats.completeCount) { if (this.projectStats.completeCount) {
let rate = this.projectStats.completeCount / this.projectStats.viewCount let rate = this.projectStats.completeCount / this.projectStats.viewCount
@ -265,7 +265,7 @@ export default {
}) })
}, },
getProjectSituation() { getProjectSituation() {
this.$api.get('/user/project/report/situation', {params: {projectKey: this.activeProjectKey}}).then(res => { 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 => { this.lineChartOptionData.xAxis.data = res.data.map(item => {
return item.createdTime return item.createdTime
}) })
@ -282,7 +282,7 @@ export default {
}, },
// //
getProjectSubmitPosition() { getProjectSubmitPosition() {
this.$api.get('/user/project/report/position', {params: {projectKey: this.activeProjectKey}}).then(res => { this.$api.get(`${process.env.VUE_APP_API_ROOT_TDUCK}/user/project/report/position`, {params: {projectKey: this.activeProjectKey}}).then(res => {
this.mapChartOptionData.series = [ this.mapChartOptionData.series = [
{ {
name: '提交数', name: '提交数',
@ -302,7 +302,7 @@ export default {
}) })
}, },
getProjectSubmitSource() { getProjectSubmitSource() {
this.$api.get('/user/project/report/source', {params: {projectKey: this.activeProjectKey}}).then(res => { 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) { if (res.data && res.data.length) {
this.barChartOptionData.yAxis.data = res.data.map(item => { this.barChartOptionData.yAxis.data = res.data.map(item => {
return item.browserName ? item.browserName : '其他' return item.browserName ? item.browserName : '其他'
@ -321,7 +321,7 @@ export default {
}) })
}, },
getProjectSubmitDevice() { getProjectSubmitDevice() {
this.$api.get('/user/project/report/device', {params: {projectKey: this.activeProjectKey}}).then(res => { 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) { if (res.data && res.data.length) {
this.pieChartOptionData.series[0].data = res.data.map(item => { this.pieChartOptionData.series[0].data = res.data.map(item => {
return {value: item.count, name: item.osName ? item.osName : '其他'} return {value: item.count, name: item.osName ? item.osName : '其他'}

4
src/views/form/statistics/index.vue

@ -4,9 +4,9 @@
<el-tab-pane label="列表视图" name="list"> <el-tab-pane label="列表视图" name="list">
<list /> <list />
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="统计视图" name="chart"> <!-- <el-tab-pane label="统计视图" name="chart">
<chart /> <chart />
</el-tab-pane> </el-tab-pane> -->
<el-tab-pane label="数据分析" name="analysis"> <el-tab-pane label="数据分析" name="analysis">
<analysis /> <analysis />
</el-tab-pane> </el-tab-pane>

24
src/views/form/statistics/list.vue

@ -48,6 +48,11 @@
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="填写人" prop="realName" />
<el-table-column label="组织/部门/网格" prop="orgName" />
<el-table-column label="来源" prop="clientType" />
<!-- <el-table-column label="填写时间" prop="createdTime" /> -->
<el-table-column <el-table-column
v-for="col in otherCustomColumns" v-for="col in otherCustomColumns"
:key="col" :label="projectItemColumns[col]" :key="col" :label="projectItemColumns[col]"
@ -66,9 +71,9 @@
{{ scope.row[col] }} {{ scope.row[col] }}
</template> </template>
</el-table-column> </el-table-column>
<!-- :render-header="renderHeader" -->
<el-table-column <el-table-column
:render-header="renderHeader"
fixed="right" fixed="right"
width="50" width="50"
> >
@ -90,7 +95,7 @@
<div> <div>
<div v-for="item in projectItemList" :key="item.id"> <div v-for="item in projectItemList" :key="item.id">
<h4>{{ item.label }}</h4> <h4>{{ item.label }}</h4>
<result-item :field-item-id="item.formItemId" :project-item-data="item" <result-item :field-item-id="Number(item.formItemId)" :project-item-data="item"
:result-data="activeResultRow" :result-data="activeResultRow"
/> />
<el-divider /> <el-divider />
@ -213,7 +218,8 @@ export default {
this.queryProjectResult() this.queryProjectResult()
this.queryProjectItems() this.queryProjectItems()
this.queryProject() this.queryProject()
}, methods: { },
methods: {
renderHeader() { renderHeader() {
return ( return (
<i class="el-icon-setting" style="color:currentColor" <i class="el-icon-setting" style="color:currentColor"
@ -225,7 +231,7 @@ export default {
this.detailDrawer = true this.detailDrawer = true
}, },
queryProject() { queryProject() {
this.$api.get(`/user/project/${this.projectKey}`).then(res => { this.$api.get(`${process.env.VUE_APP_API_ROOT_TDUCK}/user/project/${this.projectKey}`).then(res => {
this.projectData = res.data this.projectData = res.data
}) })
}, },
@ -238,7 +244,7 @@ export default {
this.queryProjectResult() this.queryProjectResult()
}, },
queryProjectResult() { queryProjectResult() {
this.$api.get('/user/project/result/page', {params: this.queryConditions}).then(res => { this.$api.get(`${process.env.VUE_APP_API_ROOT_TDUCK}/user/project/result/page`, {params: this.queryConditions}).then(res => {
let {records, total, size} = res.data let {records, total, size} = res.data
this.projectResultList = records this.projectResultList = records
this.total = total this.total = total
@ -280,7 +286,7 @@ export default {
this.$message.error('无附件,无法导出') this.$message.error('无附件,无法导出')
return return
} }
this.$api.get('/user/project/result/download/file', { this.$api.get(`${process.env.VUE_APP_API_ROOT_TDUCK}/user/project/result/download/file`, {
params: this.queryConditions params: this.queryConditions
}).then(res => { }).then(res => {
this.$process({ this.$process({
@ -294,7 +300,7 @@ export default {
this.$message.error('无表单有效反馈结果,无法导出') this.$message.error('无表单有效反馈结果,无法导出')
return return
} }
this.$api.get('user/project/result/export', { this.$api.get(`${process.env.VUE_APP_API_ROOT_TDUCK}/user/project/result/export`, {
params: this.queryConditions, params: this.queryConditions,
responseType: 'blob' responseType: 'blob'
}).then(res => { }).then(res => {
@ -310,7 +316,7 @@ export default {
}) })
}, },
queryProjectItems() { queryProjectItems() {
this.$api.get('/user/project/item/list', {params: {key: this.projectKey, displayType: false}}).then(res => { this.$api.get(`${process.env.VUE_APP_API_ROOT_TDUCK}/user/project/item/list`, {params: {key: this.projectKey, displayType: false}}).then(res => {
if (res.data) { if (res.data) {
res.data.map(item => { res.data.map(item => {
_.set(this.projectItemColumns, `field${item.formItemId}`, item.label) _.set(this.projectItemColumns, `field${item.formItemId}`, item.label)

4
vue.config.js

@ -15,6 +15,10 @@ module.exports = {
open: true, open: true,
port: 8888, port: 8888,
// 开发环境默认开启反向代理,如果不需要请自行注释 // 开发环境默认开启反向代理,如果不需要请自行注释
// "src/**/*.{js,vue}": [ 校验提交
// "eslint --fix",
// "git add"
// ]
// proxy: { // proxy: {
// '/tduck-api': { // '/tduck-api': {
// //target: 'http://localhost:8080/api/', // //target: 'http://localhost:8080/api/',

Loading…
Cancel
Save