import { getDictCache, selectProjectAuditinfoList } from '../../../api/publics' import { getProjectFunVerify, updateProjectFunVerify } from '../../../api/projectFunVerify' const app = getApp() Page({ /** * 页面的初始数据 */ data: { id: "", infoData: {}, imageList: [], minImageList: [], loadShow: false, loginName: "", request: app.globalData.reqUrl, list: [{ id: 1, text: "合格" }, { id: 2, text: "不合格" }], result: "1", comment: "", flowNodes: [{ text: '开始' }, { text: '提交申请' }, { text: '监理审批' }, { text: '结束' }], active: 2, checkFiles: [] }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { let { id } = options //获取缓存数据 wx.getStorage({ key: 'userinfo', success: res => { this.setData({ id, loginName: res.data.loginName }) this.getInfo(); this.getAuditinfo(); } }) }, /** * 获取安全检查详情信息 * */ getInfo() { let that = this; getProjectFunVerify(this.data.id).then(res => { if (res.code == 200) { let urls = []; let minUrls = []; let checkFiles = []; if (res.data.imageUrls) { res.data.imageUrls.split(',').forEach(element => { urls.push(that.data.request + element); minUrls.push(that.data.request + element + '.min.jpg'); }); } if (res.data.checkFiles) { res.data.checkFiles.split(',').forEach(item => { let it = item.split('/'); checkFiles.push({ 'name': it[it.length - 1], path: item }); }); } that.setData({ infoData: res.data, imageList: urls, minImageList: minUrls, checkFiles, }) } }); }, //保存 onSubmitSave() { let that = this let { infoData, result, comment, loginName } = that.data; //数据效验 if (!infoData.id) { app.toast("数据异常,请刷新页面重试!") return; } if (result == "") { app.toast("请选择审批结果!") return; } if (comment == "") { app.toast("请填写审批意见!") return; } let params = { id: infoData.id, checkResult: result, comment, approveStatus: result == '1' ? '4' : '3', updateBy: loginName } let msg = result == '1' ? '合格' : '不合格'; wx.showModal({ title: '提示', content: '是否确定审批' + msg + '?', success: function (sm) { if (sm.confirm) { // 用户点击了确定 可以调用了 that.submitForm(params); } else if (sm.cancel) { console.log('用户点击取消'); } } }) }, /** * 提交表单 * @param {*} params */ submitForm(params) { updateProjectFunVerify(params).then(res => { if (res.code == 200) { app.toast("审批成功!") setTimeout(() => { wx.redirectTo({ url: '../../../pageage/project_funVerify/list/index', }) }, 200) } }); }, //选择检测结果 onSelect(e) { this.setData({ result: e.detail.id }) }, //审批意见 onInputValue(e) { let comment = e.detail.value this.setData({ comment }) }, /** * 查询流程日志 */ getAuditinfo() { let params = { fromType: "5", fromId: this.data.id } selectProjectAuditinfoList(params).then(res => { if (res.code == 200) { this.setData({ flowRecordList: res.data }) } }); }, // 手风琴 onChange(event) { this.setData({ activeName: event.detail, }); }, //展示图片 showImg: function (e) { var that = this; wx.previewImage({ urls: that.data.imageList, current: that.data.imageList[e.currentTarget.dataset.index] }) }, //选择检测结果 onSelect(e) { this.setData({ result: e.detail.id }) }, //审批意见 onInputValue(e) { let comment = e.detail.value this.setData({ comment }) }, returnToPage: function () { /*关闭当前页面,跳转到应用内的某个页面。但是不允许跳转到 tabbar 页面*/ wx.redirectTo({ url: '../../../pageage/project_funVerify/list/index', }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })