import request from '@/utils/request'


// 创建资源搜索
export function createDigsearch(data) {
  return request({
    url: '/manager/digsearch/create',
    method: 'post',
    data: data
  })
}

// 更新资源搜索
export function updateDigsearch(data) {
  return request({
    url: '/manager/digsearch/update',
    method: 'put',
    data: data
  })
}

// 删除资源搜索
export function deleteDigsearch(id) {
  return request({
    url: '/manager/digsearch/delete?id=' + id,
    method: 'delete'
  })
}

// 获得资源搜索
export function getDigsearch(id) {
  return request({
    url: '/manager/digsearch/get?id=' + id,
    method: 'get'
  })
}

// 获得资源搜索分页
export function getDigsearchPage(params) {
  return request({
    url: '/manager/digsearch/page',
    method: 'get',
    params
  })
}
// 导出资源搜索 Excel
export function exportDigsearchExcel(params) {
  return request({
    url: '/manager/digsearch/export-excel',
    method: 'get',
    params,
    responseType: 'blob'
  })
}

// 资源搜索分页
export function getSearchPageJM(data) {
  return request({
    url: '/adv/search/ftp1',
    method: 'post',
    data: data
  })
}

export function getSearchPageJUEM(data) {
  return request({
    url: '/adv/search/ftp2',
    method: 'post',
    data: data
  })
}

export function getSearchPageUSER(data) {
  return request({
    url: '/adv/search/ftp3',
    method: 'post',
    data: data
  })
}

// 下载
// export function getDownload(data) {
//   return request({
//     url: '/adv/search/download',
//     method: 'post',
//     data: data
//   })
// }

export function getDownload(data) {
  return request({
    url: '/adv/search/download4',
    method: 'post',
    data: data,
    responseType:'arraybuffer'
  })
}

// 点赞量
export function visitOne(data) {
  return request({
    url: '/adv/search/visit',
    method: 'post',
    data: data
  })
}

// 点击量
export function clickOne(data) {
  return request({
    url: '/adv/search/click',
    method: 'post',
    data: data
  })
}
// 单片收藏
export function collectionOne(data) {
  return request({
    url: '/adv/search/collect',
    method: 'post',
    data: data
  })
}
// 收藏列表
export function collectionList(data) {
  return request({
    url: '/adv/search/collectlist',
    method: 'post',
    data: data
  })
}
// 取消收藏
export function unCollectOne(data) {
  return request({
    url: '/adv/search/uncollect',
    method: 'post',
    data: data
  })
}

export function updateDigFtpSource(data) {
  return request({
    url: '/adv/search/update',
    method: 'post',
    data: data
  })
}


//导出
export function exportDigFtpSourceExcel(params) {
  return request({
    url: '/adv/search/export-excel',
    method: 'get',
    params,
    responseType: 'blob'
  })
}

//导出待办
export function exportExcelDaiBan(params) {
  return request({
    url: '/adv/search/export-excel-daiban',
    method: 'get',
    params,
    responseType: 'blob'
  })
}


export function formWbData(data) {
  return request({
    url: '/rs/autocat',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
      'Authorization': ''
    },
    transformRequest: [function (data) {
      // 数据默认会以json格式传递，需要转成key-value
      let ret = '';
      for (let i in data) {
        ret += encodeURIComponent(i) + '=' + encodeURIComponent(data[i]) + '&'
      }
      return ret.slice(0, -1);
    }],
  }).catch(err=>{console.log(err)})

}


export function indexdata() {
  return request({
    url: '/adv/search/indexdata',
    method: 'post'
  })
}

export function indexdataline() {
  return request({
    url: '/adv/search/indexdataline',
    method: 'post'
  })
}

// 调用CKM接口封装
import axios from 'axios'

export const thirdPartyApi = axios.create({
    // baseURL: 'http://114.48.101.215/admin-api',
    baseURL: 'http://114.48.101.215/admin-api',
    timeout: 10000,
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',/* CKM请求头设置 */
      'Authorization': ''/*  */
    },
});

// 待办列表
export function daibanList(data) {
  return request({
    url: '/adv/search/daibanlist',
    method: 'post',
    data: data
  })
}
// 部门列表
export function deptList(data) {
  return request({
    url: '/adv/search/deptlist',
    method: 'post',
    data: data
  })
}
// 待办分配
export function daiBanFp(data) {
  return request({
    url: '/adv/search/daiban',
    method: 'post',
    data: data
  })
}
// 取消待办
export function dealdaiban(data) {
  return request({
    url: '/adv/search/dealdaiban',
    method: 'post',
    data: data
  })
}

// 数据回显
export function docDeptList(data) {
  return request({
    url: '/adv/search/docdeptlist',
    method: 'post',
    data: data
  })
}

// 部门列表新
export function deptKeyList(data) {
  return request({
    url: '/system/user/bdlist?deptId='+data.deptId,
    method: 'get',
    data: data
  })
}

// 获取标签列表
export function getBqList() {
  return request({
    url: '/system/dict-data/labellist',
    method: 'post',
    // data: data
  })
}
