index.vue
9.33 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
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
166
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
<template>
<div class="tech-performance-statistics-container">
<!-- 搜索卡片 -->
<el-card class="search-card">
<div slot="header" class="clearfix">
<span><i class="el-icon-s-promotion"></i> 科技部开单业绩统计</span>
</div>
<div class="search-form">
<el-form :inline="true" :model="searchForm" class="demo-form-inline">
<el-form-item label="统计月份">
<el-date-picker v-model="searchForm.statisticsMonth" type="month" placeholder="选择月份"
format="yyyy年MM月" value-format="yyyyMM" :clearable="false" @change="handleSearch">
</el-date-picker>
</el-form-item>
<el-form-item label="老师姓名">
<el-input v-model="searchForm.teacherName" placeholder="请输入老师姓名" clearable
@keyup.enter.native="handleSearch">
</el-input>
</el-form-item>
<el-form-item label="门店名称">
<el-input v-model="searchForm.storeName" placeholder="请输入门店名称" clearable
@keyup.enter.native="handleSearch">
</el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="handleSearch" :loading="loading">
<i class="el-icon-search"></i> 查询
</el-button>
<el-button @click="handleReset">
<i class="el-icon-refresh"></i> 重置
</el-button>
</el-form-item>
</el-form>
</div>
</el-card>
<!-- 表格卡片 -->
<el-card class="table-card">
<!-- <div slot="header" class="clearfix">
<span><i class="el-icon-s-grid"></i> 科技部开单业绩列表</span>
</div> -->
<div class="table-container">
<el-table :data="tableData" v-loading="loading" element-loading-text="加载中..." :height="tableHeight"
border stripe style="width: 100%">
<el-table-column prop="TeacherName" label="老师姓名" fixed="left"></el-table-column>
<!-- <el-table-column prop="StoreName" label="门店名称" width="150" fixed="left"></el-table-column> -->
<el-table-column prop="TotalPerformance" label="总业绩" width="100" align="right">
<template slot-scope="scope">
{{ formatMoney(scope.row.TotalPerformance) }}
</template>
</el-table-column>
<el-table-column prop="OrderCount" label="订单数量" width="100" align="right"></el-table-column>
<el-table-column prop="CreateTime" label="创建时间" width="150" align="center">
<template slot-scope="scope">
{{ formatDateTime(scope.row.CreateTime) }}
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<div class="pagination-container">
<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
:current-page="pagination.pageIndex" :page-sizes="[10, 20, 50, 100]"
:page-size="pagination.pageSize" :total="pagination.total"
layout="total, sizes, prev, pager, next, jumper">
</el-pagination>
</div>
</div>
</el-card>
</div>
</template>
<script>
import { getTechPerformanceStatisticsList } from '@/api/extend/statistics'
export default {
name: 'TechPerformanceStatistics',
data() {
return {
loading: false,
tableData: [],
tableHeight: 400,
searchForm: {
statisticsMonth: this.getCurrentMonth(),
teacherName: '',
storeName: ''
},
pagination: {
pageIndex: 1,
pageSize: 20,
total: 0
}
}
},
mounted() {
this.calculateTableHeight()
this.handleSearch()
window.addEventListener('resize', this.calculateTableHeight)
},
beforeDestroy() {
window.removeEventListener('resize', this.calculateTableHeight)
},
methods: {
getCurrentMonth() {
const now = new Date()
const year = now.getFullYear()
const month = String(now.getMonth() + 1).padStart(2, '0')
return `${year}${month}`
},
calculateTableHeight() {
this.$nextTick(() => {
const container = this.$el
if (!container) return
const containerHeight = container.clientHeight
const searchCard = container.querySelector('.search-card')
const tableCard = container.querySelector('.table-card')
let searchCardHeight = 0
if (searchCard) {
searchCardHeight = searchCard.offsetHeight + 20
}
const tableCardAvailableHeight = containerHeight - searchCardHeight - 100
const tableCardHeight = Math.max(250, tableCardAvailableHeight)
if (tableCard) {
tableCard.style.height = tableCardHeight + 'px'
}
const tableContainer = container.querySelector('.table-container')
if (tableContainer) {
const cardHeaderHeight = 50
const cardPadding = 30
const tableContainerHeight = tableCardHeight - cardHeaderHeight - cardPadding
tableContainer.style.height = tableContainerHeight + 'px'
const paginationHeight = 50
const paginationMargin = 10
this.tableHeight = Math.max(100, tableContainerHeight - paginationHeight - paginationMargin)
}
})
},
async handleSearch() {
this.loading = true
try {
const params = {
pageIndex: this.pagination.pageIndex,
pageSize: this.pagination.pageSize,
statisticsMonth: this.searchForm.statisticsMonth,
teacherName: this.searchForm.teacherName,
storeName: this.searchForm.storeName
}
const response = await getTechPerformanceStatisticsList(params)
this.tableData = response.data.list || []
this.pagination.total = response.data.pagination.total || 0
} catch (error) {
this.$message.error('查询失败: ' + error.message)
} finally {
this.loading = false
}
},
handleReset() {
this.searchForm = {
statisticsMonth: this.getCurrentMonth(),
teacherName: '',
storeName: ''
}
this.pagination.pageIndex = 1
this.handleSearch()
},
handleSizeChange(val) {
this.pagination.pageSize = val
this.pagination.pageIndex = 1
this.handleSearch()
},
handleCurrentChange(val) {
this.pagination.pageIndex = val
this.handleSearch()
},
formatMoney(value) {
if (value === null || value === undefined) return '0.00'
return Number(value).toLocaleString('zh-CN', {
minimumFractionDigits: 2,
maximumFractionDigits: 2
})
},
formatDateTime(value) {
if (!value) return '-'
return new Date(value).toLocaleString('zh-CN')
}
}
}
</script>
<style lang="scss" scoped>
.tech-performance-statistics-container {
height: calc(100vh - 60px);
display: flex;
flex-direction: column;
overflow: hidden;
padding: 20px;
background-color: #f0f2f5;
.search-card {
flex-shrink: 0;
margin-bottom: 20px;
border-radius: 8px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
.search-form {
.el-form-item {
margin-bottom: 10px;
}
}
}
.table-card {
flex: 1;
display: flex;
flex-direction: column;
overflow: hidden;
min-height: 0;
border-radius: 8px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
.table-container {
height: 100%;
display: flex;
flex-direction: column;
overflow: hidden;
position: relative;
.el-table {
flex: 1;
min-height: 0;
overflow: auto;
}
.pagination-container {
margin-top: 10px;
padding: 5px 0;
height: 50px;
display: flex;
align-items: center;
justify-content: flex-end;
flex-shrink: 0;
}
}
}
}
</style>