// 事项api
import local from "@/utils/local";
import request from "@/utils/request";
import store from "@/store";
let PHP_URL = process.env.VUE_APP_API_PHP_URL;
// 首页数据展示
export const getHomeInfo = (data) => {
  let baseUrl = local.getLocal("serverUrl");
  let siteId = local.getLocal("siteId");
  return request({
    url: `${baseUrl}sampleform/home/info`,
    method: "post",
    data: {
      siteId,
      ...data,
    },
  });
};

// 获取部门列表
export const getdeptList = (data) => {
  let baseUrl = local.getLocal("serverUrl");
  let siteId = local.getLocal("siteId");
  // let deviceCode = local.getLocal("devicenum");
  return request({
    url: `${baseUrl}sampleform/home/depts`,
    method: "post",
    data: {
      siteId,
      deviceCode: store.getters.deviceCode,
      ...data,
    },
  });
};

// 查询事项列表
export const getSampleformMatterList = (data) => {
  let baseUrl = local.getLocal("serverUrl");
  let siteId = local.getLocal("siteId");
  return request({
    url: `${baseUrl}sampleform/matter/list`,
    method: "post",
    data: {
      siteId,
      ...data,
    },
  });
};

// 查询设备关联事项列表
export const getDeviceMatterList = (data) => {
  let baseUrl = local.getLocal("serverUrl");
  let siteId = local.getLocal("siteId");
  // let deviceCode = local.getLocal("devicenum");
  return request({
    url: `${baseUrl}sampleform/device/matter/datum/list`,
    method: "post",
    data: {
      siteId,
      deviceCode: store.getters.deviceCode,
      ...data,
    },
  });
};

//   查询材料列表
export const getMaterialsList = (data) => {
  let baseUrl = local.getLocal("serverUrl");
  let siteId = local.getLocal("siteId");
  return request({
    url: `${baseUrl}sampleform/matter/datum/list`,
    method: "post",
    data: {
      siteId,
      ...data,
    },
  });
};

// 表单合成
export const mergeFormToDocx = (data) => {
  let baseUrl = local.getLocal("serverUrl");
  let siteId = local.getLocal("siteId");
  return request({
    url: `${baseUrl}sampleform/home/mergeFormToDocx`,
    method: "post",
    data: {
      siteId,
      ...data,
    },
  });
};
// 查看样表
export const checkMaterials = (data) => {
  let baseUrl = local.getLocal("serverUrl");
  let siteId = local.getLocal("siteId");
  let deviceCode = local.getLocal("devicenum");
  return request({
    url: `${baseUrl}sampleform/sample/bill/save`,
    method: "post",
    data: {
      siteId,
      deviceCode,
      ...data,
    },
  });
};
// 查询使用皮肤
export const getSkinList = (data) => {
  let baseUrl = local.getLocal("serverUrl");
  // let siteId = local.getLocal("siteId");
  return request({
    url: `${baseUrl}sampleform/skin/list`,
    method: "post",
    data,
  });
};
// 排队编号查询对应事项
export const getMatterForFlownum = (params) => {
  // let baseUrl = local.getLocal("serverUrl");
  return request({
    url: `${PHP_URL}api/matter/matterForFlownum`,
    method: "get",
    params,
  });
};
//获取设备列表
export const getDeviceList = (data) => {
  let baseUrl = local.getLocal("serverUrl");
  let deviceCode = local.getLocal("devicenum");
  return request({
    url: `${baseUrl}sampleform/device/list`,
    method: "post",
    data: {
      deviceCode,
      ...data,
    },
  });
};
//热力图背景图上传
export function screenSave(params = {}) {
  let deviceInfo = {};
  try {
    let { productId, productName } = local.getLocal("deviceInfo");
    deviceInfo = { productId, productName };
  } catch (error) {}
  let javaBase = local.getLocal("serverUrl");
  params["deviceNum"] = local.getLocal("devicenum");
  return request({
    url: `${javaBase}basics_api/zwfw/page/bury/screen/save`,
    method: "post",
    data: {
      ...deviceInfo,
      ...params,
    },
  });
}
//java数据埋点
export function burySave(params = {}) {
  let deviceInfo = {};
  try {
    let { productId, productName } = local.getLocal("deviceInfo");
    deviceInfo = { productId, productName };
  } catch (error) {}
  let javaBase = local.getLocal("serverUrl");
  params["deviceNum"] = local.getLocal("devicenum");
  return request({
    url: `${javaBase}basics_api/zwfw/page/bury/save`,
    method: "post",
    data: {
      ...deviceInfo,
      ...params,
    },
  });
}
