import request from "@/utils/request";

/**
 * 商品列表
 * @returns
 */
export function tbProductGet(params) {
  return request({
    url: "/api/tbProduct",
    method: "get",
    params
  });
}
export function tbProductlist(params) {
  return request({
    url: "/api/tbProduct/list",
    method: "get",
    params
  });
}
/**
 * 商品分类列表
 * @returns
 */
export function tbShopCategoryGet(params) {
  return request({
    url: `/api/tbShopCategory`,
    method: "get",
    params
  });
}
/**
 * 进销存类型字典
 * @returns
 */
export function dictDetail(params) {
  return request({
    url: `/api/dictDetail`,
    method: "get",
    params
  });
}

/**
 * 库存记录列表
 * @returns
 */
export function tbProductStockDetail(data) {
  return request({
    url: `/api/tbProductStockDetail/stock`,
    method: "post",
    data
  });
}

/**
 * 变动数量
 * @returns
 */
export function tbProductStockDetailSum(params) {
  return request({
    url: `/api/tbProductStockDetail/sum`,
    method: "get",
    params
  });
}

/**
 * 供应商列表
 * @returns
 */
export function tbShopPurveyorGet(params) {
  return request({
    url: `/api/tbShopPurveyorTransact`,
    method: "get",
    params
  });
}
// 供应商列表1
export function tbShopPurveyorGets(params) {
  return request({
    url: `/api/tbShopPurveyorTransact`,
    method: "get",
    params
  });
}
/**
 * 增加供应商
 * @returns
 */
export function tbShopPurveyor(data, method = "post") {
  return request({
    url: `/api/tbShopPurveyor`,
    method: method,
    data
  });
}

/**
 * 进货/退货账目
 * @returns
 */
export function tbShopPurveyorTransactGet(params) {
  return request({
    url: `/api/tbShopPurveyorTransact`,
    method: "get",
    params
  });
}

/**
 * 进货账目详情
 * @returns
 */
export function tbShopPurveyorTransactInfo(data) {
  return request({
    url: `/api/tbShopPurveyorTransact/info`,
    method: "post",
    data
  });
}
// 付款
export function paidAmount(data) {
  return request({
    url: `/api/tbShopPurveyorTransact/payTransact`,
    method: "post",
    data
  });
}
/**
 * 进货账目汇总（单一供应商）
 * @returns
 */
export function tbShopPurveyorTransactSum(params) {
  return request({
    url: `/api/tbShopPurveyorTransact/sum`,
    method: "get",
    params
  });
}

/**
 * 操作记录
 * @returns
 */
export function tbProductStockOperateList(data) {
  return request({
    url: `/api/tbProductStockOperate/list`,
    method: "post",
    data
  });
}

/**
 * 操作记录详情
 * @returns
 */
export function tbProductStockOperateDetail(id) {
  return request({
    url: `/api/tbProductStockOperate/${id}`,
    method: "get"
  });
}

/**
 * 操作出库/入库
 * @returns
 */
export function tbProductStockOperateOutAndOn(data) {
  return request({
    url: `/api/tbProductStockOperate/outAndOn`,
    method: "post",
    data
  });
}
// 副单位
export function unittbConsInfo(params) {
  return request({
    url: `/api/tbConsInfo`,
    method: "put",
    data: params
  });
}
/**
 * 库存列表
 * @returns
 */
export function stock(params) {
  return request({
    url: `/api/stock/v2`,
    method: "get",
    params
  });
}
// 库存列表子集列表
export function stocks(params) {
  return request({
    url: `/api/stock/sku`,
    method: "get",
    params
  });
}
/**
 * 导出数据
 * @returns
 */
export function stockdownload(data) {
  return request({
    url: "/api/stock/download/v2",
    method: "post",
    data: {
      shopId: localStorage.getItem("shopId"),
      ...data
    },
    responseType: "blob"
  });
}

/**
 * 导出数据
 * @returns
 */
export function stockdoImport(file) {
  const formData = new FormData();
  formData.append("file", file);
  formData.append("shopId", localStorage.getItem("shopId"));
  return request({
    url: "/api/stock/doImport/v2",
    method: "post",
    data: formData,
    Headers: {
      "Content-Type": "multipart/form-data"
    }
  });
}

/**
 * 库存开关
 * @returns
 */
export function stockStateChange(params) {
  return request({
    url: `/api/stock/isStock`,
    method: "get",
    params: {
      shopId: localStorage.getItem("shopId"),
      ...params
    }
  });
}
// 下架
export function stockStateChangess(params) {
  return request({
    url: `/api/stock/grounding`,
    method: "put",
    params: {
      ...params
    }
  });
}
// 警戒设置
export function stockStatewarnLine(params) {
  return request({
    url: `/api/stock/warnLine`,
    method: "put",
    data: {
      ...params
    }
  });
}
// 共享库存
export function stockStateChanges(params) {
  return request({
    url: `/api/stock/productStatus`,
    method: "put",
    data: {
      shopId: localStorage.getItem("shopId"),
      ...params
    }
  });
}

/**
 * 新增盘点
 * @returns
 */
export function tbProductStocktakin(data) {
  return request({
    url: `/api/tbProductStocktakin`,
    method: "post",
    data: {
      shopId: localStorage.getItem("shopId"),
      ...data
    }
  });
}

/**
 * 盘点记录查询
 * @returns
 */
export function tbProductStocktakinGet(data) {
  return request({
    url: `/api/tbProductStocktakin`,
    method: "get",
    params: {
      shopId: localStorage.getItem("shopId"),
      ...data
    }
  });
}
// 账单付款记录
export function tbShopPurveyorTransacttransactPayInfos(params) {
  return request({
    url: `/api/tbShopPurveyorTransact/transactPayInfos`,
    method: "get",
    params
  });
}

/**
 * 查询耗材信息
 * @returns
 */
export function tbConsInfoGet(data) {
  return request({
    url: `/api/tbConsInfo`,
    method: "get",
    params: {
      shopId: localStorage.getItem("shopId"),
      ...data
    }
  });
}

/**
 * 耗材出入库
 * @returns
 */
export function stockInOut(data) {
  return request({
    url: `/api/tbConsInfo/stockInOut`,
    method: "post",
    data: {
      shopId: localStorage.getItem("shopId"),
      ...data
    }
  });
}

/**
 * 新增盘点耗材
 * @returns
 */
export function tbConCheck(data) {
  return request({
    url: `/api/tbConCheck`,
    method: "post",
    data: {
      shopId: localStorage.getItem("shopId"),
      ...data
    }
  });
}

/**
 * 查询盘点耗材
 * @returns
 */
export function tbConCheckGet(data) {
  return request({
    url: `/api/tbConCheck`,
    method: "get",
    params: {
      shopId: localStorage.getItem("shopId"),
      ...data
    }
  });
}

/**
 * 耗材导出
 * @returns
 */
export function tbConsInfodownload(data) {
  return request({
    url: "/api/tbConsInfo/download",
    method: "get",
    params: {
      shopId: localStorage.getItem("shopId"),
      ...data
    },
    responseType: "blob"
  });
}

/**
 * 导入耗材
 * @returns
 */
export function tbConsInfoinputStock(file) {
  const formData = new FormData();
  formData.append("file", file);
  formData.append("shopId", localStorage.getItem("shopId"));
  return request({
    url: "/api/tbConsInfo/inputStock",
    method: "post",
    data: formData,
    Headers: {
      "Content-Type": "multipart/form-data"
    }
  });
}

/**
 * 供应商出入库记录
 * @returns
 */
export function tbProductStockOperatepage(data) {
  return request({
    url: `/api/tbProductStockOperate/page`,
    method: "post",
    data
  });
}