import axios from "axios";
import {message, notification} from "ant-design-vue";
import qs from 'qs';
import JSONBIG from 'json-bigint';
import {blobValidate, tansParams} from "@/utils/fmea";
import errorCode from '@/utils/errorCode';
import {saveAs} from 'file-saver';

var fmBaseUrl =
  process.env.VUE_APP_MERGE == 1 ? process.env.VUE_APP_BASE_URL_FM : "";
var MOrDFEBaseUrl =
  process.env.VUE_APP_MERGE == 1 ? process.env.VUE_APP_BASE_URL_DVP : "";

var isLook = getCookie("isLook") ? getCookie("isLook") : 1; //查看=1，编制=2
var stepIndex = getCookie("stepIndex") ? getCookie("stepIndex") : 0;

axios.defaults.timeout = 60000;
axios.defaults.withCredentials = true;

console.log("调式模式:" + process.env.NODE_ENV + "调用ENV:" + process.env.VUE_APP_ENV);
var globalSwitch = process.env.VUE_APP_ENV == 'localDev'; // 全局开关  true-本地开发  false-线上开发
var fmUrl;
if (process.env.VUE_APP_ENV == "dev") {
  //开发环境
  var requestUrl = "https://dfmea.mychery.com"; //后端地址
  fmUrl = "https://dfmea.mychery.com" + fmBaseUrl; //fm路径，用于跳转
} else if (process.env.VUE_APP_ENV == "production") {
  //开发环境
  var requestUrl = "https://dfmea.mychery.com"; //后端地址
  fmUrl = "https://dfmea.mychery.com" + fmBaseUrl; //fm路径，用于跳转
} else if (process.env.VUE_APP_ENV == 1081) {       //外部测试环境
  //测试环境
  var requestUrl = "http://139.196.74.209:8090"; //后端地址
  fmUrl = "http://139.196.74.209:8090" + fmBaseUrl; //fm路径，用于跳转
  // var requestUrl = "http://localhost:8080"; //后端地址
  // fmUrl = "http://localhost:8080" + fmBaseUrl; //fm路径，用于跳转
} else if (process.env.VUE_APP_ENV === 'test') { // 测试环境
  var requestUrl = "http://10.190.8.6";
  fmUrl = "http://10.190.8.6" + fmBaseUrl;
} else if (process.env.VUE_APP_ENV === 'test8080') { // 8080测试环境
  var requestUrl = "http://1.117.58.199:8080";
  fmUrl = "http://1.117.58.199:8080" + fmBaseUrl;
} else if (process.env.VUE_APP_ENV === 'test57_171_8080') { // 8080测试环境
  var requestUrl = "http://121.4.57.171:8080";
  fmUrl = "http://121.4.57.171:8080" + fmBaseUrl;
} else if (process.env.VUE_APP_ENV == "uat") {        //上汽测试环境
  //ip测试环境
  var requestUrl = "https://dfmeauat.mychery.com"; //后端地址
  fmUrl = "https://dfmeauat.mychery.com" + fmBaseUrl; //fm路径，用于跳转
  // var requestUrl = "http://10.91.202.121:8087"; //后端地址
  // fmUrl = "http://10.91.202.121:8087" + fmBaseUrl; //fm路径，用于跳转
} else if (process.env.VUE_APP_ENV == "fmea") {
  //生产环境
  var requestUrl = "https://fmea.nioint.com"; //后端地址
  fmUrl = "https://fmea.nioint.com" + fmBaseUrl; //fm路径，用于跳转
} else if (process.env.VUE_APP_ENV == "domainUat") {
  //域名测试环境
  var requestUrl = "https://fmea-test.nioint.com"; //后端地址
  fmUrl = "https://fmea-test.nioint.com" + fmBaseUrl; //fm路径，用于跳转
} else if (process.env.VUE_APP_ENV == "local") {
  //开发环境
  var requestUrl = "https://dfmea.mychery.com"; //后端地址
  fmUrl = "https://dfmea.mychery.com" + fmBaseUrl; //fm路径，用于跳转
} else if (process.env.VUE_APP_ENV == "local8080") {
  var requestUrl = "http://192.168.0.178:8080"; //后端地址
  fmUrl = "http://192.168.0.178:8080" + fmBaseUrl; //fm路径，用于跳转
} else if (process.env.VUE_APP_ENV == "localDev") {
  //本地环境
  var requestUrl = "http://localhost:8084"; //后端地址
  fmUrl = "http://localhost:8080" + fmBaseUrl; //fm路径，用于跳转
}

axios.defaults.transformResponse = [
  function (data) {
    try {
      const json = JSONBIG({
        storeAsString: true
      });
      const res = json.parse(data);
      return res;
    } catch (e) {
      return data;
    }
  }
];

axios.defaults.baseURL = requestUrl; //后端地址
//http request 拦截器
axios.interceptors.request.use(
  (config) => {
    // 只针对get方式进行序列化
    if (config.method === 'get') {
      config.paramsSerializer = function (params) {
        return qs.stringify(params, {allowDots: true});
      };
    }
    const xsrfToken = getCookie("XSRF-TOKEN");
    const token = getCookie(process.env.VUE_APP_ENV + '_token');
    if (xsrfToken) {
      config.headers['X-XSRF-TOKEN'] = xsrfToken;
    }
    if (token) {
      config.headers['Authorization'] = 'Bearer ' + token;
    }
    // console.log('request 拦截前:');
    // console.log(config);
    if (config.data && config.data.sso && config.data.sso == "sso") {
      config.data = JSON.stringify(config.data);
      config.withCredentials = false;
      config.headers['Content-Type'] = "application/json;charset=UTF-8";
    } else {
      var isFile = config.url.indexOf("importPartsExcel") != -1;
      var importExcel = config.url.indexOf("importExcel") != -1;
      var isUpload = config.url.indexOf("uploadFile") != -1;
      var isReliaBench = config.url.indexOf("/import") != -1;
      var historyChart = config.url.indexOf("uploadFmeaCharFile") != -1;
      if (isFile || isUpload || importExcel || isReliaBench || historyChart) {
        config.data = config.data;
        config.headers['Content-Type'] = "multipart/form-data";
      } else {
        config.data = JSON.stringify(config.data);
        config.headers['Content-Type'] = "application/json;charset=UTF-8";
      }
    }
    // console.log('request 拦截后:');
    // console.log(config);
    return config;
  },
  (error) => {
    // console.log('request 拦截err:');
    // console.log(error);
    return Promise.reject(err);
  }
);

//响应拦截器即异常处理
axios.interceptors.response.use(
  (response) => {
    console.log('response 拦截 success');
    console.log(response);
    if (
      response &&
      response.data &&
      response.data.code &&
      (response.data.code == 304 || response.data.code == 100)
    ) {
      console.log("系统登出！：", response);
      toLogin();
      throw new Error('登录超时');
    } else if (response && (response.data.code == 'E009905')) {
      // toLogin();
      location.href = fmUrl + '/#/unlicense';
      throw new Error('许可过期');
    } else if (response && (response.data.code == 'E009906')) {
      // toLogin();
      location.href = fmUrl + '/#/licenselimit';
      throw new Error('许可人数上限');
    } else if (response && (response.data.code == 'E009949')) {
      // toLogin();
      location.href = fmUrl + '/#/licenseServer';
      throw new Error('服务器变更');
    }
    return response;
  },
  (err) => {
    if (err && err.response) {
      switch (err.response.status) {
        case 400:
          console.log("错误请求");
          // router.push({
          // 	path: "/login",
          // 	query: {
          // 		redirect: router.currentRoute.fullPath
          // 	} //从哪个页面跳转
          // })
          break;
        case 401:
          console.log("未授权，请重新登录");
          toLogin();
          break;
        case 403:
          console.log("拒绝访问");
          break;
        case 404:
          console.log("请求错误,未找到该资源");
          break;
        case 405:
          console.log("请求方法未允许");
          break;
        case 408:
          console.log("请求超时");
          break;
        case 500:
          console.log("服务器端出错");
          break;
        case 501:
          console.log("网络未实现");
          break;
        case 502:
          console.log("网络错误");
          break;
        case 503:
          console.log("服务不可用");
          break;
        case 504:
          console.log("网络超时");
          break;
        case 505:
          console.log("http版本不支持该请求");
          break;
        default:
          console.log(`连接错误${err.response.status}`);
      }
      if (!!err.response.data && !!err.response.data.message) {
        // if (!!err.response.data ? .message) {
        if (
          err.response.data.code == "002" ||
          err.response.data.code === "003" ||
          err.response.data.code === "101" ||
          err.response.data.code === "102" ||
          err.response.data.code === "103" ||
          err.response.data.code === "707"
        ) {
          message.warning(err.response.data.message);
        }
        console.log(err.response.data.message);
      }
    } else {
      console.log("连接到服务器失败");
    }
    // console.log('response 拦截err:');
    // console.log(err);
    return Promise.reject(err);
  }
);

export function goLogin(code) {
  console.log("public接口返回状态100,304,null?==", "code");
  if (code != null && (code == 304 || code == 100)) {
    toLogin();
  }
}

export function toLogin() {
  console.log("登录超时，将返回登录页面...")
  console.log('document.cookie before', document.cookie);
  localStorage.clear();
  clearAllCookie();
  console.log('document.cookie now', document.cookie);
  toLogin = function () {
  };
  let idxUrl = fmUrl + (process.env.VUE_APP_DDLogin == 1 ? "/#/sso" : "/#/login");
  console.log('idxUrl', idxUrl);
  if (process.env.VUE_APP_MERGE == 1) {
    notification.error({
      message: "错误",
      description: `登录超时，将返回登录页面`,
      duration: 1,
      onClose: function () {
        location.href = idxUrl;
      }
    });
  } else {
    notification.error({
      message: "错误",
      description: `登录超时，将返回登录页面!`,
      duration: 1,
      onClose: function () {
        location.href = idxUrl;
      }
    });
  }
}

function clearAllCookie() {
  var keys = document.cookie.match(/[^ =;]+(?=\=)/g);
  if (keys) {
    for (let i = keys.length; i--;) {
      document.cookie = keys[i] + '=0;expires=' + new Date(0).toUTCString();
    }
  }
}

/**
 * 封装get方法
 * @param url
 * @param params
 * @returns {Promise}
 */

export function fetch(url, params = {}, config) {
  return new Promise((resolve, reject) => {
    axios.get(url, Object.assign({
      params
    }, config)).then(
      (response) => {
        resolve(
          response != null && response.data != null ? response.data : response
        );
      },
      (err) => {
        reject(err);
      }
    );
  });
}

/**
 * 封装post请求
 * @param url
 * @param data
 * @returns {Promise}
 */

export function post(url, data = {}, config) {
  return new Promise((resolve, reject) => {
    axios.post(url, data, config).then(
      (response) => {
        resolve(
          response != null && response.data != null ? response.data : response
        );
      },
      (err) => {
        reject(err);
      }
    );
  });
}


/**
 * post请求，导入接口。
 * 特殊接口，需要增长超时时间，默认30分钟
 * @param url 地址
 * @param data 参数
 * @returns {Promise}
 */
export function postImport(url, data = {}) {
  return new Promise((resolve, reject) => {
    axios.post(url, data, {timeout: 30 * 60 * 1000}).then(
      (response) => {
        resolve(
          response != null && response.data != null ? response.data : response
        );
      },
      (err) => {
        reject(err);
      }
    );
  });
}

/**
 * 通用下载
 * @param url 地址
 * @param params 参数
 */
let downloadLoading;
export function download(url, params) {
  downloadLoading = this.$loading.show({
    isFullPage: true,
    color: '#1890FF',
  }, {
    // 自定义加载动画组件
    default: this.$createElement('ant-spin-dot'),
  });
  return axios.get(this.$api.baseUrl + url + tansParams(params), {
    headers: {'Content-Type': 'application/x-www-form-urlencoded'},
    responseType: 'blob'
  }).then(async (res) => {
    let data = res.data;
    // 从响应头读取文件名称
    const fileName = decodeURIComponent(res.headers["content-disposition"].split("=")[1]);
    const isLogin = await blobValidate(data);
    if (isLogin) {
      const blob = new Blob([data])
      saveAs(blob, fileName)
    } else {
      const resText = await data.text();
      const rspObj = JSON.parse(resText);
      const errMsg = errorCode[rspObj.code] || rspObj.msg || errorCode['default'];
      message.error(errMsg);
    }
  }).catch((r) => {
    console.error(r);
    message.error('下载文件出现错误，请联系管理员！');
  }).finally(() => {
    downloadLoading.hide();
  });
}

/**
 * 封装patch请求
 * @param url
 * @param data
 * @returns {Promise}
 */

export function patch(url, data = {}) {
  return new Promise((resolve, reject) => {
    axios.patch(url, data).then(
      (response) => {
        resolve(response != null ? response.data : null);
      },
      (err) => {
        reject(err);
      }
    );
  });
}

/**
 * 封装put请求
 * @param url
 * @param data
 * @returns {Promise}
 */

export function put(url, data = {}) {
  return new Promise((resolve, reject) => {
    axios.put(url, data).then(
      (response) => {
        resolve(response);
      },
      (err) => {
        reject(err);
      }
    );
  });
}

/**
 * 封装delete请求
 * @param url
 * @param params
 * @returns {Promise}
 */
export function del(url, params = {}) {
  return new Promise((resolve, reject) => {
    axios.delete(url, params).then(
      (response) => {
        resolve(response);
      },
      (err) => {
        reject(err);
      }
    );
  });
}

// export function setCookie(name, value) {
// 	if (value) {
// 		var days = 1; //定义一天
// 		var exp = new Date();
// 		exp.setTime(exp.getTime() + days * 24 * 60 * 60 * 1000);
// 		// 写入Cookie, toGMTString将时间转换成字符串
// 		document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString;
// 	}
// }

export function getCookie(cookie_name) {
  var allcookies = document.cookie;
  var cookie_pos = allcookies.indexOf(cookie_name);
  if (cookie_pos != -1) {
    cookie_pos = cookie_pos + cookie_name.length + 1;
    var cookie_end = allcookies.indexOf(";", cookie_pos);
    if (cookie_end == -1) {
      cookie_end = allcookies.length;
    }
    var value = unescape(allcookies.substring(cookie_pos, cookie_end));
  }
  return value;
}

export function getUrlParam(paraName) {
  var url = document.location.toString();
  var arrObj = url.split("?");
  if (arrObj.length > 1) {
    var arrPara = arrObj[1].split("&");
    var arr;
    for (var i = 0; i < arrPara.length; i++) {
      arr = arrPara[i].split("=");
      if (arr != null && arr[0] == paraName) {
        return arr[1];
      }
    }
    return "";
  } else {
    return "";
  }
}

/**
 * 下面是获取数据的接口
 */
/**
 * 测试接口
 * 名称：exam
 * 参数：paramObj/null
 * 方式：fetch/post/patch/put
 */
export const api = {
  baseUrl: axios.defaults.baseURL,
  MOrDFEBaseUrl: MOrDFEBaseUrl,
  fmBaseUrl: fmBaseUrl,
  fmUrl: fmUrl,
  globalSwitch: globalSwitch,
  requestUrl: requestUrl,
  btnPms: isLook == 2,
  isLook: isLook,
  stepIndex: stepIndex,
  get: fetch,
  post: post,
  goLogin: goLogin,
  dev: process.env.NODE_ENV == "development",
  exam: function (paramObj) {
    return post("/home/getMsgList.do", paramObj);
  },

  getCookie: function (cookie_name) {
    var allcookies = document.cookie;
    var cookie_pos = allcookies.indexOf(cookie_name);
    if (cookie_pos != -1) {
      cookie_pos = cookie_pos + cookie_name.length + 1;
      var cookie_end = allcookies.indexOf(";", cookie_pos);
      if (cookie_end == -1) {
        cookie_end = allcookies.length;
      }
      var value = unescape(allcookies.substring(cookie_pos, cookie_end));
    }
    return value;
  },

  // ------------------------共通接口---------------------------
  // 修改国际化
  changeLocale: function (paramObj) {
    return fetch('/DFMEA/locale/changeLocale', paramObj);
  },
  // dvp编制-基本信息-审批记录始化
  getApprovalRecordList: function (paramObj) {
    return fetch('/DFMEA/dvp/common/getApprovalRecordList',paramObj);
  },
  // dvp编制-基本信息-审批记录始化
  getBaseInfoApprovalRecordList: function (paramObj) {
    return fetch('/DFMEA/dvp/common/getBaseInfoApprovalRecordList',paramObj);
  },
  // dvp编制-基本信息-日志管理初始化
  initDvpLogManage: function (paramObj) {
    return fetch('/DFMEA/dvp/common/initDvpLogManage', paramObj);
  },
  //上传文件
  uploadFile: function (paramObj) {
    return post("/DFMEA/file/uploadFile.do", paramObj);
  },
  // 获取CPAC信息list
  getCpacInfoList: function(paramObj) {
    return fetch('/DFMEA/projectTask/getCPACInfoList', paramObj);
  },
  // 获取FND信息list
  getFndInfoList: function(paramObj) {
    return fetch('/DFMEA/projectTask/getFNDInfoList', paramObj);
  },
  // 获取当前步骤条
  getDvpCurrentStep: function (paramObj) {
    return fetch("/DFMEA/dvp/common/getDvpCurrentStep", paramObj);
  },
  // 保存DVP步骤
  saveDvpCurrentStep: function (paramObj) {
    return fetch("/DFMEA/dvp/common/saveDvpCurrentStep",paramObj)
  },
  // 获取整车型性能DVP团队成员
  getDvpTeamMember: function (paramObj){
    return fetch("/DFMEA/dvp/common/getDvpTeamMember", paramObj);
  },
  // 系统dvp基本信息-日志管理初始化
  systemInitDvpLogManage: function (paramObj) {
    return fetch('/DFMEA/dvp/common/initDvpLogManage', paramObj);
  },
  // 系统DVP基本信息编辑页-团队成员编辑页-获取团队成员
  getSystemDvpTeamMember: function (paramObj) {
    return fetch('/DFMEA/dvp/common/getDvpTeamMember',paramObj);
  },
  // 系统dvp基本信息-日志管理初始化
  partInitDvpLogManage: function (paramObj) {
    return fetch('/DFMEA/dvp/common/initDvpLogManage', paramObj);
  },
  // 获取整车性能DVP列表
  getFullVehicleDvoList: function (paramObj) {
    return fetch('/DFMEA/dvp/fullVehicle/initDvpList', paramObj);
  },
  // 获取系统DVP列表
  getSystemDvpList: function (paramObj) {
    return fetch('/DFMEA/dvp/system/initDvpList', paramObj);
  },
  // 获取零部件DVP列表
  getComponentsDVPList: function (paramObj) {
    return fetch('/DFMEA/partDvp/initDvpList', paramObj);
  },
  // 零部件DVP-计划阶段试验列表初始化
  initDvpTestList: function (paramObj) {
    return fetch('/DFMEA/partDvp/initDvpTestList', paramObj);
  },
  // 校验数据是否填写完整
  dvpPlanFullCheck: function (paramObj) {
    return fetch('/DFMEA/dvp/common/dvpPlanFullCheck', paramObj);
  },
  // 获取用户所有权限
  getUserDvpRole: function (paramObj) {
    return fetch('/DFMEA/dvp/common/getUserDvpRole',paramObj);
  },
  // 整车DVP任务管理--频次列表初始化
  getDvpInitDvpFrequencyList: function (paramObj) {
    return fetch('/DFMEA/dvp/fullVehicle/initDvpFrequencyList', paramObj);
  },
  // 基本信息-变更管理-获取变更管理表格
  getChangePageList: function (paramObj) {
    return post('/DFMEA/dvpChange/getChangePageList', paramObj);
  },
  // 基本信息-变更管理-获取DVP变更管理详细数据
  getChangeDetail: function (paramObj) {
    return post('/DFMEA/dvpChange/getChangeDetail', paramObj);
  },
  // 基本信息-变更管理-DVP变更管理编辑变更内容
  updateChangeDescription: function (paramObj) {
    return post('/DFMEA/dvpChange/updateChangeDescription', paramObj);
  },
  // ------------------------共通接口---------------------------

  // ------------------------整车dvp---------------------------
  // 整车dvp-dvp计划列表初始化
  initDvpList: function (paramObj) {
    return fetch('/DFMEA/dvp/fullVehicle/initDvpPlanList', paramObj);
  },
  // 整车dvp-dvp计划下拉列表初始化
  initSelectList: function (paramObj) {
    return fetch('/DFMEA/dvp/fullVehicle/getConfigList', paramObj);
  },
  // 整车dvp-基本信息初始化
  initDvpBasicInformation: function (paramObj) {
    return fetch('/DFMEA/dvp/fullVehicle/getDvpBasicInformation', paramObj);
  },
  // 整车dvp-计划页试验数据编辑初始化
  editDvpTestInit: function (paramObj) {
    return post('/DFMEA/dvp/fullVehicle/editDvpTestDetailInit', paramObj);
  },
  // 整车dvp-计划页试验新增 保存
  addTestSave: function (paramObj) {
    return post('/DFMEA/dvp/fullVehicle/addTest', paramObj);
  },
  // 整车dvp-计划页试验修改 保存
  editTestSave: function (paramObj) {
    return post('/DFMEA/dvp/fullVehicle/editTest', paramObj);
  },
  // 整车dvp-计划页试验修改 保存
  deleteTest: function (paramObj) {
    return post('/DFMEA/dvp/fullVehicle/deleteTest', paramObj);
  },
  // 整车dvp-计划页获取项目节点下拉选项
  getProjectNodeList: function (paramObj) {
    return fetch('/DFMEA/dvp/fullVehicle/getProjectNodeList', paramObj);
  },
  // 整车dvp-计划页获取试验负责人下拉选项，DVP团队成员还未定，暂时获取所有用户。
  getAllUsers: function () {
    return fetch('/DFMEA/userManager/getAllUsers');
  },
  // 整车dvp-验证页初始化
  initDvpVerifyList: function (paramObj) {
    return fetch('/DFMEA/dvp/fullVehicle/initDvpVerifyList', paramObj);
  },
  // 整车dvp-验证页编辑保存初始化
  dvpVerifySave: function (paramObj) {
    return post('/DFMEA/dvp/fullVehicle/dvpVerifySave', paramObj);
  },
  // dvp-基本信息-需求负责人/工程师保存
  updateDvpBasicInformation: function (paramObj) {
    return post("/DFMEA/dvp/common/saveDvpInfoAndMember", paramObj);
  },
  // 整车性能-DVP计划-申请变更保存
  applyChange: function (paramObj) {
    return post("/DFMEA/dvp/fullVehicle/applyChange", paramObj);
  },
  // 整车性能-DVP计划-申请变更保存
  dvpNewTest: function (paramObj) {
    return fetch("/DFMEA/dvp/fullVehicle/dvpPlanNewTest", paramObj);
  },
  // 整车性能-DVP计划-频次保存
  dvpSaveFrequency: function (paramObj) {
    return post("/DFMEA/dvp/fullVehicle/saveDvpFrequency", paramObj);
  },
  // 整车DVP计划频次-新建初始化
  initAddFrequencyList: function (paramObj) {
    return post('/DFMEA/dvp/fullVehicle/initAddFrequencyList', paramObj);
  },
  // 整车DVP计划频次-新建保存
  addDvpFrequency: function (paramObj) {
    return post('/DFMEA/dvp/fullVehicle/addDvpFrequency', paramObj);
  },
  // ------------------------整车dvp---------------------------

  // ------------------------系统dvp---------------------------
  // 系统dvp基本信息-初始化
  systemDvpBasicInformation: function (paramObj) {
    return fetch('/DFMEA/dvp/system/getDvpBasicInformation', paramObj);
  },
  // 系统dvp-DVP计划列表初始化
  initDvpPlanList: function (paramObj) {
    return fetch('/DFMEA/dvp/system/initDvpPlanList', paramObj);
  },
  getSysDvpProjectNodeList: function (paramObj) {
    return fetch('/DFMEA/dvp/system/getProjectNodeList',paramObj)
  },
  // 系统dvp-DVP计划-实验编辑保存
  editTest: function (paramObj) {
    return post('/DFMEA/dvp/system/editTest', paramObj);
  },
  // 系统dvp-DVP验证-列表初始化
  initSystemDvpVerifyList: function (paramObj) {
    return fetch('/DFMEA/dvp/system/initDvpVerifyList', paramObj);
  },
  // 系统dvp-DVP验证-编辑初始化
  dvpVerifyEditInit: function (paramObj) {
    return fetch('/DFMEA/dvp/system/dvpVerifyEditInit', paramObj);
  },
  // 系统dvp-DVP验证-实验编辑保存
  editVerifyTest: function (paramObj) {
    return post('/DFMEA/dvp/system/editVerifyTest', paramObj);
  },
  // 系统dvp-DVP计划-申请变更保存
  systemApplyChange: function (paramObj) {
    return post('/DFMEA/dvp/system/applyChange', paramObj);
  },
  // ------------------------系统dvp---------------------------

  // ------------------------零部件dvp---------------------------
  // 零部件DVP基本信息编辑页初始化
  getComponentsDvpBasicInformation: function (paramObj) {
    return fetch('/DFMEA/partDvp/getDvpBasicInfo', paramObj);
  },
  // 零部件DVP零部件信息页初始化
  getDvpPartInfoList: function (paramObj) {
    return fetch('/DFMEA/partDvp/getDvpPartInfoList', paramObj);
  },
  // 零部件DVP验证页初始化
  initPartDvpVerifyList: function (paramObj) {
    return fetch('/DFMEA/partDvp/initDvpVerifyList', paramObj);
  },
  // 零部件DVP验证页编辑保存
  partVerifyTestSave: function (paramObj) {
    return post('/DFMEA/partDvp/verifyTestSave', paramObj);
  },
  // 零部件DVP验证-批量编辑
  verifyTestBatchSave: function (paramObj) {
    return post('/DFMEA/partDvp/verifyTestBatchSave', paramObj);
  },
  // 零部件DVP附件批量上传
  dvpBatchUpload: function (paramObj) {
    return post('/DFMEA/partDvp/batchUpload', paramObj);
  },
  // 零部件DVP-DVP计划列表初始化
  initPartDvpPlanList: function (paramObj) {
    return fetch('/DFMEA/partDvp/initDvpPlanList', paramObj);
  },
  // 零部件DVP-DVP计划列表编辑 保存
  planTestSave: function (paramObj) {
    return post('/DFMEA/partDvp/planTestSave', paramObj);
  },
  // 零部件DVP-DVP计划列表新增 保存
  planTestAdd: function (paramObj) {
    return post('DFMEA/partDvp/planTestAdd', paramObj);
  },
  // 零部件DVP-DVP计划 编辑零部件 零部件下拉数据
  getPartList: function (paramObj) {
    return fetch('/DFMEA/partDvp/getPartList', paramObj);
  },
  // 零部件DVP-DVP计划列表 清空
  planTestEmpty: function (paramObj) {
    return post('/DFMEA/partDvp/planTestEmpty', paramObj);
  },
  // 零部件DVP-DVP计划列表 清空
  planTestDel: function (paramObj) {
    return post('/DFMEA/partDvp/planTestDel', paramObj);
  },
  // 零部件DVP 模板批量编辑页面初始化
  initTemplateList: function (paramObj) {
    return fetch('/DFMEA/partDvp/initTemplateList', paramObj);
  },
  // 零部件DVP-模板批量保存
  templateBatchSave: function (paramObj) {
    return post('/DFMEA/partDvp/templateBatchSave', paramObj);
  },
  // 零部件DVP 历史DVP批量编辑页面初始化
  initHistoryDvpList: function (paramObj) {
    return fetch('/DFMEA/partDvp/initHistoryDvpList', paramObj);
  },
  // 零部件DVP 历史DVP批量保存
  historyDvpBatchSave: function (paramObj) {
    return post('/DFMEA/partDvp/historyDvpBatchSave', paramObj);
  },
  // 零部件DVP DVP计划列表导出
  dvpPlanExcelExport: function (paramObj) {
    return fetch('/DFMEA/partDvp/dvpPlanExcelExport', paramObj);
  },
  // 零部件DVP 材料清单上传
  materialsListUpload: function (paramObj) {
    return post('/DFMEA/partDvp/batchUpload', paramObj);
  },
  // 零部件DVP 申请变更保存
  partDvpApplyChange: function (paramObj) {
    return post('/DFMEA/partDvp/applyChange', paramObj);
  },
  // ------------------------零部件DVP---------------------------

  // ------------------------审批流----------------------------
  // 流程定义列表
  getWfProcessList: function (paramObj) {
    return post('/DFMEA/wf/process/list', paramObj);
  },
  // 流程定义xml
  getWfXml: function (paramObj) {
    return post('/DFMEA/wf/process/getXml', paramObj);
  },
  // 获取用户分页列表
  getUserPageList: function (paramObj) {
    return post('/DFMEA/userManager/getUserPageList.do', paramObj);
  },
  // ------------------------审批流----------------------------
};
