import API from '../../api/default'
import { genCargoownerAuthSearchModal } from "../../../SearchModal";

const items = [
  ...genCargoownerAuthSearchModal(1, true,false, null, null, {span: 6}),
  {
    type: 'search',
    name: 'dcName',
    label: '商品',
    title: '商品',
    destroyOnClose: true,
    targetClick: true,
    span: 6,
    toolBar: {
      items: [
        {
          type: 'input',
          name: 'dcName',
          label: '商品名称',
          span: 8,
          value: ''
        }
      ]
    },
    tableConfig: {
      rowKey: 'dcName',
      rowSelectType: 1,
      hasRowSelectCheck: true,
      columns: [{ dataIndex: 'dcName', title: '商品名称', key: 'dcName' }]
    },
    value: '',
    remoteUrl: API.wmsdcPage,
    on: {
      ok(event, value, rowData, form) {
        console.log(rowData, 'rowDatarowData')
      }
    }
  },
  {
    type: 'search',
    name: 'code1',
    label: '批号',
    title: '批号',
    destroyOnClose: true,
    targetClick: true,
    span: 6,
    toolBar: {
      items: [
        {
          type: 'input',
          name: 'code1',
          label: '批号',
          span: 8,
          value: ''
        }
      ]
    },
    tableConfig: {
      rowKey: 'dcName',
      rowSelectType: 1,
      hasRowSelectCheck: true,
      columns: [{ dataIndex: 'code1', title: '批号', key: 'code1' }]
    },
    value: '',
    remoteUrl: API.wmsdcPage,
    on: {
      ok(event, value, rowData, form) {
        console.log(rowData, 'rowDatarowData')
      }
    }
  },
  {
    type: 'search',
    name: 'code2',
    label: '货位',
    title: '货位',
    destroyOnClose: true,
    targetClick: true,
    span: 6,
    toolBar: {
      items: [
        {
          type: 'input',
          name: 'code2',
          label: '货位',
          span: 8,
          value: ''
        }
      ]
    },
    tableConfig: {
      rowKey: 'dcName',
      rowSelectType: 1,
      hasRowSelectCheck: true,
      columns: [{ dataIndex: 'code2', title: '货位', key: 'code2' }]
    },
    value: '',
    remoteUrl: API.wmsdcPage,
    on: {
      ok(event, value, rowData, form) {
        console.log(rowData, 'rowDatarowData')
      }
    }
  }
]
const columns = function(self) {
  return [
    { dataIndex: 'code1', title: '货主名称', key: 'code1' },
    { dataIndex: 'code2', title: '商品编号', key: 'code2' },
    { dataIndex: 'code3', title: '商品名称', key: 'code3' },
    { dataIndex: 'code4', title: '批号', key: 'code4' },
    { dataIndex: 'code5', title: '货位', key: 'code5' },
    { dataIndex: 'code6', title: '可用库存数量', key: 'code6' },
    { dataIndex: 'code7', title: '可锁定件数', key: 'code7' },
    { dataIndex: 'code8', title: '可锁零散数', key: 'code8' },
    { dataIndex: 'code9', title: '生产日期', key: 'code9' },
    { dataIndex: 'code10', title: '有效期至', key: 'code10' }
  ]
}

const operateColums = [
  { dataIndex: 'code10', title: '货主名称', key: 'code10' },
  { dataIndex: 'code11', title: '商品编号', key: 'code11' },
  { dataIndex: 'code12', title: '商品名称', key: 'code12' },
  { dataIndex: 'code13', title: '批号', key: 'code13' },
  { dataIndex: 'code14', title: '货位', key: 'code14' },
  { dataIndex: 'code15', title: '可用库存数量', key: 'code15' },
  { dataIndex: 'code16', title: '可锁定件数', key: 'code16' },
  { dataIndex: 'code17', title: '可锁零散数', key: 'code17' },
  { dataIndex: 'code18', title: '锁定数量', key: 'code18' },
  { dataIndex: 'code19', title: '锁定件数', key: 'code19' },
  { dataIndex: 'code20', title: '锁定零散数', key: 'code20' },
  { dataIndex: 'code21', title: '锁定原因', key: 'code21' },
  { dataIndex: 'code22', title: '生产日期', key: 'code22' },
  { dataIndex: 'code23', title: '有效期至', key: 'code23' }
]

export function detailConfig(self) {
  return [
    {
      key: 'one',
      checkedKey: 'main',
      btns: [
        { label: '查询', click() {} },
        {
          label: '重置',
          click() {
            let refMain = self.queryRefFromName('main')
            let ref = self.queryRefFromName('baseMtlItemUomConversionsList')
            refMain.form.enableItem(['warehouseName', 'cargoOwnerName'])
            ref.delItems() // 删除附表信息
          }
        },
        {
          label: '保存',
          click() {}
        }
      ],
      list: [
        {
          key: 'main',
          tab: '主要信息',
          btns: [
            // { label: '辅助功能1', click() { } },
          ],
          item: { type: 'p-grid-form', config: items }
        }
      ]
    },
    {
      key: 'two',
      checkedKey: 'baseMtlItemUomConversionsList', //
      list: [
        {
          key: 'baseMtlItem2',
          tab: '已锁定商品',
          btns: [],
          item: {
            type: 'p-table-edit',
            config: operateColums,
            rowKey: '_row_count',
            rowSelectType: 2,
            colChange({ record, name, value }) {}
          }
        },
        {
          key: 'baseMtlItemUomConversionsList',
          tab: '未锁定商品',
          btns: [],
          item: {
            type: 'p-table-edit',
            config: columns(self),
            rowKey: '_row_count',
            rowSelectType: 2,
            colChange({ record, name, value }) {}
          }
        }
      ]
    }
  ]
}
