import { SalePrice } from "@/api/interface/index";
import { CommonDynamicSelect } from "@/api/modules/common";
import { PORT1 } from "@/api/config/servicePort";
import http from "@/api";

export const getPriceList = () => {
  return http.post<SalePrice.ResPriceList>(PORT1 + `/GetPriceList`, {});
};

/**
 * @name 获取 部门列表
 */
export const getDeptList = (params: any) => {
  let newParams: any = {};
  newParams.dsname = "web_deptlist";
  newParams.queryparams = params;
  newParams.pageNum && (newParams.pageindex = params.pageNum);
  newParams.pageSize && (newParams.pagesize = params.pageSize);
  delete params.pageNum;
  delete params.pageSize;
  return CommonDynamicSelect(newParams, "web_deptlist");
};

/**
 * @name 保存 部门信息
 */
export const SaveDept = (params: SalePrice.ReqSaveDept) => {
  return http.post<SalePrice.ResSaveDept>(PORT1 + `/SaveDept`, params);
};

/**
 * @name 删除 部门信息
 */
export const DeleteDept = (params: SalePrice.ReqDeleteDept) => {
  return http.post<SalePrice.ResDeleteDept>(PORT1 + `/DeleteDept`, params);
};

/**
 * @name 获取 工厂利润率
 */
export const getProfitRateList = (params: any) => {
  let newParams: any = {};
  newParams.dsname = "web_factory_profitratelist";
  newParams.queryparams = params;
  newParams.pageNum && (newParams.pageindex = params.pageNum);
  newParams.pageSize && (newParams.pagesize = params.pageSize);
  delete params.pageNum;
  delete params.pageSize;
  return CommonDynamicSelect(newParams, "web_factory_profitratelist");
};

/**
 * @name 保存 工厂利润率
 */
export const SaveProfitRate = (params: SalePrice.ReqSaveProfitrate) => {
  return http.post<SalePrice.ResSaveProfitrate>(PORT1 + `/SaveProfitrate`, params);
};

/**
 * @name 获取 工艺加点设置
 */
export const getWorkmanShipList = (params: any) => {
  let newParams: any = {};
  newParams.dsname = "web_workmanshiplist";
  newParams.queryparams = params;
  newParams.pageNum && (newParams.pageindex = params.pageNum);
  newParams.pageSize && (newParams.pagesize = params.pageSize);
  delete params.pageNum;
  delete params.pageSize;
  return CommonDynamicSelect(newParams, "web_workmanshiplist");
};

/**
 * @name 保存 工艺加点设置
 */
export const SaveWorkmanShip = (params: SalePrice.ReqSaveWorkmanShip) => {
  return http.post<SalePrice.ResSaveWorkmanShip>(PORT1 + `/SaveWorkmanship`, params);
};

/**
 * @name 删除 工艺加点设置
 */
export const DeleteWorkmanShip = (params: SalePrice.ReqDeleteWorkmanShip) => {
  return http.post<SalePrice.ResDeleteWorkmanShip>(PORT1 + `/DeleteWorkmanship`, params);
};

/**
 * @name 获取 无效物料对应报价查询
 */
export const getInvalidMtrlList = (params: any) => {
  let newParams: any = {};
  newParams.dsname = "web_invalid_mtrllist";
  newParams.queryparams = params;
  params.pageNum && (newParams.pageindex = params.pageNum);
  params.pageSize && (newParams.pagesize = params.pageSize);
  delete params.pageNum;
  delete params.pageSize;
  return CommonDynamicSelect(newParams, "web_invalid_mtrllist");
};
