/*******************************************************************************
 * 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')
const app = getApp()
Page({
  mixins: [mixins],
  /**
   * 页面的初始数据
   */
  data: {
    // 查询条件
    searchContent: [
      { code: 'createtime', title: '近30天', defaultValue: 5, searchType: Constants.searchType.date },
      { code: 'staff', title: '业务员', dropType: 'staff' },
      // { code: 'status', title: '订单状态',searchType:Constants.searchType.switch,list:[{code:'审-异常',title:'异常'},{code:'审-待审',title:'待审'}] }, 
      {
        code: 'sort', title: '可售量升序',searchType:Constants.searchType.radio, value:1, options: [
          {
            "text": "可售量升序",
            "value": 1
          },
          {
            "text": "可售量降序",
            "value": 2
          }
        ],
      },
      { code: 'choose', title: '筛选', searchType: Constants.searchType.pick }],

    // 查询条件-筛选
    pullMenuList: [{ code: 'outStatus', pullType: 'mSelect', typeName: 'outStatus' }, { code: 'receiveStatus', pullType: 'mSelect', typeName: 'receiveStatus' }, { code: 'followCount', dataType: 'number' }, { code: 'nextFollowTime', dataType: 'date' }],

    // 假数据
    dataList: [{ salesChannelName: '零售', customerId: 11, customerName: '张三', displayStatus: '成交', backgroundColor: 'red', orderNo: 'SA-LWYD-ZOO-202401300SBG', customerPhone: '15659741980', addressFull: '辽宁省沈阳市浑南区沈阳市浑南区人民政府(新聪街西)1', orgName: '零售部', collectName: '付款', staffName: '薛玉', tsumAmount: 3000, categoryQuantity: 1, tsumQuantity: 1, makeTime: '2023-1-3', collectStatus: 'noCollect', collectAmount: 1000, collectStatusAmount: 200, customerForm: '自然进店', tags: ['ff', 'ddd'] }, { salesChannelName: '分销', customerName: '李四', displayStatus: '未成交', orderNo: 'SA-LWYD-ZOO-202401300SBD', customerPhone: '15659741980', addressFull: '辽宁省沈阳市浑南区沈阳市浑南区人民政府(新聪街西)2', orgName: '零售部', staffName: '薛玉', tsumAmount: 4000, categoryQuantity: 2, tsumQuantity: 2, makeTime: '2023-12-3', collectStatus: 'noCollect', collectAmount: 1000 }],

    // 列表区（脚部金额）
    footerAmount: { name: 'tsumAmount', title: '合计金额' },
    // 列表区（脚部信息）
    footerInfo: [{ name: 'categoryQuantity', title: '品类 共' }, { name: 'tsumQuantity', title: '件' }],
    // 列表区（内容）
    contentList: [{ name: 'orderNo', title: '订单单号' }, { name: 'customerPhone', title: '客户电话' }, { name: 'addressFull', title: '客户地址' }, { name: [{ name: 'orgName', title: '' }, { name: 'staffName', title: '业务员' }], title: '客户地址' }],

    contentObj: {
      '成交': [{ name: 'orderNo', title: '订单单号' }, { name: 'customerPhone', title: '客户电话', phone: true }, { name: 'addressFull', 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: 'follow' }, { name: 'followTask', title: '跟进任务' }, { name: 'order', title: '销售订单' },
    { name: 'collection', title: '客户收款' }, { name: 'merge', title: '客户合并' }],

    totallength: 0, //视图下方提醒数量

    // 路由
    routeObjName: 'staff',

    buttonList:[{code:'add',title:'新建',width:'120rpx',color:'#CAA977'},{code:'submit',title:'提交'}],
    contentList:[{code:'flag',title:'开单并出库办理',type:'checkbox'},{code:'need',title:'需收款',type:'str'},{code:'amount',content:2000,type:'number'}],
    // contentList:[{code:'need',title:'需收款',type:'str'},{code:'amount',content:2000,type:'number'},{code:'count',bill:5,quantity:100,type:'count'}],
    // contentList:[{code:'flag',title:'开单并出库办理',type:'checkbox'},{code:'amount',content:2000,type:'number',title:'合计收款'}],
    // contentList:[],
    btnFormData:null,

    testData: [{ id: 1, parentId: 0, name: '部门A' }, { id: 2, parentId: 1, name: '部门A1' }, { id: 3, parentId: 1, name: '部门A2' }, { id: 4, parentId: 2, name: '部门A11' }, { id: 5, parentId: 0, name: '部门B' }, { id: 6, parentId: 5, name: '部门B1' }]
  },
  /**
   * 跳转客户详细
   */
  toDetail(e) {
    let ID = e.currentTarget.dataset.item.customerId
    this.setData({
      selectflag: true
    })
    wx.navigateTo({
      url: './detail/detail?ID=' + ID,
    })
  },
  toTitle(e) {
    console.log('t1', e);
  },
  toStatus(e) {
    console.log('t2', e);
  },
  toPoint(e) {
    console.log('t3', e);
    this.setData({
      showShare: true
    })
  },
  toAdd() {
    wx.navigateTo({
      url: this.data.route.add.url,
      success: function (res) {
        // 通过eventChannel向被打开页面传送数据 TODO 测试例子url是写死的，实际中，需要从route中读取
        res.eventChannel.emit('params', { url: '/package-basic-data/pages/test/add/add' })
      }
    })
  },
  /**
   * @desc : 校验
   * @date : 2024/2/1 15:49
   * @author : 周兴
   */
  openValidData(item, name) {
    console.log('item', item, name, item.customerId);
    if (!item.customerId) {
      wx.showToast({
        title: '无此联系人,或陌生接待',
        icon: 'none'
      })
      return false;
    }
    return true;
  },

  // /**
  //  * @desc : 查询
  //  * @date : 2024/2/1 15:49
  //  * @author : 周兴
  //  */
  // getData(params) {
  //   console.log('e3',this.data.btnFormData);
  //   return this.excute(this.data.service,this.data.service.selectByCond,params);
  // },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log('ttt', util.convertToChildren(this.data.testData));
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  },
})