Blame view

src/views/report/reportQuestionAnswerDetailList.vue 6.72 KB
6ec243d6   wuxw   v1.9 点击提交后,成功提示没有...
1
  <template>
95629508   wuxw   继续开发报表功能
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
    <div class="report-question-answer-detail-container animated fadeInRight">
      <el-row :gutter="20">
        <el-col :span="24">
          <el-card class="box-card">
            <div slot="header" class="flex justify-between">
              <span>{{ $t('reportQuestionAnswerDetail.queryCondition') }}</span>
            </div>
            <el-form :inline="true" :model="queryForm" class="demo-form-inline text-left">
              <el-form-item>
                <el-select v-model="queryForm.qaType" :placeholder="$t('reportQuestionAnswerDetail.selectQaType')"
                  style="width:100%">
                  <el-option :label="$t('reportQuestionAnswerDetail.pleaseSelect')" value="" />
                  <el-option :label="$t('reportQuestionAnswerDetail.ownerQuestionnaire')" value="1001" />
                  <el-option :label="$t('reportQuestionAnswerDetail.ownerVote')" value="3003" />
                  <el-option :label="$t('reportQuestionAnswerDetail.staffVote')" value="4004" />
                </el-select>
              </el-form-item>
              <el-form-item>
                <el-date-picker v-model="queryForm.startTime" type="date"
                  :placeholder="$t('reportQuestionAnswerDetail.selectStartTime')" style="width:100%" />
              </el-form-item>
              <el-form-item>
                <el-date-picker v-model="queryForm.endTime" type="date"
                  :placeholder="$t('reportQuestionAnswerDetail.selectEndTime')" style="width:100%"
                  @change="handleEndTimeChange" />
              </el-form-item>
              <el-form-item>
                <el-button type="primary" @click="handleQuery" icon="el-icon-search">
                  {{ $t('reportQuestionAnswerDetail.query') }}
                </el-button>
                <el-button type="primary" @click="handleReset" icon="el-icon-refresh">
                  {{ $t('reportQuestionAnswerDetail.reset') }}
                </el-button>
              </el-form-item>
            </el-form>
          </el-card>
        </el-col>
      </el-row>
  
4277ec26   wuxw   v1.9 优化报表相关页面的布局以...
41
      <el-row :gutter="20" >
95629508   wuxw   继续开发报表功能
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
        <el-col :span="24">
          <el-card class="box-card">
            <div slot="header" class="flex justify-between">
              <div>
                <span>{{ $t('reportQuestionAnswerDetail.questionnaireDetail') }}</span>
                <el-tooltip class="item" effect="dark" :content="$t('reportQuestionAnswerDetail.questionnaireAnswerDetail')"
                  placement="top">
                  <i class="el-icon-info" style="cursor:pointer;margin-left:10px"></i>
                </el-tooltip>
              </div>
              <el-button type="primary" size="small" class="float-right" @click="handleExport" icon="el-icon-download">
                {{ $t('reportQuestionAnswerDetail.export') }}
              </el-button>
            </div>
            <el-table :data="tableData" border style="width: 100%" v-loading="loading">
              <el-table-column prop="index" :label="$t('reportQuestionAnswerDetail.serialNumber')" width="80"
                align="center" />
              <el-table-column prop="userName" :label="$t('reportQuestionAnswerDetail.questionnairePerson')"
                align="center" />
              <el-table-column prop="qaTypeName" :label="$t('reportQuestionAnswerDetail.questionnaireType')"
                align="center" />
              <el-table-column prop="qaName" :label="$t('reportQuestionAnswerDetail.questionnaireName')" align="center" />
              <el-table-column prop="qaTitle" :label="$t('reportQuestionAnswerDetail.questionnaireQuestion')"
                align="center" />
              <el-table-column prop="qaValue" :label="$t('reportQuestionAnswerDetail.answer')" align="center" />
              <el-table-column prop="createTime" :label="$t('reportQuestionAnswerDetail.time')" align="center" />
            </el-table>
            <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
              :current-page="pagination.current" :page-sizes="[10, 20, 30, 50]" :page-size="pagination.size"
              layout="total, sizes, prev, pager, next, jumper" :total="pagination.total" class="pagination-container" />
          </el-card>
        </el-col>
      </el-row>
    </div>
  </template>
  
  <script>
  import { queryUserQuestionAnswerValue, exportData } from '@/api/report/reportQuestionAnswerDetailApi'
  import { getCommunityId } from '@/api/community/communityApi'
  
  export default {
    name: 'ReportQuestionAnswerDetailList',
    data() {
      return {
        loading: false,
        queryForm: {
          qaType: '',
          startTime: '',
          endTime: '',
          communityId: ''
        },
        tableData: [],
        pagination: {
          current: 1,
          size: 10,
          total: 0
        }
      }
    },
    created() {
      this.queryForm.communityId = getCommunityId()
      this.getList()
    },
    methods: {
      async getList() {
        try {
          this.loading = true
          const params = {
            page: this.pagination.current,
            row: this.pagination.size,
            ...this.queryForm
          }
          const { data, total } = await queryUserQuestionAnswerValue(params)
          this.tableData = data.map((item, index) => {
            return {
              ...item,
              index: index + 1
            }
          })
          this.pagination.total = total
        } catch (error) {
          this.$message.error(this.$t('reportQuestionAnswerDetail.fetchError'))
        } finally {
          this.loading = false
        }
      },
      handleQuery() {
        this.pagination.current = 1
        this.getList()
      },
      handleReset() {
        this.queryForm = {
          qaType: '',
          startTime: '',
          endTime: '',
          communityId: this.queryForm.communityId
        }
        this.handleQuery()
      },
      handleEndTimeChange(val) {
        if (this.queryForm.startTime && val) {
          const start = new Date(this.queryForm.startTime).getTime()
          const end = new Date(val).getTime()
          if (start >= end) {
            this.$message.error(this.$t('reportQuestionAnswerDetail.endTimeMustGreater'))
            this.queryForm.endTime = ''
          }
        }
      },
      handleSizeChange(val) {
        this.pagination.size = val
        this.getList()
      },
      handleCurrentChange(val) {
        this.pagination.current = val
        this.getList()
      },
      async handleExport() {
        try {
          const params = {
            ...this.queryForm,
            pagePath: 'reportQuestionAnswerDetail'
          }
          await exportData(params)
6ec243d6   wuxw   v1.9 点击提交后,成功提示没有...
166
          this.$message.success(this.$t('common.operationSuccess'))
95629508   wuxw   继续开发报表功能
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
        } catch (error) {
          this.$message.error(this.$t('reportQuestionAnswerDetail.exportError'))
        }
      }
    }
  }
  </script>
  
  <style lang="scss" scoped>
  .report-question-answer-detail-container {
    padding: 20px;
  
    .box-card {
      margin-bottom: 20px;
    }
  
    .pagination-container {
      margin-top: 20px;
      text-align: right;
    }
  
    .float-right {
      float: right;
    }
  }
  </style>