Commit ec3417df by 李伟康

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

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