// pageage/safetyManagement/securityCheckGR/index.js
const app = getApp()
Page({

    /**
     * 页面的初始数据
     */
    data: {
        deptId:"",
        loginName:"",
        projectId:"",
        minRoleId:"",
        projectData:{},
        initData: {},
        show:false,
        listData:[],
        request:app.globalData.reqUrl
    },

    addInfo(e){
        let {id,name,deploymentId,flowKey} = e.currentTarget.dataset.set
        if(flowKey=="flow_xmglzdl_qjspb"){
          wx.redirectTo({
            url: `../initLeaveTask/index?procDefId=${id}&approveTitle=${name}&deploymentId=${deploymentId}`,
          })
        }else{
          wx.redirectTo({
            url: `../initTask/index?procDefId=${id}&approveTitle=${name}&deploymentId=${deploymentId}`,
          })
        }
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
     //获取缓存数据
      wx.getStorage({
        key: 'userinfo',
        success:res=>{
          this.setData({
            loginName:res.data.loginName,
            projectId:app.globalData.projectId,
            initData:{text:app.globalData.projectName,id:app.globalData.projectId}
          })  
          this.getListData(res.data.loginName);
        }
      })
    },

  /**
    * 查询项目举牌验收数据
    */
   getListData(loginName) {
    var that = this;
    let param = {
        "username": loginName
    }
    wx.request({
      url: app.globalData.reqUrl + '/wechat/flowTask/myFlowDefinitionList',
      data:param,
      method: "get",
      success: function (res) {
        res = res.data;
        if(res.code=="200" && res.data.records){
          that.setData({
            listData:res.data.records
          })
        }else{
          app.toast(res.msg);
        }
      }
    });
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {

    },

    returnToPage: function () {
      /*关闭当前页面，跳转到应用内的某个页面。但是不允许跳转到 tabbar 页面*/
        wx.redirectTo({
          url: '../await/index',
        })
    },

      //项目切换 返回值
  onProjectSelect(e){
    let projectId = e.detail.id;
    let projectName = e.detail.text;
    app.globalData.projectId = projectId;
    app.globalData.projectName = projectName;  
    this.onLoad();
  },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    }
})