import fetch from './fetch'
import {downInstance} from './downLoad'

export default {
    // 公共接口
    common: {
        login(params) {
            return fetch('/basic-info/v1/basic-info/basic-sys-user/login',
                params,
                'post',
                'json',
            )
        },
        fetchAllChildOrgInfo(params) {//查询当前单位的所有下级单位
            return fetch(`/v1/folacin-admin/folacin-provide-record/child-unit`, params)
        },
        fetchMedicalType(params) {//获取分类
            return fetch('/basic-info/v1/basic-info/basic-medical-breed/all', params)
        },
        fetchAllMedicalName(params) {//获取所有品种名称(单位端)
            return fetch('/basic-info/v1/basic-info/basic-medical-info/all', params)
        },

        fetchUnitInfo(params) {//获取单位（父级）
            return fetch(`/basic-info/v1/basic-info/basic-org-info/all-child/${params.id}`, params)
        },
        //供应商管理
        fetchAllSupply(params) {//获取所有供应商
            return fetch('/v1/folacin-admin/folacin-supplier-info/enable', params)
        },
        fetchAddSupply(params) {//新增供应商
            return fetch('/v1/folacin-admin/folacin-supplier-info', params, "post", "json")
        },
        fetchSupplyPageList(params) {//供应商分页查询
            return fetch('/v1/folacin-admin/folacin-supplier-info', params, "get")
        },
        fetchSupplyById(params) {//根据id获取
            return fetch(`/v1/folacin-admin/folacin-supplier-info/${params.id}`, params)
        },
        fetchSupplUpdate(params) {//供应商分页查询
            return fetch(`/v1/folacin-admin/folacin-supplier-info/${params.id}`, params, "put", 'json')
        },
        fetchSupplDelete(params) {//供应商分页查询
            return fetch(`/v1/folacin-admin/folacin-supplier-info/${params.id}`, params, "delete")
        },
        fetchAllEnum(params) {//获取所有枚举值
            return fetch(`/basic-info/v1/basic-info/basic-sys-enum/all-enum`, params)
        },
        fetchAreaByCode(areaCode) {//根据区域编码获取下级地区
            return fetch(`/v1/folacin-admin/sys-dict-area/child-area/${areaCode}`)
        },
        //知情同意书
        fetchConsentInfo(params) {//查询单位的知情同意书
            return fetch(`/v1/folacin-admin/folacin-consent-info/consent`, params)
        },
        fetchConsentInfoShow(params) {//查询单位的知情同意书
            return fetch(`/v1/folacin-admin/folacin-consent-info/consent-info`, params)
        },
        fetchAddConsentInfo(params) {//新增单位的知情同意书
            return fetch(`/v1/folacin-admin/folacin-consent-info`, params, "post", "json")
        },
        fetchUpdateConsentInfo(params) {//更新单位的知情同意书
            return fetch(`/v1/folacin-admin/folacin-consent-info/${params.id}`, params, "put", "json")
        },
        fetchAllDoctor(params) {//查询当前单位下的所有医生
            return fetch(`/v1/folacin-admin/folacin-provide-record/doctor`, params)
        }
    },

    //库存管理
    stockManage: {
        /*在库管理*/
        fetchInStockList(params) {//在库管理列表
            return fetch('/v1/folacin-admin/folacin-stock-record', params)
        },
        fetchInStockNoZeroList(params) {//在库管理列表库存不为零的
            return fetch('/v1/folacin-admin/folacin-stock-record/unit-record-page', params)
        },
        fetchInStockDetail(params) {//在库管理详情
            return fetch(`/v1/folacin-admin/folacin-stock-record/${params.id}`, params)
        },
        fetchMedicineByType(params) {//根据药具品类获取药具
            return fetch('/basic-info/v1/basic-info/basic-medical-info/query-breed', params)
        },
        fetchBatchByTypeAName(params) {//根据分类和品种名称获取生产批次
            return fetch('/basic-info/v1/basic-info/basic-batch-info/breed-medical', params)
        },
        addHistoryStock(params) {//在库管理-历史库存录入
            return fetch('/v1/folacin-admin/folacin-purchase-record', params, 'post', 'json')
        },
        fetchMedicalListByIds(params) {
            return fetch(`/v1/folacin-admin/folacin-stock-record/query-ids`, params)
        },
        /*分配入库*/
        fetchReceiveRecordList(params) {//入库管理列表
            return fetch('/v1/folacin-admin/folacin-send-record/receive-record', params);
        },
        /*查询入库单详情*/
        fetchReceiveDetails(params) {
            return fetch(`/v1/folacin-admin/folacin-send-record/receive-details/${params.id}`,params);
        },
        /*确认入库*/
        fetchReceiveConfirm(params) {
            return fetch(`/v1/folacin-admin/folacin-send-record/receive/`, params);
        },
        /*分配出库列表*/
        fetchSendRecordList(params) {//入库管理列表
            return fetch('/v1/folacin-admin/folacin-send-record/send-record', params);
        },
        /*出入库记录*/
        fetchStockTransferList(params) {//查询出入库记录
            return fetch('/v1/folacin-admin/folacin-stock-transfer', params);
        },
        /*入库管理*/
        fetchStockList(params) {//入库管理列表
            return fetch('/stock-info/v1/stock-info/stock-send-record/receive-order', params);
        },
        fetchTemplateByMedicalType(params) {//根据分类获取药具检查验收模板
            return fetch(`/basic-info/v1/basic-info/basic-template/query-breed/${params.breedId}`, params)
        },
        fetchStockDetail(params) {//查看入库详情
            return fetch(`/stock-info/v1/stock-info/stock-send-record/${params.id}`, params)
        },
        fetchConfimAddStock(params) {//入库管理-确认入库
            return fetch('/stock-info/v1/stock-info/stock-send-record/receive-goods', params, 'post', 'json');
        },
        /*物资分配*/
        fetchGoodsDistribution(params) {// 物资分配列表
            return fetch('/stock-info/v1/stock-info/stock-send-record', params);
        },
        fetchDispatchGoods(params) {//分配物资
            return fetch('/v1/folacin-admin/folacin-send-record', params, 'post', 'json');
        },
        fetchDispatchdeGoods(params) {//获取在库信息
            return fetch('/stock-info/v1/stock-info/stock-basic-info/basic-info', params);
        },
        fetchDisGoodsDetail(params) {//查看物资分配详情
            return fetch(`/stock-info/v1/stock-info/stock-send-record/${params.id}`, params);
        },
        fetchSendGoodsDetail(params) {//查看物资分配详情
            return fetch(`/stock-info/v1/stock-info/stock-send-record/send-detail/${params.id}`, params);
        },
        fetchInOrOutRecordList(params) {//出入库记录
            return fetch('/stock-info/v1/stock-info/stock-transfer-record', params)
        },
        fetchInOrOutRecordDetail(params) {//出入库记录详情
            return fetch(`/stock-info/v1/stock-info/stock-transfer-record/${params.id}`, params)
        },
        delInOrOutRecordRed(params) {//出入库记录红冲
            return fetch(`/stock-info/v1/stock-info/stock-transfer-record/red-operation/${params.id}`, params, 'put', 'json')
        },
        /*人工发放*/
        fetchManualDistributionist(params) {//人工发放记录列表
            return fetch('/stock-info/v1/stock-info/stock-provide-record', params);
        },
        fetchManualDistributionistDetail(params) {//人工发放详情
            return fetch(`/stock-info/v1/stock-info/stock-provide-record/${params.id}`, params);
        },
        addManualDistribution(params) {//新增人工发放
            return fetch('/stock-info/v1/stock-info/stock-provide-record', params, 'post', 'json');
        },
        //期初库存
        fetchBeginStock(params) {//期初库存列表
            return fetch('/stock-info/v1/stock-info/stock-opening-inventory', params);
        },
        //通过药具id和批次id判断是否有出入库记录（true:有）
        judgeInAndOutRecord(params) {
            return fetch(`/stock-info/v1/stock-info/stock-opening-inventory/check-transfer/${params.medicalId}/${params.batchId}`)
        },
        addBeginStock(params) {//新增期初库存
            return fetch('/stock-info/v1/stock-info/stock-opening-inventory/submit-data', params, 'post', 'json')
        },
        fetchBeginStockDetail(params) {//期初库存详情
            return fetch(`/stock-info/v1/stock-info/stock-opening-inventory/${params.id}`, params);
        },
        deleteBeginStock(params) {//期初库存删除
            return fetch(`/stock-info/v1/stock-info/stock-opening-inventory/${params.id}`, params, 'delete', 'json')
        },
        /*仓库盘点登记*/
        fetchStockInventoryList(params) {//仓库盘点列表
            return fetch('/stock-info/v1/stock-info/stock-inventory', params)
        },
        fetchStockInventoryDetail(params) {//仓库盘点详情
            return fetch(`/stock-info/v1/stock-info/stock-inventory/${params.id}`, params);
        },
        fetchNowStock(params) {//查询当前单位下属药具库存
            return fetch(`/stock-info/v1/stock-info/stock-inventory/query-stock-info`, params);
        },
        addStockInventory(params) {//新增仓库盘点登记
            return fetch('/stock-info/v1/stock-info/stock-inventory', params, 'post', 'json');
        },
    },

    //叶酸发放登记
    folviteDistributionManage: {
        fetchFolviteDistributionList(params) {//叶酸发放登记列表
            return fetch('/v1/folacin-admin/folacin-resident-info/grant-page', params)
        },
        fetchAddFolviteDistribution(params) {//叶酸发放
            return fetch('/v1/folacin-admin/folacin-resident-info/direct-grant', params, 'post', 'json')
        },
        fetchApplyDetail(id) {//申请详情
            return fetch(`/v1/folacin-admin/folacin-apply-info/${id}`)
        },
        fetchFolviteDistributionDetail(params) {//叶酸发放查看详情
            return fetch(`/v1/folacin-admin/folacin-resident-info/grant-details/${params.residentId}`)
        },
        fetchFolviteUploadConsent(params) {//上传知情同意书
            return fetch(`/v1/folacin-admin/folacin-resident-info/upload-consent/${params.id}/${params.consentId}`, {}, 'post')
        },
        fetchFolviteDelete(id) {//删除记录
            return fetch(`/v1/folacin-admin/folacin-resident-info/${id}`,{},"delete")
        },
        fetchLastRecord(idCard) {//查询最近一次发放记录
            return fetch(`/v1/folacin-admin/folacin-resident-info/resident/${idCard}`)
        },
    },
    //物资调拨管理
    allocationManagement: {
        /*调拨申请*/
        fetchAllotApplyList(params) {//调拨申请列表
            return fetch('/stock-info/v1/stock-info/stock-apply-record', params)
        },
        addAllotApply(params) { //新增调拨申请
            return fetch('/stock-info/v1/stock-info/stock-apply-record', params, 'post', 'json')
        },
        fetchIdApplyInfo(params) { //查询调拨申请
            return fetch(`/stock-info/v1/stock-info/stock-apply-record/${params.id}`, params)
        },
        updateAllotApply(params) { //修改调拨申请
            return fetch(`/stock-info/v1/stock-info/stock-apply-record/${params.id}`, params, 'put', 'json')
        },

        /*调拨审核 */
        fetchAllotCheckList(params) {//调拨审核列表
            return fetch('/stock-info/v1/stock-info/stock-apply-audit', params)
        },
        fetchApplyAudit(params) {// 审核
            return fetch('/stock-info/v1/stock-info/stock-apply-audit/add-examine', params, 'post', 'json');
        },
        fetchIdApplyAudit(params) {
            return fetch(`/stock-info/v1/stock-info/stock-apply-audit/${params.id}`, params);
        },
        fetchStockInfo(params) {
            return fetch(`/stock-info/v1/stock-info/stock-basic-info/unit-stock/${params.unitId}/${params.medicalIds}`);
        },
        fetchStockValidityWarn(params) {
            return fetch(`stock-info/v1/stock-info/stock-basic-info/stock-validity-warn`, params, "get");
        },
        // 调拨出库
        fetchAllotOutboundList(params) {//调拨出库列表
            return fetch('/stock-info/v1/stock-info/stock-apply-record/allocation', params);
        },
        fetchAllotOutbound(params) {//调拨出库
            return fetch('/stock-info/v1/stock-info/stock-send-record', params, 'post', 'json');
        }
    },
    folviteApplyManage: {
        fetchFolviteApplyList(params) {//叶酸申请列表
            return fetch('/v1/folacin-admin/folacin-apply-info/apply', params)
        },
        delFolviteApplyById(params) {//删除叶酸申请
            return fetch(`/v1/folacin-admin/folacin-apply-info/delete/${params.id}`, params, 'delete', 'json');
        },
        addFolviteDistributionByApply(params) {
            return fetch(`/v1/folacin-admin/folacin-resident-info/apply-grant/${params.id}`, params, "post", 'json');
        },
        addApplyGrant(params) {//对申请记录进行发放
            return fetch(`/v1/folacin-admin/folacin-apply-info/apply-grant`, params, "post", 'json');
        }
    },
    fyManage: {
        //从妇幼系统获取菜单及用户信息
        fetchFYLoginUser(params) {
            return fetch('/v1/folacin-admin/sys-login/getLoginInfo', params);
        },
    },
    download: {
        stockRecord(params) {//下载库存信息
            downInstance.get(`/v1/folacin-admin/folacin-stock-record/download`, {params});
        }
    },
    //常用工具
    utils: {
        //直接下载文件，不让浏览器直接打开
        downloadFile(url, fileName) {
            window.open(url)
        },
        //判断对象是否为空白
        isBlank(obj) {
            if (obj == undefined || obj == null || obj == "" || obj == " ") {
                return true;
            }
            return false;
        },
        isNoBlank(obj) {
            return !this.isBlank(obj);
        }
    }
}
