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.

160 lines
4.2 KiB

import {
getUnsatisfiedCategory,
getUnsatisfiedMattersList,
satisfactionMonthGroupForResident
} from "../../../../../utils/statisticsApi";
const formatTime = date => {
const year = date.getFullYear()
const month = date.getMonth() + 1
return [year, month].map(formatNumber).join('-')
}
const formatTime2 = date => {
const year = date.getFullYear()
const month = date.getMonth() + 1
const day = date.getDate()
return [year, month, day].map(formatNumber).join('-')
}
const formatNumber = n => {
n = n.toString()
return n[1] ? n : '0' + n
}
Page({
data: {
month: '',
typeIndex: -1,
typeList: [],
satisfactionSourceIndex: 0,
satisfactionSourceOptions: [{
value: '',
label: '按来源',
}, {
value: 'satisfaction_12345',
label: '12345投诉',
color: '#FFB73C',
}, {
value: 'satisfaction_province',
label: '省满意度调查',
color: '#64C1FF'
}, {
value: 'satisfaction_community',
label: '社区满意度自查',
color: '#08EBAE'
}],
satisfactionCategory: 0,
satisfactionCategoryOptions: [{
value: '',
label: '按类型'
}],
list: {},
total: 0,
pageNo: 1,
pageSize: 20,
},
onLoad(options) {
this.setData({
month: formatTime(new Date())
})
this.getList()
},
nextMonth() {
console.log('next');
if (this.data.list[this.data.month].data.length < this.data.list[this.data.month].total) {
this.setData({
pageNo: this.data.pageNo + 1
})
this.getList()
return
}
let now = new Date(this.data.month)
this.setData({
pageNo: 1,
month: formatTime(new Date(now.getFullYear(), now.getMonth() - 1))
})
this.getList()
},
prevMonth() {
console.log('prev');
/* let now = new Date(this.data.month)
let now2 = new Date()
if (now.getMonth() < now2) {
this.setData({
month: formatTime(new Date(now.getFullYear(), now.getMonth() + 1))
})
this.getList()
}*/
},
sourceChange(e) {
console.log(e)
this.getSatisfactionCategoryOptions()
},
getSatisfactionCategoryOptions() {
this.setData({
satisfactionCategory: -1,
satisfactionCategoryOptions: []
})
getUnsatisfiedCategory({
satisfactionSource: this.data.satisfactionSourceOptions[this.data.satisfactionSourceIndex].value
}).then(({ data }) => {
this.setData({
satisfactionCategoryOptions: [
{
value: '',
label: '按类型'
},
...data.map(item => {
return {
label: item.categoryName,
value: item.categoryCode
}
})
]
})
})
},
onConfirm() {
this.setData({
list: {},
})
this.getList();
},
getList() {
let params = {
pageNo: this.data.pageNo,
pageSize: this.data.pageSize,
month: this.data.month,
satisfactionSource: this.data.satisfactionSourceIndex >= 0 ? this.data.satisfactionSourceOptions[this.data.satisfactionSourceIndex].value : '',
satisfactionCategory: this.data.satisfactionCategory >= 0 ? this.data.satisfactionCategoryOptions[this.data.satisfactionCategory].value : '',
}
let list = this.data.list
getUnsatisfiedMattersList(params).then(({ data }) => {
list[params.month] = {
data: this.data.list[params.month] ? this.data.list[params.month].data.concat(data.list) : data.list,
total: data.total,
month: params.month.split('-')[1],
}
this.setData({
list
})
this.getCount(params);
})
},
getCount({ month }) {
let now = new Date(month);
var startTime = formatTime2(new Date(now.getFullYear(), now.getMonth(), 1));
var endTime = formatTime2(new Date(now.getFullYear(), now.getMonth() + 1, 0, 23, 59, 59));
satisfactionMonthGroupForResident({
startTime, endTime
}).then(({ data }) => {
this.setData(JSON.parse(`{"list.${month}.sumNumber": "${data.sumNumber}","list.${month}.sumPeople": "${data.sumPeople}"}`))
})
},
gotopage(e) {
wx.navigateTo({
url: '/subpages/statistics/pages/dissatisfied/detial/detail?id=' + JSON.stringify(e.currentTarget.dataset.id)
})
}
})