/*
 *    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 getScorePackagePage(query) {
  return request({
    url: '/admin/wmscorepackage/getScorePackagePage',
    method: 'get',
    params: query
  });
}
// 分页查询
export function getTeamScorePackagePage(query) {
  return request({
    url: '/admin/wmscorepackage/page-settle-package',
    method: 'get',
    params: query
  });
}
export function getMahScorePackagePage(query) {
  return request({
    url: '/admin/wmscorepackage/page-mah-settle-package',
    method: 'get',
    params: query
  });
}

//积分包类型-前面值
export function packageType1(query) {
  return request({
    url: '/admin/dict/type/packageType1',
    method: 'get',
    params: query
  });
}

//积分包类型-后面值
export function packageType2(query) {
  return request({
    url: '/admin/dict/type/packageType2',
    method: 'get',
    params: query
  });
}

// 关联任务积分包
export function getRelationScoreList(query) {
  return request({
    url: '/admin/wmscorepackage/getRelationScoreList',
    method: 'get',
    params: query
  });
}

// 接单对象类型
export function typeid(query) {
  return request({
    url: '/admin/dict/type/typeid',
    method: 'get',
    params: query
  });
}

// 接单对象类型
export function typeidPersonal(query) {
  return request({
    url: '/admin/dict/type/typeid_personal',
    method: 'get',
    params: query
  });
}

// 接单对象
export function objectScope(query) {
  return request({
    url: '/admin/user/list?role=5',
    method: 'get',
    params: query
  });
}

export function objectScope1(query) {
  return request({
    url: '/admin/user/list/available?role=5',
    method: 'get',
    params: query
  });
}

export function objectScope2(roleId) {
  return request({
    url: `/admin/user/list/available?role=${roleId}`,
    method: 'get'
  });
}

// 接单对象范围
export function packageUserScope(query) {
  return request({
    url: '/admin/dict/type/package_user_scope',
    method: 'get',
    params: query
  });
}

// 接单对象范围团队
export function packageUserScopeByOpt(query) {
  return request({
    url: '/admin/team/list-package-user-scope',
    method: 'get',
    params: query
  });
}

// 根据积分包任务类型 展示 可选的有效任务类型
export function showDescription(value) {
  return request({
    url: '/admin/dict/item/page?type=score_task_type&description=' + value,
    method: 'get'
  });
}

// 确认发布
export function addWmScorePackage(obj) {
  return request({
    url: '/admin/wmscorepackage/addWmScorePackage',
    method: 'post',
    data: obj
  });
}

// 导出-汇总报告，报告详情 word
export function exportZbReport(query) {
  return request({
    url: '/admin/reportExport/exportZbReport',
    method: 'get',
    params: query
  });
}

export function taskNewExportNbqybg(query) {
  return request({
    url: '/admin/reportExport/new-personal-export',
    method: 'get',
    params: query
  });
}
// 导出-汇总报告，报告详情
export function exportZbReportExcel(query) {
  return request({
    url: '/admin/report/excel/export/exportZbReport',
    method: 'get',
    params: query
  });
}

export function taskExportNewExcelNbqybg(query) {
  return request({
    url: '/admin/reportExport/new-excel-export',
    method: 'get',
    params: query
  });
}

// 导出-汇总报告，报告详情
export function exportZbInfoJs(query) {
  return request({
    url: '/admin/reportExport/exportZbInfoJs',
    method: 'get',
    params: query
  });
}

// 终止按钮
export function updateEnable(query) {
  return request({
    url: '/admin/wmscorepackage/updateEnable',
    method: 'get',
    params: query
  });
}

// 结算,删除
export function updateWmScorePackage(obj) {
  return request({
    url: '/admin/wmscorepackage/updateEasy',
    method: 'post',
    data: obj
  });
}
// 编辑
export function editData(obj) {
  return request({
    url: '/admin/wmscorepackage/updateWmScorePackage',
    method: 'post',
    data: obj
  });
}

// 编辑回显
export function getScorePackagePageById(query) {
  return request({
    url: '/admin/wmscorepackage/getScorePackagePageById',
    method: 'get',
    params: query
  });
}
// 关联服务企业
export function getAllParentDept(query) {
  return request({
    url: '/admin/dept/getAllParentDept',
    method: 'get',
    params: query
  });
}

// 发包管理服务企业
export function getListAncestorApi() {
  return request({
    url: '/admin/dept/list/ancestor',
    method: 'get'
  });
}

// 有效任务类型
export function getTaskTypeTree(query) {
  return request({
    url: '/admin/wmtasktype/getTaskTypeTree',
    method: 'get',
    params: query
  });
}

// 编辑-查询数据
export function searchById(query) {
  return request({
    url: '/admin/wmscorepackage/getScorePackagePageById',
    method: 'get',
    params: query
  });
}

// 编辑-保存
export function saveById(obj) {
  return request({
    url: '/admin/wmscorepackage/updateWmScorePackage',
    method: 'post',
    data: obj
  });
}

// 推广产品企业
export function getDrugProducerList(data) {
  return request({
    url: `/admin/wmdadrugentdrugtable/list-drug-producer?deptId=${data.deptId}`,
    method: 'get'
  });
}
// 拆包列表

export function getSplitList(query) {
  return request({
    url: `/admin/wmtask/getWmTaskList`,
    method: 'get',
    params: query
  });
}
export function getSplitUnpack(data) {
  return request({
    url: `/admin/wmscorepackage/unpack`,
    method: 'post',
    data
  });
}

// 获取产品列表
export function getListDrugApi() {
  return request({
    url: `/admin/wmdadrugentdrugtable/list-drug`,
    method: 'get'
  });
}

export function exportInfoApi(query) {
  return request({
    url: `/admin/wmscorepackage/export-score-package`,
    method: 'get',
    responseType: 'arraybuffer',
    params: query
  });
}

export function exportInfoApi2(query) {
  return request({
    url: `/admin/wmscorepackage/export-score-package-mah`,
    method: 'get',
    responseType: 'arraybuffer',
    params: query
  });
}

export function restartApi(obj) {
  return request({
    url: `/admin/wmscorepackage/restart`,
    method: 'post',
    data: obj
  });
}

export function getPkgTaskDetailsApi(query) {
  return request({
    url: `/admin/api/v2/getPkgTaskDetails`,
    method: 'get',
    params: query
  });
}
