Commit 4619d737 by 张立顺

fix 驻店日报 bug修复

1 parent 88914b9f
import api from '~/api/api.js' import api from '~/api/api.js'
import { envIndex } from '~/config' import { envIndex } from '~/config'
import { removeSystemStorage } from '~/utils/cache/storageApi'
import util from '~/utils/util.js'
// const app = getApp() // const app = getApp()
// console.log(app, 'app') // console.log(app, 'app')
// console.log(wx)globalData // console.log(wx)globalData
...@@ -206,6 +208,7 @@ export const getBusinessSchoolScene = () => { ...@@ -206,6 +208,7 @@ export const getBusinessSchoolScene = () => {
// 扫码进来的处理 // 扫码进来的处理
export const checkScene = options => { export const checkScene = options => {
// let query = options.query // let query = options.query
let { query } = options let { query } = options
if (query) { if (query) {
...@@ -217,9 +220,22 @@ export const checkScene = options => { ...@@ -217,9 +220,22 @@ export const checkScene = options => {
} }
console.log(query, 'query') console.log(query, 'query')
let userInfo = wx.$util.getStorageSync('dj_boutique_user_info') let userInfo = wx.$util.getStorageSync('dj_boutique_user_info')
if (query && query.reportDate) {
// const app = getApp()
// console.log(app, 'app');
// app.globalData.yqdInfo = {}
// app.globalData.YQorderSetting = ''
// app.globalData.YQList = ''
// app.globalData.businessSchoolScene = ''
util.removeStorage()
removeSystemStorage()
// wx.$relogin = relogin
}
// 判断对象是否满足任意一个key // 判断对象是否满足任意一个key
// console.log(query, ' query') // console.log(query, ' query')
if (query && (query.scene || query.merchantId || query.type || query.page)) { if (query && (query.scene || query.merchantId || query.type || query.page)) {
// 如果是跳转员工日报页面,需先情况之前的用户登录信息
if (query.merchantId && !query.reportDate) { if (query.merchantId && !query.reportDate) {
// &&options.patch == 'tabIndex/pages/index/index' // &&options.patch == 'tabIndex/pages/index/index'
......
...@@ -175,5 +175,10 @@ module.exports = { ...@@ -175,5 +175,10 @@ module.exports = {
/** 批复员工日报 */ /** 批复员工日报 */
staffDailyReportApprove(data) { staffDailyReportApprove(data) {
return api.post('dj.api.smartcarlife.staff.daily.report.approve', data) return api.post('dj.api.smartcarlife.staff.daily.report.approve', data)
},
/** 4s店查询对应的园区店 */
querySceneRefByShop(data) {
return api.post('dj.api.scenemerchantref.querySceneRefByShop', data)
} }
} }
...@@ -85,7 +85,7 @@ Page({ ...@@ -85,7 +85,7 @@ Page({
}) })
}, },
changePicker(e) { changePicker(e) {
console.log(e) // console.log(e)
let { merchantRange, pickerType, staffList } = this.data let { merchantRange, pickerType, staffList } = this.data
let { value } = e.detail let { value } = e.detail
if (pickerType == 'merchant') { if (pickerType == 'merchant') {
...@@ -123,7 +123,7 @@ Page({ ...@@ -123,7 +123,7 @@ Page({
} }
try { try {
target.map(key => { target.map(key => {
if (!obj[key]) { if (!obj[key] && obj[key] != 0) {
throw key throw key
} }
}) })
...@@ -142,7 +142,7 @@ Page({ ...@@ -142,7 +142,7 @@ Page({
// 判断是否有审批意见 // 判断是否有审批意见
let { approvedContent, approvedSource, orderObj, timeBean } = this.data let { approvedContent, approvedSource, orderObj, timeBean } = this.data
if (!approvedContent.length) { if (!approvedContent.length) {
wx.$util.showToast('请输入审批意见') return wx.$util.showToast('请输入审批意见')
} }
let params = { let params = {
// approvedContent, // approvedContent,
...@@ -154,19 +154,28 @@ Page({ ...@@ -154,19 +154,28 @@ Page({
approvedSource, approvedSource,
approvalList: [{ approvedBy: approvedSource == 0 ? orderObj.approvedBy : '区域督导', approvedContent }] approvalList: [{ approvedBy: approvedSource == 0 ? orderObj.approvedBy : '区域督导', approvedContent }]
} }
console.log(params, 'submitApproval'); // console.log(params, 'submitApproval');
api api
.staffDailyReportApprove(params) .staffDailyReportApprove(params)
.then(res => { .then(res => {
console.log(res) // console.log(res)
let { code, data, message } = res let { code, data, message } = res
if (code == 0) { if (code == 0) {
this.setData({ this.setData({
approvedContent: '', approvedContent: '',
approvedContentCurrentWordNumber: 0 approvedContentCurrentWordNumber: 0
}) })
wx.$util.showToast('提交成功')
this.getStaffReport() this.getStaffReport()
// wx.$util.showToast('提交成功')
wx.showModal({
title: '提示',
content: '提交成功',
showCancel: false,
confirmText: '确定',
confirmColor: '#347BFF',
success(res) {
}
})
} else { } else {
wx.$util.showToast(message) wx.$util.showToast(message)
} }
...@@ -180,14 +189,14 @@ Page({ ...@@ -180,14 +189,14 @@ Page({
let { role, approvedSource, orderObj, formData } = this.data let { role, approvedSource, orderObj, formData } = this.data
// 是督导和老板,提交评论 // 是督导和老板,提交评论
// console.log(approvedSource != '', approvedSource, 'approvedSource') // console.log(approvedSource != '', approvedSource, 'approvedSource')
console.log(approvedSource, [0, 1].includes(approvedSource), 'submitApproval',); // console.log(approvedSource, [0, 1].includes(approvedSource), 'submitApproval',);
if ([0, 1, '0', '1'].includes(approvedSource)) { if ([0, 1, '0', '1'].includes(approvedSource)) {
return this.submitApproval() return this.submitApproval()
} }
if ((role != 'staff' || !orderObj.isDateWithin7Days) && (role != 'super' || !orderObj.isDateWithin60Days)) return wx.$util.showToast('已超过提交时效') if ((role != 'staff' || !orderObj.isDateWithin7Days) && (role != 'super' || !orderObj.isDateWithin60Days)) return wx.$util.showToast('已超过提交时效')
// let { orderObj, formData } = this.data // let { orderObj, formData } = this.data
let key = this.checkRequired(orderObj) let key = this.checkRequired(orderObj)
console.log(key) // console.log(key)
// debugger // debugger
if (key) { if (key) {
this.showToast(toastList[key]) this.showToast(toastList[key])
...@@ -207,17 +216,26 @@ Page({ ...@@ -207,17 +216,26 @@ Page({
}) })
orderObj[name] = arr orderObj[name] = arr
}) })
console.log(orderObj, 'orderObj') // console.log(orderObj, 'orderObj')
wx.$util.showLoading() wx.$util.showLoading()
api api
.staffDailyReportSave(orderObj) .staffDailyReportSave(orderObj)
.then(result => { .then(result => {
wx.$util.hideLoading() wx.$util.hideLoading()
console.log('result', result) // console.log('result', result)
let { code, data, message } = result let { code, data, message } = result
if (code == 0) { if (code == 0) {
wx.$util.showToast('提交成功')
this.getStaffDailyReportDetailWeeklyList() this.getStaffDailyReportDetailWeeklyList()
// wx.$util.showToast('提交成功')
wx.showModal({
title: '提示',
content: '提交成功',
showCancel: false,
confirmText: '确定',
confirmColor: '#347BFF',
success(res) {
}
})
} else { } else {
wx.$util.showToast(message) wx.$util.showToast(message)
} }
...@@ -314,7 +332,7 @@ Page({ ...@@ -314,7 +332,7 @@ Page({
}, },
getStaffDailyReportDetailWeeklyList() { getStaffDailyReportDetailWeeklyList() {
let { orderObj, timeBean } = this.data let { orderObj, timeBean } = this.data
console.log({ ...orderObj, ...timeBean }, 'getStaffDailyReportDetailWeeklyList'); // console.log({ ...orderObj, ...timeBean }, 'getStaffDailyReportDetailWeeklyList');
orderObj?.merchantId && api.staffDailyReportDetailWeeklyList({ ...orderObj, ...timeBean }).then(res => { orderObj?.merchantId && api.staffDailyReportDetailWeeklyList({ ...orderObj, ...timeBean }).then(res => {
let { code, data, message } = res let { code, data, message } = res
if (code == 0) { if (code == 0) {
...@@ -338,7 +356,7 @@ Page({ ...@@ -338,7 +356,7 @@ Page({
orderObj: { yqMerchantId, merchantId, staffUuid, reportDate }, orderObj: { yqMerchantId, merchantId, staffUuid, reportDate },
formData formData
} = this.data } = this.data
console.log({ yqMerchantId, merchantId, staffUuid, reportDate }, 'getStaffReport'); // console.log({ yqMerchantId, merchantId, staffUuid, reportDate }, 'getStaffReport');
merchantId && api.staffDailyReportDetail({ yqMerchantId, merchantId, staffUuid, reportDate }).then(res => { merchantId && api.staffDailyReportDetail({ yqMerchantId, merchantId, staffUuid, reportDate }).then(res => {
let { code, data, message } = res let { code, data, message } = res
// console.log(data, 'data') // console.log(data, 'data')
...@@ -420,35 +438,67 @@ Page({ ...@@ -420,35 +438,67 @@ Page({
}, },
getConversionEmployeeList() { getConversionEmployeeList() {
// debugger // debugger
let { orderObj } = this.data let { orderObj, scene } = this.data
comApi // 先查4s店对应的园区店,再用园区店查员工
.getConversionEmployeeList({ api.querySceneRefByShop({ scene, merchantId: orderObj.merchantId }).then((result) => {
merchantId: orderObj.merchantId // console.log(result, 'result')
}) let { code, data, message } = result
.then(res => { if (code == 0) {
// debugger console.log(data.yqMerchant?.merchantId, '!data.yqMerchant?.merchantId)');
console.log(res, 'res') if (!data.yqMerchant?.merchantId) {
let { code, data, message } = res this.setData({
if (code == 0) { staffList: []
if (!data.length) { })
// 没有员工 return wx.$util.showToast('该4s店查无数据')
wx.$util.showToast('该门店没有员工')
} else {
this.setData({
staffList: data,
staffCurrent: 0,
['orderObj.staffUuid']: data[0].uuid,
['orderObj.staffName']: data[0].staffName,
['orderObj.yqMerchantId']: data[0].yqMerchantId,
['orderObj.yqMerchantName']: data[0].yqMerchantName
})
this.getStaffReport()
this.getStaffDailyReportDetailWeeklyList()
}
} else {
wx.$util.showToast(message)
} }
})
this.setData({
['orderObj.yqMerchantId']: data.yqMerchant.merchantId,
['orderObj.yqMerchantName']: data.yqMerchant.merchantName,
})
comApi
.getConversionEmployeeList({
merchantId: data.yqMerchant.merchantId
})
.then(res => {
// debugger
// console.log(res, 'res')
let { code, data, message } = res
if (code == 0) {
if (!data.length) {
this.setData({
staffList: []
})
// 没有员工
wx.$util.showToast('该门店没有员工')
} else {
this.setData({
staffList: data,
staffCurrent: 0,
['orderObj.staffUuid']: data[0].uuid,
['orderObj.staffName']: data[0].staffName,
// ['orderObj.yqMerchantId']: data[0].yqMerchantId,
// ['orderObj.yqMerchantName']: data[0].yqMerchantName
})
this.getStaffReport()
this.getStaffDailyReportDetailWeeklyList()
}
} else {
wx.$util.showToast(message)
}
})
} else {
wx.$util.message(message)
}
}).catch((err) => {
});
}, },
getListShop4s(e = {}) { getListShop4s(e = {}) {
// let { value } = e?.detail // let { value } = e?.detail
...@@ -464,7 +514,7 @@ Page({ ...@@ -464,7 +514,7 @@ Page({
}) })
.then(result => { .then(result => {
let { code, data, message } = result let { code, data, message } = result
console.log(result, 'result') // console.log(result, 'result')
if (code == 0) { if (code == 0) {
this.setData({ this.setData({
merchantRange: data.list, merchantRange: data.list,
...@@ -482,7 +532,7 @@ Page({ ...@@ -482,7 +532,7 @@ Page({
} else { } else {
wx.$util.showToast(message) wx.$util.showToast(message)
} }
console.log(result, 'result') // console.log(result, 'result')
}) })
.catch(err => { }) .catch(err => { })
}, },
...@@ -491,7 +541,7 @@ Page({ ...@@ -491,7 +541,7 @@ Page({
}, },
initData(userInfo) { initData(userInfo) {
let { orderObj, reportDate, role } = this.data let { orderObj, reportDate, role } = this.data
console.log(this.data, 'initData'); // console.log(this.data, 'initData');
// const { sceneType, } = userInfo // const { sceneType, } = userInfo
// 根据不同角色做页面回显 // 根据不同角色做页面回显
const isStaff = app.globalData.isStaff || false const isStaff = app.globalData.isStaff || false
...@@ -507,7 +557,7 @@ Page({ ...@@ -507,7 +557,7 @@ Page({
this.setReportDate() this.setReportDate()
setTimeout(() => { setTimeout(() => {
console.log(this.data.role, this.data, 'roleOther'); // console.log(this.data.role, this.data, 'roleOther');
if (this.data.role == 'other') { if (this.data.role == 'other') {
this.getStaffReport() this.getStaffReport()
this.getStaffDailyReportDetailWeeklyList() this.getStaffDailyReportDetailWeeklyList()
...@@ -516,7 +566,7 @@ Page({ ...@@ -516,7 +566,7 @@ Page({
}) })
if (isStaff) { if (isStaff) {
console.log(userInfo, 'userInfo'); // console.log(userInfo, 'userInfo');
const { merchantId, merchantName, name, uuid, shopMerchantId, shopMerchantName } = userInfo const { merchantId, merchantName, name, uuid, shopMerchantId, shopMerchantName } = userInfo
this.setData({ this.setData({
role: 'staff', role: 'staff',
...@@ -545,30 +595,37 @@ Page({ ...@@ -545,30 +595,37 @@ Page({
// 4s店-员工-员工数据 的请求逻辑 // 4s店-员工-员工数据 的请求逻辑
this.getListShop4s() this.getListShop4s()
} }
console.log(this.data, 'roleOther'); // console.log(this.data, 'roleOther');
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
if (options) {
for (const key in options) {
options[key] = decodeURIComponent(options[key])
}
}
console.log(options, 'options,onLoad'); console.log(options, 'options,onLoad');
this.setData({ this.setData({
flag: true flag: true
}) })
let { orderObj } = this.data let { orderObj } = this.data
console.log(options.hasOwnProperty('approvedSource'), options, 'approvedSource'); // console.log(options.hasOwnProperty('approvedSource'), options, 'approvedSource');
if (options.hasOwnProperty('approvedSource')) { if (options.hasOwnProperty('approvedSource')) {
this.setData({ this.setData({
role: 'other', role: 'other',
approvedSource: options.approvedSource, approvedSource: options.approvedSource,
merchantRange: [{ merchantName: options.merchantName, merchantId: options.merhchantid }],
orderObj: { orderObj: {
...orderObj, ...orderObj,
...options ...options
} },
reportDate: options.reportDate
}, this.initData({})) }, this.initData({}))
} }
// else { // else {
// this.initData(wx.$util.getUserInfo()) // this.initData(wx.$util.getUserInfo())
......
...@@ -68,7 +68,8 @@ ...@@ -68,7 +68,8 @@
</view> </view>
<view class="approvalFromSuperiorsCon"> <view class="approvalFromSuperiorsCon">
<view class="title"> <view class="title">
上级批复 <!-- -->
{{role=='other'? approvedSource == 0 ? orderObj.approvedBy : '区域督导' : '上级批复'}}
<text class="data">({{timeBean.starDayLabel+ '-' + timeBean.endDayLabel}})</text> <text class="data">({{timeBean.starDayLabel+ '-' + timeBean.endDayLabel}})</text>
</view> </view>
<view class="tips">数据来源生意助手小程序,每周更新</view> <view class="tips">数据来源生意助手小程序,每周更新</view>
......
...@@ -8,7 +8,11 @@ function getWeekDayList(selectWeek, selectDay) { ...@@ -8,7 +8,11 @@ function getWeekDayList(selectWeek, selectDay) {
// 2.用循环七次添加周一到周日对应得周几和几号 // 2.用循环七次添加周一到周日对应得周几和几号
var selectWeekTime = getCurrentTimeStamp(selectDay) + selectWeek * 7 * 24 * 60 * 60 * 1000 var selectWeekTime = getCurrentTimeStamp(selectDay) + selectWeek * 7 * 24 * 60 * 60 * 1000
var mondayTime = selectWeekTime - (getWeekNumber(selectWeekTime) - 1) * 24 * 60 * 60 * 1000 var mondayTime = selectWeekTime - (getWeekNumber(selectWeekTime) - 1) * 24 * 60 * 60 * 1000
// console.log(mondayTime, 'mondayTime') // let testDate = new Date(mondayTime)
// console.log(getWeekNumber(selectWeekTime), getWeekNumber(selectWeekTime) - 1, 'getWeekNumber(selectWeekTime) - 1')
// console.log(getDataFormat(selectWeekTime), 'selectWeekTime')
// console.log(getDataFormat(mondayTime), 'mondayTime')
var timeBean = { var timeBean = {
selectDay: 0, selectDay: 0,
yearMonth: '', yearMonth: '',
...@@ -112,7 +116,8 @@ function getWeek(res) { ...@@ -112,7 +116,8 @@ function getWeek(res) {
//时间戳转周几 0123456 -- //时间戳转周几 0123456 --
function getWeekNumber(res) { function getWeekNumber(res) {
var days = [0, 1, 2, 3, 4, 5, 6]; // var days = [6, 0, 1, 2, 3, 4, 5,];
var days = [7, 1, 2, 3, 4, 5, 6];
var time = new Date(res); var time = new Date(res);
var dayIndex = time.getDay(); var dayIndex = time.getDay();
return days[dayIndex]; return days[dayIndex];
...@@ -134,19 +139,33 @@ function getDataFormat(res) { ...@@ -134,19 +139,33 @@ function getDataFormat(res) {
return `${year}-${month}-${day}` return `${year}-${month}-${day}`
} }
// function isTimestampInCurrentWeek(timestamp) {
// const currentDate = new Date()
// const currentDay = currentDate.getDay() // 获取当前日期是星期几
// // 计算当前周的起始日期(周一)
// const currentWeekStart = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate() - currentDay + 1)
// console.log(currentWeekStart, 'currentWeekStart');
// // 计算当前周的结束日期(周日)
// const currentWeekEnd = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate() + (7 - currentDay), 23, 59, 59, 999)
// console.log(currentWeekEnd, 'currentWeekEnd');
// const targetDate = new Date(timestamp) // 不再乘以1000
// return targetDate >= currentWeekStart && targetDate <= currentWeekEnd
// }
function isTimestampInCurrentWeek(timestamp) { function isTimestampInCurrentWeek(timestamp) {
const currentDate = new Date() const currentDate = new Date();
const currentDay = currentDate.getDay() // 获取当前日期是星期几 const currentDay = currentDate.getDay(); // 获取当前日期是星期几
// 计算当前周的起始日期(周一) // 计算当前周的起始日期(周一)
const currentWeekStart = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate() - currentDay + 1) const currentWeekStart = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate() - currentDay + (currentDay === 0 ? -6 : 1));
// 计算当前周的结束日期(周日) // 计算当前周的结束日期(周日)
const currentWeekEnd = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate() + (7 - currentDay), 23, 59, 59, 999) const currentWeekEnd = new Date(currentWeekStart.getFullYear(), currentWeekStart.getMonth(), currentWeekStart.getDate() + 6, 23, 59, 59, 999);
const targetDate = new Date(timestamp) // 不再乘以1000 const targetDate = new Date(timestamp);
return targetDate >= currentWeekStart && targetDate <= currentWeekEnd return targetDate >= currentWeekStart && targetDate <= currentWeekEnd;
} }
function getWeeksDiff(startDate, endDate) { function getWeeksDiff(startDate, endDate) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!