2024-12-29 21:35:34 +08:00
|
|
|
|
import config from '../../../config'
|
2024-10-13 11:24:45 +08:00
|
|
|
|
import {
|
|
|
|
|
reject,
|
|
|
|
|
complete,
|
|
|
|
|
returnTask,
|
|
|
|
|
returnList,
|
|
|
|
|
readDeployNotes,
|
|
|
|
|
findCommentByProcInsId
|
|
|
|
|
} from '../../../api/flowable'
|
2024-12-29 21:35:34 +08:00
|
|
|
|
import {
|
|
|
|
|
findProSubDeptsInfoById,
|
|
|
|
|
findProSubDeptsUserInfoById
|
|
|
|
|
} from '../../../api/project'
|
2025-02-13 00:20:07 +08:00
|
|
|
|
import {
|
|
|
|
|
getToken
|
|
|
|
|
} from '../../../utils/auth'
|
2024-10-13 11:24:45 +08:00
|
|
|
|
const app = getApp()
|
|
|
|
|
Page({
|
|
|
|
|
/**
|
|
|
|
|
* 页面的初始数据
|
|
|
|
|
*/
|
|
|
|
|
data: {
|
|
|
|
|
options: {},
|
|
|
|
|
active: 0,
|
|
|
|
|
stepList: [],
|
2024-12-29 21:35:34 +08:00
|
|
|
|
rejectNode: false,
|
2024-10-13 11:24:45 +08:00
|
|
|
|
activeName: "",
|
|
|
|
|
flowRecordList: [],
|
2024-12-29 21:35:34 +08:00
|
|
|
|
subDeptData: {
|
|
|
|
|
subDeptInfos: {}
|
|
|
|
|
},
|
|
|
|
|
subDeptUserData: {
|
|
|
|
|
user: {},
|
|
|
|
|
},
|
2024-10-13 11:24:45 +08:00
|
|
|
|
comment: "",
|
2024-12-29 21:35:34 +08:00
|
|
|
|
targetKey: "",
|
2024-10-13 11:24:45 +08:00
|
|
|
|
targetKeyList: [],
|
2024-12-29 21:35:34 +08:00
|
|
|
|
imgBaseUrl: config.baseImgUrl
|
2024-10-13 11:24:45 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
|
*/
|
|
|
|
|
onLoad(options) {
|
|
|
|
|
this.setData({
|
|
|
|
|
options: options
|
|
|
|
|
})
|
|
|
|
|
this.findFlowNodes();
|
|
|
|
|
this.findCommentByProcInsId();
|
|
|
|
|
this.findApplyDataInfo();
|
|
|
|
|
this.initTargetKeyList();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
//查询工作流节点
|
|
|
|
|
findFlowNodes() {
|
|
|
|
|
readDeployNotes(this.data.options.deployId).then(res => {
|
|
|
|
|
let list = [{
|
|
|
|
|
text: '开始'
|
|
|
|
|
}];
|
|
|
|
|
let index = this.data.active;
|
2024-12-29 21:35:34 +08:00
|
|
|
|
res.data.forEach((item, idx) => {
|
|
|
|
|
if (this.data.options.taskName == item.name) {
|
|
|
|
|
index = idx + 1;
|
2024-10-13 11:24:45 +08:00
|
|
|
|
}
|
|
|
|
|
list.push({
|
2025-02-13 00:20:07 +08:00
|
|
|
|
text: item.name.substr(0,6),
|
2024-10-13 11:24:45 +08:00
|
|
|
|
desc: ''
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
list.push({
|
|
|
|
|
text: '结束'
|
|
|
|
|
});
|
|
|
|
|
this.setData({
|
|
|
|
|
active: index,
|
|
|
|
|
stepList: list
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
//查询审批日志
|
|
|
|
|
findCommentByProcInsId() {
|
|
|
|
|
findCommentByProcInsId({
|
|
|
|
|
procInsId: this.data.options.procInsId
|
|
|
|
|
}).then(res => {
|
|
|
|
|
this.setData({
|
|
|
|
|
flowRecordList: res.data
|
|
|
|
|
})
|
|
|
|
|
let list = [];
|
|
|
|
|
res.data.forEach((item, idx) => {
|
|
|
|
|
if (idx == 1 && (item.commentType == "3" || item.commentType == "2")) {
|
|
|
|
|
that.setData({
|
|
|
|
|
rejectNode: true
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
if (item.deleteReason) {
|
|
|
|
|
item.deleteReason = this.getDeleteReason(item.deleteReason);
|
|
|
|
|
}
|
|
|
|
|
if (item.duration) {
|
|
|
|
|
item.duration = app.getDurationDate(item.duration);
|
|
|
|
|
}
|
|
|
|
|
list.push(item);
|
|
|
|
|
})
|
|
|
|
|
this.setData({
|
|
|
|
|
flowRecordList: list
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
//查询审批表单参数
|
|
|
|
|
findApplyDataInfo() {
|
2024-12-29 21:35:34 +08:00
|
|
|
|
findProSubDeptsUserInfoById(this.data.options.businessKey).then(res => {
|
|
|
|
|
if (res.data.eduFilePath) {
|
|
|
|
|
let files = res.data.eduFilePath.split('/');
|
|
|
|
|
res.data.eduFileName = files[files.length - 1];
|
2024-10-13 11:24:45 +08:00
|
|
|
|
}
|
2025-02-05 21:34:18 +08:00
|
|
|
|
if(res.data.userInfos){
|
|
|
|
|
res.data.userInfos = JSON.parse(res.data.userInfos);
|
2024-12-29 21:35:34 +08:00
|
|
|
|
}
|
|
|
|
|
this.setData({
|
|
|
|
|
subDeptUserData: res.data
|
|
|
|
|
})
|
|
|
|
|
//查询单位信息
|
|
|
|
|
this.getSubDeptInfo(res.data.subDeptId);
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
//查询审批表单参数
|
|
|
|
|
getSubDeptInfo(subDeptId) {
|
|
|
|
|
findProSubDeptsInfoById(subDeptId).then(res => {
|
|
|
|
|
res.data.subDeptInfos = JSON.parse(res.data.subDeptInfos);
|
2024-10-13 11:24:45 +08:00
|
|
|
|
this.setData({
|
2024-12-29 21:35:34 +08:00
|
|
|
|
subDeptData: res.data
|
2024-10-13 11:24:45 +08:00
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
2024-12-29 21:35:34 +08:00
|
|
|
|
|
2024-10-13 11:24:45 +08:00
|
|
|
|
//初始化退回节点
|
|
|
|
|
initTargetKeyList() {
|
|
|
|
|
returnList({
|
|
|
|
|
taskId: this.data.options.taskId
|
|
|
|
|
}).then(res => {
|
|
|
|
|
if (res.data && res.data.length > 0) {
|
|
|
|
|
let list = [];
|
|
|
|
|
res.data.forEach(item => {
|
|
|
|
|
list.push({
|
|
|
|
|
id: item.id,
|
|
|
|
|
text: item.name
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
this.setData({
|
|
|
|
|
targetKey: list[0].id,
|
|
|
|
|
targetKeyList: list
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
//退回
|
|
|
|
|
onBack() {
|
|
|
|
|
let {
|
|
|
|
|
options,
|
|
|
|
|
comment
|
|
|
|
|
} = this.data;
|
|
|
|
|
//数据效验
|
|
|
|
|
if (!options.taskId) {
|
|
|
|
|
app.toast("数据异常,请刷新页面重试!")
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!comment) {
|
|
|
|
|
app.toast("请填写审批意见!")
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
let that = this;
|
|
|
|
|
//弹出确认
|
|
|
|
|
wx.showModal({
|
|
|
|
|
title: '提示',
|
|
|
|
|
content: '是否确认审批驳回?',
|
|
|
|
|
success: function (sm) {
|
|
|
|
|
if (sm.confirm) {
|
|
|
|
|
that.submitBackTask();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 提交退回任务
|
|
|
|
|
*/
|
|
|
|
|
submitBackTask() {
|
|
|
|
|
let {
|
|
|
|
|
options,
|
|
|
|
|
comment,
|
|
|
|
|
targetKeyList
|
|
|
|
|
} = this.data;
|
|
|
|
|
returnTask({
|
2024-12-29 21:35:34 +08:00
|
|
|
|
taskId: options.taskId,
|
|
|
|
|
targetKey: targetKeyList[0].id,
|
2024-10-13 11:24:45 +08:00
|
|
|
|
comment
|
|
|
|
|
}).then(res => {
|
|
|
|
|
if (res.code == 200) {
|
|
|
|
|
app.toast("驳回申请成功!")
|
|
|
|
|
setTimeout(() => {
|
2024-12-29 21:35:34 +08:00
|
|
|
|
this.returnToPage();
|
2024-10-13 11:24:45 +08:00
|
|
|
|
}, 500)
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
//通过
|
|
|
|
|
onPass() {
|
|
|
|
|
let {
|
|
|
|
|
options,
|
|
|
|
|
comment
|
|
|
|
|
} = this.data;
|
|
|
|
|
//数据效验
|
|
|
|
|
if (!options.taskId) {
|
|
|
|
|
app.toast("数据异常,请刷新页面重试!")
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (comment == "") {
|
|
|
|
|
app.toast("请填写审批意见!")
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
let that = this;
|
|
|
|
|
//弹出确认
|
|
|
|
|
wx.showModal({
|
|
|
|
|
title: '提示',
|
|
|
|
|
content: '是否确认审批通过?',
|
|
|
|
|
success: function (sm) {
|
|
|
|
|
if (sm.confirm) {
|
|
|
|
|
that.submitPassTask();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 提交审核结果
|
|
|
|
|
*/
|
|
|
|
|
submitPassTask() {
|
|
|
|
|
let {
|
|
|
|
|
options,
|
|
|
|
|
procInsId,
|
|
|
|
|
comment
|
|
|
|
|
} = this.data;
|
|
|
|
|
complete({
|
2024-12-29 21:35:34 +08:00
|
|
|
|
taskId: options.taskId,
|
2024-10-13 11:24:45 +08:00
|
|
|
|
instanceId: procInsId,
|
|
|
|
|
comment
|
|
|
|
|
}).then(res => {
|
|
|
|
|
if (res.code == 200) {
|
|
|
|
|
app.toast("申请审批通过成功!")
|
|
|
|
|
setTimeout(() => {
|
2024-12-29 21:35:34 +08:00
|
|
|
|
this.returnToPage();
|
2024-10-13 11:24:45 +08:00
|
|
|
|
}, 500)
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
//驳回
|
|
|
|
|
onReject() {
|
|
|
|
|
let {
|
|
|
|
|
taskId,
|
|
|
|
|
procInsId,
|
|
|
|
|
comment
|
|
|
|
|
} = this.data;
|
|
|
|
|
//数据效验
|
|
|
|
|
if (!taskId || !procInsId) {
|
|
|
|
|
app.toast("数据异常,请刷新页面重试!")
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (comment == "") {
|
|
|
|
|
app.toast("请填写审批意见!")
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
let that = this;
|
|
|
|
|
//弹出确认
|
|
|
|
|
wx.showModal({
|
|
|
|
|
title: '提示',
|
|
|
|
|
content: '是否确认审批驳回?',
|
|
|
|
|
success: function (sm) {
|
|
|
|
|
if (sm.confirm) {
|
|
|
|
|
that.submitRejectTask();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 提交流程驳回
|
|
|
|
|
*/
|
|
|
|
|
submitRejectTask() {
|
|
|
|
|
let {
|
|
|
|
|
taskId,
|
|
|
|
|
procInsId,
|
|
|
|
|
comment
|
|
|
|
|
} = this.data;
|
|
|
|
|
reject({
|
|
|
|
|
taskId,
|
|
|
|
|
instanceId: procInsId,
|
|
|
|
|
comment
|
|
|
|
|
}).then(res => {
|
|
|
|
|
if (res.code == 200) {
|
|
|
|
|
app.toast("驳回申请流程成功!")
|
|
|
|
|
setTimeout(() => {
|
2024-12-29 21:35:34 +08:00
|
|
|
|
this.returnToPage();
|
2024-10-13 11:24:45 +08:00
|
|
|
|
}, 500)
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
//申请说明
|
|
|
|
|
commentInput: function (options) {
|
|
|
|
|
this.data.comment = options.detail.value;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 手风琴
|
|
|
|
|
onChange(event) {
|
|
|
|
|
this.setData({
|
|
|
|
|
activeName: event.detail,
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取驳回节点
|
|
|
|
|
* @param {*} val
|
|
|
|
|
*/
|
|
|
|
|
getDeleteReason(val) {
|
|
|
|
|
val = val.replace("Change activity to ", "");
|
|
|
|
|
let flowRecordList = this.data.flowRecordList;
|
|
|
|
|
for (let i = 0; i < flowRecordList.length; i++) {
|
|
|
|
|
if (flowRecordList[i].taskDefKey == val) {
|
|
|
|
|
return "驳回至" + flowRecordList[i].taskName;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
//终止原因
|
|
|
|
|
commentblur: function (options) {
|
|
|
|
|
this.data.comment = options.detail.value;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
//展示图片
|
2024-12-29 21:35:34 +08:00
|
|
|
|
showImg: function (e) {
|
2024-10-13 11:24:45 +08:00
|
|
|
|
let paths = e.target.dataset.set;
|
|
|
|
|
let path = [];
|
|
|
|
|
paths.split(',').forEach(url => {
|
2025-02-05 21:34:18 +08:00
|
|
|
|
path.push(config.baseImgUrl + url);
|
2024-10-13 11:24:45 +08:00
|
|
|
|
});
|
|
|
|
|
wx.previewImage({
|
|
|
|
|
urls: path,
|
|
|
|
|
current: path[0]
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 下载并打开文档
|
|
|
|
|
* @param {*} e
|
|
|
|
|
*/
|
|
|
|
|
downFile: function (e) {
|
|
|
|
|
let {
|
|
|
|
|
path
|
|
|
|
|
} = e.currentTarget.dataset.set
|
|
|
|
|
wx.downloadFile({
|
|
|
|
|
// 示例 url,并非真实存在
|
2024-12-29 21:35:34 +08:00
|
|
|
|
url: config.baseUrl + '/file/download?fileName=' + path,
|
2025-02-13 00:20:07 +08:00
|
|
|
|
header: {
|
|
|
|
|
'Authorization': 'Bearer ' + getToken()
|
|
|
|
|
},
|
2024-10-13 11:24:45 +08:00
|
|
|
|
success: function (res) {
|
|
|
|
|
const filePath = res.tempFilePath
|
|
|
|
|
let fpt = filePath.split(".");
|
|
|
|
|
wx.openDocument({
|
|
|
|
|
filePath: filePath,
|
|
|
|
|
fileType: fpt[fpt.length - 1],
|
|
|
|
|
success: function (res) {
|
|
|
|
|
console.log('打开文档成功')
|
|
|
|
|
},
|
|
|
|
|
fail: function (res) {
|
|
|
|
|
console.log(res)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
//选择退回节点
|
|
|
|
|
onSelectTargetKey(e) {
|
|
|
|
|
this.setData({
|
|
|
|
|
targetKey: e.detail.id,
|
|
|
|
|
backName: e.detail.name
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
2024-12-29 21:35:34 +08:00
|
|
|
|
/**
|
|
|
|
|
* 返回页面
|
|
|
|
|
*/
|
2024-10-13 11:24:45 +08:00
|
|
|
|
returnToPage: function () {
|
2024-12-29 21:35:34 +08:00
|
|
|
|
if (wx.getStorageSync('nav-types') == "depts") {
|
|
|
|
|
wx.redirectTo({
|
|
|
|
|
url: '../subDepts/index',
|
|
|
|
|
})
|
|
|
|
|
} else if (wx.getStorageSync('nav-types') == "users") {
|
|
|
|
|
wx.redirectTo({
|
|
|
|
|
url: '../subDeptsUsers/index',
|
|
|
|
|
})
|
|
|
|
|
}
|
2024-10-13 11:24:45 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 修改申请
|
|
|
|
|
*/
|
|
|
|
|
onEditApply: function () {
|
|
|
|
|
wx.redirectTo({
|
|
|
|
|
url: `../editTask/index?deployId=${this.data.options.deployId}&procInsId=${this.data.options.procInsId}&nickName=${this.data.options.nickName}&deptName=${this.data.options.deptName}&procDefName=${this.data.options.procDefName}&taskId=${this.data.options.taskId}&taskName=${this.data.options.taskName}&category=${this.data.options.category}&projectName=${this.data.options.projectName}&businessKey=${this.data.options.businessKey}&businessKeyParName=${this.data.options.businessKeyParName}&businessDeptId=${this.data.options.businessDeptId}&startUserId=${this.data.options.startUserId}`,
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
|
|
*/
|
|
|
|
|
onReady() {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面显示
|
|
|
|
|
*/
|
|
|
|
|
onShow() {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
|
|
*/
|
|
|
|
|
onHide() {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
|
|
*/
|
|
|
|
|
onUnload() {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
|
|
|
*/
|
|
|
|
|
onPullDownRefresh() {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
|
|
*/
|
|
|
|
|
onReachBottom() {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 用户点击右上角分享
|
|
|
|
|
*/
|
|
|
|
|
onShareAppMessage() {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
})
|