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

  data: {
    allDisabled:true,//有客户下拉时临时用来控制其他下拉不显示
    c_txt_Show:false,
    customerShow:false,
 
  
   
    id:"",
    
 
    rules: {
      remark: [{ required: true, message: '内容必填', trigger: 'blur' }],
 
    },
    // 新增/编辑
    create: {
        dialogStatus: '',
        temp: {          
  
           payDate: '',
           remark: '', 
           created: util.getToday(), 
           id:"",
 
        },

        
    }
  },

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

   
    var id = options.id;
    this.setData({
      id:id,
      ['create.temp.id']:id
    })
 
 
  },
   
 
  
 
  
  //保存
  submit:function(e){
    
    var detail_value = e.detail.values
    var detail_errors = e.detail.errors
    var detail_errors = e.detail.errors
    console.log("detail_value",detail_value)
    console.log("create.temp",this.data.create.temp)

 
    const submit_data = Object.assign({}, this.data.create.temp, detail_value)
   
    console.log("保存发送：",submit_data)
 
    
    submit_data.createrId = app.globalData.g_createrId

    var send_data =    {
      "name":"insertServiceFeedback",
      "page":1,"offset":1,
      "pagecount":1000,
      "returntype":"Map",
      "parammaps":{
        "serviceId":this.data.id,
        "createrId":app.globalData.g_createrId,
        "remark":submit_data.remark,
      }
    }

    console.log("send_data",JSON.stringify(send_data))

 

    

    //验证必填项是否为空
    if(submit_data.costStatus == ""){
      wx.showToast({title: '款项状态必填',icon: 'none',duration: 2000})
    } else {
      if( wx.getStorageSync('isLoading')  == "true"){
        wx.showToast({
          title: '正在保存中，请稍等！',
          icon: 'none',
          duration: 2000
        })
      } else {
        util.postDataByName(send_data, this.getListSuccess)
      }
    }
  },

  getListSuccess:  function (res) {
    console.log('table数据======>', res)
    if (res.msg !== 'fail') {
      wx.showToast({
        title: '保存成功',
        icon: 'success',
        duration: 2000,
        success: function(){
            setTimeout(() => {
                wx.redirectTo({ url:"../siteService/siteService"})
              }, 1500)
        }
      })
    } else {
      wx.showToast({
        title: '保存失败'+res.data,
        icon: 'error',
        duration: 2000,
      })
    }
  },

 
  
  onReady: function () {

  },

  
  onShow: function () {

  },

 
  onHide: function () {

  },

   
  onUnload: function () {

  },

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

  },

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

  },

 
  onShareAppMessage: function () {

  }
})