Commit ec3417df by 李伟康

fix: 优化缺失接待报备功能,增加分批次提交和总数显示

1 parent 023bcf05
......@@ -27,19 +27,19 @@ Page({
track_event_code: 'mini_pad_missing_reception', //埋点动作类型
scene: 0
},
jump() {
jump () {
wx.$router.back()
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
onLoad (options) {
console.log(options)
this.initData(options.reportDate)
this.getMissingOptions()
},
async getMissingOptions() {
async getMissingOptions () {
try {
const {
code,
......@@ -59,7 +59,7 @@ Page({
wx.$util.showToast(error)
}
},
navbarReady(e) {
navbarReady (e) {
let navBarHeight = e.detail.height
this.setData({
navBarHeight
......@@ -82,7 +82,7 @@ Page({
})
this.setReportDate()
},
initData(reportDate = '') {
initData (reportDate = '') {
if (reportDate) {
let dateisSunday = dayjs(reportDate).toDate(),
countSundays = this.countSundays(
......@@ -105,7 +105,7 @@ Page({
}
this.setReportDate()
},
countSundays(startDate, endDate) {
countSundays (startDate, endDate) {
let start = new Date(startDate)
let end = new Date(endDate)
let sundays = 0
......@@ -153,7 +153,7 @@ Page({
this.getMissingCustomerList()
},
// 设置报告日期
async setReportDate() {
async setReportDate () {
try {
wx.$util.showLoading()
const {
......@@ -181,7 +181,7 @@ Page({
weekDayList,
selectDay
} = timeBean,
detailObj = {},
detailObj = {},
currentDate = weekDayList[selectDay].date
weekDayList.map(e => {
data.map(i => {
......@@ -201,7 +201,7 @@ Page({
wx.$util.showToast(error)
}
},
async getMissingCustomerList() {
async getMissingCustomerList () {
try {
wx.$util.showLoading()
this.setData({
......@@ -228,9 +228,10 @@ Page({
reportDate: currentDate
})
wx.hideLoading()
let total = 0
if (code == 0) {
let responseList = data.list
total = data.total
if (responseList.length) {
list = responseList.map(e => {
return {
......@@ -249,7 +250,7 @@ Page({
if (len) {
for (let index = 0; index < len; index++) {
list.push({
customerName: `客户${index + 1}`
customerName: `客户${index + 1}`,
})
}
}
......@@ -257,6 +258,7 @@ Page({
} else wx.$util.showToast(message)
this.setData({
list,
total,
isDateWithin7Days: dayjs().diff(dayjs(currentDate), 'day') < dayLimit
})
} catch (error) {
......@@ -265,7 +267,7 @@ Page({
if (error) wx.$util.showToast(error)
}
},
inputBlur(e) {
inputBlur (e) {
let {
index
} = e.target.dataset, {
......@@ -276,14 +278,14 @@ Page({
[`list[${index}].inputErrorText`]: value ? '' : '必填不能为空'
})
},
changeReason(e) {
changeReason (e) {
const {
missingOptions
} = this.data, {
index
} = e.target.dataset, {
value
} = e.detail,
index
} = e.target.dataset, {
value
} = e.detail,
item = missingOptions[value]
this.setData({
[`list[${index}].errorText`]: '',
......@@ -291,7 +293,7 @@ Page({
[`list[${index}].reasonCode`]: item.reasonCode,
})
},
cancel() {
cancel () {
wx.showModal({
title: '温馨提示',
content: '接待录音缺失将影响工资绩效,是否确认放弃报备?',
......@@ -303,7 +305,7 @@ Page({
}
})
},
async submit() {
async submit () {
try {
const {
list,
......@@ -334,39 +336,41 @@ Page({
reasonCode: e.reasonCode,
})
})
wx.$util.showLoading('提交中...')
wx.$track.setTrackData(0, 'mini_add_pad_missing_reception')
const {
code,
data,
message
} = await addMissingReception({
missingReceptionReportAddRequests,
reportDate: currentDate,
merchantId: shopMerchantId,
merchantName: shopMerchantName,
staffUuid: uuid,
staffName: name,
staffPhone: phone,
sceneType: 0
})
if (code == 0) {
wx.hideLoading()
let _this = this
wx.showModal({
title: '提示',
content: '提交成功',
showCancel: false,
confirmColor: '#347BFF',
success: (res) => {
if (res.confirm) {
_this.setReportDate()
// wx.$router.back()
}
}
wx.$util.showLoading('提交中...')
// 分批提交,每批最多50条
const batchSize = 50
for (let i = 0; i < missingReceptionReportAddRequests.length; i += batchSize) {
const batch = missingReceptionReportAddRequests.slice(i, i + batchSize)
const {
code,
message
} = await addMissingReception({
missingReceptionReportAddRequests: batch,
reportDate: currentDate,
merchantId: shopMerchantId,
merchantName: shopMerchantName,
staffUuid: uuid,
staffName: name,
staffPhone: phone,
sceneType: 0
})
console.log(data)
} else throw message
if (code != 0) throw message
}
wx.hideLoading()
let _this = this
wx.showModal({
title: '提示',
content: '提交成功',
showCancel: false,
confirmColor: '#347BFF',
success: (res) => {
if (res.confirm) {
_this.setReportDate()
// wx.$router.back()
}
}
})
} catch (error) {
wx.hideLoading()
if (error) wx.$util.showToast(error)
......@@ -375,49 +379,49 @@ Page({
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
onReady () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
onShow () {
this.onPageShow()
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
onHide () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
onUnload () {
this.onPageHide()
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
onPullDownRefresh () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
onReachBottom () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
onShareAppMessage () {
}
})
\ No newline at end of file
......@@ -34,9 +34,9 @@
</block>
<block wx:else>
<block wx:if="{{detailObj[currentDate].hasDailyReport}}">
<block wx:if="{{detailObj[currentDate].missingReceptionRecord}}">
<block wx:if="{{detailObj[currentDate].missingReceptionRecord || list.length}}">
<view class="title flex">
{{detailObj[currentDate].hasReceptionReport?'已':'需'}}报备客户·{{list.length}}
{{detailObj[currentDate].hasReceptionReport?'已':'需'}}报备客户·{{detailObj[currentDate].hasReceptionReport ? total : list.length}}
</view>
<view class="list {{detailObj[currentDate].hasReceptionReport?'has-reception-report':''}}">
<block wx:for="{{list}}" wx:key="index">
......
......@@ -58,7 +58,7 @@ module.exports = {
data = {
sceneType: 0,
currentPage: 1,
pageSize: 100,
pageSize: 999999,
...data
}
return api.post('dj.api.smartcarlife.staff.missing.reception.report.mini.list', data)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!