index.vue
2.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<template>
<GLDialog
mode="big"
bigTitle="数据"
:hasFooter="false"
:before-close="handleClose"
:visible.sync="dataObj.show"
>
<el-button
type="default"
@click="handleExport"
>导出</el-button>
<GLTable
:tableData="tableData"
:noDataImg="url"
:tableParams="tableParams"
:tableTotal="tableTotal"
:pageConf="pageConf"
@refreshTable="refreshTable"
ref="listRef"
>
</GLTable>
</GLDialog>
</template>
<script type='text/ecmascript-6'>
import url from '@/assets/empty.png'
import { exportFn } from '@/common/constant'
export default {
name: '',
props: {
dataObj: {
type: Object,
default: () => { }
}
},
data () {
return {
url,
pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'count' },
tableParams: {
listName: 'data',
tableOption: false,
tableColumns: []
},
tableData: [],
tableTotal: 0
}
},
mounted () {
},
watch: {
'dataObj' (n) {
if (n.id) {
this.setTableColumns(n.id)
this.refreshTable()
}
}
},
methods: {
async setTableColumns (id) {
const data = await this.$apis.questionnaire.getQuestionnaireDetail({ id }),
tableColumns = [
{
label: '手机号码',
prop: 'phone',
minWidth: 180
},
{
label: '微信昵称',
prop: 'wechatNickname',
minWidth: 180,
},
{
label: '答题时间',
prop: 'updatedTime',
minWidth: 180
},
]
data.questions.map(e => {
tableColumns.push({
label: e.text,
prop: `${e.num}_prop`,
minWidth: 180
})
})
this.tableParams.tableColumns = tableColumns
console.log(data)
},
async refreshTable (pageCon) {
pageCon && (this.pageConfig = pageCon)
const { id } = this.dataObj,
params = {
formId: id,
pageSize: 10,
pageNum: 1,
...this.pageConfig
}
const { data, count } = await this.$apis.questionnaire.getQuestionnaireDetailPage(params)
data.map(e => {
e.questions.map(i => {
e[`${i.num}_prop`] = i.answer
})
})
this.tableData = data || []
this.tableTotal = count || 0
},
handleClose () {
this.$emit('update:dataObj', {})
},
handleExport () {
const { id } = this.dataObj
this.$apis.questionnaire.exportUserQuestionnaireList({ formId: id, ...this.$refs.listRef.page }).then(res => {
exportFn(res)
})
}
}
}
</script>
<style scoped lang='scss'>
.el-button {
display: flex;
margin: 0 0 8px auto;
}
</style>