// pages/vehicleMaintenance/maintainSend/maintainSend.ts import { postAction } from '../../../../api/base'; const dayjs = require('dayjs'); Page({ /** * 页面的初始数据 */ data: { checkIdea: '', // 报修内容 repairObject: '' as any, // 维修单数据 checkResult: '' as any, // 评审结果 userInfo: '' as any, // 用户信息 checkPeople: '' //审批人 }, // 输入报修内容 textareaInput(e: any) { console.log(e.detail.value); console.log(e.detail.value.length); this.setData({ checkIdea: e.detail.value }); }, selectRadio(e: any) { this.setData({ checkResult: e.currentTarget.dataset.inf }); }, // 提交申请 submit() { if (this.data.checkResult) { if (this.data.checkResult == '2' && !this.data.checkIdea) { wx.showToast({ title: this.data.repairObject.flowStatus == 4 ? '请填写评审意见' : this.data.repairObject.flowStatus == 5 ? '请填写审批意见' : '请填写复核意见', icon: 'none' }); return; } let params = { id: this.data.repairObject.id, //id flowStatus: this.data.repairObject.flowStatus, //当前流程状态 checkFlag: this.data.checkResult, //审核状态 1-》通过, 2-》不通过 repairInfo: {}, repairAssign: {}, repairOffer: {}, currentRepairCheck: { checkResult: this.data.checkResult, //审核结果/维修结果 checkPeople: this.data.userInfo.realname, //审批人 checkIdea: this.data.checkIdea //审核意见 } }; wx.showLoading({ title: '加载中', mask: true }); postAction('api/vehicles/repair/submitRepairObject', 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, price: this.data.repairObject.repairOffer.repairCost, // 维修金额 id: this.data.repairObject.id, flowStatus: this.data.repairObject.flowStatus, checkFlag: this.data.checkResult // 通过结果 }); 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' }); }); } else { wx.showToast({ title: this.data.repairObject.flowStatus == 4 ? '请选择评审结果' : this.data.repairObject.flowStatus == 5 ? '请选择审批结果' : '请选择复核结果', icon: 'none' }); } }, getInf() { // 获取信息 let info = wx.getStorageSync('repairObject'); wx.removeStorage({ key: 'repairObject' }); let userInfo = wx.getStorageSync('userInfo'); this.setData({ repairObject: info, userInfo: userInfo, checkPeople: userInfo.realname }); let title = ''; if (info.flowStatus == 4) title = '评审'; else if (info.flowStatus == 5) title = '审批'; else if (info.flowStatus == 10) title = '复核'; wx.setNavigationBarTitle({ title: title }); }, /** * 生命周期函数--监听页面加载 */ onLoad() {}, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { this.getInf(); }, /** * 生命周期函数--监听页面显示 */ onShow() { // 不放onReady 是因为有可能切出去然后状态改了得跳转到别的页面 }, /** * 生命周期函数--监听页面隐藏 */ onHide() {}, /** * 生命周期函数--监听页面卸载 */ onUnload() {}, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() {}, /** * 页面上拉触底事件的处理函数 */ onReachBottom() {}, /** * 用户点击右上角分享 */ onShareAppMessage() {} });