var util = require('../../../utils/util.js')
const app = getApp();
Page({

  data: {
    customerNameList: [
      // {id: 11, name: "海文牧场"}, {id: 22, name: "成宏牧场"}, {id: 32, name: "瑞福牧业"}
    ],
    customerIndex:'',
    customerId:'',
    receiverNameList: [
      // {id: 56, name: "苗舒怡"},{id: 57, name: "颛孙洋洋"},{id: 58, name: "李涛"}
    ],
    receiverIndex:'',
    receiverId:'',
    visitNameList: [
      // {id: 222, name: "拜访"}, {id: 223, name: "远程服务"}, {id: 224, name: "现场服务"}
    ],
    visitIndex:'',
    visitId:'',
    telvisitNameList: [
      // {id: 222, name: "拜访"}, {id: 223, name: "远程服务"}, {id: 224, name: "现场服务"}
    ],
    telvisitIndex:'',
    telvisitId:'',
    groupId: '', 
    groupName: '',

   
   
 
    rules: {
      customerName: [{ required: true, message: '客户必填', trigger: 'blur' }],
      rdate: [{ required: true, message: '拜访日期必填', trigger: 'blur' }],
      // visiterId: [{ required: true, message: '必填', trigger: 'blur' }],
      receiverName: [{ required: true, message: '接待人必填', trigger: 'blur' }],
      content: [{  required: true, message: '情况说明必填', trigger: 'blur' }],
    },
    // 新增/编辑
    create: {
        dialogStatus: '',
        temp: {
           customerId: '', 
           customerName: '', 
           groupId: '', 
           groupName: '', 
           rdate: util.getToday(), 
           employeeId: '', 
           employeeName: '', 
           receiverId: '', 
           receiverId2: '@insertContactsNew.LastInsertId', 
           receiverName: '', 
           remark: '', 
           content: '', 
           visitId: '', 
           visitName: '', 
           telvisitId: '', 
           telvisitName: '',
           created: util.getToday(), 
           receiverChoose: 'true' 
        },
        
    }
  },

  onLoad: function (options) {
    // 表单初始化
    wx.lin.initValidateForm(this)

    var id = options.id;
    console.log(id)
    //获取编辑内容
    util.getDataByName({ name:'getRemoteById', parammaps: {"id":id} }, this.getShowList)

  
    
  },
  getShowList:function(res){
    console.log('展示数据======>', res.data.list)
    var customerId = res.data.list[0].customerId
    this.setData({
      ['create.temp']:  res.data.list[0],
 
      customerId: res.data.list[0].customerId, 
      receiverId: res.data.list[0].receiverId, 
      visitId: res.data.list[0].visitId,
      telvisitId: res.data.list[0].telvisitId
    })
  
  },

  
 
  
  onReady: function () {

  },

  
  onShow: function () {

  },

 
  onHide: function () {

  },

   
  onUnload: function () {

  },

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

  },

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

  },

 
  onShareAppMessage: function () {

  }
})