import request from '@/router/axios';
import { Message } from 'element-ui';
/*获取人才列表*/
export const getList =
    (current, size, params, groupId) => {
      return request({
        url: '/api/jobslink-api/policy/list',
        method: 'get',
        params: {...params, current, size, groupId}
      })
    }

/*新增人才*/
export const add =
    (row) => {
      return request(
          {url: '/api/jobslink-api/policy/save', method: 'post', data: row})
    }

/*编辑人才*/
export const update =
    (row) => {
      return request({
        url: '/api/jobslink-api/policy/update',
        method: 'post',
        data: row
      })
    }

/*删除人才*/
export const remove =
    (ids) => {
      return request({
        url: '/api/jobslink-api/policy/remove',
        method: 'post',
        params: {ids}
      })
    }

/*人才详情*/
export const detail =
    (id) => {
      return request({
        url: '/api/jobslink-api/policy/detail',
        method: 'get',
        params: {id}
      })
    }


/*获取分组*/
export const getDept =
    () => {
      return request({
        url: '/api/jobslink-api/policy/group/listAll',
        method: 'get',
        params: {}
      })
    }

/*新建分组*/
export const addDept =
    (row) => {
      return request({
        url: '/api/jobslink-api/policy/group/save',
        method: 'post',
        data: row
      })
    }


/*编辑分组*/
export const updateDept =
    (row) => {
      return request({
        url: '/api/jobslink-api/policy/group/update',
        method: 'post',
        data: row
      })
    }


/*删除分组*/
export const removeDept =
    (ids) => {
      return request({
        url: '/api/jobslink-api/policy/group/remove',
        method: 'post',
        params: {ids}
      })
    }


/*转移分组*/
export const transferDept =
    (groupIds, ids) => {
      return request({
        url: '/api/jobslink-api/policy/updateAllGroup',
        method: 'post',
        params: {groupIds, ids}
      })
    }

/*导入人才库*/
export const upload = () => {
  return `/api/jobslink-api/policy/group/import?isCovered=1`
}


export  const  uploadFilePolicy = (formData) => {
  return new Promise((resolve, reject) => {
    request({
        url: '/api/jobslink-api/resource/file/save',
        method: 'post',
        data: formData,
        headers: {
          'Content-Type': 'multipart/form-data;'
        }
      })
      .then((res) => {
        resolve(res)
      }).catch(err => {
      Message.error('上传失败' + err.data.message || '上传失败');
    })
  })
}
