jhwxapp/miniprogram/pageage/flow_labour/check/index.js

336 lines
8.4 KiB
JavaScript

import config from '../../../config'
import {
syncFileUpload
} from '../../../utils/request'
import {
getInfo,
submitFlowLabour,
findMyFlowLabourNodes
} from "../../../api/flowLabour"
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
id: "",
infoData: {
files: ""
},
activeName: "",
flowRecordList: [],
request: app.globalData.reqUrl,
flowNodes: [{
text: '提交投诉'
}, {
text: '项目经理'
}, {
text: '甲方代表'
}, {
text: '集团公司'
}],
active: 100,
rejectNode: 0,
flowComment: "",
imageInfoData: [],
minRole: 99,
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
let {
id
} = options
this.setData({
id
})
//获取缓存数据
wx.getStorage({
key: 'userinfo',
success: res => {
this.setData({
minRoleId: res.data.minRoleId
})
}
})
this.getInfo();
this.getAuditinfo();
},
/**
* 获取劳资投诉详情信息
*
*/
getInfo() {
getInfo(this.data.id).then(res => {
if (res.code == 200) {
let active = this.data.active;
let rejectNode = this.data.rejectNode;
if (res.data.approveStatus == "10" || res.data.approveStatus == "21") {
active = 1;
if (res.data.approveStatus == "21") {
rejectNode = active + 1;
}
} else if (res.data.approveStatus == "20" || res.data.approveStatus == "31") {
active = 2;
if (res.data.approveStatus == "31") {
rejectNode = active + 1;
}
} else if (res.data.approveStatus == "30") {
active = 3;
}
this.setData({
active,
rejectNode,
infoData: res.data
})
}
});
},
/**
* 查询流程日志
*/
getAuditinfo() {
findMyFlowLabourNodes(this.data.id).then(res => {
if (res.code == 200) {
this.setData({
flowRecordList: res.data
})
}
});
},
// 手风琴
onChange(event) {
this.setData({
activeName: event.detail,
});
},
//展示图片
showImg: function (e) {
let paths = e.target.dataset.set;
let path = [];
paths.split(',').forEach(url => {
path.push(config.baseUrl + url);
});
wx.previewImage({
urls: path,
current: path[e.currentTarget.dataset.index]
})
},
//整改要求
onInputFlowComment(e) {
let flowComment = e.detail.value
this.setData({
flowComment
})
},
// list 上传图片
onImagesArr(e) {
var data = this.data.imageInfoData
data = e.detail
this.setData({
imageInfoData: data
})
},
//审批劳资投诉
onSubmitPass() {
let {
flowComment
} = this.data;
//数据效验
if (flowComment == "") {
app.toast("请填写处理意见!")
return;
}
let that = this;
let msg = "";
if ((this.data.infoData.approveStatus == '20' || this.data.infoData.approveStatus == '31') && (this.data.minRoleId == '2' || this.data.minRoleId == '3')) {
msg = "当前数据甲方代表正在审批,您";
}
//弹出确认
wx.showModal({
title: '提示',
content: msg + '是否确认审批通过当前劳资投诉?',
success: function (sm) {
if (sm.confirm) {
that.submitForm(100);
}
}
})
},
/**
* 驳回劳资投诉
*/
onSubmitReject() {
let {
flowComment
} = this.data;
//数据效验
if (flowComment == "") {
app.toast("请填写处理意见!")
return;
}
let that = this;
let msg = "";
if ((this.data.infoData.approveStatus == '20' || this.data.infoData.approveStatus == '31') && (this.data.minRoleId == '2' || this.data.minRoleId == '3')) {
msg = "当前数据甲方代表正在审批,您";
}
//弹出确认
wx.showModal({
title: '提示',
content: msg + '是否确认审批驳回当前劳资投诉?',
success: function (sm) {
if (sm.confirm) {
that.submitForm(1);
}
}
})
},
//提交处理结果
onSubmitSave() {
let {
flowComment
} = this.data;
//数据效验
if (flowComment == "") {
app.toast("请填写处理意见!")
return;
}
let that = this;
let msg = "";
if (this.data.minRoleId == '2' || this.data.minRoleId == '3' || this.data.minRoleId == '4') {
msg = "当前数据总包单位正在处理,您";
}
//弹出确认
wx.showModal({
title: '提示',
content: msg + '是否确提交劳资投诉处理结果?',
success: function (sm) {
if (sm.confirm) {
that.submitForm(100);
}
}
})
},
/**
* 提交审核结果
*/
submitForm(result) {
let {
id,
flowComment,
imageInfoData
} = this.data;
if (imageInfoData.length > 0) {
let images = [];
imageInfoData.forEach(item => {
syncFileUpload(item).then(res => {
images.push(res.fileName);
//验证图片上传完毕
if (images.length == imageInfoData.length) {
let params = {
flowId: id,
flowResult: result,
flowComment: flowComment,
files: images.toString()
}
submitFlowLabour(params).then(res => {
if (res.code == 200) {
app.toast("处理劳资投诉成功!")
setTimeout(() => {
wx.redirectTo({
url: '../list/index',
})
}, 300)
}
});
}
});
})
} else {
let params = {
flowId: id,
flowResult: result,
flowComment: flowComment
}
submitFlowLabour(params).then(res => {
if (res.code == 200) {
app.toast("处理劳资投诉成功!")
setTimeout(() => {
wx.redirectTo({
url: '../list/index',
})
}, 300)
}
});
}
},
returnToPage: function () {
/*关闭当前页面,跳转到应用内的某个页面。但是不允许跳转到 tabbar 页面*/
wx.redirectTo({
url: '../list/index',
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})