YZProjectCloud/yanzhu-ui-app/miniprogram/pageage/project_flowable/subDeptsUsers/index.js

372 lines
9.3 KiB
JavaScript
Raw Normal View History

2025-05-18 10:49:52 +08:00
import config from '../../../config'
import {
getToken,
getUserInfo
} from '../../../utils/auth'
import {
quueryCount,
batchComplete,
myAwaitFlowTaskList,
myFinishedFlowTaskList,
} from '../../../api/flowable'
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
projectId: '',
projectName: '',
initData: {},
activeState: "dsh",
dshCount: 0,
yshCount: 0,
listData: [],
pageNum: 1,
pageSize: 10,
total: 0,
checkedAll:false,
showChecked:false,
imgBaseUrl: config.baseImgUrl
},
//项目切换 返回值
onProjectSelect(e) {
let projectId = e.detail.id;
let projectName = e.detail.text;
app.globalData.useProjectId = projectId;
app.globalData.useProjectName = projectName;
this.onLoad();
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
if (getToken()) {
this.setData({
pageNum: 1,
pageSize: 10,
lastDataSize: 10,
listData: [],
total: 0,
dshCount: 0,
yshCount: 0,
activeState: "dsh",
projectId: app.globalData.useProjectId,
projectName: app.globalData.useProjectName,
initData: {
id: app.globalData.useProjectId,
text: app.globalData.useProjectName,
}
});
let userInfo = getUserInfo();
if(userInfo && userInfo.projectUserInfo && userInfo.projectUserInfo.subDeptType=="1"){
this.setData({
showChecked:true
});
}
this.getListData();
this.getFlowableCount();
} else {
console.log("未查询到Token...{}...准备重新登录")
wx.redirectTo({
url: '../../login/login',
})
}
},
/**
* 查询列表数据
*/
getListData() {
let params = "pageNum=" + this.data.pageNum + "&pageSize=" + this.data.pageSize + "&activeTags=users&startProId=" + app.globalData.useProjectId;
if (this.data.activeState == 'dsh') {
myAwaitFlowTaskList(params).then(res => {
if (res.code == "200") {
res.rows.forEach(item => {
item.businessImg = this.data.imgBaseUrl + item.businessImg;
item.durationStr = this.getDurationDate(item.duration);
});
this.setData({
total: res.total,
listData: this.data.listData.concat(res.rows)
})
}
});
} else {
myFinishedFlowTaskList(params).then(res => {
if (res.code == "200") {
res.rows.forEach(item => {
item.businessImg = this.data.imgBaseUrl + item.businessImg;
item.durationStr = this.getDurationDate(item.duration);
});
this.setData({
total: res.total,
listData: this.data.listData.concat(res.rows)
})
}
});
}
},
/**
* 统计分包单位数据
*/
getFlowableCount() {
let params = "activeTags=users&startProId=" + app.globalData.useProjectId;
quueryCount(params).then(res => {
if (res.code == 200) {
this.setData({
dshCount: res.data.await,
yshCount: res.data.finished
})
}
});
},
/**
* 统计审批数据
*/
onScrollToLower() {
let nal = Math.ceil(this.data.total / this.data.pageSize);
if (this.data.pageNum < nal) {
this.setData({
pageNum: this.data.pageNum + 1
});
this.getListData();
}
},
/**
* 切换页签数据
*/
switchTabJump(e) {
let index = e.currentTarget.dataset.index;
let nav = "";
if (index == 1) {
nav = 'dsh';
} else {
nav = 'ysh';
}
if (nav != this.data.activeState) {
this.setData({
activeState: nav,
pageNum: 1,
pageSize: 10,
listData: [],
});
this.getListData();
}
},
/**
* 点击栏目
* @param {*} e
*/
findDetail(e) {
let {
taskId,
taskName,
procInsId,
deployId,
category,
businessKey
} = e.currentTarget.dataset.set
wx.setStorageSync('nav-types', "users");
if (this.data.activeState=="ysh") {
//详情页面
wx.redirectTo({
url: `../detailTask/index?taskId=${taskId}&taskName=${taskName}&procInsId=${procInsId}&deployId=${deployId}&category=${category}&businessKey=${businessKey}`
})
} else {
//审批页面
wx.redirectTo({
url: `../approveTask/index?taskId=${taskId}&taskName=${taskName}&procInsId=${procInsId}&deployId=${deployId}&category=${category}&businessKey=${businessKey}`
})
}
},
/**
* 选中节点
* @param {*} e
*/
selectItem: function(event){
let procInsId = event.currentTarget.dataset.set;
console.log("procInsId==>",procInsId)
let _listData = this.data.listData;
_listData.forEach(item =>{
if(procInsId==item.procInsId){
item.selected=!item.selected;
}
})
this.setData({
listData: _listData
});
},
/**
* 全选
*/
onCheckedAll(){
let _checked = !this.data.checkedAll;
let _listData = this.data.listData;
_listData.forEach(item =>{
item.selected=_checked;
});
this.setData({
listData: _listData,
checkedAll: _checked
});
},
/**
* 批量
* 审核通过
*/
onBatchPass(){
let taskIds = [];
let _listData = this.data.listData;
_listData.forEach(item =>{
if(item.selected){
taskIds.push(item.taskId);
}
});
if(taskIds.length==0){
app.toast("请选择要审批的数据项!","none",1500);
return false;
}
let that = this;
//弹出确认
wx.showModal({
title: '提示',
content: '是否确认批量审批通过?',
success: function (sm) {
if (sm.confirm) {
that.submitBatchPass();
}
}
})
},
/**
* 提交审批
*/
submitBatchPass(){
let taskIds = [];
let instanceIds = [];
let _listData = this.data.listData;
_listData.forEach(item =>{
if(item.selected){
taskIds.push(item.taskId);
instanceIds.push(item.procInsId);
}
});
let _data = {
'taskIds':taskIds,
'instanceIds':instanceIds
}
batchComplete(_data).then(res =>{
app.toast("批量审批通过成功!");
this.onLoad();
});
},
/**
* 办理时间计算
* @param {*} val
*/
getDurationDate(val) {
let day = 0;
let hours = 0;
let min = val;
if (min > 1440) {
day = parseInt(min / 1440);
min = min % 1440;
if (min > 60) {
hours = parseInt(min / 60);
min = min % 60;
}
} else if (min > 60) {
hours = parseInt(min / 60);
min = min % 60;
}
if (day > 0) {
if (day < 10) day = "0" + day;
if (hours < 10) hours = "0" + hours;
if (min < 10) min = "0" + min;
return day + "天" + hours + "小时" + min + "分钟";
}
if (hours > 0) {
if (hours < 10) hours = "0" + hours;
if (min < 10) min = "0" + min;
return hours + "小时" + min + "分钟";
}
if (min > 0) {
if (min < 10) min = "0" + min;
return min + "分钟";
}
if (min == 0) {
return "1分钟";
}
},
/**
* 返回页面
*/
returnToPage: function () {
wx.redirectTo({
url: '../../project_more/index',
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})