const mixins = require('@/mixins/index.js')
const Constants = require('@/utils/Constants.js');
Page({
  mixins: [mixins],
  /**
   * 页面的初始数据
   */
  data: {

    cardList: [{
      name: 'main'
    }, {
      name: 'items',
      title: '资金转账'
    }, {
      name: 'file'
    }],
    contentObj: {
      main: [{
          code: 'staffId',
          name: 'staffName',
          title: '经手人', //'经手人',mixins.$t("procureStaff")
          type: 'choose',
          urlKey: 'chooseStaff',
          required: true,
        },
        {
          code: 'orgId',
          name: 'orgName',
          title: '经手部门',
          type: 'choose',
          urlKey: 'chooseOrg',
          required: true,
        },

      ],
      items: [{
          code: 'trfOutMac',
          name: 'trfOutMacName',
          title: '转出账户',
          type: 'choose',
          urlKey: 'chooseMoneyAccount'
        },
        {
          code: 'trfInMac',
          name: 'trfInMacName',
          title: '转入账户',
          type: 'choose',
          urlKey: 'chooseMoneyAccount'
        }, {
          code: 'amtTrf',
          type: 'number',
          title: '转出金额',
          required: true,
          control:'trfOutMac'
        }
      ],
      file: [{
        code: 'remarks',
        type: 'textarea',
        title: '备注',
        readonly:true,
      }, {
        code: 'file',
        type: 'uploader',
        title: '附件',
        readonly:true,
      }]
    },
    routeObjName: 'transfer',
  },
  /**
   * @desc : 给表单赋值
   * @date : 2024/2/1 15:49
   * @author : 王英杰
   */
  setValuesByEdit(data) {
    console.log("setValuesByEdit", data);
    let formData = JSON.parse(this.data.formData)
    formData = data.data
    formData.accountDate = data.data.accDate
    formData.itemList = data.dataItem
    this.setData({
      formData: JSON.stringify(formData),
    })

  },
    /**
     * @desc : 详细页面 （编辑）
     * @date : 2024/2/1 15:49
     * @author : 王英杰
     */
    toEdit(e) {
      let formData = JSON.parse(this.data.formData)
      let trfId = formData.trfId
      let that = this
      wx.navigateTo({
          url: this.data.route.add.url,
          events: {
              // 回调后，在这里给页面赋值
              bandData: function (e) { 
              }
          },
          success: function (res) {
              res.eventChannel.emit('params', {
                  id: trfId,
                  formMode: Constants.formMode.edit
              })
          }
      })
  },
  /**
   * @desc : 重写detail 
   * @date : 2024/2/1 15:49
   * @author : 王英杰
   */
  detail(id) {
    return this.excute(this.data.service, this.data.service.getMacTransferForUpdate + '/' + id, null);
  },







})