import http from "@/utils/http";
import { AppDispatch } from "..";
/**
 * 获取 进度统计 表格列表（存到仓库）
 */
export const B2_APIgetlist = (data: any) => {
  return async (dispatch: AppDispatch) => {
    const res = await http.post("cms/scene/pageList", data);
    if (res.code === 0) {
      const obj = {
        list: res.data.records,
        total: res.data.total,
      };
      dispatch({ type: "B2/getList", payload: obj });
    }
  };
};

/**
 * 获取 进度统计 表格列表（导出表格）
 */
export const B2_APIgetlistAll = (data: any) => {
  return http.post("cms/scene/pageList", data);
};

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

/**
 * 重置 单个表格数据
 */
export const B2_APIreset = (id: number) => {
  return http.get(`cms/scene/reset/${id}`);
};

/**
 * 审核
 */
export const B2_APIAudit = (data: any) => {
  return http.post("cms/scene/audit", data);
};

/**
 * 重复的场景
 */
export const B2_APIlookReDo = () => {
  return http.get("cms/scene/duplicateRoom");
};

// /**
//  * 查询机房编码是否存在
//  */
// export const B2_APIcheckNum = (num: string) => {
//   return http.get(`cms/room/exist/${num}`);
// };

/**
 * 更新机房编码
 */
export const B2_APIeditNum = (id: number, num: string) => {
  return http.get(`cms/scene/update/${id}/${num}`);
};

/**
 * 查询机房编码是否存在
 */
export const B2_APInumIsOk = (num: string) => {
  return http.get(`cms/scene/room/exist/${num}`);
};
