import { $postParam, $post } from "@/plugins/axios";

// user-manage
export const userListPage = datas => {
  return $postParam("/api/admin/sys/user/list_customer", datas);
};
export const updateUser = datas => {
  return $post("/api/admin/sys/user/save_customer", datas);
};
export const ableUser = ({ id, enable }) => {
  return $post("/api/admin/sys/user/enable", { id, enable });
};
export const resetPwd = id => {
  return $post("/api/admin/sys/user/reset_password", { id });
};
export const userRoleListPage = () => {
  return $postParam("/api/admin/sys/role/list_to_user", {});
};

// menu-manage
export const menuList = datas => {
  return $postParam("/api/admin/sys/privilege/list", datas);
};
export const updateMenu = datas => {
  return $post("/api/admin/sys/privilege/save", datas);
};
export const deleteMenu = id => {
  return $post("/api/admin/sys/privilege/remove", { id });
};

// auth-set
export const authSelect = () => {
  return $post("/api/admin/auth/select", {});
};
export const offlineActivation = datas => {
  return $post("/api/admin/auth/offline/activation", datas);
};
export const onlineActivation = datas => {
  return $postParam("/api/admin/auth/online/activation", datas);
};
export const exportDeviceInfo = () => {
  return $post(
    "/api/admin/auth/export/device/info",
    {},
    {
      responseType: "blob"
    }
  );
};

// school-manage
export const schoolList = () => {
  return $postParam("/api/admin/common/school/list", {});
};
export const schoolSync = () => {
  return $postParam("/api/admin/auth/sync/org", {});
};
export const updateSchool = datas => {
  let formData = new FormData();
  Object.keys(datas).forEach(k => {
    formData.append(k, datas[k]);
  });
  return $post("/api/admin/common/school/update", formData);
};

export const schoolSetSyncInfo = schoolId => {
  return $postParam("/api/report/set/sync/select", {
    schoolId
  });
};
export const schoolSetSyncUpdate = datas => {
  return $post("/api/report/set/sync/save", datas);
};
