// other/pages/qualityAcceptDetail/qualityAcceptDetail.js
const {
  qualityDetailData,
} = require("../../../api/api");
const app = getApp()
const { routeLink } = require("../../../utils/route.js");
Page({

  /**
   * 页面的初始数据
   */
  data: {
    tabIndex: 1,
    detail: {},
    cjEntry: [],//检验电站   
    searchData: ''
  },

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

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    this.getDetail()
  },
  /** 搜索 **/
  keyWordsSearch(res) { 
    this.setData({
      searchData: res.detail, //搜索内容 
    })   
    this.getDetail()
  },
  //详情
  getDetail(){
    wx.showLoading({
      title: "加载中"
    });
    qualityDetailData({     
      id: this.data.id,
      tenantName: this.data.searchData
    }).then(res=>{     
      if(res.code == 200){
        this.setData({
          detail: res.data.detailRecord.columns,
          cjEntry: res.data.cjEntry.map(itm=>itm.columns),
        })  
      }
      wx.hideLoading();
    });
  },

  /** 复制 **/
  copy(e) {
    const code = e.currentTarget.dataset.code;
    wx.setClipboardData({
      data: code,
      success(res) {
        wx.showToast({
          title: '已复制',
          icon: 'none'
        })
      }
    })
  },
  //查看
  bindSee(e){
    routeLink("/other/pages/rectifyForm/rectifyForm?entryId=" + e.currentTarget.dataset.id+ '&projectId='+ e.currentTarget.dataset.eid+'&title=查看');
  },
})