/*
 * @Author: zhanghaifeng
 * @Date: 2025-01-06 17:11:11
 * @LastEditors: zhanghaifeng
 * @LastEditTime: 2025-06-12 10:19:03
 * @Description:
 * @FilePath: /hospital-project/src/api/indexData.ts
 */
import { http } from "@/utils/http";
import axios from "axios";
const FLIE_URL = import.meta.env.VITE_BASE_URL;

type PageListType = {
  code: number;
  msg: string;
  data: recordsList;
};
type recordsList = {
  totalRow: number;
  records: Array<any>;
};
type PageListItemDelType = {
  code: number;
  msg: string;
  data: boolean;
};

// 分页查询
export const getPageList = data => {
  return http.request<PageListType>("post", "/source/pageSourceData", { data });
};

// 分页-删除
export const delListItemApi = params => {
  return http.request<PageListItemDelType>("get", "/source/deleteSourceData", {
    params
  });
};

// 分页-新增
export const addListApi = data => {
  return http.request<PageListItemDelType>("post", "/source/addSourceData", {
    data
  });
};

// 分页-编辑
export const editListApi = data => {
  return http.request<PageListItemDelType>("post", "/source/updateSourceData", {
    data
  });
};

// 分页-日志
export const getLogInfo = params => {
  return http.request<PageListType>("get", "/source/getSourceDataUpdateText", {
    params
  });
};

// 批量导入
export const uploadData = async data => {
  const token = localStorage.getItem("token") || "";
  return axios.post(`${FLIE_URL}/source/importSourceData`, data, {
    headers: {
      "Content-Type": "multipart/form-data", // 指定内容类型
      satoken: token // 将 Token 添加到请求头
    }
  });
};
