orderList.js
7.13 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
// tabWorkOrder/pages/index/index.js
import api from '../../carEquityApi'
import order_mixins from '../../order_mixins.js'
const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/dj-car-boutique-work-wechat/'
let timeoutId;
Page({
/**
* 页面的初始数据
*/
data: {
IMG_URL,
...order_mixins.data,
showIcon1: true, // 初始显示图标
// showIcon2: true, // 初始隐藏第二个图标
activeIndex: 0,
orderObj: [{
label: '销售顾问',
arr: ['merchantName', 'employeeName']
},
{
label: '转化人员',
arr: ['sellerMerchantName', 'sellerName']
},
{
label: '工单编号',
key: 'orderCode'
},
{
label: '工单时间',
key: 'orderTime'
}
],
searchObj: {},
pageNum: 1,
keyword: '',
list: [],
tabIndex: 0,
tabList: ['全部', '待跟进', '已升级', '战败'],
tabListTemplate: ['全部', '待跟进', '已升级', '战败']
},
navbarReady(e) {
let navBarHeight = e.detail.height
this.setData({
navBarHeight
})
},
jumpReception(e) {
const {
item
} = e.currentTarget.dataset;
wx.$router.go("reception", Object.assign(item, {
customerPhone: item.customer.customerPhone
}));
},
tabClick(e) {
let {
searchObj
} = this.data
delete searchObj.statusList
this.setData({
tabIndex: e.detail,
searchObj
})
this.search()
},
input(e) {
let {
value
} = e.detail
this.setData({
keyword: value
})
},
clear() {
this.setData({
keyword: ''
})
this.search()
},
// 查看全部商品
showAllGoodsList(e) {
let {
item
} = e.currentTarget.dataset
let {
list
} = this.data
list.forEach(val => {
val?.forEach(subVal => {
if (subVal.id == item.id) subVal.showAllGoodsListFlag = !subVal?.showAllGoodsListFlag
})
})
this.setData({
list
})
},
search() {
wx.$orderListRefresh = false
let {
searchObj,
userInfo
} = this.data
let merchantId
// 判断是不是超管,不是只能筛选当前4s店的
if (!searchObj.merchantId && !userInfo.isSuper) {
merchantId = userInfo?.shopMerchantId
this.setData({
['searchObj.merchantId']: merchantId
})
}
this.setData({
list: [],
pageNum: 1,
flag: false,
nothing: false,
})
this.getWorkList()
},
getWorkList() {
this.showLoading && this.showLoading('加载中...')
let {
searchObj,
pageNum,
keyword,
userInfo,
status,
staffUuid,
searchdate,
phoneNumberLists,
merchantId
} = this.data
let obj = {
keyword,
pageNum,
installUpgradeBeginTimeStr: searchdate + ' 00:00:00',
installUpgradeEndTimeStr: searchdate + ' 23:59:59',
sellerUserIdList: [staffUuid],
customerPhoneList: phoneNumberLists,
// merchantIdList: [merchantId]
}
api.getWorkList(obj).then(res => {
wx.$util.hideLoading()
let {
code,
data,
errId,
message
} = res
let total = 0
let list = []
if (code == 0) {
// 这个是用来判断哪些用户可以撤销的
let userType = !userInfo.isSuper && userInfo.merchantType
// let userType = true
data.list.map(e => {
if (e.orderTime) e.orderTime = new Date(e.orderTime).format('yyyy-MM-dd hh:mm:ss')
e.subOrderList.map(i => {
i.totalPrice = Number(wx.$util.decimal(i.totalPrice, 2)).toFixed(2)
})
e.total_price = e.totalPrice
e.totalPrice = Number(wx.$util.decimal(e.totalPrice, 2)).toFixed(2)
// && e.status != 1 待跟进现在也能撤销
let orderType = (userInfo.userType == 1 || userInfo.userType == 2) && e.status != 9 && ![1, 3, 4].includes(e.selectPayType)
// let orderType = userInfo.userType !== 1 && e.status != 9 && e.status != 1 && e.selectPayType != 3 && e.selectPayType != 1
// console.log(userType);
// console.log(orderType);
e.repeal = userType && orderType
// 处理subOrderList 商品为空的情况
e.subOrderList = e.subOrderList.filter(item => item.merchantGoodsId)
// e.subOrderList = e.subOrderList.filter(item => item.id)
// 处理显示订单右上角文字
// console.log(status[e.status])
// console.log(' status[e.status]', status[e.status])
let text = status[e.status].text
let color = status[e.status].color
let background = status[e.status].background
// 不是订单失效状态优先显示已施工
if (![9, 11, 12].includes(e.status) && e.constructionFlag == 'Y') {
text = '已施工'
color = '#347BFF'
background = '#F3F7FC'
}
e.statusText = text
e.statuscolor = color
e.statusbackground = background
// 商品是否包含太阳膜
e.isFilmOrder = e.subOrderList?.findIndex(subE => subE.upgradeGoodsType == 1) > -1
})
list = data.list
total = data.total
} else {
if (errId != '-5003') wx.$util.showToast(message)
}
if (total != 0) {
this.setData({
[`list[${pageNum - 1}]`]: list
})
}
this.setData({
total,
flag: true,
triggered: false
})
})
},
onRoute(options) {
if (Object.keys(options)?.length) {
this.setData({
staffUuid: options?.staffUuid, // 员工id
searchdate: options?.searchdate, // 质检页面筛选的时间条件
merchantId: options?.merchantId, // 员工归属门店
phoneNumberLists: options.phoneNumberLists ? options.phoneNumberLists : [] // 接待客户手机号
})
}
let userInfo = wx.$util.getUserInfo()
this.setData({
userInfo: {
...userInfo,
merchantType: userInfo?.merchantAccountList.includes('6') || userInfo?.merchantAccountList.includes('8')
}
})
this.getWorkList()
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {},
scrollonReachBottom() {
let {
total,
pageNum
} = this.data
wx.$util.onReachBottom({
total,
pageNum
},
res => {
this.getWorkList()
}
)
},
/**
* 监听 TabBar 切换点击
*/
// onTabItemTap(item) {
// console.log(item, 'item')
// },
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {}
})