|
|
|
import {event12345Rates} from "../../../../utils/statisticsApi";
|
|
|
|
const formatNumber = n => (n < 10 ? '0' : '') + n;
|
|
|
|
|
|
|
|
const formatCurrentAndLastMonthDay = () => {
|
|
|
|
const today = new Date();
|
|
|
|
const year = today.getFullYear();
|
|
|
|
const month = today.getMonth() + 1;
|
|
|
|
const day = today.getDate();
|
|
|
|
|
|
|
|
// 上个月的日期
|
|
|
|
const lastMonthDate = new Date(year, month - 1, day);
|
|
|
|
const lastYear = lastMonthDate.getFullYear();
|
|
|
|
const lastMonth = lastMonthDate.getMonth() + 1;
|
|
|
|
const lastDay = lastMonthDate.getDate();
|
|
|
|
return {
|
|
|
|
currentDay: [year, month, day].map(formatNumber).join('-'),
|
|
|
|
lastMonthDay: [lastYear, lastMonth-1, lastDay].map(formatNumber).join('-'),
|
|
|
|
};
|
|
|
|
};
|
|
|
|
Component({
|
|
|
|
properties: {
|
|
|
|
curVal: {
|
|
|
|
type: String,
|
|
|
|
value: '1',
|
|
|
|
observer: function () {
|
|
|
|
this.getList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
data: {
|
|
|
|
list: [],
|
|
|
|
day: '',
|
|
|
|
day2: '',
|
|
|
|
showitem: 3,
|
|
|
|
},
|
|
|
|
ready() {
|
|
|
|
const { currentDay, lastMonthDay } = formatCurrentAndLastMonthDay();
|
|
|
|
this.setData({
|
|
|
|
day:lastMonthDay,
|
|
|
|
day2: currentDay
|
|
|
|
})
|
|
|
|
this.getList()
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
toNumber(data) {
|
|
|
|
console.log(data.currentTarget.dataset,"dskljflksdfjl");
|
|
|
|
let type=data.currentTarget.dataset.type
|
|
|
|
let staffId=data.currentTarget.dataset.staffid
|
|
|
|
let token=wx.getStorageSync('token')
|
|
|
|
wx.navigateTo({
|
|
|
|
url: '/pages/webView/webView?worktoken='+token+'&staffId='+staffId+'&type='+type+'&day='+this.data.day+'&day2='+this.data.day2,
|
|
|
|
})
|
|
|
|
},
|
|
|
|
onChange(e) {
|
|
|
|
this.setData({
|
|
|
|
day: e.detail.value
|
|
|
|
})
|
|
|
|
},
|
|
|
|
onChange2(e) {
|
|
|
|
this.setData({
|
|
|
|
day2: e.detail.value
|
|
|
|
})
|
|
|
|
},
|
|
|
|
onSearch(){
|
|
|
|
if(this.data.day>this.data.day2){
|
|
|
|
wx.showToast({
|
|
|
|
title: '起止日期错误',
|
|
|
|
icon: 'error',
|
|
|
|
duration: 2000
|
|
|
|
})
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
this.getList()
|
|
|
|
},
|
|
|
|
showall(){
|
|
|
|
if(this.data.showitem==99999){
|
|
|
|
this.setData({
|
|
|
|
showitem: 3
|
|
|
|
})
|
|
|
|
}else{
|
|
|
|
this.setData({
|
|
|
|
showitem: 99999
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
getList() {
|
|
|
|
if (this.data.curVal == '1') {
|
|
|
|
this.getEventList(false)
|
|
|
|
} else {
|
|
|
|
this.getEventList(false)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
getEventList(deptFlag) {
|
|
|
|
let parm = {
|
|
|
|
startDate: this.data.day.toString() + ' ' + '00:00:00',
|
|
|
|
endDate: this.data.day2.toString() + ' ' + '23:59:59',
|
|
|
|
usableFlag: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
if(this.data.curVal == '1'){
|
|
|
|
parm.recountFlag=1
|
|
|
|
}
|
|
|
|
event12345Rates(parm).then(res => {
|
|
|
|
console.log('++++++++++++',res.data)
|
|
|
|
// res.data.list.forEach(item => {
|
|
|
|
// item.reportTime = this.formatTime(item.reportTime)
|
|
|
|
// })
|
|
|
|
this.setData({
|
|
|
|
list: res.data
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
formatTime(date) {
|
|
|
|
if (date) {
|
|
|
|
let _date = new Date(date)
|
|
|
|
let M = _date.getMonth() - 0 + 1 > 10 ? _date.getMonth() - 0 + 1 : '0' + (_date.getMonth() - 0 + 1)
|
|
|
|
let D = _date.getDate() > 10 ? _date.getDate() : '0' + _date.getDate()
|
|
|
|
return M + '-' +D
|
|
|
|
}
|
|
|
|
return ''
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
gotopage(e) {
|
|
|
|
if (this.data.stayVal === '1') {
|
|
|
|
wx.navigateTo({
|
|
|
|
url: '/subpages/statistics/pages/event/detail/detail?id=' + e.currentTarget.dataset.id+'&is12345=2',
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
wx.navigateTo({
|
|
|
|
url: '/subpages/statistics/pages/demand/detail/detail?id=' + e.currentTarget.dataset.id+'&type=1',
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|