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.

235 lines
6.9 KiB

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 () {
const { currentDay, lastMonthDay } = formatCurrentAndLastMonthDay();
console.log(currentDay, lastMonthDay, "sdflkjdslfkj");
this.setData({
day: lastMonthDay,
day2: currentDay
})
console.log(this.data.day, this.data.day2, "123");
this.getList();
}
}
},
data: {
orderBy:"",
sortList:[
{
lable:"收件数",
value:1,
type:0 //0为正常排序, 1为正序,2为倒叙
},
{
lable:"不满意",
value:2,
type:0
},
{
lable:"未解决",
value:3,
type:0
},
{
lable:"退件次数",
value:4,
type:0
},
{
lable:"超期退件",
value:5,
type:0
},
],
list: [],
sortNameList: [
{
label:"total",
value:1
},
{
label:"notSatisfiedTotal",
value:2
},
{
label:"unresolveTotal",
value:3
},
{
label:"overTimeTotal",
value:4
},
{
label:"returnTotal",
value:5
},
],
day: '',
day2: '',
showitem: 3,
},
ready() {
const { currentDay, lastMonthDay } = formatCurrentAndLastMonthDay();
console.log(currentDay,lastMonthDay,"sdflkjdslfkj");
this.setData({
day:lastMonthDay,
day2: currentDay
})
console.log(this.data.day,this.data.day2,"123");
this.getList()
},
methods: {
toSort(value){
let sortlist= value.currentTarget.dataset.sortlist
const evenNumbers= this.data.sortNameList.filter(item=>{
return item.value===sortlist.value
})[0].label
if (this.data.sortList[sortlist.value-1].type==1) {
this.data.sortList[sortlist.value-1].type=2
this.setData({
sortList:this.data.sortList,
orderBy:evenNumbers+"Down"
}
)
}else if (this.data.sortList[sortlist.value-1].type==2) {
let sortlist= value.currentTarget.dataset.sortlist
this.data.sortList[sortlist.value-1].type=1
this.setData({
sortList:this.data.sortList,
orderBy:evenNumbers+"Up"
}
)
}else{
this.data.sortList.map(item=>{
if (item.type==1||item.type==2) {
item.type=0
}
})
let sortlist= value.currentTarget.dataset.sortlist
this.data.sortList[sortlist.value-1].type=1
this.setData({
sortList:this.data.sortList,
orderBy:evenNumbers+"Up"
}
)
}
this.getEventList()
},
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',
})
},
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) {
console.log(this.data.day,this.data.day2,"这里的值");
let parm = {
orderBy: this.data.orderBy,
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',
})
}
}
}
});