/*
 * @Author: your name
 * @Date: 2021-09-23 09:04:27
 * @LastEditTime: 2021-11-12 18:22:44
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /MedicalWisdomCheckSys/src/pages/DataManagement/publicData/serve.ts
 */

import { request } from 'umi';

// 获取公共资料树结构
export const getTreeList  = (keyword?: string|number)=>{
  
    return request('/api/pfm/publicResource/list', {
        method: 'GET',
        params:{keyword}
    });

}

// 获取所有四码列表
export const getAllAccreditionLevelFourList  = (params: any)=>{
    return request('/api/pfm/publicresource/getByPublicResourceId', {
        method: 'GET',
        params:{...params}
    });

}

// 获取公共资料树结构对应表格数据
export const getTreeTableList  = (data: API.GetTableListRequestType)=>{
  
    return request('/api/pfm/publicresource/getResourceList', {
        method: 'GET',
        params:{...data}
    });

}


// 新增公共资料树结构
export const addTreeTableList  = (data: API.AddTableListRequestType)=>{
  
    return request('/api/pfm/publicResource/create', {
        method: 'POST',
        data:{...data}
    });

}

// 修改公共资料树结构
export const editTreeTableList  = (data: API.EditTableListRequestType)=>{
  
    return request('/api/pfm/publicResource/update', {
        method: 'POST',
        data:{...data}
    });

}


// 关联条款
export const connectAccreditation  = (data: API.BatchConnectAccreditation)=>{
  
    return request('/api/pfm/publicresource/updateBatchArticles', {
        method: 'POST',
        data:{...data}
    });

}

// 删除公共资料树结构
export const delTreeTableList  = (id: number[])=>{
  
    return request('/api/pfm/publicResource/delete', {
        method: 'POST',
        data:id
    });

}

// 删除树结构对应的公共资料
export const delTableFlieList  = (id: number)=>{
  
    return request('/api/pfm/publicresource/deleteResource', {
        method: 'POST',
        params:{id}
    });

}



// 公共资料上传
export const publicResourceUpload  = (data: {files: any,id: number})=>{
    const formData = new FormData();
    data.files.map((t: any)=>{
        formData.append('file',t.originFileObj);
    })
    formData.set('id',`${data.id}`);
    return request('/api/pfm/publicresource/uploadPublicFile', {
        method: 'POST',
        data:formData
    });

}

// 删除公共资料
export const delPublicResource  = (id: number[])=>{
  
    return request('/api/pfm/publicResource/delete', {
        method: 'POST',
        data:id
    });

}

// 公共资料批量下载
export const batchDownloadResource  = (ids: number[],cateType: number)=>{
  
    return request('/api/pfm/publicResource/downloadCates', {
        method: 'GET',
        params:{
            ids:ids.join(','),cateType
        },
        responseType:'blob'
    });

}