/*******************************************************************************
 * Copyright(c) 2022 dongke All rights reserved. / Confidential
 * 类的信息：
 *		1.程序名称：
 *		2.销售退货列表
 * 编辑履历：
 *		作者				日期					版本				修改内容
 *		于继渤		        2022-0-12	            1.00		   	    
 *******************************************************************************/
const Constants = require('@/utils/Constants.js');
const util = require('@/utils/util.js')
const mixins = require('@/mixins/index.js')
Page({
  mixins: [mixins],
  /**
   * 页面的初始数据 
   */
  data: {
    tagList: [{ title: "全部单据" }, { title: "待出库" }, { title: "已出库" }],

    // 查询条件
    searchContent: [{
      code: 'createtime',
      title: '近30天',
      defaultValue: 5,
      searchType: Constants.searchType.date
    }, {
      code: 'choose',
      title: '筛选',
      searchType: Constants.searchType.pick
    }],

    // 查询条件-筛选
    pullMenuList: [{
      code: 'outStatus',
      pullType: 'mSelect',
      typeName: 'outStatus'
    }, {
      code: 'receiveStatus',
      pullType: 'mSelect',
      typeName: 'receiveStatus'
    }, {
      code: 'designStatus',
      pullType: 'mSelect',
      typeName: 'designStatus'
    }, {
      code: 'customerFrom',
      pullType: 'mSelect',
      typeName: 'customerFrom'
    }, {
      code: 'keyType',
      pullType: 'mSelect',
      typeName: 'keyType'
    }, {
      code: 'delivery_Time',
      dataType: 'date'
    }],



    // 列表区（脚部金额）
    footerAmount: {
      name: 'outAmt',
      title: '退货金额'
    },
    // 列表区（脚部信息）
    footerInfo: [{
      name: 'categoryQuantity',
      title: '共计'
    }, {
      name: 'outQty',
      title: '件'
    }],
    // 列表区（内容）
    contentList: [
      { name: 'outNo', title: '订单编号' },
      { name: 'cusPhone', title: '客户电话' },
      { name: 'addressFull', title: '客户地址' },
      { name: [{ name: 'orgName', title: '' }, { name: 'staffName', title: mixins.$t('staffId')  }], title: mixins.$t('storeInformation') }
    ],
    buttonSaveList: [{ code: 'add', title: mixins.$t("add") }],
    contentSaveList: [{ code: 'need', title: mixins.$t("totalAmount"), type: 'str' }, { code: 'amount', content: 2000, type: 'number' }],
    contentObj: {
      '成交': [{
        name: 'orderNo',
        title: '订单单号'
      }, {
        name: [{
          name: 'orgName',
          title: ''
        }, {
          name: 'staffName',
          title: '业务员'
        }],
        title: '客户地址'
      }],
      '未成交': [{
        name: 'orderNo',
        title: '订单单号'
      }, {
        name: 'customerPhone',
        title: '客户电话'
      }, {
        name: [{
          name: 'orgName',
          title: ''
        }, {
          name: 'staffName',
          title: '业务员'
        }],
        title: '客户地址'
      }]
    },

    // 弹出按钮
    buttonList: [{
      name: 'warehousingProcessing',
      title: '入库办理'
    }, , {
      name: 'salesReturnReversal',
      title: '销售退货冲正'
    }

    ],

    // 路由
    routeObjName: 'saleOutBoundReturn',
    active: 0
  },
  /**
     * @desc : 加载数据
     * @author : 于继渤
     * @date : 2024/1/23 9:16
     */
  getData(params) {
    return this.excute(this.data.service, this.data.service.selectByCond, params);
  },


  toDetail(e){
    let outId = e.detail.item.outId
    wx.navigateTo({
      url: this.data.route.edit.url,
      success: function (res) {
        // 通过eventChannel向被打开页面传送数据 TODO 测试例子url是写死的，实际中，需要从route中读取
        res.eventChannel.emit('params', { id: outId, formMode: Constants.formMode.detail,formType: Constants.formMode.detail})
      }
    })
  }
})