203 lines
5.1 KiB
JavaScript
203 lines
5.1 KiB
JavaScript
// pages/approvalWarning/approvalForm/approvalForm.js
|
|
import {base_url} from '../../../utils/http';
|
|
import {API} from "../../../utils/api";
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
//父组件数据
|
|
fData:null,
|
|
fileList:[],
|
|
submit_form:{
|
|
nowScore:'',
|
|
remark:''
|
|
},
|
|
scoreMsg:''
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad(options) {
|
|
if(options && JSON.parse(options.data)){
|
|
let _data = JSON.parse(options.data);
|
|
let _fileData = _data.files?_data.files.split(","):[];
|
|
let _newFileData = [];
|
|
_fileData.forEach(item => {
|
|
let _lastNum = item.lastIndexOf('/')+1;
|
|
_newFileData.push({
|
|
name:item.substr(_lastNum,item.length-1),
|
|
url:base_url+item
|
|
})
|
|
})
|
|
this.setData({
|
|
fData:_data,
|
|
fileList:_newFileData
|
|
})
|
|
}
|
|
},
|
|
|
|
//预览图片或文件
|
|
handlePreView(e){
|
|
let _url = e.currentTarget.dataset.url;
|
|
if(_url.indexOf('.jpg') > -1 || _url.indexOf('.png') > -1){ //预览图片
|
|
wx.previewImage({
|
|
urls:[_url],
|
|
current:_url
|
|
})
|
|
}else{ //下载文件
|
|
wx.downloadFile({
|
|
url: _url, //仅为示例,并非真实的资源
|
|
success (res) {
|
|
if(res.statusCode === 200){
|
|
wx.openDocument({
|
|
filePath: res.tempFilePath,
|
|
success: function (res) {
|
|
console.log(res,'打开文档成功')
|
|
}
|
|
})
|
|
}
|
|
}
|
|
})
|
|
}
|
|
},
|
|
|
|
//公共输入方法
|
|
handlePublicInput(e){
|
|
let _type = e.currentTarget.dataset.type;
|
|
switch (_type) {
|
|
case "score":
|
|
let _tips = e.detail?'':'请输入评定分数';
|
|
this.setData({
|
|
'submit_form.nowScore':e.detail,
|
|
scoreMsg:_tips
|
|
})
|
|
break;
|
|
case "remark":
|
|
this.setData({
|
|
'submit_form.remark':e.detail
|
|
})
|
|
break;
|
|
}
|
|
},
|
|
|
|
//审核
|
|
handleApproval(){
|
|
let _this = this;
|
|
if(!_this.data.submit_form.nowScore){
|
|
_this.setData({
|
|
scoreMsg:'请输入评定分数'
|
|
});
|
|
return false;
|
|
}else{
|
|
_this.setData({
|
|
scoreMsg:''
|
|
})
|
|
}
|
|
API.reviewedSave({
|
|
id:_this.data.fData.id,
|
|
reviewer:_this.data.fData.reviewer,
|
|
nowScore:_this.data.submit_form.nowScore,
|
|
remark:_this.data.submit_form.remark
|
|
}).then(res => {
|
|
if(res.code === 0){
|
|
wx.showToast({
|
|
title:'审核成功!',
|
|
duration:1500
|
|
});
|
|
setTimeout(function () {
|
|
wx.navigateBack();
|
|
},1500)
|
|
}else{
|
|
wx.showToast({
|
|
title:res.msg,
|
|
duration:1500,
|
|
icon:'none'
|
|
});
|
|
}
|
|
})
|
|
},
|
|
|
|
//驳回
|
|
handleOverrule(){
|
|
let _this = this;
|
|
wx.showModal({
|
|
title: '温馨提示',
|
|
content: '是否驳回?',
|
|
success (res) {
|
|
if (res.confirm) {
|
|
API.reback({
|
|
id:_this.data.fData.id
|
|
}).then(res => {
|
|
if(res.code === 0){
|
|
wx.showToast({
|
|
title:'驳回成功!',
|
|
duration:1500
|
|
});
|
|
setTimeout(function () {
|
|
wx.navigateBack();
|
|
},1500)
|
|
}else{
|
|
wx.showToast({
|
|
title:res.msg,
|
|
duration:1500,
|
|
icon:'none'
|
|
});
|
|
}
|
|
})
|
|
}
|
|
}
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage() {
|
|
|
|
}
|
|
}) |