/*
 * @Date: 2022-07-04 15:59:58
 * @LastEditors: 陈禹琨 cyk910622@163.com
 * @LastEditTime: 2023-04-28 14:41:37
 * @FilePath: \upcloud-wms-henanyiyao-web\src\views\kzyWMS\outboundStrategy\strategy\orderSort\api\index.js
 * @Description: cyk
 */
import { axios } from "@/utils/request";
import request from "@/utils/request";
import qs from "qs";
import { upcloud_base_strategy, upcloud_base_common, upcloud_base_wh_outbound } from "@/config/serviceSettings";

const baseUrl = upcloud_base_wh_outbound;
// 列表页
export const listRemoteUrl = {
  url: baseUrl + "/rule/queryBillSortRuleList",
  method: "post",
};

// 导出
export const exportUrl = baseUrl + "/rule/export";

// 排序规则保存
export const saveRule = (data) => {
  return axios.post(baseUrl + "/rule/saveBillSortRule", data);
};
// 获取字典
export const getDictionary = (dicttypeCodes) => {
  return axios.post(upcloud_base_common + `/dict/listbytype?dicttypeCodes=${dicttypeCodes}`).then((res) => {
    return res.success ? res.data.map((_) => ({ ..._, label: _.dictName, value: _.dictCode })) : [];
  });
};
// 新增
export const add = (data) => {
  return axios.post(baseUrl + "/rule/saveBillSortRule", data);
};
// 修改
export const update = (data) => {
  return axios.post(baseUrl + "/rule/saveBillSortRule", data);
};
// 获取详情
export const getDetail = (data) => {
  return axios.post(baseUrl + "/itemType/itemTypeDetail", data);
};
// 删除
// export const del = (data) => {
//   return axios.post(baseUrl + "/rule/delBillSortRule", qs.stringify(data), {
//     headers: {
//       "content-type": "application/x-www-form-urlencoded",
//     },
//   });
// };

export function del(data) {
  return request({
    method: "post",
    url: baseUrl + "/rule/saveBillSortRule",
    data,
  });
}
