// import { remote } from './remote';
import store from '@/store';
import {genWarehouseAuthSearchModal, genBldgSearchModal} from '@/views/kzyWMS/SearchModal';
// 待索取tab
export const items0 = function (_this) {
  let warehouseId = store.state.user.warehouse.warehouseId;
  return (
    [
      // 仓库
      ...genWarehouseAuthSearchModal(1, true, false, null,
        function (rowData, form) {
          if (!rowData) {
            warehouseId = null;
            form.setFieldsValue({
              companyId: '',
              companyCode: '',
              companyName: ''
            })
          } else {
            // [integer] 扫描监管码节点：0=拣货 1=外复核
            _this.$emit('update:warehouseId', rowData[0].companyId);
            warehouseId = rowData[0].companyId;
            form.setFieldsValue({
              warehouseId: rowData[0].companyId,
              warehouseCode: rowData[0].companyCode,
              warehouseName: rowData[0].companyName,
            })
          }
        },
        {span: 8, labelCol: {span: 5}}
      ),
      // 建筑物
      ...genBldgSearchModal(1, true, false,
        function (vn, p) {
          p.params.warehouseId = warehouseId;
          return p;
        },
        function (rowData, form) {
          if (rowData) {
            _this.$emit('update:bldgInfo', rowData[0]);
          }
        }, {span: 8, labelCol: {span: 5}},
      ),
      {name: 'pickTaskType', label: '任务类型（0-整件/2-整散合一）', value: '0', hidden: true},
      {type: 'input', name: 'warehouseAreaCode', label: '库区编码', value: '', span: 8, labelCol: {span: 5}},
      {type: 'input', name: 'itemCode', label: '商品编号', value: '', span: 8, labelCol: {span: 5}},
      {type: 'input', name: 'srcCode', label: '订单编号', value: '', span: 8, labelCol: {span: 5}},
      {
        type: 'buttonGroup',
        style: {textAlign: 'center'},
        span: 8,
        labelCol: {span: 5},
        options: [
          {value: '查询', icon: 'search', btnType: 'primary', style: 'margin-right:16px', htmlType: 'submit'},
          {
            value: "重置", name: "ccz", icon: "redo", style: 'margin-right:16px',
            on: {
              click(event, form) {
                form.resetFields();
              },
            },
          },
        ]
      }
    ]
  )
}
// 索取任务tab
export const items = function (_this) {
  let warehouseId = store.state.user.warehouse.warehouseId;
  return (
    [
      // 仓库
      ...genWarehouseAuthSearchModal(1, true, false, null,
        function (rowData, form) {
          if (!rowData) {
            warehouseId = null;
            form.setFieldsValue({
              companyId: '',
              companyCode: '',
              companyName: ''
            })
          } else {
            // [integer] 扫描监管码节点：0=拣货 1=外复核
            _this.$emit('update:warehouseId', rowData[0].companyId);
            warehouseId = rowData[0].companyId;
            form.setFieldsValue({
              warehouseId: rowData[0].companyId,
              warehouseCode: rowData[0].companyCode,
              warehouseName: rowData[0].companyName,
            })
          }
        },
        {span: 8, labelCol: {span: 5}}
      ),
      ...genBldgSearchModal(1, true, false,
        function (vn, p) {
          p.params.warehouseId = warehouseId;
          return p;
        }, function (rowData, form) {
          if (rowData) {
            _this.$emit('update:bldgInfo', rowData[0]);
          }
        }, {span: 8, labelCol: {span: 5}}
      ),
      {name: 'type', label: '0：任务索取 1：任务确认', value: '0', hidden: true},
      {type: 'input', name: 'operatorCode', label: '索取人工号', required: true, value: '', span: 8, labelCol: {span: 5}},
      {type: 'input', name: 'pickOrderId', label: '拣选单', value: '', span: 8, labelCol: {span: 5}},
      {type: 'input', name: 'itemCode', label: '商品编号', value: '', span: 8, labelCol: {span: 5}},
      {type: 'input', name: 'barcode', label: '条码', value: '', span: 8, labelCol: {span: 5}},
      {type: 'input', name: 'srcCode', label: '订单编号', value: '', span: 8, labelCol: {span: 5}},
      {
        name: 'operate',
        span: 8, wrapperCol: {span: 19, offset: 5},
        scopedSlots: {customRender: 'operate'},
      }
    ]
  )
}
export const items21 = function (_this) {
  let warehouseId = store.state.user.warehouse.warehouseId;
  return (
    [
      // 仓库
      ...genWarehouseAuthSearchModal(1, true, false, null,
        function (rowData, form) {
          if (!rowData) {
            warehouseId = null;
            form.setFieldsValue({
              companyId: '',
              companyCode: '',
              companyName: ''
            })
          } else {
            // [integer] 扫描监管码节点：0=拣货 1=外复核
            _this.$emit('update:warehouseId', rowData[0].companyId);
            warehouseId = rowData[0].companyId;
            form.setFieldsValue({
              warehouseId: rowData[0].companyId,
              warehouseCode: rowData[0].companyCode,
              warehouseName: rowData[0].companyName,
            })
          }
        },
        {span: 8, labelCol: {span: 5}}
      ),
      ...genBldgSearchModal(1, true, false,
        function (vn, p) {
          p.params.warehouseId = warehouseId;
          return p;
        }, function (rowData, form) {
          if (rowData) {
            _this.$emit('update:bldgInfo', rowData[0]);
          }
        }, {span: 8, labelCol: {span: 5}}
      ),
      {name: 'type', label: '0：任务索取 1：任务确认', value: '1', hidden: true},
      {type: 'input', name: 'operatorCode', label: '工号', required: true, value: '', span: 8, labelCol: {span: 5}},
      {type: 'input', name: 'pickOrderId', label: '拣选单', value: '', span: 8, labelCol: {span: 5}},
      {type: 'input', name: 'itemCode', label: '商品编号', value: '', span: 8, labelCol: {span: 5}},
      {type: 'input', name: 'barcode', label: '条码', value: '', span: 8, labelCol: {span: 5}},
      {type: 'input', name: 'srcCode', label: '订单编号', required: true, value: '', span: 8, labelCol: {span: 5}},
      {
        type: 'buttonGroup',
        style: {textAlign: 'right'},
        span: 16,
        labelCol: {span: 5},
        options: [
          {value: '查询', icon: 'search', btnType: 'primary', style: 'margin-right:16px', htmlType: 'submit'},
          {
            value: "重置", name: "ccz", icon: "redo", style: 'margin-right:16px',
            on: {
              click(event, form) {
                form.resetFields();
              },
            },
          },
          {
            value: '确认', btnType: 'primary', icon: 'check', style: 'margin-right:16px',
            on: {
              click: _this.confirmSave
            }
          },
          {
            value: '数量解锁', btnType: 'primary', icon: 'unlock', style: 'margin-right:16px',
            on: {
              click: _this.unlock
            }
          },
          {
            value: '打印', btnType: 'primary', icon: 'printer',
            on: {
              click: _this.println
            }
          },
        ]
      }

    ]
  )

}
export const items31 = function (_this) {
  let warehouseId = store.state.user.warehouse.warehouseId;
  return (
    [
      // 仓库
      ...genWarehouseAuthSearchModal(1, true, false, null,
        function (rowData, form) {
          if (!rowData) {
            warehouseId = null;
            form.setFieldsValue({
              companyId: '',
              companyCode: '',
              companyName: ''
            })
          } else {
            // [integer] 扫描监管码节点：0=拣货 1=外复核
            _this.$emit('update:warehouseId', rowData[0].companyId);
            warehouseId = rowData[0].companyId;
            form.setFieldsValue({
              warehouseId: rowData[0].companyId,
              warehouseCode: rowData[0].companyCode,
              warehouseName: rowData[0].companyName,
            })
          }
        },
        {span: 8, labelCol: {span: 5}}
      ),
      ...genBldgSearchModal(1, true, false,
        function (vn, p) {
          p.params.warehouseId = warehouseId;
          return p;
        }, function (rowData, form) {
          if (rowData) {
            _this.$emit('update:bldgInfo', rowData[0]);
          }
        }, {span: 8, labelCol: {span: 5}}
      ),
      {name: 'type', label: '0：任务索取 1：任务确认 2：补打标签', value: '2', hidden: true},
      {type: 'input', name: 'operatorCode', label: '工号', require: true, value: '', span: 8, labelCol: {span: 5}},
      {type: 'input', required: true, name: 'srcCode', label: '订单编号', value: '', span: 8, labelCol: {span: 5}},
      {
        name: 'operate',
        span: 8, wrapperCol: {span: 19, offset: 5},
        scopedSlots: {customRender: 'operate'},
      }
    ]
  )

}
// 整件拣货（ 待索取 ）
export const columns = [
  /* { dataIndex: 'pickOrderId', title: '拣选单id' }, */
  {dataIndex: 'srcCode', title: '订单编号', width: 100},
  {dataIndex: 'char3', title: '容器编号', width: 100},
  {dataIndex: 'manufacturerLotNum', title: '批号', width: 100},
  {dataIndex: 'consignorName', title: '货主', width: 100},
  {dataIndex: 'itemId', title: '商品ID', hidden: true, width: 100},
  {dataIndex: 'itemCode', title: '商品编号', width: 100},
  {dataIndex: 'itemName', title: '商品名称', width: 120},
  {dataIndex: 'uomQty', title: '件数', width: 80, customRender: (text, rows, index) => (text || parseInt(rows.qty / rows.conversionRate, 10))},
  {dataIndex: 'qty', title: '数量', width: 80},
  {dataIndex: 'uom', title: '单位', width: 80},
  {dataIndex: 'conversionRate', title: '包装数量', width: 80},
  {dataIndex: 'shipperName', title: '客户名称', width: 120},
  {dataIndex: 'containerCode', title: '容器编号', width: 120},
  {dataIndex: 'billType', title: '出库单类型', width: 120},
  {dataIndex: 'manufacturer', title: '生产厂家', width: 120},
  // { dataIndex: 'barcode', title: '标签条码',width:140 },
  {dataIndex: 'type', title: '任务类型', customRender: text => (text ? '补货任务' : '拣货任务'), width: 100},  //ype：0，拣货任务,1 补货任务"
  {dataIndex: 'printStatus', title: '打印状态', scopedSlots: {customRender: 'printStatus'}, width: 100},
  {dataIndex: 'status', title: '任务状态', scopedSlots: {customRender: 'status'}, width: 100},
  {dataIndex: 'warehouseAreaCode', title: '库区', width: 100},
  {dataIndex: 'locatorCode', title: '库位', width: 100},
  {dataIndex: 'batchNum', title: '批次', width: 100},
  {dataIndex: 'operatorCode', title: '拣选人工号', width: 100},
  {dataIndex: 'operatorName', title: '拣选人', width: 100},
//   {title: '生产日期',dataIndex: 'productionDate',width:120},
//   {title: '有效期至',dataIndex: 'expiredDate',width:120},
  {title: '生产日期', dataIndex: 'productionDateShow', width: 120},
  {title: '有效期至', dataIndex: 'expiredDateShow', width: 120},
  {title: '操作', dataIndex: 'operation', fixed: 'right', scopedSlots: {customRender: 'operation'}},
]
//  整件拣货（tab1自动确认+tab2任务确认）
export const columns2 = [
  /* { dataIndex: 'pickTaskDId', title: '拣选任务明细id' }, */
  {dataIndex: 'srcCode', title: '订单编号'},
  {dataIndex: 'itemCode', title: '商品编号'},
  {dataIndex: 'itemName', title: '商品名称'},
  // { dataIndex: 'barcode', title: '条码' },
  {dataIndex: 'qty', title: '数量'},
  {dataIndex: 'saleRedQty', title: '红冲数量'},
  {dataIndex: 'pickQty', slots: {title: 'customTitle'}, customRender: (text, rows, index) => (rows.qty - (+rows.saleRedQty))},
]
// 整件拣货（ 任务确认 ）
export const columns3 = [
  {dataIndex: 'srcCode', title: '订单编号', width: 120},
  {title: '是否监管', dataIndex: 'isSupervise', width: 80, customRender: text => text ? '是' : '否'},
  {dataIndex: 'manufacturerLotNum', title: '批号', width: 80},
  {dataIndex: 'pickOrderId', title: '拣选单', width: 140},
  {dataIndex: 'barcode', title: '标签条码', width: 140},
  {dataIndex: 'locatorId', title: '货位', width: 140},
  {dataIndex: 'itemId', title: '商品ID', hidden: true},
  {dataIndex: 'itemCode', title: '商品编号', width: 120},
  {dataIndex: 'itemName', title: '商品名称', width: 120},
  {dataIndex: 'qty', title: '数量', className: 'qtyColor', width: 80},
  {dataIndex: 'uomQty', title: '件数', width: 140,customRender: (text, rows, index) => (text || parseInt(rows.qty / rows.conversionRate, 10))},
  {dataIndex: 'saleRedQty', title: '红冲数量', width: 80},
  {dataIndex: 'pickQty', title: '已拣数量', width: 80},
  {dataIndex: 'uom', title: '单位', width: 80},
  {dataIndex: 'conversionRate', title: '包装数量', width: 80},
  {dataIndex: 'shipperName', title: '客户名称', width: 140},
  {dataIndex: 'containerCode', title: '容器编号', width: 140},
  {dataIndex: 'billType', title: '出库单类型', width: 140},
  {dataIndex: 'manufacturer', title: '生产厂家', width: 120},
  {dataIndex: 'type', title: '任务类型', customRender: text => (text ? '补货任务' : '拣货任务'), width: 100},  //ype：0，拣货任务,1 补货任务"
  {dataIndex: 'printStatus', title: '打印状态', scopedSlots: {customRender: 'printStatus'}, width: 80},
  {dataIndex: 'status', title: '任务状态', scopedSlots: {customRender: 'status'}, width: 80},
  {dataIndex: 'warehouseAreaCode', title: '库区', width: 120},
  {dataIndex: 'locatorCode', title: '库位', width: 120},
  {dataIndex: 'batchNum', title: '批次', width: 120},
  {dataIndex: 'operatorCode', title: '拣选人工号', width: 120},
  {dataIndex: 'operatorName', title: '拣选人', width: 120},
  {title: '生产日期', dataIndex: 'productionDateShow', width: 120},
  {title: '有效期至', dataIndex: 'expiredDateShow', width: 120},
  {title: '操作', dataIndex: 'operation', fixed: 'right', scopedSlots: {customRender: 'operation'}},
]
