/*
 *    Copyright (c) 2018-2025, hnqz All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the pig4cloud.com developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: hnqz
 */

import request from '@/router/axios';

export function fetchList(data) {
  console.log('data', data);
  return request({
    url: '/admin/user/selectUserList',
    method: 'post',
    data
  });
}

export function addObj(obj) {
  return request({
    url: '/admin/user',
    method: 'post',
    data: obj
  });
}

export function getObj(id) {
  return request({
    url: '/admin/user/' + id,
    method: 'get'
  });
}

//根据药企id关联查询药企
// export function getuserdrugEntId(obj) {
//   return request({
//     url: '/admin/user/getuserdrugEntId',
//     method: 'post',
//     data: obj
//   })
// }

// export function getuserdeptId(obj) {
//   return request({
//     url: '/admin/user/getuserdeptId',
//     method: 'post',
//     data: obj
//   })
// }
//根据用户deptId查询企业信息
export function getUserDeptId(obj) {
  return request({
    url: '/admin/wmdaagent/getUserDeptId',
    method: 'post',
    data: obj
  });
}
//修改用户企业信息
export function updateUserByDeptId(obj) {
  return request({
    url: '/admin/wmdaagent/updateUserByDeptId',
    method: 'post',
    data: obj
  });
}

export function delObj(id) {
  return request({
    url: '/admin/user/' + id,
    method: 'delete'
  });
}

export function putObj(obj) {
  return request({
    url: '/admin/user',
    method: 'put',
    data: obj
  });
}

export function getDetails(obj) {
  return request({
    url: '/admin/user/details/' + obj.deptId + '/' + obj.username,
    method: 'get'
  });
}

export function getUserDetails(obj) {
  return request({
    url: '/admin/user/getDetails',
    method: 'get',
    params: obj
  });
}

// 更改个人信息
export function editInfo(obj) {
  return request({
    url: '/admin/user/edit',
    method: 'put',
    data: obj
  });
}

export function batchChannelCert(obj) {
  return request({
    url: '/admin/user/batchChannelCert',
    method: 'post',
    data: obj
  });
}

export function getAuthInfo(query) {
  return request({
    url: '/admin/user/getAuthInfo',
    method: 'get',
    params: query
  });
}

// 回访
export function getRevisitRecordPage(query) {
  console.log(query);
  return request({
    url: `/admin/user/record/${query.userId}`,
    method: 'get',
    params: query
  });
}

// 新增回访记录
export function addRevisitRecord(data) {
  return request({
    url: '/admin/user/record',
    method: 'post',
    data
  });
}

// 删除回访记录
export function delRevisitRecord(data) {
  return request({
    url: '/admin/user/record',
    method: 'delete',
    data
  });
}

// 删除回访记录
export function getUserInfoApi(id) {
  return request({
    url: `/admin/api/get-personal-business-card/${id}`,
    method: 'get'
  });
}

// 修改密码
export function renewPwdApi(data) {
  return request({
    url: `/admin/user/pwd/renew`,
    method: 'post',
    data
  });
}

export function pwdEWxceedingApi(data) {
  return request({
    url: `/admin/user/pwd/exceeding`,
    method: 'post',
    data
  });
}

// 新增沟通专员
export function salesmanCreateApi(data) {
  return request({
    url: `/admin/user/salesman/create`,
    method: 'post',
    data
  });
}

// 获取绑定药品列表接口
export function getWmdadrugentdrugtableListApi(id) {
  return request({
    url: `/admin/wmdadrugentdrugtable/list`,
    method: 'get'
  });
}
// 绑定药品
export function userProdBindApi(data) {
  return request({
    url: `/admin/user/prod/bind`,
    method: 'post',
    data
  });
}

export function getBindProdApi(userId) {
  return request({
    url: `/admin/user/list/bind/prod`,
    method: 'get',
    params: {
      userId
    }
  });
}
