236 lines
5.9 KiB
JavaScript
236 lines
5.9 KiB
JavaScript
// pages/approvalWarning/approvalForm/approvalForm.js
|
|
import {base_url} from '../../../utils/http';
|
|
import {API as $api, API} from "../../../utils/api";
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
//父组件数据
|
|
fData:null,
|
|
fileList:[],
|
|
submit_form:{
|
|
nowScore:'',
|
|
remark:''
|
|
},
|
|
scoreMsg:'',
|
|
overruleShow:false,
|
|
remark:''
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad(options) {
|
|
if(options && JSON.stringify(options) !== '{}'){
|
|
let _fileData = options.files?options.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.loadDetailData({
|
|
pageNum:1,
|
|
pageSize:10,
|
|
type:options.type,
|
|
id:options.id
|
|
})
|
|
this.setData({
|
|
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'
|
|
});
|
|
}
|
|
})
|
|
},
|
|
|
|
//驳回
|
|
handleOverruleOpen(){
|
|
this.setData({
|
|
overruleShow:true
|
|
})
|
|
},
|
|
handleOverruleClose(){
|
|
this.setData({
|
|
overruleShow:false,
|
|
remark:''
|
|
})
|
|
},
|
|
handleOverruleSubmit(){
|
|
let _this = this;
|
|
wx.showModal({
|
|
title: '温馨提示',
|
|
content: '是否驳回?',
|
|
success (res) {
|
|
if (res.confirm) {
|
|
API.reback({
|
|
id:_this.data.fData.id,
|
|
remark:_this.data.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'
|
|
});
|
|
}
|
|
})
|
|
}
|
|
}
|
|
})
|
|
},
|
|
//加载详情数据
|
|
loadDetailData(param){
|
|
let _this = this;
|
|
$api.queryList(param).then(res => {
|
|
if(res.code === 0){
|
|
let _data = null;
|
|
if(res.rows.length>0){
|
|
_data = res.rows[0];
|
|
}
|
|
_this.setData({
|
|
fData:_data
|
|
})
|
|
}
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage() {
|
|
|
|
}
|
|
}) |