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.
232 lines
6.0 KiB
232 lines
6.0 KiB
5 years ago
|
import regeneratorRuntime from '../../../utils/runtime.js'
|
||
|
var api = require('../../../api/common.js')
|
||
|
var _api = require('../../../api/itemDetail.js')
|
||
|
var utils = require('../../../utils/util.js');
|
||
|
import {
|
||
|
listByUserId,
|
||
|
read
|
||
|
} from '../../../api/projectprogress.'
|
||
|
const app = getApp()
|
||
|
Page({
|
||
|
data: {
|
||
|
timestamp: '', //时间戳
|
||
|
pageIndex: 1,
|
||
|
pageSize: 10,
|
||
|
tabs: [{
|
||
|
key: 'tab1',
|
||
|
title: 'Tab 1',
|
||
|
},
|
||
|
{
|
||
|
key: 'tab2',
|
||
|
title: 'Tab 2',
|
||
|
}
|
||
|
],
|
||
|
key: 'tab1',
|
||
|
projrctItems: [], //议题项目列表
|
||
|
projrctItemslength: 0,
|
||
|
listByUserId: [], //工作日志
|
||
|
listByUserIdlength: 0,
|
||
|
loadVisible: true,
|
||
|
loadType: 'more',
|
||
|
isShow: false,
|
||
|
},
|
||
|
/**
|
||
|
* 生命周期函数--监听页面显示
|
||
|
*/
|
||
|
onShow: function() {
|
||
|
console.log(this.data.key)
|
||
|
var timestamp = utils.formatTimestamp(new Date());
|
||
|
this.setData({
|
||
|
timestamp: timestamp,
|
||
|
pageIndex: 1,
|
||
|
loadType: 'more',
|
||
|
isShow: false,
|
||
|
projrctItems: [], //议题/项目置空
|
||
|
listByUserId: [], //工作日志置空
|
||
|
projrctItemslength: 0,
|
||
|
listByUserIdlength: 0,
|
||
|
})
|
||
|
if (this.data.key == 'tab1') {
|
||
|
this.getItemNotice()
|
||
|
} else if (this.data.key == 'tab2') {
|
||
|
this.listByUserId() //工作日志
|
||
|
}
|
||
|
},
|
||
|
// /**
|
||
|
// * 生命周期函数--监听页面加载
|
||
|
// */
|
||
|
// onLoad: function(options) {
|
||
|
// var timestamp = utils.formatTimestamp(new Date());
|
||
|
// this.setData({
|
||
|
// timestamp: timestamp
|
||
|
// })
|
||
|
// this.getItemNotice()
|
||
|
// },
|
||
|
// tab切换
|
||
|
async onTabsChange(e) {
|
||
|
const {
|
||
|
key
|
||
|
} = e.detail
|
||
|
const index = this.data.tabs.map((n) => n.key).indexOf(key)
|
||
|
this.setData({
|
||
|
key,
|
||
|
index,
|
||
|
pageIndex: 1,
|
||
|
loadType: 'more',
|
||
|
isShow: false,
|
||
|
projrctItems: [], //议题/项目置空
|
||
|
listByUserId: [], //工作日志置空
|
||
|
projrctItemslength: 0,
|
||
|
listByUserIdlength: 0,
|
||
|
})
|
||
|
if (this.data.key == 'tab1') {
|
||
|
await this.getItemNotice()
|
||
|
} else if (this.data.key == 'tab2') {
|
||
|
await this.listByUserId() //工作日志
|
||
|
}
|
||
|
},
|
||
|
// 项目议题列表
|
||
|
async getItemNotice() {
|
||
|
let that = this
|
||
|
let deptId = ''
|
||
|
let currentGrid = wx.getStorageSync('currentGrid')
|
||
|
if (currentGrid !== undefined && currentGrid !== 'undefined' && currentGrid !== '') {
|
||
|
deptId = currentGrid.deptId
|
||
|
}
|
||
|
let params = {
|
||
|
deptId: deptId,
|
||
|
pageIndex: that.data.pageIndex,
|
||
|
pageSize: app.globalData.pageSize,
|
||
|
timestamp: that.data.timestamp
|
||
|
}
|
||
|
api.getItemNotice(params).then(function(res) {
|
||
|
let temp = res.data;
|
||
|
for (let i = 0; i < res.data.length; i++) {
|
||
|
if (res.data[i].whistleDeps) {
|
||
|
temp[i].whistleDepsArray = JSON.parse([res.data[i].whistleDeps].join());
|
||
|
}
|
||
|
}
|
||
|
that.setData({
|
||
|
loadType: 'none',
|
||
|
projrctItems: that.data.projrctItems.concat(temp),
|
||
|
projrctItemslength: temp.length
|
||
|
})
|
||
|
|
||
|
if (that.data.projrctItems.length == 0) {
|
||
|
that.setData({
|
||
|
isShow: true,
|
||
|
loadVisible: false,
|
||
|
})
|
||
|
}
|
||
|
})
|
||
|
},
|
||
|
// 工作日志
|
||
|
async listByUserId() {
|
||
|
let that = this
|
||
|
let params = {
|
||
|
pageIndex: that.data.pageIndex,
|
||
|
pageSize: app.globalData.pageSize,
|
||
|
timestamp: that.data.timestamp
|
||
|
}
|
||
|
try {
|
||
|
let res = await listByUserId(params)
|
||
|
// console.log('res工作日志', res)
|
||
|
that.setData({
|
||
|
loadType: 'none',
|
||
|
listByUserId: that.data.listByUserId.concat(res.data),
|
||
|
listByUserIdlength: res.data.length
|
||
|
})
|
||
|
if (that.data.listByUserId.length == 0) {
|
||
|
that.setData({
|
||
|
isShow: true,
|
||
|
loadVisible: false,
|
||
|
})
|
||
|
}
|
||
|
} catch (err) {
|
||
|
|
||
|
}
|
||
|
},
|
||
|
|
||
|
// 议题/项目点击事件
|
||
|
navigateToDetail(e) {
|
||
|
let id = e.detail.id
|
||
|
this.getItemDetail(id); //获取详情 判断页面跳转
|
||
|
},
|
||
|
// 获取事件详情
|
||
|
getItemDetail(id) {
|
||
|
_api.getItemDetail(id).then((res) => {
|
||
|
let itemState = res.data.itemState
|
||
|
if (itemState == '0') {
|
||
|
wx.navigateTo({
|
||
|
url: `../../../pages/itemDetail/itemDetail?itemId=${id}&itemState=0`
|
||
|
})
|
||
|
} else if (itemState == '5') { // 2:已关闭
|
||
|
wx.navigateTo({
|
||
|
url: `../../../pages/project/projectDetail/projectDetail?itemId=${id}&itemState=2`
|
||
|
})
|
||
|
} else if (itemState == '10') { //1:已结案
|
||
|
wx.navigateTo({
|
||
|
url: `../../../pages/project/projectDetail/projectDetail?itemId=${id}&itemState=1`
|
||
|
})
|
||
|
} else {
|
||
|
wx.navigateTo({
|
||
|
url: `../../../pages/itemDetail/itemDetail?itemId=${id}&itemState=0`
|
||
|
})
|
||
|
}
|
||
|
})
|
||
|
},
|
||
|
//工作日志点击事件
|
||
|
navigateToWork(e) {
|
||
|
let id = e.detail.id
|
||
|
let type = e.detail.type
|
||
|
this.read(id, type)
|
||
|
},
|
||
|
async read(id, type) {
|
||
|
let that = this
|
||
|
let params = {
|
||
|
informationId: id
|
||
|
}
|
||
|
try {
|
||
|
let res = await read(params)
|
||
|
if (type == '4') { //周报
|
||
|
wx.navigateTo({
|
||
|
url: '../../../subpages/weeklyReport/pages/weeklyReportIndex/weeklyReportIndex?weeklyType=publish'
|
||
|
})
|
||
|
} else if (type == '5') { //月报
|
||
|
wx.navigateTo({
|
||
|
url: '../../../subpages/monthlyReport/pages/monthlyIndex/monthlyIndex?weeklyType=publish'
|
||
|
})
|
||
|
}
|
||
|
} catch (err) {
|
||
|
|
||
|
}
|
||
|
},
|
||
|
// 上拉
|
||
|
onReachBottom() {
|
||
|
if (this.data.key == 'tab1') { //议题/项目
|
||
|
if (this.data.projrctItemslength !== this.data.pageSize) {
|
||
|
this.setData({
|
||
|
loadType: 'none',
|
||
|
})
|
||
|
return
|
||
|
}
|
||
|
this.setData({
|
||
|
loadType: 'more',
|
||
|
pageIndex: this.data.pageIndex + 1
|
||
|
})
|
||
|
this.getItemNotice()
|
||
|
} else if (this.data.key == 'tab2') {
|
||
|
if (this.data.listByUserIdlength !== this.data.pageSize) {
|
||
|
this.setData({
|
||
|
loadType: 'none',
|
||
|
})
|
||
|
return
|
||
|
}
|
||
|
this.setData({
|
||
|
loadType: 'more',
|
||
|
pageIndex: this.data.pageIndex + 1
|
||
|
})
|
||
|
this.listByUserId()
|
||
|
}
|
||
|
},
|
||
|
})
|