榆山
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.
 
 

240 lines
5.6 KiB

import {
$wuxSelect
} from '../../../../dist/index'
import {
getDeptInfo,
getVerificationLogs
} from '../../../../api/pointManagement.js'
let util = require('../../../../utils/util.js')
Page({
data: {
visibleTimeLeft: false,
visibleTimeRight: false,
/****时间选择器 *****/
value1: [],
value2: [],
value3: "",
displayValue1: '请选择开始时间',
displayValue2: '请选择截至时间',
displayValue3: '请选择所属网格',
optionsGrid: [],
valueRight: [],
lang: 'zh_CN',
typeKey: "grid_party",
pageIndex: 1,
pageSize: 15,
startTime: "",
endTime: "",
deptId: '',
pointList: [],
loadMoreVisible: false, //false
loadMoreType: "none",
nodata: false,
pointsTotal: 0,
optionsGridOrgin: [],
},
onLoad: function (options) {
this.getDeptInfo()
this.getVerificationLogs()
console.log('当天时间', util.getData())
this.setData({
value1: util.getData().split('-'),
value2: util.getData().split('-'),
})
},
selectTapLeft() {
this.setData({
visibleTimeLeft: true,
});
},
selectTapRight() {
this.setData({
visibleTimeRight: true,
});
},
selectTapGrid() {
wx.showLoading({
duration: 2000
})
$wuxSelect('#wux-select1').open({
options: this.data.optionsGrid,
onConfirm: (value, index, options) => {
console.log('onConfirm', value, index, options)
if (index !== -1) {
this.setData({
value3: value,
displayValue3: options[index],
})
}
this.setData({
deptId: this.data.optionsGridOrgin[index].id,
pointList: [],
pageIndex: 1
})
this.getVerificationLogs()
},
})
},
setValue(values, key) {
this.setData({
[`value${key}`]: values.value,
[`displayValue${key}`]: values.label,
// [`displayValue${key}`]: values.displayValue.join(' '),
})
},
onConfirmLeft(e) {
const {
mode
} = e.currentTarget.dataset
this.setValue(e.detail, mode)
this.setData({
pageIndex: 1,
visibleTimeLeft: false,
pointList: [],
startTime: this.data.displayValue1
})
this.getVerificationLogs()
},
onConfirmRight(e) {
const {
mode
} = e.currentTarget.dataset
this.setValue(e.detail, mode)
this.setData({
pageIndex: 1,
visibleTimeRight: false,
pointList: [],
endTime: this.data.displayValue2
})
this.getVerificationLogs()
},
cancelTimeLeft() {
this.setData({
visibleTimeLeft: false,
})
},
cancelTimeRight() {
this.setData({
visibleTimeRight: false,
})
},
clearValue1() {
this.setData({
startTime: '',
displayValue1: "请选择开始时间",
pointList: [],
value1: util.getData().split('-'),
})
this.getVerificationLogs()
},
clearValue2() {
this.setData({
endTime: '',
displayValue2: "请选择截至时间",
pointList: [],
value2: util.getData().split('-'),
})
this.getVerificationLogs()
},
clearValue3() {
this.setData({
deptId: '',
displayValue3: '请选择所属网格',
pointList: [],
})
this.getVerificationLogs()
},
// 所属网格
getDeptInfo() {
getDeptInfo(this.data.typeKey).then((res) => {
console.log('所属网格', res)
let optionsGrid = []
res.data.forEach((item) => {
optionsGrid.push(item.name)
})
this.setData({
optionsGrid,
optionsGridOrgin: res.data
})
}).catch((err) => {})
},
// 工作端积分核销记录接口
// 获取居民兑换记录接口
getVerificationLogs() {
// 判断时间问题
// let startTime = 0
// let endTime = 0
// this.data.value1.forEach((item) => {
// startTime += Number(item)
// })
// this.data.value2.forEach((item) => {
// endTime += Number(item)
// })
// if (startTime > endTime) {
// wx.showToast({
// icon: 'none',
// title: '开始时间不能晚于截止时间',
// duration: 1500,
// })
// return
// } else if (startTime < endTime) {
// this.setData({
// pointList: [],
// })
// }
/**
* 工作端积分核销记录接口
* @param pageIndex Number 页码
* @param pageSize Number 页容量
* @param startTime 开始时间
* @param endTime 结束时间
* @param deptId 部门ID
*/
let para = {
pageIndex: this.data.pageIndex,
pageSize: this.data.pageSize,
startTime: this.data.startTime,
endTime: this.data.endTime,
deptId: this.data.deptId
}
this.setData({
loadMoreVisible: true,
nodata: false,
loadMoreType: "loading",
})
getVerificationLogs(para).then((res) => {
this.setData({
// loadMoreVisible: false,
loadMoreType: res.data.verificationLogs.length === this.data.pageSize ? 'loading' : 'none',
pointList: this.data.pointList.concat(res.data.verificationLogs),
pointsTotal: res.data.pointsTotal
})
if (this.data.pointList.length == 0) {
this.setData({
loadMoreVisible: false,
nodata: true
})
}
}).catch(() => {
this.setData({
loadMoreVisible: false,
nodata: true,
})
})
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
console.log('下拉了')
if (this.data.loadMoreType === 'loading') {
this.setData({
loadMoreVisible: true,
})
this.data.pageIndex += 1
this.getVerificationLogs()
}
},
})