
var app = getApp()
var that;
Page({
  data: {
    review_id: '',
    isBh: false,//是否显示驳回弹窗
    textArea: ""
  },
  onLoad(e) {
    that = this;

    dd.setNavigationBar({ title: "详情" });
    if (e.id) {
      that.setData({ review_id: e.id });
      that.getData();
    }
    if (e.is) {
      that.setData({ is: e.is });
    }
  },
  showImg(e) {
    var index = e.target.dataset.index;
    var item = e.target.dataset.item
    dd.previewImage({
      current: index,
      urls: item
    });
  },
  submit() {
    dd.navigateTo({
      url: '../approve/approve?id=' + that.data.dataDetail.id
    })
  },
  bindTextAreaBlur(e) {
    this.setData({
      textArea: e.detail.value
    });
  },
  openBh(e) {
    this.setData({ isBh: !this.data.isBh, textArea: '' })
  },
  confirmBh() {
    var item = that.data.bhItem;
    if (!that.data.textArea) {
      app.globalData.showToast("请输入审批意见");
      return;
    }
    app.$post("api/integral/review", { review_id: that.data.review_id, remark: that.data.textArea, action: "refuse", ticket_count: 0 }).then((res) => {
      app.globalData.showToast("已审批");
      setTimeout(() => {
        dd.navigateBack({ delta: 1 });
      }, 1000);
    })
  },
  openCx() {
    dd.confirm({
      title: '温馨提示',
      content: '您确定撤销此项吗?',
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      success: (result) => {
        if (result.confirm) {
          app.$post("api/integral/review/destroy", { review_id: that.data.review_id }).then((res) => {
            app.globalData.showToast("已撤销");
            setTimeout(() => {
              dd.navigateBack({
                delta: 1
              })
            }, 1000);
          })
        }
      },
    });
  },
  getData() {
    // that.data.review_id
    app.$get("api/integral/review", { review_id: that.data.review_id }).then((res) => {
      var data = res.data.data;
      data.typeName = app.getTypesItem(data.pt_id).name;
      this.setData({
        dataDetail: data
      })
    })
  },
});
