riku
2026-01-19 068be2757aa2d51e3f6604dae54287683160ad0e
pages/mExtra/pSupervisionchange/pSupervisionchange.js
@@ -1,8 +1,8 @@
// pages/mExtra/pSupervisionchange/pSupervisionchange.js
import moment from '../../../utils/moment.min'
import bLoadingStatus from '../../../base/behaviors/bLoadingStatus'
import bLoadingToast from '../../../base/behaviors/bLoadingToast'
const taskservice = require('../../../service/taskservice')
import moment from '../../../utils/moment.min';
import bLoadingStatus from '../../../base/behaviors/bLoadingStatus';
import bLoadingToast from '../../../base/behaviors/bLoadingToast';
const taskservice = require('../../../service/taskservice');
Page({
  behaviors: [bLoadingStatus, bLoadingToast],
@@ -16,7 +16,7 @@
    subTask: {},
    problemList: [],
    previewImageUrls:[],
    previewImageUrls: [],
    previewCurrent: 0,
    showPreview: false,
  },
@@ -27,130 +27,135 @@
  onLoad(options) {
    console.log(options);
    if (options.time) {
      let now = new Date()
      now = now.getTime()
      if (now - options.time <= (1000 * 60 * 60 * 24 * 2)) {
      let now = new Date();
      now = now.getTime();
      if (now - options.time <= 1000 * 60 * 60 * 24 * 2) {
        this.setData({
          enable: true,
        })
        });
        if (options.subTaskId) {
          this.sId = options.subTaskId
          this.getSubtask()
          this.getProblems()
          this.sId = options.subTaskId;
          this.getSubtask();
          this.getProblems();
        } else {
          this.setData({
            enable: false,
            reason: '该巡查任务已失效',
          })
          });
        }
      }
    } else {
      this.setData({
        enable: true,
      });
      this.sId = '6tsjAYdt0EUGxsdU';
      this.getSubtask();
      this.getProblems();
    }
    // this.sId = 'TUIk7Jf3UKmaZM90'
    // this.getSubtask()
    // this.getProblems()
  },
  onShow() {
    wx.hideHomeButton({
      success: (res) => {},
      fail: (res) => {},
      complete: (res) => {},
    })
      success: res => {},
      fail: res => {},
      complete: res => {},
    });
  },
  getSubtask() {
    var that = this
    var that = this;
    taskservice.getSubtask(this.sId, {
      success(data) {
        data.planstarttime = moment(data.planstarttime).format('YYYY年MM月DD日')
        data.planstarttime = moment(data.planstarttime).format(
          'YYYY年MM月DD日',
        );
        that.setData({
          subTask: data
        })
          subTask: data,
        });
      },
      fail(err) {
      },
      complete() {
      }
    })
      fail(err) {},
      complete() {},
    });
  },
  getProblems() {
    var that = this
    this.setData({loading: true})
    var that = this;
    this.setData({ loading: true });
    taskservice.getProblem(this.sId, {
      success(data) {
        data.forEach(d => {
          d.proPics = []
          d.changePics = []
          d.proPics = [];
          d.changePics = [];
          if (d.mediafileList) {
            d.mediafileList.forEach(m => {
              const pic = taskservice.imgUrl + m.extension1 + m.guid + '.jpg'
              const pic = taskservice.imgUrl + m.extension1 + m.guid + '.jpg';
              if (m.ischanged) {
                d.changePics.push(pic)
                d.changePics.push(pic);
              } else {
                d.proPics.push(pic)
                d.proPics.push(pic);
              }
            });
            });
          }
        });
        that.setData({
          problemList: data
        })
          problemList: data,
        });
      },
      fail(err) {
        that.setData({
          problemList: []
        })
          problemList: [],
        });
      },
      complete() {
        that.setData({
          loading: false
        })
      }
    })
          loading: false,
        });
      },
    });
  },
  changeProblem(e) {
    const index = e.currentTarget.dataset.index;
    const pro = this.data.problemList[index]
    const pro = this.data.problemList[index];
    wx.navigateTo({
      url: '/pages/mExtra/pSupervisionchangeDetail/pSupervisionchangeDetail',
      events: {
        uploadOver: (data) => {
        uploadOver: data => {
          console.log(data);
          setTimeout(() => {
            this.getProblems()
            this.getProblems();
          }, 1000);
        }
          this.getOpenerEventChannel().emit('uploadDone')
        },
      },
      success: (res) => {
      success: res => {
        res.eventChannel.emit('acceptDataFromOpenerPage', {
          data: [pro],
          index: index
        })
          index: index,
        });
      },
    })
    });
  },
  //图片放大预览
  previewImage(e) {
    const {index, type} = e.currentTarget.dataset;
    const previewImageUrls = []
    const pro = this.data.problemList[index[0]]
    const { index, type } = e.currentTarget.dataset;
    const previewImageUrls = [];
    const pro = this.data.problemList[index[0]];
    if (type == 'pro') {
      pro.proPics.forEach(p => {
        previewImageUrls.push(p)
      });
        previewImageUrls.push(p);
      });
    } else {
      pro.changePics.forEach(p => {
        previewImageUrls.push(p)
        previewImageUrls.push(p);
      });
    }
    this.setData({
      previewImageUrls,
      previewCurrent: index[1],
      showPreview: true,
      title: pro.problemname
      title: pro.problemname,
    });
  },
})
});