import store from "@/store";
import { genWarehouseAuthSearchModal, genCargoownerAuthSearchModal, genItemSearchModal } from "../../SearchModal";
// import { SERVICE_DATA_API_BASE } from "@/config/serviceSettings";
import {
  upcloud_base_wh,
  upcloud_base_chain,
  upcloud_base_wh_operate,
  upcloud_base_wh_control,
  upcloud_base_common,
  SERVICE_DATA_API_BASE,
  upcloud_base_inventory,
  SERVICE_PLATFORM_POWER_BASE,
  upcloud_base_strategy,
} from "@/config/serviceSettings";
let warehouseId = "";
let bldgId = "";
let warehouseRoomId = "";
let warehouseAreaId = "";
let warehouseLocatorId = "";

const baseUrl = upcloud_base_inventory;
const API = {
  CargoOwnerLicenseList: {
    method: "post",
    url: upcloud_base_chain + "/baseCargoOwnerMst/v1.0/pageList",
    params: {},
  },
  warehouse: {
    // 仓库查询
    method: "get",
    url: upcloud_base_wh + "/warehouse/page",
    params: {},
  },
  wmsdcPage: {
    // 仓配中心查询
    method: "get",
    url: upcloud_base_wh + "/wmsdc/page",
    params: {},
  },
  wmsWhBldgPage: {
    // 建筑物查询
    method: "get",
    url: upcloud_base_wh + "/wmsWhBldg/v1/page",
    params: {},
  },
  wmsWhRoomMst: {
    // 库房查询
    method: "get",
    url: upcloud_base_wh + "/baseWmsWarehouseRoomMst/page2",
    params: {},
  },
  wmsWhArea: {
    // 库区查询
    method: "get",
    url: upcloud_base_wh + "/baseWmsWarehouseArea/page2",
    params: {},
  },

  locatorWHPage: {
    // 货位查询
    method: "get",
    url: upcloud_base_wh + "/locator/page",
    params: {},
  },
  locatorPage: {
    // 货位限定
    method: "get",
    url: upcloud_base_wh_control + "/item-locator/v1/locator-limit-inbound",
    params: {},
  },
  locatorPageLK: {
    // 立库移入货位
    method: "get",
    url: upcloud_base_wh_control + "/item-locator/v1/locator-limit-lk-inbound",
    params: {},
  },
  locatorStocks: {
    // 货位库存
    method: "get",
    url: upcloud_base_wh_operate + "/locator/stocks",
    params: {},
  },
  whItems: {
    // 仓商品总可用库存
    method: "get",
    url: upcloud_base_wh_operate + "/wh/items",
    params: {},
  },
  commonUrl: {
    // 查询服务接口
    method: "post",
    url: SERVICE_DATA_API_BASE + "/search/page",
  },
  batchPage: {
    // 批次号查询
    method: "get",
    url: upcloud_base_inventory + "/batch-number/v1/page",
    params: {},
  },
  getstock: {
    // 获取可用库存
    method: "get",
    url: upcloud_base_inventory + "/stock/v1/qty/avl",
    params: {},
  },
  getstoc1: {
    // 获取可用库存
    method: "get",
    url: upcloud_base_inventory + "/stock/v1/qty/avl",
    params: {
      lkFlag: "Y",
    },
  },
  batchNum: {
    // 分页查询库存商品
    method: "get",
    url: upcloud_base_inventory + "/batch-number/v1/item-page",
    params: {},
  },
  employeePage: {
    // 员工查询
    method: "get",
    url: SERVICE_PLATFORM_POWER_BASE + "/employee/page",
    params: {},
  },
  departmentPage: {
    // 部门查询
    method: "get",
    url: upcloud_base_chain + "/department/page",
    params: {},
  },
  ruleMoveList: {
    // 目标库别查询-通过源库别
    method: "get",
    url: upcloud_base_strategy + "/rule/move/v1/list",
    params: {},
  },
  itemBatchInfiPage: {
    // 库存商品信息查询分页
    method: "post",
    url: upcloud_base_inventory + "/batch-adjust/v1/item-batchinfo-page",
    params: {},
  },
  remoteUrlFun: (type) => {
    return {
      url: upcloud_base_common + `/dict/listbytype/?dicttypeCodes=${type}`,
      method: "post",
    };
  },
  relationOwnerStockStatus: {
    // 库存状态查询
    method: "post",
    url: upcloud_base_wh_control + "/relationOwnerStockStatus/list",
    params: {},
  },
};
import { remote } from "@/views/EIS/remote/index.js";

const config = function (that) {
  return {
    remoteUrl: {
      url: baseUrl + "/stock-lot/getDeviceContainerStockPage",
      headers: {
        "Content-Type": "application/JSON",
      },
      method: "get",
    },
    items: [
      ...genWarehouseAuthSearchModal(
        1,
        true,
        false,
        null,
        function (modalRowData, form) {
          if (modalRowData) {
            warehouseId = modalRowData[0].warehouseId ? modalRowData[0].warehouseId : modalRowData[0].companyId;
            form.setFieldsValue({
              warehouseId: modalRowData[0].warehouseId ? modalRowData[0].warehouseId : modalRowData[0].companyId,
              warehouseLocatorId: "",
              warehouseLocatorName: "",
            });
          } else {
            form.setFieldsValue({
              warehouseId: "",
              warehouseLocatorId: "",
              warehouseLocatorName: "",
            });
            warehouseLocatorName = "";
            warehouseId = "";
            warehouseLocatorId = "";
          }
        },
        { span: 8 }
      ),
      ...genCargoownerAuthSearchModal(1, true, false, null, null, {
        span: 8,
      }),
      //   ...genItemSearchModal(1, false, false, null, null, {
      //     span: 8,
      //   }),
      //   { type: "input", name: "manufacturerLotNum", label: "批号" },
      { type: "input", name: "containerCode", label: "托盘号" },
      //   { type: "input", name: "containerCode", label: "操作员" },
      {
        type: "input",
        name: "warehouseWorkerName",
        label: "操作员id",
        value: store.getters.userInfo.username,
        disabled: true,
      },

      {
        type: "buttonGroup",
        wrapperCol: { span: 16, offset: 8 },
        options: [
          {
            value: "查询",
            icon: "search",
            btnType: "primary",
            style: "margin-left:10px",
            htmlType: "submit",
          },
          {
            value: "重置",
            icon: "redo",
            style: "margin-left:10px",
            on: {
              click(event, form) {
                form.resetFields();
                form.setFieldsValue({ warehouseWorkerName: store.getters.userInfo.username });
              },
            },
          },
        ],
      },
    ],
    columns: [
      // customRender(text) {
      //     text == 10 && (text = "区域");
      //     text == 20 && (text = "接驳口");
      //     return text;
      //   },
      //   { title: "操作员", dataIndex: "操作员", key: "areaNo", align: "center" },
      { title: "仓名称", dataIndex: "warehouseName", align: "center", key: "warehouseName" },
      { title: "库区", dataIndex: "warehouseAreaName", ellipsis: true, align: "center", key: "warehouseAreaName" },
      { title: "货位", key: "locatorName", ellipsis: true, dataIndex: "locatorName", align: "center" },
      { title: "托盘号", dataIndex: "containerCode", align: "center", ellipsis: true, key: "containerCode" },
      { title: "库存量", key: "quantity", ellipsis: true, dataIndex: "quantity", align: "center" },
      { title: "货主", key: "cargoOwnerName", ellipsis: true, dataIndex: "cargoOwnerName", align: "center" },
      {
        title: "操作",
        key: "operation",
        scopedSlots: { customRender: "operation" },
        // fixed: 'right',
        align: "center",
      },
    ],
    ModelColumns: [
      { title: "商品编码", dataIndex: "itemCode", key: "itemCode", align: "center" },
      { title: "商品名称", dataIndex: "itemName", align: "center", key: "itemName" },
      { title: "包装数量", dataIndex: "packSize", ellipsis: true, align: "center", key: "packSize" },
      { title: "包装单位", key: "packUnits", ellipsis: true, dataIndex: "packUnits", align: "center" },
      { title: "批号", dataIndex: "manufacturerLotNum", align: "center", ellipsis: true, key: "manufacturerLotNum" },
      {
        title: "生产日期",
        key: "batchProductionDate",
        ellipsis: true,
        dataIndex: "batchProductionDate",
        align: "center",
      },
      { title: "有效期至", key: "batchExpiredDate", ellipsis: true, dataIndex: "batchExpiredDate", align: "center" },
      { title: "库存数量", key: "quantity", ellipsis: true, dataIndex: "quantity", align: "center" },
      { title: "货主", key: "cargoOwnerName", ellipsis: true, dataIndex: "cargoOwnerName", align: "center" },
    ],
  };
};

export default config;
