import { remote, remote2 } from "./remote";
import moment from "moment";
import { genBranchAuthSearchModal, genCargoownerAuthSearchModal, genCustomerSearchModal } from "@/views/kzyWMS/SearchModal";
import { upcloud_base_common, upcloud_base_inventory, upcloud_base_chain } from "@/config/serviceSettings";

// 批号弹窗
const getLOTItems = (changeFun, remoteBeforeFun, modalOpenChange) => {
  return {
    type: "searchModal",
    value: "",
    rowKey: "id",
    destroyOnClose: true,
    targetClick: true,
    labelCol: {
      span: 8,
    },
    wrapperCol: {
      span: 16,
    },
    span: 6,
    remoteUrl: {
      url: upcloud_base_inventory + "/stock/v1/queryStockInfoList",
      method: "post",
    },
    required: true,
    toolBar: {
      items: [
        { type: "input", name: "batchNum", label: "批号", span: 8, value: "" },
        { type: "input", name: "locatorId", label: "货位", span: 8, value: "" },
        { type: "input", name: "containerCode", label: "托盘", span: 8, value: "" },
      ],
    },
    tableConfig: {
      scroll: { x: true },
      remoteBefore: remoteBeforeFun,
      columns: [
        { dataIndex: "itemName", title: "商品名称" },
        { dataIndex: "locatorId", title: "货位", ellipsis: true },
        { dataIndex: "containerCode", title: "托盘", ellipsis: true },
        { dataIndex: "manufacturerLotNum", title: "批号" },
        {
          dataIndex: "status",
          title: "库存状态",
          customRender(text) {
            text = String(text);
            if (text === "1") return "合格";
            if (text === "2") return "不合格";
            if (text === "3") return "待检";
            if (text === "4") return "退货";
            return text;
          },
        },
        {
          dataIndex: "invoicedQuantity",
          title: "库存数量",
        },
      ],
      hasRowSelectCheck: true,
      rowSelectType: 1,
    },
    on: {
      change: changeFun,
    },
    modalOpenChange,
  };
};

const grid = {
  labelCol: { span: 8 },
  wrapperCol: { span: 16 },
  span: 6,
};
let warehouseId = "";

export function changeFun(modalRowData, form) {
  // form.setFieldsValue({ cargoOwnerId: modalRowData.cargoOwnerId })
  warehouseId = modalRowData[0].companyId;
  console.log(modalRowData);
}

export function remoteBefore(res, remoteParams) {
  console.log(remoteParams, "remoteParamsremoteParams");
  remoteParams.params.warehouseId = warehouseId;
  // remoteParams.data.id = '587643938693844992' // 添加建筑物查询
  // remoteParams.data.params = {
  //   ...remoteParams.data
  // }
  return remoteParams;
}

const extendConfig = {
  mapper: { cargoOwnerId: "consignorid", cargoOwnerName: "consignorname", cargoOwnerCode: "consignorcode" },
};
const src = upcloud_base_common + "/dict/listbytype?dicttypeCodes=";

function itemfun(self) {
  return [
    ...genBranchAuthSearchModal(1, true, false, null, null, grid, null),

    ...genCargoownerAuthSearchModal(1, true, false, null, null, grid, extendConfig),
    ...genCustomerSearchModal(
      1,
      false,
      false,
      function (vnode, p) {
        let vals = self.$refs.modelForm.form.getFieldsValue();
        console.log(vals);
        p.data.cargoOwnerId = vals.consignorid;
        return p;
      },
      null,
      grid
    ),
    {
      type: "input",
      name: "cargoOwnerCode",
      label: "cargoOwnerCode",
      hidden: true,
    },
    {
      type: "input",
      name: "cargoOwnerId",
      label: "cargoOwnerId",
      hidden: true,
    },
    {
      name: "billno",
      label: "订单编号",
      type: "input",
      ...grid,
    },
    // {
    //   name: 'saleBranchname',
    //   label: '部门',
    //   type: 'input',
    //   ...grid
    // },
    // {
    //   name: 'salesPersonName',
    //   label: '业务员',
    //   type: 'input',
    //   ...grid
    // },
    // {
    //   name: 'arrivalMode',
    //   label: '提货方式',
    //   ...remote2('pub_workstage_delivertype'),
    //   type: 'select',
    //   ...grid
    // },
    {
      name: "billtype",
      label: "单据类型",
      ...remote2("do_bill_type"),
      type: "select",
      ...grid,
    },
    {
      name: "isEmergency",
      label: "是否急单",
      type: "select",
      ...grid,
      options: [
        { label: "是", value: "1" },
        { label: "否", value: "0" },
      ],
    },
    {
      type: "date",
      name: "billDateStart",
      label: "订单开始时间",
      format: "YYYY-MM-DD HH:mm:ss",
      showTime: {
        format: "HH:mm:ss",
        defaultValue: moment("00:00:00", "HH:mm:ss"),
      },
      ...grid,
    },
    {
      type: "date",
      name: "billDateEnd",
      label: "订单结束时间",
      format: "YYYY-MM-DD HH:mm:ss",
      showTime: {
        format: "HH:mm:ss",
        defaultValue: moment("23:59:59", "HH:mm:ss"),
      },
      ...grid,
    },
    // {
    //   type: "date",
    //   name: "attainDateStart",
    //   label: "配送开始时间",
    //   format: "YYYY-MM-DD HH:mm:ss",
    //   showTime: {
    //     format: "HH:mm:ss",
    //     defaultValue: moment("23:59:59", "HH:mm:ss"),
    //   },
    //   ...grid,
    // },
    // {
    //   type: "date",
    //   name: "attainDateEnd",
    //   label: "配送结束时间",
    //   format: "YYYY-MM-DD HH:mm:ss",
    //   showTime: {
    //     format: "HH:mm:ss",
    //     defaultValue: moment("23:59:59", "HH:mm:ss"),
    //   },
    //   ...grid,
    // },
    {
      type: "select",
      name: "char",
      label: "承运商",
      value: "",
      // ...remote2("common_shiplineid"),
      destroyOptions: true,
      autoLoad: true,
      remoteUrl: { url: upcloud_base_chain + "/baseCarrierMst/v1.0/findAll", method: "post", data:{} },
      replaceFields: { value: "carrierCode", label: "carrierName" },
      ...grid,
    },
    {
      ...grid,
      type: "buttonGroup",
      style: { textAlign: "center" },
      options: [
        {
          value: "查询",
          icon: "search",
          btnType: "primary",
          style: "margin-right:10px",
          htmlType: "submit",
        },
        {
          value: "重置",
          name: "ccz",
          icon: "redo",
          on: {
            click(event, form) {
              form.resetFields();
            },
          },
        },
      ],
    },
  ];
}

const columns = [
  {
    dataIndex: "billno",
    sorter: (a, b) => (a.billno ? a.billno : "").localeCompare(b.billno ? b.billno : ""),
    title: "订单编号",
    width: 120,
  },
  {
    dataIndex: "billTypeName",
    sorter: (a, b) => (a.billTypeName ? a.billTypeName : "").localeCompare(b.billTypeName ? b.billTypeName : ""),
    title: "单据类型",
    width: 140,
  },
  {
    dataIndex: "shippername",
    sorter: (a, b) => (a.shippername ? a.shippername : "").localeCompare(b.shippername ? b.shippername : ""),
    ellipsis: true,
    width: 200,
    title: "收货单位名称",
  },
  {
    dataIndex: "remark",
    sorter: (a, b) => (a.remark ? a.remark : "").localeCompare(b.remark ? b.remark : ""),
    ellipsis: true,
    width: 100,
    title: "备注",
  },
  {
    dataIndex: "createby",
    sorter: (a, b) => (a.createby ? a.createby : "").localeCompare(b.createby ? b.createby : ""),
    width: 100,
    title: "录入人",
  },
  {
    dataIndex: "createdate",
    sorter: (a, b) => (a.createdate ? a.createdate : "").localeCompare(b.createdate ? b.createdate : ""),
    width: 150,
    title: "录入时间",
  },
  {
    dataIndex: "billDate",
    sorter: (a, b) => (a.billDate ? a.billDate : "").localeCompare(b.billDate ? b.billDate : ""),
    width: 150,
    title: "制单日期",
  },
  // {
  //   dataIndex: "salespersonName",
  //   sorter: (a, b) => (a.salespersonName ? a.salespersonName : "").localeCompare(b.salespersonName ? b.salespersonName : ""),
  //   title: "业务员",
  //   width: 150,
  // },
  // {
  //   dataIndex: "rtReason",
  //   sorter: (a, b) => (a.salespersonName ? a.salespersonName : "").localeCompare(b.salespersonName ? b.salespersonName : ""),
  //   title: "退货原因",
  //   width: 150,
  // },
  {
    dataIndex: "billtype",
    sorter: (a, b) => (a.billtype ? a.billtype : "").localeCompare(b.billtype ? b.billtype : ""),
    title: "交货类型",
    width: 120,
    remoteUrl: { url: src + "do_bill_type", method: "post" },
    replaceFields: {
      value: "dictCode",
      label: "dictName",
    },
  },
  // {
  //   dataIndex: "lineCode",
  //   sorter: (a, b) => (a.lineCode ? a.lineCode : "").localeCompare(b.lineCode ? b.lineCode : ""),
  //   width: 100,
  //   title: "运输路线编码",
  // },
  // {
  //   dataIndex: "lineName",
  //   sorter: (a, b) => (a.lineName ? a.lineName : "").localeCompare(b.lineName ? b.lineName : ""),
  //   width: 100,
  //   title: "运输路线名称",
  // },
  {
    dataIndex: "partlyRed",
    title: "部分红冲状态",
    width: 100,
    customRender: (text, record) => {
      if (text == 1) {
        return "部分红冲";
      } else {
        if (record.isCancelled == 1) {
          return "完全红冲";
        } else {
          return "未红冲";
        }
      }
    },
    sorter: (a, b) => (a.partlyRed ? a.partlyRed : "").localeCompare(b.partlyRed ? b.partlyRed : ""),
  },

  // {
  //   dataIndex: "saleBranchname1",
  //   sorter: (a, b) => (a.saleBranchname1 ? a.saleBranchname1 : "").localeCompare(b.saleBranchname1 ? b.saleBranchname1 : ""),
  //   title: "要货部门",
  //   width: 150,
  // },
  // {
  //   dataIndex: 'isCancelled',
  // sorter:(a,b)=>(a.isCancelled? a.isCancelled : '').localeCompare((b.isCancelled? b.isCancelled : '')),
  //  title: '红冲状态',
  //   width: 100,
  //   customRender: (text, record) => {
  //     // console.log(record)
  //     if (text == 1) {
  //       return '已红冲'
  //     } else {
  //       return '未红冲'
  //     }
  //   }
  // },

  {
    dataIndex: "arrivalMode",
    sorter: (a, b) => (a.arrivalMode ? a.arrivalMode : "").localeCompare(b.arrivalMode ? b.arrivalMode : ""),
    title: "提货方式",
    width: 150,
    // remoteUrl: { url: src + "pub_workstage_delivertype", method: "post" },
    // replaceFields: {
    //   value: "dictCode",
    //   label: "dictName",
    // },
  },
  // {
  //   dataIndex: "shipLineId",
  //   sorter: (a, b) => (a.shipLineId ? a.shipLineId : "").localeCompare(b.shipLineId ? b.shipLineId : ""),
  //   title: "配送路线",
  //   width: 150,
  // },
  // {
  //   dataIndex: 'billDateStart',
  // sorter:(a,b)=>(a.billDateStart? a.billDateStart : '').localeCompare((b.billDateStart? b.billDateStart : '')),
  //  width: 150,
  //   title: '单据日期',
  // },
  // {
  //   dataIndex: "attainDate",
  //   sorter: (a, b) => (a.attainDate ? a.attainDate : "").localeCompare(b.attainDate ? b.attainDate : ""),
  //   title: "预定到货日",
  //   width: 150,
  // },
  {
    dataIndex: "custPerson",
    sorter: (a, b) => (a.custPerson ? a.custPerson : "").localeCompare(b.custPerson ? b.custPerson : ""),
    width: 100,
    title: "收货联系人",
  },
  {
    dataIndex: "custPersonTel",
    sorter: (a, b) => (a.custPersonTel ? a.custPersonTel : "").localeCompare(b.custPersonTel ? b.custPersonTel : ""),
    width: 150,
    title: "收货联系人电话",
  },
  {
    dataIndex: "receiveAddress",
    sorter: (a, b) => (a.receiveAddress ? a.receiveAddress : "").localeCompare(b.receiveAddress ? b.receiveAddress : ""),
    ellipsis: true,
    width: 200,
    title: "收货地址",
  },
  // {
  //   dataIndex: "receiveCityName",
  //   sorter: (a, b) => (a.receiveCityName ? a.receiveCityName : "").localeCompare(b.receiveCityName ? b.receiveCityName : ""),
  //   width: 100,
  //   title: "收货市",
  // },
  // {
  //   dataIndex: "receiveCityNo",
  //   sorter: (a, b) => (a.receiveCityNo ? a.receiveCityNo : "").localeCompare(b.receiveCityNo ? b.receiveCityNo : ""),
  //   width: 100,
  //   title: "收货市编号",
  // },

  // {
  //   dataIndex: "receiveDistrictNo",
  //   sorter: (a, b) => (a.receiveDistrictNo ? a.receiveDistrictNo : "").localeCompare(b.receiveDistrictNo ? b.receiveDistrictNo : ""),
  //   width: 120,
  //   title: "收货区/县编号",
  // },
  // {
  //   dataIndex: "shippercode",
  //   sorter: (a, b) => (a.shippercode ? a.shippercode : "").localeCompare(b.shippercode ? b.shippercode : ""),
  //   width: 100,
  //   title: "收货单位类型",
  // },
  // {
  //   dataIndex: "shipTerm",
  //   sorter: (a, b) => (a.shipTerm ? a.shipTerm : "").localeCompare(b.shipTerm ? b.shipTerm : ""),
  //   width: 100,
  //   title: "运输条件",
  // },
  {
    dataIndex: "priorityLevel",
    sorter: (a, b) => (a.priorityLevel ? a.priorityLevel : "").localeCompare(b.priorityLevel ? b.priorityLevel : ""),
    width: 120,
    title: "订单紧急等级",
  },
  // {
  //   dataIndex: "paymentdaytype",
  //   sorter: (a, b) => (a.paymentdaytype ? a.paymentdaytype : "").localeCompare(b.paymentdaytype ? b.paymentdaytype : ""),
  //   ellipsis: true,
  //   title: "账期类型",
  //   width: 100,
  // },
  // {
  //   dataIndex: "salesContrNumb",
  //   sorter: (a, b) => (a.salesContrNumb ? a.salesContrNumb : "").localeCompare(b.salesContrNumb ? b.salesContrNumb : ""),
  //   title: "购销合同号",
  //   width: 150,
  // },
  {
    dataIndex: "carrierName",
    sorter: (a, b) => (a.carrierName ? a.carrierName : "").localeCompare(b.carrierName ? b.carrierName : ""),
    ellipsis: true,
    title: "承运商名称",
    width: 100,
  },
  // {
  //   dataIndex: "advdeliverydate",
  //   sorter: (a, b) => (a.advdeliverydate ? a.advdeliverydate : "").localeCompare(b.advdeliverydate ? b.advdeliverydate : ""),
  //   title: "预约送货日期",
  //   width: 200,
  // },
  // {
  //   dataIndex: "branchAddress",
  //   sorter: (a, b) => (a.branchAddress ? a.branchAddress : "").localeCompare(b.branchAddress ? b.branchAddress : ""),
  //   title: "出库仓库详细地址",
  //   width: 150,
  // },
  // {
  //   dataIndex: "enquiryDepartment",
  //   sorter: (a, b) => (a.enquiryDepartment ? a.enquiryDepartment : "").localeCompare(b.enquiryDepartment ? b.enquiryDepartment : ""),
  //   title: "部门",
  //   width: 100,
  // },
  // {
  //   dataIndex: 'salespersonName',
  // sorter:(a,b)=>(a.salespersonName? a.salespersonName : '').localeCompare((b.salespersonName? b.salespersonName : '')),
  //  title: '要货业务员',
  //   width: 100,

  // },
  // {
  //   dataIndex: "branchAddress10",
  //   sorter: (a, b) => (a.branchAddress10 ? a.branchAddress10 : "").localeCompare(b.branchAddress10 ? b.branchAddress10 : ""),
  //   title: "客户采购计划单号",
  //   width: 200,
  // },
  // {
  //   dataIndex: "branchAddress11",
  //   sorter: (a, b) => (a.branchAddress11 ? a.branchAddress11 : "").localeCompare(b.branchAddress11 ? b.branchAddress11 : ""),
  //   title: "要货业务员",
  //   width: 100,
  // },
  // {
  //   dataIndex: "branchAddress12",
  //   sorter: (a, b) => (a.branchAddress12 ? a.branchAddress12 : "").localeCompare(b.branchAddress12 ? b.branchAddress12 : ""),
  //   title: "品规数",
  //   width: 100,
  // },
  // {
  //   dataIndex: "branchAddress13",
  //   sorter: (a, b) => (a.branchAddress13 ? a.branchAddress13 : "").localeCompare(b.branchAddress13 ? b.branchAddress13 : ""),
  //   title: "零货品规数",
  //   width: 100,
  // },
  // {
  //   dataIndex: "brancharea",
  //   sorter: (a, b) => (a.brancharea ? a.brancharea : "").localeCompare(b.brancharea ? b.brancharea : ""),
  //   title: "出库仓库库区",
  //   width: 150,
  // },
  {
    dataIndex: "branchcode",
    sorter: (a, b) => (a.branchcode ? a.branchcode : "").localeCompare(b.branchcode ? b.branchcode : ""),
    width: 100,
    title: "出库仓库编号",
  },
  {
    dataIndex: "branchname",
    sorter: (a, b) => (a.branchname ? a.branchname : "").localeCompare(b.branchname ? b.branchname : ""),
    width: 100,
    title: "出库仓库名称",
  },
  // {
  //   dataIndex: "closedReason",
  //   sorter: (a, b) => (a.closedReason ? a.closedReason : "").localeCompare(b.closedReason ? b.closedReason : ""),
  //   width: 100,
  //   title: "作废原因",
  // },
  // {
  //   dataIndex: "containersNum",
  //   sorter: (a, b) => (a.containersNum ? a.containersNum : "").localeCompare(b.containersNum ? b.containersNum : ""),
  //   width: 100,
  //   title: "包装数量",
  // },
  // {
  //   dataIndex: "totBoxNum",
  //   sorter: (a, b) => (a.totBoxNum ? a.totBoxNum : "").localeCompare(b.totBoxNum ? b.totBoxNum : ""),
  //   width: 100,
  //   title: "总拼箱数",
  // },
  // {
  //   dataIndex: "totPcs",
  //   sorter: (a, b) => (a.totPcs ? a.totPcs : "").localeCompare(b.totPcs ? b.totPcs : ""),
  //   width: 100,
  //   title: "总件数",
  // },
  // {
  //   dataIndex: "totQty",
  //   sorter: (a, b) => (a.totQty ? a.totQty : "").localeCompare(b.totQty ? b.totQty : ""),
  //   width: 100,
  //   title: "折合件数",
  // },
  {
    dataIndex: "totVolume",
    sorter: (a, b) => (a.totVolume ? a.totVolume : "").localeCompare(b.totVolume ? b.totVolume : ""),
    width: 100,
    title: "总体积",
  },
  {
    dataIndex: "totWeight",
    sorter: (a, b) => (a.totWeight ? a.totWeight : "").localeCompare(b.totWeight ? b.totWeight : ""),
    width: 100,
    title: "总重量",
  },
  // {
  //   dataIndex: "totamt",
  //   sorter: (a, b) => (a.totamt ? a.totamt : "").localeCompare(b.totamt ? b.totamt : ""),
  //   width: 100,
  //   title: "总含税金额",
  // },
  // {
  //   dataIndex: "totnetamt",
  //   sorter: (a, b) => (a.totnetamt ? a.totnetamt : "").localeCompare(b.totnetamt ? b.totnetamt : ""),
  //   width: 100,
  //   title: "总未税金额",
  // },
  // {
  //   dataIndex: 'receiveAddress',
  // sorter:(a,b)=>(a.receiveAddress? a.receiveAddress : '').localeCompare((b.receiveAddress? b.receiveAddress : '')),
  //  width: 200,
  //   title: '收货单位名称',
  // },
  // {
  //   dataIndex: "branchareacode",
  //   sorter: (a, b) => (a.branchareacode ? a.branchareacode : "").localeCompare(b.branchareacode ? b.branchareacode : ""),
  //   width: 150,
  //   title: "出库仓库库区编码",
  // },

  // {
  //   dataIndex: "carriercode",
  //   sorter: (a, b) => (a.carriercode ? a.carriercode : "").localeCompare(b.carriercode ? b.carriercode : ""),
  //   width: 100,
  //   title: "物流商编码",
  // },
  // {
  //   dataIndex: "salespersonCode",
  //   sorter: (a, b) => (a.salespersonCode ? a.salespersonCode : "").localeCompare(b.salespersonCode ? b.salespersonCode : ""),
  //   width: 100,
  //   title: "业务员编码",
  // },
  // {
  //   dataIndex: "excReason",
  //   sorter: (a, b) => (a.excReason ? a.excReason : "").localeCompare(b.excReason ? b.excReason : ""),
  //   width: 100,
  //   title: "异常原因",
  // },
  {
    dataIndex: "status",
    sorter: (a, b) => (a.status ? a.status : "").localeCompare(b.status ? b.status : ""),
    width: 100,
    title: "状态",
    scopedSlots: { customRender: "isEnable" },
  },
  {
    dataIndex: "consignorcode",
    sorter: (a, b) => (a.consignorcode ? a.consignorcode : "").localeCompare(b.consignorcode ? b.consignorcode : ""),
    width: 100,
    title: "货主编码",
  },
  {
    dataIndex: "consignorname",
    sorter: (a, b) => (a.consignorname ? a.consignorname : "").localeCompare(b.consignorname ? b.consignorname : ""),
    title: "货主名称",
    width: 200,
    ellipsis: true,
  },
  // {
  //   dataIndex: "action",
  //   title: "操作",
  //   scopedSlots: { customRender: "action" },
  //   width: 120,
  //   align: "center",
  //   fixed: "right",
  // },
];

const columnsNew = function (self) {
  return [
    { field: "billno", title: "订单编号", width: 120 },
    {
      field: "billtype",
      title: "单据类型",
      width: 140,
      options: [
        { value: "1", label: "单据1" },
        { value: "2", label: "单据2" },
      ],
    },
    { field: "shippername", ellipsis: true, width: 200, title: "收货单位名称" },
    { field: "remark", ellipsis: true, width: 100, title: "备注" },
    { field: "createby", width: 100, title: "录入人" },
    { field: "createdate", width: 150, title: "录入时间" },
    { field: "billDate", width: 150, title: "制单日期" },
    { field: "salespersonName", title: "业务员", width: 150 },
    { field: "rtReason", title: "退货原因", width: 150 },
    {
      field: "billtype",
      title: "交货类型",
      width: 120,
      remoteUrl: { url: src + "do_bill_type", method: "post" },
      replaceFields: {
        value: "dictCode",
        label: "dictName",
      },
    },
    { field: "lineCode", width: 100, title: "运输路线编码" },
    { field: "lineName", width: 100, title: "运输路线名称" },
    { field: "partlyRed", title: "部分红冲状态", width: 100 },
    { field: "saleBranchname1", title: "要货部门", width: 150 },
    { field: "arrivalMode", title: "提货方式", width: 150 },
    { field: "shipLineId", title: "配送路线", width: 150 },
    { field: "attainDate", title: "预定到货日", width: 150 },
    { field: "custPerson", width: 100, title: "收货联系人" },
    { field: "custPersonTel", width: 150, title: "收货联系人电话" },
    { field: "receiveAddress", ellipsis: true, width: 200, title: "收货地址" },
    { field: "receiveCityName", width: 100, title: "收货市" },
    { field: "receiveCityNo", width: 100, title: "收货市编号" },
    { field: "receiveDistrictNo", width: 120, title: "收货区/县编号" },
    { field: "shippercode", width: 100, title: "收货单位类型" },
    { field: "shipTerm", width: 100, title: "运输条件" },
    { field: "priorityLevel", width: 120, title: "订单紧急等级" },
    { field: "paymentdaytype", ellipsis: true, title: "账期类型", width: 100 },
    { field: "salesContrNumb", title: "购销合同号", width: 150 },
    { field: "carrierName", ellipsis: true, title: "承运商名称", width: 100 },
    { field: "advdeliverydate", title: "预约送货日期", width: 200 },
    { field: "branchAddress", title: "出库仓库详细地址", width: 150 },
    { field: "enquiryDepartment", title: "部门", width: 100 },
    { field: "branchAddress10", title: "客户采购计划单号", width: 200 },
    { field: "branchAddress11", title: "要货业务员", width: 100 },
    { field: "branchAddress12", title: "品规数", width: 100 },
    { field: "branchAddress13", title: "零货品规数", width: 100 },
    { field: "brancharea", title: "出库仓库库区", width: 150 },
    { field: "branchcode", width: 100, title: "出库仓库编号" },
    { field: "branchname", width: 100, title: "出库仓库名称" },
    { field: "closedReason", width: 100, title: "作废原因" },
    { field: "containersNum", width: 100, title: "包装数量" },
    { field: "totBoxNum", width: 100, title: "总拼箱数" },
    { field: "totPcs", width: 100, title: "总件数" },
    { field: "totQty", width: 100, title: "折合件数" },
    { field: "totVolume", width: 100, title: "总体积" },
    { field: "totWeight", width: 100, title: "总重量" },
    { field: "totamt", width: 100, title: "总含税金额" },
    { field: "totnetamt", width: 100, title: "总未税金额" },
    { field: "branchareacode", width: 150, title: "出库仓库库区编码" },
    { field: "carrierCode", width: 100, title: "物流商编码" },
    { field: "salespersonCode", width: 100, title: "业务员编码" },
    { field: "excReason", width: 100, title: "异常原因" },
    { field: "status", width: 100, title: "状态" },
    { field: "consignorcode", width: 100, title: "货主编码" },
    { field: "consignorname", title: "货主名称", width: 200 },
    {
      title: "操作",
      align: "center",
      fixed: "right",
      // filterType: "checkbox",
      cellRender: {
        name: "CustomButtons",
        options: [{ type: "text", title: "红冲", handler: self.HcOrderNew }],
      },
      // width: 200,
    },
  ];
};

const singleColumns = (self) => {
  return [
    { type: "txt", dataIndex: "typeName", width: 100, title: "商品大类" },
    { type: "txt", width: 150, dataIndex: "itemcode", title: "商品编号" },
    { type: "txt", width: 200, dataIndex: "itemname", ellipsis: true, title: "商品名称" },
    // { type: "txt", dataIndex: "itemSpecs", title: "商品规格", width: 100 },
    { type: "txt", dataIndex: "itemHealthListedLicensor", width: 150, title: "上市许可持有人" },
    { type: "txt", dataIndex: "manufacturer", title: "生产厂家", width: 150 },
    { type: "txt", dataIndex: "itemHealthRegisterNbr", width: 150, title: "注册证号" },
    { type: "txt", dataIndex: "packUnits", title: "包装单位", width: 150 },
    { type: "txt", dataIndex: "lotNo", title: "批号", width: 150 },
    { type: "txt", dataIndex: "pdateFrom", title: "生产日期", width: 150 },
    // { type: "txt", dataIndex: "locatorId", title: "货位", width: 150, scopedSlots: { customRender: "locatorslot" } },
    // { type: "txt", dataIndex: "containerCode", title: "托盘", width: 150 },

    // // 货位
    // {
    //   ...getLOTItems(
    //     (rowData) => {
    //       const {modalRowData, index} = rowData
    //       let itemData = self.singleData[index]
    //       itemData.locatorId = modalRowData[0].locatorId
    //       itemData.containerCode = modalRowData[0].containerCode
    //       self.singleData = [...self.singleData]
    //     },
    //   ),
    //   title: '货位',
    //   label: '货位',
    //   dataIndex: 'locatorId',
    //   name: "locatorId",
    //   targetValueKey: 'locatorId',
    // },
    // // 托盘
    // {
    //   ...getLOTItems(
    //     (rowData) => {
    //       const {modalRowData, index} = rowData
    //       let itemData = self.singleData[index]
    //       itemData.locatorId = modalRowData[0].locatorId
    //       itemData.containerCode = modalRowData[0].containerCode
    //       self.singleData = [...self.singleData]
    //     },
    //   ),
    //   title: '托盘',
    //   label: '托盘',
    //   dataIndex: 'containerCode',
    //   name: 'containerCode',
    //   targetValueKey: 'containerCode'
    // },
    {
      type: "txt",
      dataIndex: "itemQty",
      title: "数量",
      width: 80,
    },
    {
      type: "txt",
      dataIndex: "itemPcs",
      title: "件数",
      width: 80,
    },
    {
      type: "txt",
      dataIndex: "itemOdd",
      title: "零数",
      width: 80,
    },
    // {
    //   type: "txt",
    //   dataIndex: "packTypeNum",
    //   title: "包装数量",
    //   width: 80,
    // },
    {
      type: "txt",
      dataIndex: "amt",
      title: "含税金额",
      width: 100,
    },
    {
      type: "txt",
      dataIndex: "batchNo",
      title: "批次号",
      width: 100,
    },
    // {
    //   type: "txt",
    //   dataIndex: "stockStatusName",
    //   title: "库存状态",
    //   width: 100,
    // },
    {
      type: "txt",
      dataIndex: "consignorname",
      width: 200,
      title: "货主名称",
    },
    {
      type: "txt",
      dataIndex: "freeQty",
      title: "赠品数量",
      width: 80,
    },
    {
      type: "txt",
      dataIndex: "itemVolume",
      title: "体积",
      width: 80,
    },
    {
      type: "txt",
      dataIndex: "price",
      title: "含税单价",
      width: 100,
    },
    {
      type: "txt",
      dataIndex: "tniAmt",
      title: "未税金额",
      width: 100,
    },
    {
      type: "txt",
      dataIndex: "tniPrice",
      title: "未税单价",
      width: 100,
    },
    {
      type: "txt",
      width: 150,
      dataIndex: "typeCode",
      title: "商品大类编码",
    },
    {
      type: "txt",
      width: 150,
      dataIndex: "validUntil",
      title: "有效期至",
    },
    // {
    //   type: "txt",
    //   width: 150,
    //   dataIndex: "vendorItemcode",
    //   title: "供应商商品编号",
    // },
    {
      type: "txt",
      dataIndex: "itemHealthIsDouble",
      width: 150,
      title: "是否双人复核",
      customRender: (text, record) => {
        if (text == "0") return "单人";
        if (text == "1") return "双人";
        return text;
      },
    },
    // { type: "txt", dataIndex: "itemHealthApprovalNbr", width: 100, title: "批准文号" },
    {
      type: "txt",
      dataIndex: "isCaseOrPiece",
      width: 100,
      title: "整散标志",
      customRender: (text, record) => {
        if (text == "0") return "整散合一";
        if (text == "1") return "整散分离";
        return text;
      },
    },
    {
      type: "txt",
      dataIndex: "itemHealthSuperviseflag",
      width: 100,
      title: "是否监管",
      customRender: (text, record) => {
        if (text == "0") return "否";
        if (text == "1") return "是";
        return text;
      },
    },
    {
      type: "txt",
      dataIndex: "itemIsValuable",
      width: 100,
      title: "是否贵重商品",
      customRender: (text, record) => {
        if (text == "0") return "否";
        if (text == "1") return "是";
        return text;
      },
    },
    {
      type: "txt",
      dataIndex: "itemIsFragile",
      width: 100,
      title: "是否易碎",
      customRender: (text, record) => {
        if (text == "0") return "否";
        if (text == "1") return "是";
        return text;
      },
    },
    {
      type: "txt",
      dataIndex: "isBacteria",
      width: 100,
      title: "是否无菌",
      customRender: (text, record) => {
        if (text == "0") return "否";
        if (text == "1") return "是";
        return text;
      },
    },
    {
      type: "txt",
      dataIndex: "isDelegate",
      width: 100,
      title: "是否委托生产",
      customRender: (text, record) => {
        // text = String(text);
        if (text == "0") return "否";
        if (text == "1") return "是";
        return text;
      },
    },
    {
      type: "txt",
      dataIndex: "isHosted",
      width: 100,
      title: "商品是否代管",
      customRender: (text, record) => {
        // text = String(text);
        if (text == "0") return "否";
        if (text == "1") return "是";
        return text;
      },
    },
    { type: "txt", dataIndex: "itemAssistantCode", width: 100, title: "助记码" },
    { type: "txt", dataIndex: "cargoOwnerCode", width: 100, title: "货主编码" },
    // { type: "txt", dataIndex: "countryOriginId", width: 150, title: "产地" },
    // { type: "txt", dataIndex: "itemHealthProduceLicense", width: 150, title: "生产企业许可证号" },
    // { type: "txt", dataIndex: "itemHealthRecordNbr", width: 100, title: "备案号" },
    { type: "txt", dataIndex: "itemVolume", width: 100, title: "箱体积" },
    { type: "txt", dataIndex: "itemWeight", width: 100, title: "箱重量" },
    {
      dataIndex: "action",
      title: "操作",
      scopedSlots: { customRender: "action" },
      width: 140,
      align: "center",
      fixed: "right",
    },
  ];
};
const singleColumnsEdit = [
  { type: "txt", ellipsis: true, dataIndex: "itemcode", title: "商品编号" },
  { type: "txt", ellipsis: true, dataIndex: "itemname", title: "商品名称" },
  { type: "txt", ellipsis: true, dataIndex: "itemOdd", title: "零数" },
  { type: "txt", ellipsis: true, dataIndex: "itemPcs", title: "件数" },
  { type: "txt", ellipsis: true, dataIndex: "itemQty", title: "数量" },
  { type: "number", ellipsis: true, dataIndex: "reditemQty", title: "红冲数量" },
  { type: "edit", ellipsis: true, dataIndex: "reditemrelut", title: "红冲原因" },
  { type: "txt", ellipsis: true, dataIndex: "lotNo", title: "批号" },
  { type: "txt", ellipsis: true, dataIndex: "batchNo", title: "批次号" },
  { type: "txt", ellipsis: true, dataIndex: "consignorname", title: "货主名称" },
  {
    dataIndex: "action",
    title: "操作",
    scopedSlots: { customRender: "action" },
    width: 140,
    align: "center",
    fixed: "right",
  },
];

const redColumns = [
  { dataIndex: "id", hidden: true, title: "波次订单明细id" },
  { type: "txt", dataIndex: "qty", title: "冲红数量" },
  { type: "txt", dataIndex: "reason", title: "冲红原因" },
  { type: "txt", dataIndex: "modifierName", title: "冲红人员" },
  { type: "txt", dataIndex: "gmtModified", title: "冲红时间" },
  {
    type: "txt",
    dataIndex: "type",
    title: "冲红类型",
    customRender: (text, record) => {
      text = String(text);
      if (text === "0") return "拣货";
      if (text === "1") return "波次";
      if (text === "2") return "外复核";
      if (text === "3") return "原单整单红";
      if (text === "4") return "内复核红冲";
      if (text === "5") return "原单明细红冲";
      return text;
    },
  },
];

export { columns, singleColumns, singleColumnsEdit, redColumns, itemfun, columnsNew };
