Commit c4f48212 by zhangxw

优化修改

1 parent 8ea1770c
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
import api from '~/api/api' import api from '~/api/api'
import dayjs from 'dayjs' import dayjs from 'dayjs'
let currentObj let currentObj
let weekColumnsCache
let weekColumnsPromise
Component({ Component({
/** /**
...@@ -90,16 +92,35 @@ Component({ ...@@ -90,16 +92,35 @@ Component({
*/ */
methods: { methods: {
async getWeeklyData() { async getWeeklyData() {
const result = await api.getWeekSelectData() if (Array.isArray(weekColumnsCache) && weekColumnsCache.length) {
this.setData({ weekColumns: weekColumnsCache })
return
}
if (!weekColumnsPromise) {
weekColumnsPromise = api.getWeekSelectData()
.then((result) => {
const weekColumns = result.data?.map((item, index) => ({ const weekColumns = result.data?.map((item, index) => ({
label: `${dayjs(item.startDate).format('YYYY/MM/DD')}-${dayjs(item.endDate).format('YYYY/MM/DD')}`, label: `${dayjs(item.startDate).format('YYYY/MM/DD')}-${dayjs(item.endDate).format('YYYY/MM/DD')}`,
startDate: dayjs(item.startDate).format('YYYY/MM/DD'), startDate: dayjs(item.startDate).format('YYYY/MM/DD'),
endDate: dayjs(item.endDate).format('YYYY/MM/DD'), endDate: dayjs(item.endDate).format('YYYY/MM/DD'),
index index
})) })) || []
this.setData({ weekColumnsCache = weekColumns
weekColumns return weekColumns
}) })
.catch(() => {
return []
})
.finally(() => {
weekColumnsPromise = null
})
}
const weekColumns = await weekColumnsPromise
if (Array.isArray(weekColumns) && weekColumns.length) {
this.setData({ weekColumns })
}
}, },
// 切换日期类型 // 切换日期类型
selectDate(event) { selectDate(event) {
...@@ -191,7 +212,9 @@ Component({ ...@@ -191,7 +212,9 @@ Component({
if (timeType == 'custom') { if (timeType == 'custom') {
this.setData({ this.setData({
show: true show: true
}) }, () => {
this._emitPopupVisible(true)
wx.nextTick(() => {
const calendar = this.selectComponent("#calendar") const calendar = this.selectComponent("#calendar")
if (calendar && calendar.__data__ && calendar.__data__.currentDate) { if (calendar && calendar.__data__ && calendar.__data__.currentDate) {
const _calendar = calendar.__data__.currentDate.map(item => dayjs(item).format('YYYY/MM/DD')) const _calendar = calendar.__data__.currentDate.map(item => dayjs(item).format('YYYY/MM/DD'))
...@@ -200,10 +223,14 @@ Component({ ...@@ -200,10 +223,14 @@ Component({
calendar.reset() calendar.reset()
} }
} }
})
})
} else { } else {
this.setData({ this.setData({
dateShow: true dateShow: true
}) }, () => {
this._emitPopupVisible(true)
wx.nextTick(() => {
if (timeType == 'date' && currentObj) { if (timeType == 'date' && currentObj) {
const c_value = currentObj.getValues() const c_value = currentObj.getValues()
const _date = date.split('-') const _date = date.split('-')
...@@ -214,7 +241,7 @@ Component({ ...@@ -214,7 +241,7 @@ Component({
maxDate: dayjs().valueOf(), maxDate: dayjs().valueOf(),
}, },
() => { () => {
picker.picker.setValues(_date) picker?.picker?.setValues?.(_date)
}) })
} }
} else if (timeType == 'year-month'&& currentObj) { } else if (timeType == 'year-month'&& currentObj) {
...@@ -227,7 +254,7 @@ Component({ ...@@ -227,7 +254,7 @@ Component({
maxDate: dayjs().valueOf(), maxDate: dayjs().valueOf(),
}, },
() => { () => {
picker.picker.setValues(_date) picker?.picker?.setValues?.(_date)
}) })
} }
} else if (timeType == 'week') { } else if (timeType == 'week') {
...@@ -236,15 +263,19 @@ Component({ ...@@ -236,15 +263,19 @@ Component({
const label = date const label = date
const index = weekColumns.findIndex(i => i.label == label) const index = weekColumns.findIndex(i => i.label == label)
setTimeout(() => { setTimeout(() => {
picker.setColumnIndex(0, index) picker?.setColumnIndex?.(0, index)
}, 0) }, 0)
} }
})
})
} }
}, },
// 取消 // 取消
cancel() { cancel() {
this.setData({ this.setData({
dateShow: false dateShow: false
}, () => {
this._emitPopupVisible(false)
}) })
}, },
// 年月日确认 // 年月日确认
...@@ -294,8 +325,13 @@ Component({ ...@@ -294,8 +325,13 @@ Component({
dateShow: false, dateShow: false,
currentDate: (formatMap[timeType] || (() => ''))(), currentDate: (formatMap[timeType] || (() => ''))(),
date: (formatMap[timeType] || (() => ''))() date: (formatMap[timeType] || (() => ''))()
}); }, () => {
this._emitPopupVisible(false)
this.triggerEvent('search', this.getParams()) this.triggerEvent('search', this.getParams())
});
},
_emitPopupVisible(visible) {
this.triggerEvent('popupvisible', { visible }, { bubbles: true, composed: true })
}, },
onChange(e) { onChange(e) {
currentObj = e.detail currentObj = e.detail
......
...@@ -16,7 +16,8 @@ ...@@ -16,7 +16,8 @@
</view> </view>
</view> </view>
<!-- 年月日 --> <!-- 年月日 -->
<popup bind:hidePopup="cancel" bind:confirm="confirm" show="{{dateShow}}" title="{{titleEnum[timeType]}}" height="60vh"> <block wx:if="{{dateShow}}">
<popup bindcancel="cancel" bindconfirm="confirm" show="{{dateShow}}" title="{{titleEnum[timeType]}}" height="60vh">
<block wx:if="{{timeType == 'date' || timeType == 'year-month'}}"> <block wx:if="{{timeType == 'date' || timeType == 'year-month'}}">
<van-datetime-picker id="datePicker" show-toolbar="{{false}}" min-date="{{ minDate }}" max-date="{{ maxDate }}" model:value="{{ currentDate }}" type="{{timeType=='date'?'date':'year-month'}}" bind:change="onChange" bind:input="onInput" /> <van-datetime-picker id="datePicker" show-toolbar="{{false}}" min-date="{{ minDate }}" max-date="{{ maxDate }}" model:value="{{ currentDate }}" type="{{timeType=='date'?'date':'year-month'}}" bind:change="onChange" bind:input="onInput" />
</block> </block>
...@@ -24,8 +25,10 @@ ...@@ -24,8 +25,10 @@
<block wx:if="{{timeType == 'week'}}"> <block wx:if="{{timeType == 'week'}}">
<van-picker id="weekPicker" show-toolbar="{{false}}" model:value="{{ currentDate }}" default-index="{{defaultIndex}}" value-key="label" columns="{{ weekColumns }}" bind:change="onWeekChange" /> <van-picker id="weekPicker" show-toolbar="{{false}}" model:value="{{ currentDate }}" default-index="{{defaultIndex}}" value-key="label" columns="{{ weekColumns }}" bind:change="onWeekChange" />
</block> </block>
</popup> </popup>
<van-calendar </block>
<block wx:if="{{show}}">
<van-calendar
id="calendar" id="calendar"
max-range="{{ 31 }}" max-range="{{ 31 }}"
min-date="{{ minDate }}" min-date="{{ minDate }}"
...@@ -36,3 +39,4 @@ ...@@ -36,3 +39,4 @@
bind:confirm="onConfirm" bind:confirm="onConfirm"
bind:close="onClose" bind:close="onClose"
/> />
</block>
...@@ -68,6 +68,13 @@ Component({ ...@@ -68,6 +68,13 @@ Component({
behaviorInfo: {} behaviorInfo: {}
}, },
methods: { methods: {
_beginRequest() {
this._reqSeq = (this._reqSeq || 0) + 1
return this._reqSeq
},
_isLatestRequest(seq) {
return seq === this._reqSeq
},
search(e) { search(e) {
this.setData({ this.setData({
startStr: e.detail.startDay?.replace(/\//g, '-'), startStr: e.detail.startDay?.replace(/\//g, '-'),
...@@ -104,6 +111,7 @@ Component({ ...@@ -104,6 +111,7 @@ Component({
return result return result
}, },
getData() { getData() {
const seq = this._beginRequest()
let { detailInfo, startStr, endStr, selectedMerchantObj } = this.data let { detailInfo, startStr, endStr, selectedMerchantObj } = this.data
let params = { let params = {
phone: detailInfo.employeePhone, phone: detailInfo.employeePhone,
...@@ -115,6 +123,7 @@ Component({ ...@@ -115,6 +123,7 @@ Component({
} }
wx.$util.showLoading() wx.$util.showLoading()
api.getEmployeebehaviorData(params).then(res => { api.getEmployeebehaviorData(params).then(res => {
if (!this._isLatestRequest(seq)) return
wx.$util.hideLoading() wx.$util.hideLoading()
let { code, data, message } = res let { code, data, message } = res
if (code == 0) { if (code == 0) {
...@@ -127,6 +136,7 @@ Component({ ...@@ -127,6 +136,7 @@ Component({
wx.$util.showToast(message) wx.$util.showToast(message)
} }
}).catch(() => { }).catch(() => {
if (!this._isLatestRequest(seq)) return
wx.$util.hideLoading() wx.$util.hideLoading()
}) })
}, },
......
...@@ -37,6 +37,10 @@ export default class WxCanvas { ...@@ -37,6 +37,10 @@ export default class WxCanvas {
// noop // noop
} }
removeEventListener() {
// noop
}
attachEvent() { attachEvent() {
// noop // noop
} }
......
...@@ -32,21 +32,41 @@ Component({ ...@@ -32,21 +32,41 @@ Component({
data: { data: {
ec: { ec: {
lazyLoad: true lazyLoad: true
} },
}, },
lifetimes: {
detached() {
if (this.chart) {
try {
this.chart.dispose()
} catch (e) {
}
this.chart = null
}
if (this._initTimer) {
clearTimeout(this._initTimer)
this._initTimer = null
}
}
},
/** /**
* 组件的方法列表 * 组件的方法列表
*/ */
methods: { methods: {
onInitChart(xData, yData, yData2) { onInitChart(xData, yData, yData2) {
if (this.chart) {
this.setOption(this.chart, xData, yData, yData2)
return
}
this.ecComponent && this.ecComponent.init((canvas, width, height, dpr) => { this.ecComponent && this.ecComponent.init((canvas, width, height, dpr) => {
const chart = echarts.init(canvas, null, { const chart = echarts.init(canvas, null, {
width: width, width: width,
height: height, height: height,
devicePixelRatio: dpr // new devicePixelRatio: dpr
}); });
this.chart = chart
this.setOption(chart, xData, yData, yData2); this.setOption(chart, xData, yData, yData2);
return chart; return chart;
}) })
...@@ -177,7 +197,7 @@ Component({ ...@@ -177,7 +197,7 @@ Component({
itemStyle: { itemStyle: {
color: "rgba(52, 123, 255, 1)", color: "rgba(52, 123, 255, 1)",
}, },
// smooth: true, smooth: true,
color: this.data.color, color: this.data.color,
areaStyle: { areaStyle: {
color: { color: {
...@@ -216,7 +236,10 @@ Component({ ...@@ -216,7 +236,10 @@ Component({
yData, yData,
yData2 yData2
}) })
if (this._initTimer) clearTimeout(this._initTimer)
this._initTimer = setTimeout(() => {
this.onInitChart(xData, yData, yData2) this.onInitChart(xData, yData, yData2)
}, 0)
}, },
}, },
ready() { ready() {
......
...@@ -273,6 +273,13 @@ Component({ ...@@ -273,6 +273,13 @@ Component({
lineData: [] lineData: []
}, },
methods: { methods: {
_beginRequest() {
this._reqSeq = (this._reqSeq || 0) + 1
return this._reqSeq
},
_isLatestRequest(seq) {
return seq === this._reqSeq
},
onDateSearch(e) { onDateSearch(e) {
this.setData({ this.setData({
startStr: e.detail.startDay?.replace(/\//g, '-'), startStr: e.detail.startDay?.replace(/\//g, '-'),
...@@ -306,6 +313,7 @@ Component({ ...@@ -306,6 +313,7 @@ Component({
}, 350) }, 350)
}, },
async refreshViewModel() { async refreshViewModel() {
const seq = this._beginRequest()
let { detailInfo, startStr, endStr, dateType, selectedMerchantObj } = this.data let { detailInfo, startStr, endStr, dateType, selectedMerchantObj } = this.data
let params = { let params = {
employeePhone: detailInfo.employeePhone, employeePhone: detailInfo.employeePhone,
...@@ -317,6 +325,7 @@ Component({ ...@@ -317,6 +325,7 @@ Component({
} }
wx.$util.showLoading() wx.$util.showLoading()
api.getEmployeePerformanceData(params).then(res => { api.getEmployeePerformanceData(params).then(res => {
if (!this._isLatestRequest(seq)) return
wx.$util.hideLoading() wx.$util.hideLoading()
let { code, data, message } = res let { code, data, message } = res
if (code == 0) { if (code == 0) {
...@@ -402,12 +411,14 @@ Component({ ...@@ -402,12 +411,14 @@ Component({
wx.$util.showToast(message) wx.$util.showToast(message)
} }
}).catch(() => { }).catch(() => {
if (!this._isLatestRequest(seq)) return
wx.$util.hideLoading() wx.$util.hideLoading()
}) })
}, },
// 获取个人产值趋势及达成率 // 获取个人产值趋势及达成率
getTrendList() { getTrendList() {
const seq = this._beginRequest()
let { detailInfo, startStr, endStr, dateType, selectedMerchantObj } = this.data let { detailInfo, startStr, endStr, dateType, selectedMerchantObj } = this.data
let params = { let params = {
staffUuids: [selectedMerchantObj?.employeeId], staffUuids: [selectedMerchantObj?.employeeId],
...@@ -418,6 +429,7 @@ Component({ ...@@ -418,6 +429,7 @@ Component({
merchantIds: [selectedMerchantObj?.merchantId] merchantIds: [selectedMerchantObj?.merchantId]
} }
api.getEmployeeOutPutTrendApi(params).then(res => { api.getEmployeeOutPutTrendApi(params).then(res => {
if (!this._isLatestRequest(seq)) return
let { code, data, message } = res let { code, data, message } = res
if (code == 0) { if (code == 0) {
data?.list?.forEach((val, index) => { data?.list?.forEach((val, index) => {
......
...@@ -23,6 +23,20 @@ Component({ ...@@ -23,6 +23,20 @@ Component({
list: [] list: []
}, },
methods: { methods: {
_beginListRequest() {
this._listReqSeq = (this._listReqSeq || 0) + 1
return this._listReqSeq
},
_isLatestListRequest(seq) {
return seq === this._listReqSeq
},
_beginTopRequest() {
this._topReqSeq = (this._topReqSeq || 0) + 1
return this._topReqSeq
},
_isLatestTopRequest(seq) {
return seq === this._topReqSeq
},
search(e) { search(e) {
this.setData({ this.setData({
startDate: e.detail.startDay?.replace(/\//g, '-'), startDate: e.detail.startDay?.replace(/\//g, '-'),
...@@ -33,6 +47,7 @@ Component({ ...@@ -33,6 +47,7 @@ Component({
}) })
}, },
getStaticsData() { getStaticsData() {
const seq = this._beginTopRequest()
let { detailInfo, startDate, endDate } = this.data let { detailInfo, startDate, endDate } = this.data
let params = { let params = {
businessType: detailInfo.scene || undefined, businessType: detailInfo.scene || undefined,
...@@ -43,6 +58,7 @@ Component({ ...@@ -43,6 +58,7 @@ Component({
storeManagerPhone: detailInfo?.employeePhone storeManagerPhone: detailInfo?.employeePhone
} }
api.getTrainingStaffList(params).then(res => { api.getTrainingStaffList(params).then(res => {
if (!this._isLatestTopRequest(seq)) return
let { code, data, message } = res let { code, data, message } = res
if (code == 0) { if (code == 0) {
this.setData({ this.setData({
...@@ -54,6 +70,7 @@ Component({ ...@@ -54,6 +70,7 @@ Component({
}) })
}, },
getData() { getData() {
const seq = this._beginListRequest()
let { activeTab, detailInfo, startDate, endDate } = this.data let { activeTab, detailInfo, startDate, endDate } = this.data
let params = { let params = {
businessType: detailInfo?.scene, businessType: detailInfo?.scene,
...@@ -64,6 +81,7 @@ Component({ ...@@ -64,6 +81,7 @@ Component({
} }
wx.$util.showLoading() wx.$util.showLoading()
api.getTrainingExperienceList(params).then(res => { api.getTrainingExperienceList(params).then(res => {
if (!this._isLatestListRequest(seq)) return
wx.$util.hideLoading() wx.$util.hideLoading()
let { code, data, message } = res let { code, data, message } = res
if (code == 0) { if (code == 0) {
...@@ -77,6 +95,7 @@ Component({ ...@@ -77,6 +95,7 @@ Component({
wx.$util.showToast(message) wx.$util.showToast(message)
} }
}).catch(() => { }).catch(() => {
if (!this._isLatestListRequest(seq)) return
wx.$util.hideLoading() wx.$util.hideLoading()
}) })
}, },
......
...@@ -9,6 +9,7 @@ Page({ ...@@ -9,6 +9,7 @@ Page({
data: { data: {
IMG_URL, IMG_URL,
navBarHeight: 84, navBarHeight: 84,
isFooterHidden: false,
AIContent: '', AIContent: '',
detailInfo: {}, detailInfo: {},
detailItems: [{ detailItems: [{
...@@ -49,6 +50,11 @@ Page({ ...@@ -49,6 +50,11 @@ Page({
tabIndex: e.detail tabIndex: e.detail
}) })
}, },
onDatePopupVisible(e) {
this.setData({
isFooterHidden: !!e?.detail?.visible
})
},
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
......
...@@ -120,3 +120,7 @@ page{ ...@@ -120,3 +120,7 @@ page{
background: #347BFF; background: #347BFF;
} }
} }
.footerBtn.hidden {
opacity: 0;
pointer-events: none;
}
...@@ -36,14 +36,14 @@ ...@@ -36,14 +36,14 @@
</view> </view>
<view class="tab-content"> <view class="tab-content">
<basic-info wx:if="{{tabIndex === 0}}" baseInfo="{{baseInfo}}" /> <basic-info wx:if="{{tabIndex === 0}}" baseInfo="{{baseInfo}}" />
<personal-performance wx:if="{{tabIndex === 1}}" detailInfo="{{detailInfo}}" merchantList="{{merchantList}}" selectedMerchantObj="{{selectedMerchantObj}}" /> <personal-performance wx:if="{{tabIndex === 1}}" detailInfo="{{detailInfo}}" merchantList="{{merchantList}}" selectedMerchantObj="{{selectedMerchantObj}}" bindpopupvisible="onDatePopupVisible" />
<behavior-analysis wx:if="{{tabIndex === 2}}" detailInfo="{{detailInfo}}" selectedMerchantObj="{{selectedMerchantObj}}" /> <behavior-analysis wx:if="{{tabIndex === 2}}" detailInfo="{{detailInfo}}" selectedMerchantObj="{{selectedMerchantObj}}" bindpopupvisible="onDatePopupVisible" />
<training-experience wx:if="{{tabIndex === 3}}" detailInfo="{{detailInfo}}" /> <training-experience wx:if="{{tabIndex === 3}}" detailInfo="{{detailInfo}}" bindpopupvisible="onDatePopupVisible" />
<view style="width: 100%;height: 200rpx;"></view> <view style="width: 100%;height: 200rpx;"></view>
</view> </view>
</view> </view>
</scroll-view> </scroll-view>
<view class="footerBtn {{ isFullSucreen?'isFullSucreen-btn':'' }}"> <view class="footerBtn {{ isFullSucreen?'isFullSucreen-btn':'' }} {{ isFooterHidden ? 'hidden' : '' }}">
<view class="btn cancle" bindtap="handleRecording">接待录音</view> <view class="btn cancle" bindtap="handleRecording">接待录音</view>
<view class="btn next" bindtap="handleMentoring">发起带教</view> <view class="btn next" bindtap="handleMentoring">发起带教</view>
</view> </view>
...@@ -63,7 +63,9 @@ Page({ ...@@ -63,7 +63,9 @@ Page({
AIContent: '', AIContent: '',
staticData: {}, staticData: {},
employeeList: [], employeeList: [],
mode: 'performance' mode: 'performance',
sortField: 1,
sortOrder: 1
}, },
onTabItemTap(e) { onTabItemTap(e) {
...@@ -126,14 +128,17 @@ Page({ ...@@ -126,14 +128,17 @@ Page({
this.setData({ this.setData({
tabIndex: index, tabIndex: index,
mode: target.value, mode: target.value,
sceneTabIndex: 0, // sceneTabIndex: 0,
sortField: index == 1 ? 4 : 1, // 行为排序初始为4成交数 sortField: index == 1 ? 4 : 1, // 行为排序初始为4成交数
sortOrder: 1 sortOrder: 1
}, () => { }, () => {
const comp = this.selectComponent('#date') // const comp = this.selectComponent('#date')
if (comp) comp.initLoad('date') // if (comp) comp.initLoad('date')
const sortComp = this.selectComponent('#employee-ranking') const sortComp = this.selectComponent('#employee-ranking')
if (comp) sortComp.initLoad() if (sortComp) sortComp.initLoad()
setTimeout(() => {
this.getEmployeeRank()
})
}) })
}, },
......
...@@ -63,7 +63,7 @@ page { ...@@ -63,7 +63,7 @@ page {
} }
.login-btn { .login-btn {
margin: 6vh 0 0; margin: 3vh 0 0;
background: #2c66f7; background: #2c66f7;
border-radius: var(--fontSize28); border-radius: var(--fontSize28);
text-align: center; text-align: center;
...@@ -254,7 +254,7 @@ page { ...@@ -254,7 +254,7 @@ page {
} }
.auth_box { .auth_box {
padding: var(--fontSize96) 0; padding: 6vh 0 0;
/* position: fixed; */ /* position: fixed; */
width: 100%; width: 100%;
/* left: 50%; */ /* left: 50%; */
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!