import http from "@/utils/http";
import { AppDispatch } from "..";

/**
 * 获取 机房管理 表格列表（存到仓库）
 */
export const A2_APIgetlist = (data: any) => {
  return async (dispatch: AppDispatch) => {
    const res = await http.post("cms/room/pageList", data);
    if (res.code === 0) {
      const obj = {
        list: res.data.records,
        total: res.data.total,
      };
      // console.log(123,obj);

      dispatch({ type: "A2/getList", payload: obj });
    }
  };
};

/**
 * 获取 机房管理 表格列表（导出表格）
 */
export const A2_APIgetlistDerive = (data:any) => {
  return http.post("cms/room/pageList", data);
};

/**
 * 删除表格单个
 */
export const A2_APIremoves = (id: number) => {
  return http.get(`cms/room/remove/${id}`);
};

/**
 * 新增/编辑
 */
export const A2_APIadd = (data: any) => {
  return http.post("cms/room/save", data);
};

/**
 * 通过id获取详情
 */
export const A2_APIgetInfo = (id:number) => {
  return http.get(`cms/room/detail/${id}`);
};

/**
 * 机房管理-站址地区下拉框
 */
export const A2_APIgetCity = () => {
  return http.get('cms/room/getCityTree');
};
