Commit c4f48212 by zhangxw

优化修改

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