274 lines
7.2 KiB
JavaScript
274 lines
7.2 KiB
JavaScript
import UserApi from '../../assets/js/http/userApi'
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
statusBarHeight: wx.getSystemInfoSync()['statusBarHeight'],
|
|
index: 0,
|
|
type: '', // project 是来款项目 work 是工作组 ziliao是资料网员 draft 是起草组
|
|
list: [], // 项目列表
|
|
searchParams: {
|
|
pageNo: 1,
|
|
pageSize: 10,
|
|
needInvoice: '', // 是否需要发票 0 4
|
|
pack: '', // 是否打包 0 1
|
|
year: '', // 运行年份
|
|
particularYear:'',// 资料网元的运行年份,
|
|
// 创建时间倒叙排序
|
|
column:'createTime',
|
|
order:'desc',
|
|
pageTitle:'项目'
|
|
}
|
|
},
|
|
// 编辑联系人信息
|
|
editContactsInfo(e) {
|
|
// 跳转到联系人页面
|
|
let params = ''
|
|
switch (this.data.type) {
|
|
case 'work':
|
|
params = `workingGroupId=${e.currentTarget.dataset.project.workingGroupId}`
|
|
break
|
|
case 'draft':
|
|
params = `draftingGroupId=${e.currentTarget.dataset.project.draftingGroupId}`
|
|
break
|
|
}
|
|
wx.navigateTo({
|
|
url: `../contacts/contacts?id=${e.currentTarget.dataset.project.id}&type=${this.data.type}&` + params,
|
|
})
|
|
|
|
},
|
|
goBack(){
|
|
wx.navigateBack()
|
|
},
|
|
// 发票改变
|
|
bindNeedInvoiceChange(e){
|
|
console.log(e.detail.value)
|
|
this.data.searchParams.pageNo = 1
|
|
if(e.detail.value == 0) {
|
|
this.setData({
|
|
"searchParams.needInvoice": 1,
|
|
})
|
|
}else{
|
|
this.setData({
|
|
"searchParams.needInvoice": 0,
|
|
})
|
|
}
|
|
this.loadData()
|
|
},
|
|
// 打包改变
|
|
bindPackChange(e){
|
|
this.data.searchParams.pageNo = 1
|
|
if(e.detail.value == 0) {
|
|
this.setData({
|
|
"searchParams.pack": 1,
|
|
})
|
|
}else{
|
|
this.setData({
|
|
"searchParams.pack": 0,
|
|
})
|
|
}
|
|
this.loadData()
|
|
},
|
|
bindDateChange(e){
|
|
this.data.searchParams.pageNo = 1
|
|
// 资料网员的年份查询字段与其他的不一样
|
|
if(this.data.type === 'ziliao'){
|
|
this.setData({
|
|
"searchParams.particularYear": e.detail.value
|
|
})
|
|
}else{
|
|
this.setData({
|
|
"searchParams.year": e.detail.value
|
|
})
|
|
}
|
|
this.loadData()
|
|
},
|
|
// 项目详情
|
|
projectDetail(e){
|
|
// 工作组id
|
|
const workingGroupId = e.currentTarget.dataset.project.workingGroupId
|
|
// 起草组id
|
|
const draftingGroupId = e.currentTarget.dataset.project.draftingGroupId
|
|
if (workingGroupId) {
|
|
wx.navigateTo({
|
|
url: `../projectDetail/projectDetail?id=${e.currentTarget.dataset.project.id}&type=${this.data.type}&workingGroupId=${workingGroupId}`,
|
|
})
|
|
} else if (draftingGroupId) {
|
|
wx.navigateTo({
|
|
url: `../projectDetail/projectDetail?id=${e.currentTarget.dataset.project.id}&type=${this.data.type}&draftingGroupId=${draftingGroupId}`,
|
|
})
|
|
}
|
|
},
|
|
loadData(){
|
|
const that = this
|
|
wx.showToast({
|
|
title: '加载中...',
|
|
icon: 'loading'
|
|
})
|
|
if(this.data.type == 'project'){
|
|
UserApi.projectList(this.data.searchParams).then(res=>{
|
|
if(res.success){
|
|
// 搜索时,把原数据清空,重新筛选
|
|
if(that.data.searchParams.pageNo === 1) {
|
|
that.setData({
|
|
list: []
|
|
})
|
|
}
|
|
if(res.result.records && res.result.records.length){
|
|
that.setData({
|
|
list: [...that.data.list, ...res.result.records]
|
|
})
|
|
}
|
|
}
|
|
}).catch(err=>{
|
|
wx.showToast({
|
|
title: '加载失败',
|
|
icon: 'none',
|
|
duration: 2000
|
|
})
|
|
})
|
|
}else if(this.data.type == 'work'){
|
|
UserApi.workList(this.data.searchParams).then(res=>{
|
|
if(res.success){
|
|
// 这里没有返回负责人的id
|
|
// 后端直接返回
|
|
// res.result.records.map(async tt => {
|
|
// // tt.principalIdA
|
|
// let userInfo = await this.getUserInfoById('1432214744864772098')
|
|
// tt.userInfo = userInfo
|
|
// tt.name = userInfo.username
|
|
// })
|
|
console.log(res.result.records);
|
|
// 搜索时,把原数据清空,重新筛选
|
|
if(that.data.searchParams.pageNo === 1) {
|
|
that.setData({
|
|
list: []
|
|
})
|
|
}
|
|
if(res.result.records && res.result.records.length){
|
|
that.setData({
|
|
list: [...that.data.list, ...res.result.records]
|
|
})
|
|
}
|
|
console.log(that.data.list,'this.data.list');
|
|
}
|
|
}).catch(err=>{
|
|
wx.showToast({
|
|
title: '加载失败',
|
|
icon: 'none',
|
|
duration: 2000
|
|
})
|
|
})
|
|
}else if(this.data.type == 'ziliao'){
|
|
UserApi.queryDataMemberList(this.data.searchParams).then(res=>{
|
|
if(res.success){
|
|
// 搜索时,把原数据清空,重新筛选
|
|
if(this.data.searchParams.pageNo === 1) {
|
|
this.setData({
|
|
list: []
|
|
})
|
|
}
|
|
if(res.result.records && res.result.records.length){
|
|
this.setData({
|
|
list: [...this.data.list, ...res.result.records]
|
|
})
|
|
}
|
|
}
|
|
}).catch(err=>{
|
|
wx.showToast({
|
|
title: '加载失败',
|
|
icon: 'none',
|
|
duration: 2000
|
|
})
|
|
})
|
|
} else if(this.data.type == 'draft'){
|
|
UserApi.draftList(this.data.searchParams).then(res=>{
|
|
if(res.success){
|
|
// 搜索时,把原数据清空,重新筛选
|
|
if(that.data.searchParams.pageNo === 1) {
|
|
that.setData({
|
|
list: []
|
|
})
|
|
}
|
|
if(res.result.records && res.result.records.length){
|
|
that.setData({
|
|
list: [...that.data.list, ...res.result.records]
|
|
})
|
|
}
|
|
}
|
|
}).catch(err=>{
|
|
wx.showToast({
|
|
title: '加载失败',
|
|
icon: 'none',
|
|
duration: 2000
|
|
})
|
|
})
|
|
}
|
|
},
|
|
/**
|
|
* @description 通过用户id获取用户信息
|
|
* @param: id 用户id
|
|
*/
|
|
getUserInfoById(id){
|
|
return new Promise(resolve => {
|
|
let result = {}
|
|
UserApi.getUserInfoNolimit({id:id}).then(res => {
|
|
if(res.success){
|
|
result = res.result
|
|
}
|
|
}).finally( () => {
|
|
resolve(result)
|
|
})
|
|
})
|
|
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
this.data.type = options.type
|
|
let pageTitle = ''
|
|
switch(options.type){
|
|
case 'ziliao':
|
|
pageTitle = '资料网员'
|
|
break
|
|
case 'work':
|
|
pageTitle = '工作组'
|
|
break
|
|
case 'draft':
|
|
pageTitle = '起草组'
|
|
break
|
|
default :
|
|
pageTitle = '项目'
|
|
break
|
|
}
|
|
this.setData({
|
|
pageTitle: pageTitle,
|
|
type: this.data.type
|
|
})
|
|
|
|
this.loadData()
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
// 联系人操作完返回重新获取数据
|
|
this.setData({
|
|
searchParams: Object.assign({}, this.data.searchParams, {
|
|
pageNo: 1
|
|
})
|
|
})
|
|
this.loadData()
|
|
},
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
this.data.searchParams.pageNo++
|
|
this.loadData()
|
|
},
|
|
})
|