/*
 * @Author: liuJie
 * @Date: 2026-02-05 11:15:09
 * @LastEditors: liuJie
 * @LastEditTime: 2026-02-09 16:13:40
 * @Describe: 安全组织体系管理
 */

import { http } from '@/utils/http/axios';

// ————————————————左侧菜单——————————————————————
/**
 * 新增安全组织列表
 */
export function addSafetySystem(data) {
  return http.request({
    url: '/safetyorguser/saveorg',
    method: 'post',
    data,
  });
}
/**
 * 获取安全组织列表
 */
export function getSafetySystemList() {
  return http.request({
    url: '/safetyorguser/workDetail',
    method: 'get',
  });
}

/**
 * 编辑组织
 * @param {Object} data - 组织数据 { id: '组织ID', name: '新名称' }
 */
export function updateSafetySystem(data) {
  return http.request({
    url: '/safetyorguser/updateorg',
    method: 'put',
    data,
  });
}

/**
 * 删除组织
 * @param {string} id - 组织ID
 */
export function deleteSafetySystem(id) {
  return http.request({
    url: `/safetyorguser/deleteorg?id=${id}`,
    method: 'delete',
  });
}

// —————————————右侧table列表—————————————————

/**
 * 获取安全组织列表
 */

export const fetchTableList = (data) => {
  return http.request({
    url: '/safetyorguser/query-page',
    method: 'post',
    data,
  });
};

//—————————————员工数据添加、编辑、查看、删除功能—————————————————

export const addEmployee = (data) => {
  return http.request({
    url: '/safetyorguser/save',
    method: 'post',
    data,
  });
};

export const updateEmployee = (data) => {
  return http.request({
    url: '/safetyorguser/update',
    method: 'put',
    data,
  });
};

export const employeeDetail = (id) => {
  return http.request({
    url: '/safetyorguser/detail?id=' + id,
    method: 'get',
  });
};

export const delEmployee = (id) => {
  return http.request({
    url: '/safetyorguser/delete?id=' + id,
    method: 'delete',
  });
};
