epmet 工作端 小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

138 lines
4.2 KiB

10 months ago
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('-'),
};
};
10 months ago
Component({
properties: {
curVal: {
type: String,
value: '1',
observer: function () {
this.getList();
}
}
},
data: {
list: [],
day: '',
day2: '',
showitem: 3,
},
ready() {
const { currentDay, lastMonthDay } = formatCurrentAndLastMonthDay();
10 months ago
this.setData({
day:lastMonthDay,
day2: currentDay
10 months ago
})
this.getList()
},
methods: {
8 months ago
toNumber(data) {
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+'&Hotline='+'https://epmet-preview.elinkservice.cn/epmet-work-h5/#/Hotline',
8 months ago
})
},
10 months ago
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) {
10 months ago
let parm = {
10 months ago
startDate: this.data.day.toString() + ' ' + '00:00:00',
endDate: this.data.day2.toString() + ' ' + '23:59:59',
usableFlag: true,
10 months ago
}
if(this.data.curVal == '1'){
parm.recountFlag=1
}
event12345Rates(parm).then(res => {
10 months ago
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',
})
}
}
}
});
8 months ago