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
3.7 KiB

// pages/infoList/infoList.js
const {
qualityListData,
IMG_BASE_URL,
} = require("../../../api/api");
const app = getApp()
const { routeLink } = require("../../../utils/route.js");
Page({
data: {
IMG_BASE_URL: IMG_BASE_URL,
statusBarHeight: app.globalData.statusBarHeight, //状态栏高度
navHeight: app.globalData.navHeight, //导航栏高度
keyWords: '', //关键字
searchData: [],
pageNum: 1, //分页页面
pageSize: 10, //分页条数
loadEnd: false, //加载到最底部
navTitle: '',
tabIndex: 0
},
onLoad(options) {
console.log('type',options.type)
this.setData({
type: options.type, //存贮状态l
userType: wx.getStorageSync('userType'),
userId: wx.getStorageSync('userId'),
PTpermission: wx.getStorageSync('PTpermission'),
})
wx.setNavigationBarTitle({
title: options.name,
});
this.setData({
navTitle: options.name
});
},
onShow() {
this.setData({
pageNum:1,
});
this.getList()
},
//tab切换
changeStatus(e){
let type = e.currentTarget.dataset.index
this.setData({
tabIndex: type,
pageNum: 1
})
this.getList()
},
/** 下拉刷新 **/
onPullDownRefresh(e) {
this.setData({
pageNum: 1,
pageSize: 10,
loadEnd: false,
})
this.getList()
},
/** 页面触底上拉刷新 **/
onReachBottom(e) {
if (!this.data.loadEnd) {
this.getList()
} else {
wx.showToast({
title: '暂无更多数据',
icon: 'none',
duration: 1500
})
}
},
/** 获取电站列表 **/
getList(e) {
let status = '1,2'
if(this.data.tabIndex == '0'){
status = '1,2' //验收中
}else if(this.data.tabIndex == '1'){
status = '5' //已完成
}
wx.showLoading({
title: '加载中',
})
qualityListData({
userId: wx.getStorageSync('userId'),
smallCondition: this.data.searchData.length > 0 ? this.data.searchData + "" : "",
status: status,
page: this.data.pageNum,
limit: this.data.pageSize,
}).then((res) => {
wx.hideLoading()
wx.stopPullDownRefresh()
if (res.code == 200) {
this.data.loadEnd = res.data.length < this.data.pageSize
if (this.data.pageNum == 1) {
this.data.rows = res.data
} else {
this.data.rows = this.data.rows.concat(res.data)
}
if (!this.data.loadEnd) {
this.data.pageNum++;
}
this.setData({
list: this.data.rows,
loadEnd: this.data.loadEnd,
})
} else {
wx.showToast({
title: res.errMsg,
icon: 'none'
})
}
})
},
/** 搜索 **/
keyWordsSearch(res) {
this.setData({
searchData: [],
})
const search = res.detail; //搜索内容
this.setData({
searchData: this.data.searchData.concat(search),
pageNum:1
})
wx.pageScrollTo({
scrollTop: 0,
})
this.getList()
},
/** 复制 **/
copy(e) {
const code = e.currentTarget.dataset.code;
wx.setClipboardData({
data: code,
success(res) {
wx.showToast({
title: '已复制',
icon: 'none'
})
}
})
},
/** 派工-按钮 **/
bindDispatch(e){
routeLink("/other/pages/dispatch/dispatch?projectId=" + e.currentTarget.dataset.projectid);
},
/** 抽检验收-按钮 **/
bindAccept(e){
routeLink("/other/pages/qualityAcceptList/qualityAcceptList?projectId=" + e.currentTarget.dataset.projectid);
},
/** 查看-按钮 **/
bindAcceptSee(e){
routeLink("/other/pages/qualityAcceptDetail/qualityAcceptDetail?projectId=" + e.currentTarget.dataset.projectid);
},
})