// monitor/pages/materialDetail/materialDetail.js
var Api = require("../../../utils/util.js");
Page({

  /**
   * 页面的初始数据
   */
  data: {
    formData: {}
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.setData({   
      materialId: options.materialId,   
      id: options.id,
      title: options.title 
    })
    wx.setNavigationBarTitle({
      title: options.title,
    })

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    this.getDetail()
  },

  //详情
  getDetail(e) {
    let that = this
    let url = '', dataObj = {}
    wx.showLoading({
      title: '加载中...',
    }) 
    if(this.data.title == '已用物料') {
      url = 'blade-operationOrderMaterial/operationOrderMaterial/getOrderUseFittingDetail'
      dataObj = {
        id: this.data.id,
      }   
    }else if(this.data.title == '可用物料') {
      url = 'blade-operationOrderMaterial/operationOrderMaterial/getOrderCanUseFittingDetail'      
      dataObj = {
        materialId: this.data.materialId,
        empUserId: wx.getStorageSync('userId')
      }     
    }
    Api.req(url, dataObj, 'get').then(res => {
        wx.hideLoading()
        if(res.code == 200){
          that.setData({
            formData: res.data,
          })
        }
      })
  },
})