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:'',
    //被投诉人
    respondentNameList: [
      // {id: 222, name: "拜访"}, {id: 223, name: "远程服务"}, {id: 224, name: "现场服务"}
    ],
    respondentIndex:'',
    respondentId:'',
   



    //投诉人
    proposerNameList: [
      // {id: 222, name: "拜访"}, {id: 223, name: "远程服务"}, {id: 224, name: "现场服务"}
    ],
    proposerIndex:'',
    proposerId:'',

    groupId: '', 
    groupName: '',


    rules: {
      customerName: [{ required: true, message: '客户必填', trigger: 'blur' }],
      cdate: [{ required: true, message: '日期必填', trigger: 'blur' }],
      proposerName: [{ required: true, message: '投诉人必填', trigger: 'blur' }],
      telephone: [{ required: true, message: '投诉人电话必填', trigger: 'blur' }],
      receiverName: [{ required: true, message: '投诉接收人必填', trigger: 'blur' }],
      respondentName: [{ required: true, message: '被投诉人必填', trigger: 'blur' }],
      content: [{  required: true, message: '情况说明必填', trigger: 'blur' }],
    },
    // 新增/编辑
    create: {
        dialogStatus: '',
        temp: {
           customerId: '', customerName: '',  groupId: '',  groupName: '', cdate: util.getToday(),  proposerId: '',  proposerName: '',   receiverId: '',  receiverId2: '@insertContactsNew.LastInsertId', receiverName: '',   telephone: '', respondentId: '',  respondentName: '', content: '',  remark: '',  created: util.getToday(), receiverChoose: 'true' 
        },
    },
    create2: {
      dialogStatus: '',
        temp: {
          handlerName: '', hdate: '',  groupId: '',  content: '', remark: '' 
        },
    }
  },

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

    console.log(app.globalData.g_lgName)


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

    //获取编辑内容
    util.getDataByName({ name:'getHandle', parammaps: {"cid":id} }, this.getShowList2)

    
  },
  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, 
      respondentId: res.data.list[0].respondentId,
      proposerId: res.data.list[0].proposerId
    })
  },
  getShowList2:function(res){
    console.log('展示数据======>', res.data.list)
 
    this.setData({
      ['create2.temp']:  res.data.list[0]
    })
  },
 
  
  onReady: function () {

  },

  
  onShow: function () {

  },

 
  onHide: function () {

  },

   
  onUnload: function () {

  },

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

  },

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

  },

 
  onShareAppMessage: function () {

  }
})