// pages/transaction/transactionDetail/transactionDetail.js
import * as UTIL from '../../../utils/util.js';
import * as API from '../../../utils/API.js';
let EVN_CONFIG = require('../../../env/env');

const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    isIPX: app.globalData.isIPX,
    form:{}
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    var that = this ;
    let array = JSON.parse(options.options);
    // 账户分类 字典查询
    UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'town_account_type', {method:'GET'}, {
      success: (res) => {
        that.setData({
          townAccountTypeOptions:res.data,
        })
      }
    })
    // 管控类型 字典查询
    UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'cashier_account_management_control_type', {method:'GET'}, {
      success: (res) => {
        that.setData({
          managementControlTypeOptions:res.data,
        })
        array.managementControlTypeText = UTIL.getTransform(array.managementControlType,res.data);
      }
    })
    //中心账套查询
    UTIL.httpRequest(API.URL_GET_GETTACCOUNTCENTRAL, {method:'GET'}, {
      success: (res2) => {
        array.centralBookIdText = res2.data.filter(function (e) { return e.id == array.centralBookId; })[0].bookName;
        that.setData({
          centralBookIdOptions:res2.data,
        })
      }
    })
    if (array.managementControlType == 2) {
      //会计科目查询
      UTIL.httpRequest(API.URL_GET_GETACCOUNTCENTRAL, {method:'GET',bookId:array.centralBookId}, {
        success: (res2) => {
          array.centralSubjectIdText = res2.data.filter(function (e) { return e.subjectId == array.centralSubjectId; })[0].subjectName;
          that.setData({
            centralSubjectIdOptions:res2.data,
          })
        }
      })
    }

    setTimeout(function(){
      that.setData({
        form:array
      })
    },3000)
  },
  back:function(){
    wx.navigateBack({
      delta: 1
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

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

  },

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

  },

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

  },

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

  },

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

  },

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

  }
})