123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 |
- // pages/meeting-inspection/meeting-inspection.js
- const util = require('../../utils/util.js');
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- inspectionProjectList: [],
- currentTab: 20,//20:会前 30:会中 40:会后
- meetingId: '',
- inspectionResultList: [],
- abnormalIndex: null,
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- let that = this;
- let templetId = options.templetId;
- let meetingId = options.meetingId;
- util.get({
- url: '/api/inspection/template/getProjectByTemplateId',
- header: {
- 'Content-Type': 'application/x-www-form-urlencoded'
- },
- data: {
- templateId: templetId
- },
- success: (res) => {
- wx.hideLoading();
- if (res.data.code != 200) {
- util.toast(res.data.msg);
- } else {
- that.setData({
- inspectionProjectList: res.data.data,
- meetingId: meetingId
- });
- }
- }
- });
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- let that = this;
- let item = wx.getStorageSync('inspectionResultItem');
- if (item) {
- let obj = JSON.parse(item);
- let index = that.data.abnormalIndex;
- that.data.inspectionProjectList[index].result = 20;
- that.data.inspectionProjectList[index].color = '#E95543';
- that.data.inspectionProjectList[index].results = '不正常';
- let list = that.data.inspectionResultList;
- list.push(obj);
- that.setData({
- inspectionProjectList: that.data.inspectionProjectList,
- inspectionResultList: list,
- abnormalIndex: null
- });
- wx.removeStorageSync('inspectionResultItem');
- }
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- },
- switchTab(e) {
- this.setData({ currentTab: e.currentTarget.dataset.no });
- },
- /**
- * 巡检结果正常
- * @param {*} e
- */
- normal: function (e) {
- let that = this;
- // 修改巡检结果为正常(10)
- that.data.inspectionProjectList[e.currentTarget.dataset.index].result = 10;
- that.data.inspectionProjectList[e.currentTarget.dataset.index].color = '#2EC3CD';
- that.data.inspectionProjectList[e.currentTarget.dataset.index].results = '正常';
- let list = that.data.inspectionResultList;
- list.push({
- inspectionProjectId: e.currentTarget.dataset.id,
- result: 10
- });
- that.setData({
- inspectionProjectList: that.data.inspectionProjectList,
- inspectionResultList: list
- });
- },
- /**
- * 巡检结果不正常
- * @param {*} e
- */
- abnormal: function (e) {
- this.setData({
- abnormalIndex: e.currentTarget.dataset.index
- });
- wx.navigateTo({
- url: '../meeting-inspection-abnormal/meeting-inspection-abnormal?inspectionProjectId=' + e.currentTarget.dataset.id,
- })
- },
- /**
- * 历史记录
- * @param {*} e
- */
- history: function (e) {
- wx.navigateTo({
- url: '../meeting-inspection-history/meeting-inspection-history',
- });
- },
- /**
- * 提交巡检结果
- */
- submitInspection: function () {
- let that = this;
- let inspectionResultList = that.data.inspectionResultList;
- if (!inspectionResultList || inspectionResultList.length < 1) {
- util.toast('请选择巡检结果');
- return;
- }
- wx.showModal({
- cancelColor: 'cancelColor',
- title: '巡检工程师',
- showCancel: false,
- editable: true,
- placeholderText: '请输入姓名',
- success: (res) => {
- if (!res.content) {
- util.toast('请输入姓名');
- return;
- } else {
- util.post({
- url: '/api/inspection/record/addBean',
- data: {
- meetingId: that.data.meetingId,
- inspectionType: that.data.currentTab,
- inspectionResultList: inspectionResultList,
- inspectionPersonnel: res.content
- },
- success: (res) => {
- wx.hideLoading();
- if (res.data.code != 200) {
- util.toast(res.data.msg);
- } else {
- util.toast(res.data.msg);
- setTimeout(() => {
- wx.navigateBack({
- delta: -1,
- });
- }, 1000);
- }
- }
- });
- }
- }
- });
- }
- })
|