295 lines
7.0 KiB
JavaScript
295 lines
7.0 KiB
JavaScript
// pages/queryList/queryList.js
|
|
const $api = require('../../utils/api').API;
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
pageNum: 1,
|
|
pageSize: 10,
|
|
//所有数据
|
|
list: [],
|
|
isRefreshing:false,//下拉刷新
|
|
isFinish:false,//下拉加载,
|
|
//搜索
|
|
typeOpt:[
|
|
{text:'请选择类型',value:''},
|
|
{text:'党务及意识形态',value:'党务及意识形态'},
|
|
{text:'党风廉政建设',value:'党风廉政建设'},
|
|
{text:'日常考核指标',value:'日常考核指标'},
|
|
{text:'季度考核指标',value:'季度考核指标'},
|
|
],
|
|
deptOpt:[],
|
|
targetOpt:[],
|
|
personOpt:[],
|
|
searchForm:{
|
|
deptId:'',
|
|
type:'',
|
|
target:'',
|
|
head:''
|
|
},
|
|
moreSearchShow:false,
|
|
targetShow:false,
|
|
mainActiveIndex:0,
|
|
activeId:null,
|
|
targetValue:'请先选择类型'
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad(options) {
|
|
this.informPort();
|
|
this.loadDeptData();
|
|
this.loadPersonData();
|
|
},
|
|
|
|
//重置
|
|
handleReset(){
|
|
this.setData({
|
|
"searchForm.type":'',
|
|
"searchForm.deptId":'',
|
|
"searchForm.target":'',
|
|
"searchForm.head":'',
|
|
pageNum: 1,
|
|
pageSize: 10,
|
|
mainActiveIndex:0,
|
|
activeId:null,
|
|
targetValue:'请先选择类型',
|
|
targetOpt:[]
|
|
});
|
|
this.informPort();
|
|
},
|
|
|
|
//类型搜索
|
|
handleSearchType(e){
|
|
this.setData({
|
|
"searchForm.type":e.detail
|
|
})
|
|
if(e.detail){
|
|
this.loadTargetData({type:e.detail});
|
|
}
|
|
this.informPort();
|
|
},
|
|
//更多查询
|
|
handleMoreSearchOpen(){
|
|
this.setData({
|
|
moreSearchShow:true
|
|
})
|
|
},
|
|
handleMoreSearchClose(){
|
|
this.setData({
|
|
moreSearchShow:false
|
|
})
|
|
},
|
|
//部门搜索
|
|
handleSearchDept(e){
|
|
this.setData({
|
|
"searchForm.deptId":e.detail,
|
|
moreSearchShow:false
|
|
})
|
|
this.informPort();
|
|
},
|
|
//指标搜索
|
|
handleTargetOpen(){
|
|
this.setData({
|
|
targetShow:true
|
|
})
|
|
},
|
|
handleTargetClose(){
|
|
this.setData({
|
|
targetShow:false
|
|
})
|
|
},
|
|
handleTargetNav(e){
|
|
this.setData({
|
|
mainActiveIndex:e.detail.index
|
|
})
|
|
},
|
|
handleTargettem(e){
|
|
this.setData({
|
|
"searchForm.target":e.detail.text,
|
|
activeId:e.detail.id,
|
|
targetValue:e.detail.text,
|
|
targetShow:false,
|
|
moreSearchShow:false
|
|
})
|
|
this.informPort();
|
|
},
|
|
//人员搜索
|
|
handleSearchPerson(e){
|
|
this.setData({
|
|
"searchForm.head":e.detail,
|
|
moreSearchShow:false
|
|
})
|
|
this.informPort();
|
|
},
|
|
|
|
//上拉加载
|
|
onLoadMore(){
|
|
let _num = this.data.pageNum+1;
|
|
this.setData({
|
|
pageNum:_num
|
|
});
|
|
this.informPort();
|
|
},
|
|
//下拉刷新
|
|
onRefresh(){
|
|
this.setData({
|
|
list:[],
|
|
pageNum:1,
|
|
isFinish:false
|
|
});
|
|
this.informPort();
|
|
},
|
|
/**
|
|
* 列表接口
|
|
*/
|
|
informPort() {
|
|
var that = this; // //防止this指向问题
|
|
wx.showLoading({
|
|
title: '加载中',
|
|
});
|
|
let _param = {
|
|
pageSize:that.data.pageSize,
|
|
pageNum:that.data.pageNum,
|
|
type:that.data.searchForm.type,
|
|
deptId:that.data.searchForm.deptId,
|
|
head:that.data.searchForm.head,
|
|
target: that.data.searchForm.target
|
|
}
|
|
$api.queryList(_param).then(res => {
|
|
if(res.code === 0){
|
|
wx.hideLoading();
|
|
let _data = res.rows;
|
|
_data.forEach(item => {
|
|
item.point = item.nowScore?(item.nowScore/item.score).toFixed(2)*100+'%':'0%';
|
|
})
|
|
if(that.data.pageNum > 1){ //上拉加载的逻辑
|
|
if(_data.length == 0){
|
|
that.setData({
|
|
isFinish:true
|
|
})
|
|
}
|
|
_data = that.data.list.concat(_data); //数据合并
|
|
that.setData({
|
|
list:_data
|
|
})
|
|
}else{
|
|
if(_data.length < that.data.pageSize){
|
|
that.setData({
|
|
list:_data,
|
|
isRefreshing:false,
|
|
isFinish:true
|
|
})
|
|
}else{
|
|
that.setData({
|
|
list:_data,
|
|
isRefreshing:false,
|
|
})
|
|
}
|
|
}
|
|
}
|
|
});
|
|
},
|
|
//加载指标
|
|
loadTargetData(param){
|
|
let _this = this;
|
|
$api.queryTree(param).then(res => {
|
|
if(res.code === 0){
|
|
res.data.forEach((item,index) => {
|
|
item.index = index;
|
|
})
|
|
_this.setData({
|
|
targetOpt:res.data
|
|
})
|
|
}
|
|
})
|
|
},
|
|
//加载部门
|
|
loadDeptData(){
|
|
let _this = this;
|
|
$api.deptList({}).then(res => {
|
|
if(res.code === 0){
|
|
let _newData = [{text:'请选择部门',value:''}];
|
|
res.data.forEach(item => {
|
|
_newData.push({
|
|
text:item.deptName,
|
|
value:item.deptId
|
|
})
|
|
})
|
|
_this.setData({
|
|
deptOpt:_newData
|
|
})
|
|
}
|
|
})
|
|
},
|
|
//加载人员
|
|
loadPersonData(){
|
|
let _this = this;
|
|
$api.personList({}).then(res => {
|
|
if(res.code === 0){
|
|
let _newData = [{text:'请选择人员',value:''}];
|
|
res.data.forEach(item => {
|
|
_newData.push({
|
|
text:item.name,
|
|
value:item.id
|
|
})
|
|
})
|
|
_this.setData({
|
|
personOpt:_newData
|
|
})
|
|
}
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage() {
|
|
|
|
}
|
|
}) |