export function reload() {
  /** 初化数据 form表单默认是post*/
  let { remoteUrl, remoteParams , requestFormat} = this;
  if (!remoteUrl) {
    return;
  }
  let _this = this;
  console.log( remoteUrl, remoteParams, requestFormat);
  let remoteUrlParams = {
    method: "post",
    url: remoteUrl,
    data: remoteParams || {},
  }
  if(requestFormat === "JSON" ) {
    remoteUrlParams.data = remoteParams;
  } else if(requestFormat === "formData") {
    remoteUrlParams.headers= {
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  }
  this.vLoading = true;
  return this.axios(remoteUrlParams)
    .then((response) => {
      if (response.success) {
        _this.$emit("onSubmit", response);
        _this.$emit('change', false);
      } else {
        _this.$exception({
          code: response.code,
          data: null,
          message: response.message || "操作失败",
          success: false,
        })
        _this.$emit("onSubmit", response);
      }
      _this.vLoading = false;
      return
    })
    .catch((error) => {
      _this.vLoading = false;
      _this.$emit("onSubmit", false);
    });
}

export default { reload };
