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) {
const weekColumns = result.data?.map((item, index) => ({ this.setData({ weekColumns: weekColumnsCache })
label: `${dayjs(item.startDate).format('YYYY/MM/DD')}-${dayjs(item.endDate).format('YYYY/MM/DD')}`, return
startDate: dayjs(item.startDate).format('YYYY/MM/DD'), }
endDate: dayjs(item.endDate).format('YYYY/MM/DD'),
index if (!weekColumnsPromise) {
})) weekColumnsPromise = api.getWeekSelectData()
this.setData({ .then((result) => {
weekColumns const weekColumns = result.data?.map((item, index) => ({
}) label: `${dayjs(item.startDate).format('YYYY/MM/DD')}-${dayjs(item.endDate).format('YYYY/MM/DD')}`,
startDate: dayjs(item.startDate).format('YYYY/MM/DD'),
endDate: dayjs(item.endDate).format('YYYY/MM/DD'),
index
})) || []
weekColumnsCache = 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,61 +212,71 @@ Component({ ...@@ -191,61 +212,71 @@ Component({
if (timeType == 'custom') { if (timeType == 'custom') {
this.setData({ this.setData({
show: true show: true
}) }, () => {
const calendar = this.selectComponent("#calendar") this._emitPopupVisible(true)
if (calendar && calendar.__data__ && calendar.__data__.currentDate) { wx.nextTick(() => {
const _calendar = calendar.__data__.currentDate.map(item => dayjs(item).format('YYYY/MM/DD')) const calendar = this.selectComponent("#calendar")
const _value = date.split('-') if (calendar && calendar.__data__ && calendar.__data__.currentDate) {
if (_value[0] != _calendar[0] || _value[1] != _calendar[1]) { const _calendar = calendar.__data__.currentDate.map(item => dayjs(item).format('YYYY/MM/DD'))
calendar.reset() const _value = date.split('-')
} if (_value[0] != _calendar[0] || _value[1] != _calendar[1]) {
} calendar.reset()
}
}
})
})
} else { } else {
this.setData({ this.setData({
dateShow: true dateShow: true
}) }, () => {
if (timeType == 'date' && currentObj) { this._emitPopupVisible(true)
const c_value = currentObj.getValues() wx.nextTick(() => {
const _date = date.split('-') if (timeType == 'date' && currentObj) {
if (c_value[0] != _date[0] || c_value[1] != _date[1] || c_value[2] != _date[2]) { const c_value = currentObj.getValues()
const picker = this.selectComponent("#datePicker") const _date = date.split('-')
this.setData({ if (c_value[0] != _date[0] || c_value[1] != _date[1] || c_value[2] != _date[2]) {
minDate: dayjs().subtract(3, 'year').valueOf(), const picker = this.selectComponent("#datePicker")
maxDate: dayjs().valueOf(), this.setData({
}, minDate: dayjs().subtract(3, 'year').valueOf(),
() => { maxDate: dayjs().valueOf(),
picker.picker.setValues(_date) },
}) () => {
} picker?.picker?.setValues?.(_date)
} else if (timeType == 'year-month'&& currentObj) { })
const c_value = currentObj.getValues() }
const _date = date.split('-') } else if (timeType == 'year-month'&& currentObj) {
if (c_value[0] != _date[0] || c_value[1] != _date[1]) { const c_value = currentObj.getValues()
const picker = this.selectComponent("#datePicker") const _date = date.split('-')
this.setData({ if (c_value[0] != _date[0] || c_value[1] != _date[1]) {
minDate: dayjs().subtract(3, 'year').valueOf(), const picker = this.selectComponent("#datePicker")
maxDate: dayjs().valueOf(), this.setData({
}, minDate: dayjs().subtract(3, 'year').valueOf(),
() => { maxDate: dayjs().valueOf(),
picker.picker.setValues(_date) },
}) () => {
} picker?.picker?.setValues?.(_date)
} else if (timeType == 'week') { })
const { date, weekColumns} = this.data }
const picker = this.selectComponent("#weekPicker") } else if (timeType == 'week') {
const label = date const { date, weekColumns} = this.data
const index = weekColumns.findIndex(i => i.label == label) const picker = this.selectComponent("#weekPicker")
setTimeout(() => { const label = date
picker.setColumnIndex(0, index) const index = weekColumns.findIndex(i => i.label == label)
}, 0) setTimeout(() => {
} picker?.setColumnIndex?.(0, index)
}, 0)
}
})
})
} }
}, },
// 取消 // 取消
cancel() { cancel() {
this.setData({ this.setData({
dateShow: false dateShow: false
}) }, () => {
this._emitPopupVisible(false)
})
}, },
// 年月日确认 // 年月日确认
confirm() { confirm() {
...@@ -294,9 +325,14 @@ Component({ ...@@ -294,9 +325,14 @@ Component({
dateShow: false, dateShow: false,
currentDate: (formatMap[timeType] || (() => ''))(), currentDate: (formatMap[timeType] || (() => ''))(),
date: (formatMap[timeType] || (() => ''))() date: (formatMap[timeType] || (() => ''))()
}); }, () => {
this.triggerEvent('search', this.getParams()) this._emitPopupVisible(false)
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
}, },
...@@ -405,4 +441,4 @@ Component({ ...@@ -405,4 +441,4 @@ Component({
this.triggerEvent('search', this.getParams()) this.triggerEvent('search', this.getParams())
} }
} }
})
\ No newline at end of file \ No newline at end of file
})
...@@ -16,23 +16,27 @@ ...@@ -16,23 +16,27 @@
</view> </view>
</view> </view>
<!-- 年月日 --> <!-- 年月日 -->
<popup bind:hidePopup="cancel" bind:confirm="confirm" show="{{dateShow}}" title="{{titleEnum[timeType]}}" height="60vh"> <block wx:if="{{dateShow}}">
<block wx:if="{{timeType == 'date' || timeType == 'year-month'}}"> <popup bindcancel="cancel" bindconfirm="confirm" show="{{dateShow}}" title="{{titleEnum[timeType]}}" height="60vh">
<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 wx:if="{{timeType == 'date' || timeType == 'year-month'}}">
</block> <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 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" />
</block> </block>
</popup>
<van-calendar
id="calendar"
max-range="{{ 31 }}"
min-date="{{ minDate }}"
max-date="{{ maxDate }}"
show="{{ show }}"
type="range"
color="#2C66F7"
bind:confirm="onConfirm"
bind:close="onClose"
/>
\ No newline at end of file \ No newline at end of file
<!-- 周 -->
<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" />
</block>
</popup>
</block>
<block wx:if="{{show}}">
<van-calendar
id="calendar"
max-range="{{ 31 }}"
min-date="{{ minDate }}"
max-date="{{ maxDate }}"
show="{{ show }}"
type="range"
color="#2C66F7"
bind:confirm="onConfirm"
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()
}) })
}, },
......
...@@ -36,6 +36,10 @@ export default class WxCanvas { ...@@ -36,6 +36,10 @@ export default class WxCanvas {
addEventListener() { addEventListener() {
// noop // noop
} }
removeEventListener() {
// noop
}
attachEvent() { attachEvent() {
// noop // noop
......
...@@ -32,25 +32,45 @@ Component({ ...@@ -32,25 +32,45 @@ 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) {
this.ecComponent && this.ecComponent.init((canvas, width, height, dpr) => { if (this.chart) {
const chart = echarts.init(canvas, null, { this.setOption(this.chart, xData, yData, yData2)
width: width, return
height: height, }
devicePixelRatio: dpr // new this.ecComponent && this.ecComponent.init((canvas, width, height, dpr) => {
}); const chart = echarts.init(canvas, null, {
width: width,
height: height,
devicePixelRatio: dpr
});
this.chart = chart
this.setOption(chart, xData, yData, yData2); this.setOption(chart, xData, yData, yData2);
return chart; return chart;
}) })
}, },
setOption(chart, xData, yData, yData2) { setOption(chart, xData, yData, yData2) {
let maxSpan = xData.length < 10 ? 80 : 20 let maxSpan = xData.length < 10 ? 80 : 20
// let start= xData.length < 10 ? 50 : 80 // let start= xData.length < 10 ? 50 : 80
...@@ -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,11 +236,14 @@ Component({ ...@@ -216,11 +236,14 @@ Component({
yData, yData,
yData2 yData2
}) })
this.onInitChart(xData, yData, yData2) if (this._initTimer) clearTimeout(this._initTimer)
this._initTimer = setTimeout(() => {
this.onInitChart(xData, yData, yData2)
}, 0)
}, },
}, },
ready() { ready() {
// 获取组件 // 获取组件
this.ecComponent = this.selectComponent('#mychart-dom-line'); this.ecComponent = this.selectComponent('#mychart-dom-line');
} }
})
\ No newline at end of file \ No newline at end of file
})
...@@ -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!