// pages/vehicleMaintenance/maintainSend/maintainSend.ts import { postAction } from '../../../../api/base'; const dayjs = require('dayjs'); Page({ /** * 页面的初始数据 */ data: { checkIdea: '', // 报修内容 upkeepObject: '' as any, // 保养单数据 checkResult: '' as any, // 评审结果 userInfo: '' as any, // 用户信息 checkPeople: '', //审批人 finished: '' as any // 已完成/未完成 }, // 选择保养结果 selectRadio(e: any) { this.setData({ finished: e.currentTarget.dataset.inf, checkResult: e.currentTarget.dataset.inf }); }, // 输入报修内容 textareaInput(e: any) { this.setData({ checkIdea: e.detail.value }); }, // 提交申请 submit() { // 未完成的情况下没有填写原因 if (!this.data.finished) { wx.showToast({ title: '请选择保养结果', icon: 'none' }); return; } if (this.data.finished == 2 && !this.data.checkIdea) { wx.showToast({ title: '请填写未完成原因', icon: 'none' }); return; } let params = { id: this.data.upkeepObject.id, //id flowStatus: this.data.upkeepObject.flowStatus, //当前流程状态 checkFlag: this.data.checkResult, //审核状态 1-》通过, 2-》不通过 upkeepBill: {}, upkeepAssign: {}, upkeepOffer: {}, currentUpkeepCheck: { checkResult: this.data.checkResult, //审核结果/保养结果 checkPeople: this.data.userInfo.realname, //审批人 checkIdea: this.data.checkIdea //审核意见 } }; wx.showLoading({ title: '加载中', mask: true }); postAction('api/vehicles/upkeepBill/submitUpkeepObject', params) .then((res: any) => { if (res.code == 200) { wx.hideLoading(); wx.showToast({ title: '提交成功', icon: 'none' }); wx.setStorageSync('message', { checkPeople: this.data.userInfo.realname, date: dayjs().format('YYYY-MM-DD HH:mm:ss'), checkIdea: this.data.checkIdea, checkResult: this.data.checkResult, id: this.data.upkeepObject.id, flowStatus: this.data.upkeepObject.flowStatus, checkFlag: this.data.checkResult, // 通过结果 finished: this.data.finished == 1 ? true : false }); wx.redirectTo({ url: '../message/message', fail: e => { console.log(e); } }); } else { wx.hideLoading(); wx.showToast({ title: res.message, icon: 'none' }); } }) .catch((err: any) => { wx.hideLoading(); wx.showToast({ title: err.message, icon: 'none' }); }); }, getInf() { // 获取信息 let info = wx.getStorageSync('upkeepObject'); wx.removeStorage({ key: 'upkeepObject' }); let userInfo = wx.getStorageSync('userInfo'); this.setData({ upkeepObject: info, userInfo: userInfo, checkPeople: userInfo.realname }); }, /** * 生命周期函数--监听页面加载 */ onLoad() {}, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { this.getInf(); }, /** * 生命周期函数--监听页面显示 */ onShow() { // 不放onReady 是因为有可能切出去然后状态改了得跳转到别的页面 }, /** * 生命周期函数--监听页面隐藏 */ onHide() {}, /** * 生命周期函数--监听页面卸载 */ onUnload() {}, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() {}, /** * 页面上拉触底事件的处理函数 */ onReachBottom() {}, /** * 用户点击右上角分享 */ onShareAppMessage() {} });