// 基础信息接口
import request from "@/Utils/requestUtils.js";
import $api from "@/Apis/api";

// 区域网格管理
export const regionalGridManageService = {
  pageList(data) {
    return request.post($api.basicInfo.regionalGridManage.pageList, data);
  },
  gridTree(districtId) {
    return request.get($api.basicInfo.regionalGridManage.gridTree, {
      params: districtId,
    });
  },
  update(data) {
    return request.post($api.basicInfo.regionalGridManage.update, data);
  },
  delete(data) {
    return request.post($api.basicInfo.regionalGridManage.delete, data);
  },
  selectList(data) {
    return request.post($api.basicInfo.regionalGridManage.selectList, data);
  },
  uploadFile(data) {
    return request.post($api.basicInfo.regionalGridManage.uploadFile, data);
  },
  add(data) {
    return request.post($api.basicInfo.regionalGridManage.add, data);
  },
  batchAdd(data) {
    return request.post($api.basicInfo.regionalGridManage.batchAdd, data);
  },
  principalList(data) {
    return request.post($api.basicInfo.regionalGridManage.principalList, data);
  },
  gridExport(data) {
    return request
      .post($api.basicInfo.regionalGridManage.export, data, {
        responseType: "blob",
      })
      .then((res) => {
        request.download("区域网格记录", res);
      });
  },
};

// 场景管理
export const sceneManageService = {
  gridTree(districtId) {
    return request.get($api.basicInfo.sceneManage.gridTree, {
      params: districtId,
    });
  },
  pageList(data) {
    return request.post($api.basicInfo.sceneManage.pageList, data);
  },
  update(data) {
    return request.post($api.basicInfo.sceneManage.update, data);
  },
  delete(data) {
    return request.post($api.basicInfo.sceneManage.delete, data);
  },
  add(data) {
    return request.post($api.basicInfo.sceneManage.add, data);
  },
  oneScenesList(data) {
    return request.post($api.dropdown.oneScenesList, data);
  },
  export(data) {
    return request
      .post($api.basicInfo.sceneManage.export, data, {
        responseType: "blob",
      })
      .then((res) => {
        request.download("场景数据记录", res);
      });
  },
};

// 对象数据管理
export const objectManageService = {
  objectPageList(data) {
    return request.post($api.basicInfo.objectDataManage.objectPageList, data);
  },
  addOrUpdateObject(data) {
    return request.post(
      $api.basicInfo.objectDataManage.addOrUpdateObject,
      data
    );
  },
  removeObject(data) {
    return request.post($api.basicInfo.objectDataManage.removeObject, data);
  },
  uploadFileObject(data) {
    return request.post($api.basicInfo.objectDataManage.uploadFileObject, data);
  },
  batchAddObject(data) {
    return request.post($api.basicInfo.objectDataManage.batchAddObject, data);
  },
  objectExport(data) {
    return request
      .post($api.basicInfo.objectDataManage.objectExport, data, {
        responseType: "blob",
      })
      .then((res) => {
        request.download("对象数据列表记录", res);
      });
  },
};

// 服务事项管理
export const serveMatterManageService = {
  matterPageList(data) {
    return request.post($api.basicInfo.serveMatterManage.matterPageList, data);
  },
  addMatter(data) {
    return request.post($api.basicInfo.serveMatterManage.addMatter, data);
  },
  removeMatter(data) {
    return request.post($api.basicInfo.serveMatterManage.removeMatter, data);
  },
  updateMatter(data) {
    return request.post($api.basicInfo.serveMatterManage.updateMatter, data);
  },
  matterExport(data) {
    return request
      .post($api.basicInfo.serveMatterManage.matterExport, data, {
        responseType: "blob",
      })
      .then((res) => {
        request.download("服务事项记录", res);
      });
  },
};

// 场景对象管理
export const sceneMatterManageService = {
  sceneObjectPageList(data) {
    return request.post(
      $api.basicInfo.sceneMatterManage.sceneObjectPageList,
      data
    );
  },
  setSceneObject(data) {
    return request.post($api.basicInfo.sceneMatterManage.setSceneObject, data);
  },
  removeSceneObject(data) {
    return request.post(
      $api.basicInfo.sceneMatterManage.removeSceneObject,
      data
    );
  },
  updateSceneObject(data) {
    return request.post(
      $api.basicInfo.sceneMatterManage.updateSceneObject,
      data
    );
  },
  sceneObjectExport(data) {
    return request
      .post($api.basicInfo.sceneMatterManage.sceneObjectExport, data, {
        responseType: "blob",
      })
      .then((res) => {
        request.download("服务事项记录", res);
      });
  },
};

// 作业管理
export const operationManageService = {
  oprationPageList(data) {
    return request.post($api.basicInfo.operationManage.oprationPageList, data);
  },
  addOperation(data) {
    return request.post($api.basicInfo.operationManage.addOperation, data);
  },
  updateOperation(data) {
    return request.post($api.basicInfo.operationManage.updateOperation, data);
  },
  removeOperation(id) {
    return request.get($api.basicInfo.operationManage.removeOperation, {
      params: id,
    });
  },
  toolsExport(data) {
    return request
      .post($api.basicInfo.operationManage.operationExport, data, {
        responseType: "blob",
      })
      .then((res) => {
        request.download("对象作业标准化记录", res);
      });
  },
};

// 工具管理
export const toolManageService = {
  toolsPageList(data) {
    return request.post($api.basicInfo.toolMange.toolsPageList, data);
  },
  addOrUpdateTools(data) {
    return request.post($api.basicInfo.toolMange.addOrUpdateTools, data);
  },
  removeTools(data) {
    return request.post($api.basicInfo.toolMange.removeTools, data);
  },
  toolsExport(data) {
    return request
      .post($api.basicInfo.toolMange.toolsExport, data, {
        responseType: "blob",
      })
      .then((res) => {
        request.download("工具数据列表记录", res);
      });
  },
};
