warningStoreList.js
4.97 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
// packageIndex/pages/salesSummary/salesSummary.js
import IndexApi from '~/api/index/index'
import { tsFormatTime } from '~/utils/format'
function formatYMDHM(val) {
if (!val) return '-'
const d = new Date(val)
if (isNaN(d.getTime())) return '-'
const yyyy = d.getFullYear()
const MM = String(d.getMonth() + 1).padStart(2, '0')
const DD = String(d.getDate()).padStart(2, '0')
// const HH = String(d.getHours()).padStart(2, '0')
// const mm = String(d.getMinutes()).padStart(2, '0')
return `${yyyy}-${MM}-${DD}`
}
Page({
/**
* 页面的初始数据
*/
data: {
activeIndex: 0,
tabList: [
{
count: 0,
text: '兜底指标预警'
},
{
count: 0,
text: '丢店风险预警'
},
{
count: 0,
text: '亏损预警'
}
],
list: []
},
getWarningStores() {
let { month, staffUuid, regionId, tabList, activeIndex } = this.data
let params = { month }
if (staffUuid) {
params.staffUuid = staffUuid
}
if (regionId) {
params.regionId = regionId
}
IndexApi.getWarningStores(params).then(res => {
console.log(res, 'res')
let {
backstopWarningCount,
lostShopWarningCount,
lossWarningCount,
backstopWarningList = [],
lostShopWarningList = [],
lossWarningList = []
} = res.data
tabList[0].count = backstopWarningCount || 0
tabList[1].count = lostShopWarningCount || 0
tabList[2].count = lossWarningCount
const mapExpected = arr =>
Array.isArray(arr)
? arr.map(item => ({
...item,
expectedOperationDateFormatted: formatYMDHM(
item.expectedOperationDate
),
signedTimeFormatted: formatYMDHM(item.signedTime)
}))
: []
const _backstop = mapExpected(backstopWarningList)
const _lostShop = mapExpected(lostShopWarningList)
const _loss = mapExpected(lossWarningList)
// list 根据
this.setData({
tabList,
backstopWarningList: _backstop,
lostShopWarningList: _lostShop,
lossWarningList: _loss,
list:
activeIndex == 0
? _backstop || []
: activeIndex == 1
? _lostShop || []
: _loss || []
})
})
},
getList() {
let { activeIndex } = this.data
IndexApi.summaryMonthShowPersonList({
personType: activeIndex == 0 ? 1 : 2
}).then(res => {
console.log(res)
res.data = res.data.map(item => ({
...item,
lastFollowUpTime: item.lastFollowUpTime
? tsFormatTime(item.lastFollowUpTime)
: '-'
}))
this.setData({
list: res.data
})
})
},
initTablist() {
IndexApi.summaryMonthShow({}).then(res => {
console.log(res)
const { noExpansionPersonCount = 0, noSignCustomerCount = 0 } =
res.data || {}
const tabList = this.data.tabList.map(item => ({ ...item }))
tabList[0].count = noExpansionPersonCount
tabList[1].count = noSignCustomerCount
this.setData({ tabList })
// this.setData({
// tabList[0].count: res.data.noExpansionPersonCount,
// tabList[1].count: res.data.noSignCustomerCount,
// })
})
},
tabClick(e) {
// 根据索引获取数据
let { backstopWarningList, lostShopWarningList, lossWarningList } =
this.data
let list =
e.detail == 0
? backstopWarningList
: e.detail == 1
? lostShopWarningList
: lossWarningList
this.setData({
activeIndex: e.detail,
list: list || []
})
},
navigateToStoreDetail(e) {
let { item } = e.currentTarget.dataset
item.currentTab = 2
wx.navigateTo({
url: `/packageCustomer/pages/merchantDetail/merchantDetail?query=${encodeURIComponent(
JSON.stringify(item)
)}`
})
},
onRoute(options) {
console.log(options, 'options')
// console.log(options, 'options')
this.setData({
month: options.month,
staffUuid: options.staffUuid,
regionId: options.regionId,
activeIndex: options.index || 0
})
this.getWarningStores()
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {},
/**
* 生命周期函数--监听页面显示
*/
onShow() {},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {}
})