cyx-ament-wechat/miniprogram/pages/approvalWarning/approvalForm/approvalForm.js

236 lines
5.9 KiB
JavaScript
Raw Normal View History

2023-08-31 10:38:54 +08:00
// pages/approvalWarning/approvalForm/approvalForm.js
2023-08-31 11:12:54 +08:00
import {base_url} from '../../../utils/http';
2023-10-09 16:44:50 +08:00
import {API as $api, API} from "../../../utils/api";
2023-08-31 10:38:54 +08:00
Page({
/**
* 页面的初始数据
*/
data: {
//父组件数据
fData:null,
2023-08-31 11:12:54 +08:00
fileList:[],
submit_form:{
nowScore:'',
remark:''
},
2023-10-09 11:07:41 +08:00
scoreMsg:'',
overruleShow:false,
remark:''
2023-08-31 10:38:54 +08:00
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
2023-10-09 16:44:50 +08:00
if(options && JSON.stringify(options) !== '{}'){
let _fileData = options.files?options.files.split(","):[];
2023-08-31 10:38:54 +08:00
let _newFileData = [];
_fileData.forEach(item => {
let _lastNum = item.lastIndexOf('/')+1;
_newFileData.push({
name:item.substr(_lastNum,item.length-1),
url:base_url+item
})
})
2023-10-09 16:44:50 +08:00
this.loadDetailData({
pageNum:1,
pageSize:10,
type:options.type,
id:options.id
})
2023-08-31 10:38:54 +08:00
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,'打开文档成功')
}
})
}
}
})
}
},
2023-08-31 11:12:54 +08:00
//公共输入方法
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,
2023-08-31 17:11:28 +08:00
duration:1500,
icon:'none'
2023-08-31 11:12:54 +08:00
});
}
})
},
//驳回
2023-10-09 11:07:41 +08:00
handleOverruleOpen(){
this.setData({
overruleShow:true
})
},
handleOverruleClose(){
this.setData({
overruleShow:false,
remark:''
})
},
handleOverruleSubmit(){
2023-08-31 11:12:54 +08:00
let _this = this;
wx.showModal({
title: '温馨提示',
content: '是否驳回?',
success (res) {
if (res.confirm) {
API.reback({
2023-10-09 11:07:41 +08:00
id:_this.data.fData.id,
remark:_this.data.remark
2023-08-31 11:12:54 +08:00
}).then(res => {
if(res.code === 0){
wx.showToast({
title:'驳回成功!',
duration:1500
});
setTimeout(function () {
wx.navigateBack();
},1500)
}else{
wx.showToast({
title:res.msg,
2023-08-31 17:11:28 +08:00
duration:1500,
icon:'none'
2023-08-31 11:12:54 +08:00
});
}
})
}
}
})
},
2023-10-09 16:44:50 +08:00
//加载详情数据
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
})
}
})
},
2023-08-31 11:12:54 +08:00
2023-08-31 10:38:54 +08:00
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})