index.vue
10.9 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
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
<template>
<view class="container">
<view class="fs-bg__primary fs-pt160 fs-pb120 fs-pl30 fs-color__white">
{{ config.weather }} / {{ config.city }} {{ config.temperature }}°C
</view>
<view class="fs-pl30 fs-pr30 fs-mt-60">
<view class="fs-py36 fs-px30 fs-bg__white fs-radius__sm">
<tui-list-cell unlined padding="0" :size="30" color="#000" :hover="false">
<view class="fs-flex__between">
<view>任务统计</view>
<view>
<tui-tag :type="summaryDate == 7 ? 'primary' : 'gray'" size="24rpx" padding="6rpx 15rpx" class="fs-mr20"
@click="getSummary(7)">近7日
</tui-tag>
<tui-tag :type="summaryDate == 30 ? 'primary' : 'gray'" size="24rpx" padding="6rpx 15rpx"
@click="getSummary(30)">近30日
</tui-tag>
</view>
</view>
</tui-list-cell>
<view class="fs-flex__between fs-mt30 fs-size__h4">
<view class="fs-flex__column fs-items__center">
<tui-circular-progress :diam="70" progressColor="#577EE3" fontColor="#577EE3" :lineWidth="5" :fontSize="16"
:percentage="summaryDateList.patrolTaskCount"></tui-circular-progress>
<tui-text text="巡查任务数" color="#577EE3"></tui-text>
</view>
<view class="fs-flex__column fs-items__center">
<tui-circular-progress :diam="70" progressColor="#FF2B2B" fontColor="#FF2B2B" :lineWidth="5" :fontSize="16"
:percentage="summaryDateList.maintainTaskCount"></tui-circular-progress>
<tui-text text="养护任务数" color="#FF2B2B"></tui-text>
</view>
<view class="fs-flex__column fs-items__center">
<tui-circular-progress :diam="70" progressColor="#FFB703" fontColor="#FFB703" :lineWidth="5" :fontSize="16"
:percentage="summaryDateList.problemCreateCount"></tui-circular-progress>
<tui-text text="问题单数" color="#FFB703"></tui-text>
</view>
<view class="fs-flex__column fs-items__center">
<tui-circular-progress :diam="70" progressColor="#09BE4F" fontColor="#09BE4F" :lineWidth="5" :fontSize="16"
:percentage="summaryDateList.maintainOrderCount"></tui-circular-progress>
<tui-text text="养护单数" color="#09BE4F"></tui-text>
</view>
</view>
</view>
<view class="fs-mt30 fs-py36 fs-px30 fs-bg__white fs-radius__sm">
<tui-list-cell unlined padding="0" :size="30" color="#000" :hover="false">
<view class="fs-flex__between">
<view>养护类型统计</view>
<view>
<tui-tag :type="summaryType == 7 ? 'primary' : 'gray'" size="24rpx" padding="6rpx 15rpx" class="fs-mr20"
@click="getSummaryType(7)">近7日
</tui-tag>
<tui-tag :type="summaryType == 30 ? 'primary' : 'gray'" size="24rpx" padding="6rpx 15rpx"
@click="getSummaryType(30)">近30日
</tui-tag>
</view>
</view>
</tui-list-cell>
<view class="fs-p30">
<tui-charts-pie ref="tui_charts_pie" :type="2"></tui-charts-pie>
</view>
<!-- 员工养护类型统计 -->
<tui-list-cell unlined padding="0" marginTop="20" :size="30" color="#000" :hover="false">
<view class="fs-flex__between">
<view>员工养护类型统计</view>
<view>
<!-- 近7日/30日标签:用 :type 绑定状态,点击传递对应天数 -->
<tui-tag
:type="staffSummary === 7 ? 'primary' : 'gray'"
size="24rpx"
padding="6rpx 15rpx"
class="fs-mr20"
@click="getStaffSummary(7, isAsc)"
>近7日
</tui-tag>
<tui-tag
:type="staffSummary === 30 ? 'primary' : 'gray'"
size="24rpx"
padding="6rpx 15rpx"
@click="getStaffSummary(30, isAsc)"
>近30日
</tui-tag>
</view>
</view>
</tui-list-cell>
<!-- 排序标签 -->
<tui-list-cell unlined padding="0" marginTop="40" :size="30" color="#000" :hover="false">
<view class="fs-flex__between">
<view></view>
<view>
<!-- 正序/倒序标签:修复为 :type 绑定状态,点击传递对应排序值(1/2) -->
<tui-tag
:type="isAsc == 'asc' ? 'primary' : 'gray'"
size="24rpx"
padding="6rpx 15rpx"
class="fs-mr20"
@click="getStaffSummary(staffSummary, 'asc')"
>正序
</tui-tag>
<tui-tag
:type="isAsc == 'desc' ? 'primary' : 'gray'"
size="24rpx"
padding="6rpx 15rpx"
@click="getStaffSummary(staffSummary, 'desc')"
>倒序
</tui-tag>
</view>
</view>
</tui-list-cell>
<view class="fs-p30">
<view class="fs-flex__between">
<view style="width: 100px;height: 100%"></view>
<tui-charts-bar ref="tui_charts_bar" :tooltip="true" :width="400" :yAxis="staffSummaryList.yAxis" :yAxisVal="staffSummaryList.yAxisLabel"
:splitNumber="staffSummaryList.splitNumber" ></tui-charts-bar>
</view>
</view>
</view>
</view>
<tui-white-space :height="30"></tui-white-space>
<!-- <tui-modal :show="showModal" @click="handleModal" @cancel="hideModal" content="发现新版本,是否升级到最新版本?"></tui-modal>-->
</view>
</template>
<script>
import { version, OSSURL } from '@/config/app'
import { apiVersion, apiGetSummary, apiSummaryType, apiStaffSummary } from '@/api/app'
import { apiGetUserInfo } from '@/api/user'
import moment from 'moment'
export default {
data() {
return {
summaryDate: 7,
summaryDateList: {},
summaryType: 7,
isAsc: 'asc',
summaryTypeList: [
{
value: 0,
color: '#03ABBE',
name: '浇水'
},
{
value: 0,
color: '#EB0909',
name: '修剪'
},
{
value: 0,
color: '#FFD54F',
name: '有害生物防治'
},
{
value: 0,
color: '#07c160',
name: '中耕除草'
},
{
value: 0,
color: '#c084fc',
name: '补植'
},
{
value: 0,
color: '#409EFF',
name: '清理保洁'
},
{
value: 0,
color: '#e5e5e5',
name: '绿地巡视'
},
{
value: 0,
color: '#f59e0b',
name: '施肥'
},
{
value: 0,
color: '#999',
name: '树池篦子'
}
],
staffSummary: 7,
staffSummaryList: {
yAxis: [],
dataset: [{
name: '',
color: '#5677fc',
source: []
}],
max: 120,
splitNumber: 20,
yAxisLabel:{
width: 100, // 限制文字最大宽度,超出则换行(根据需求调整数值)
breakWord: true, // 开启自动换行
lineHeight: 16 // 换行后行高,保证文字不重叠(根据字体大小调整)
}
},
showModal: false,
downloadUrl: ''
}
},
onLoad() {
this.getUserInfo()
// this.upgradation()
this.getSummary(this.summaryDate)
this.getSummaryType(this.summaryType)
this.getStaffSummary(this.staffSummary, this.isAsc)
},
methods: {
// 获取用户基本信息
getUserInfo() {
apiGetUserInfo().then(res => {
this.setUserInfo(res.user)
})
},
// 获取统计数据
getSummary(type) {
this.summaryDate = type
const beginTime = moment().subtract(type, 'days').format('YYYY-MM-DD 00:00:00')
const endTime = moment().format('YYYY-MM-DD 23:59:59')
apiGetSummary({data: {beginTime, endTime}}).then(res => {
this.summaryDateList = res.data
})
},
// 养护类型统计
getSummaryType(type) {
this.summaryType = type
const beginTime = moment().subtract(type, 'days').format('YYYY-MM-DD 00:00:00')
const endTime = moment().format('YYYY-MM-DD 23:59:59')
apiSummaryType({data: {beginTime, endTime}}).then(res => {
// console.log(res.data)
res.data.forEach((item, index) => {
console.log(this.summaryTypeList[index])
this.summaryTypeList[index].value = item.countNum
})
// console.log(this.summaryTypeList)
this.$refs.tui_charts_pie.draw(this.summaryTypeList)
})
},
truncateText(text, maxLength = 8) {
if (text.length <= maxLength) return text;
return text.slice(0, maxLength) + '...';
},
// 按员工养护类型统计
getStaffSummary(type, isAsc) {
this.staffSummary = type
this.isAsc = isAsc
console.log(type)
console.log(isAsc)
const beginTime = moment().subtract(type, 'days').format('YYYY-MM-DD 00:00:00')
const endTime = moment().format('YYYY-MM-DD 23:59:59')
const pageNum = 1
const pageSize = 10
const pageReq = {
"isAsc": this.isAsc,
// "orderBy": "",
// "orderByColumn": "user_id",
// "pageNum": 1,
// "pageSize": 10
}
apiStaffSummary({data: {beginTime, endTime, pageReq}}).then(res => {
res.data.forEach((item, index) => {
this.staffSummaryList.yAxis[index] = item.userName
// this.staffSummaryList.yAxis[index] = this.truncateText(item.userName, 7);
this.staffSummaryList.dataset[0].source[index] = item.countNum
this.staffSummaryList.tooltip = {
formatter: (params) => {
// params 中可获取当前项索引,进而拿到原始完整文字
const fullText = item.userName[params.dataIndex];
return `${fullText}: ${params.value}`; // tooltip 显示完整文字
}
};
})
this.$refs.tui_charts_bar.draw(this.staffSummaryList.dataset)
})
},
// 检查升级
upgradation() {
// 检查版本更新
apiVersion().then(res => {
const newVersion = res.data.version
this.downloadUrl = OSSURL + res.data.url
if (version < newVersion) {
this.showModal = true
}
})
},
// 确定升级
handleModal(event) {
this.hideModal()
if (event.index == 1) {
// 打开系统浏览器下载
plus.runtime.openURL(this.downloadUrl)
}
},
// 取消升级
hideModal() {
this.showModal = false
}
}
}
</script>
<style lang="scss" scoped>
</style>