import {genBldgSearchModal, genWarehouseAuthSearchModal} from '@/views/kzyWMS/SearchModal'
import {remote2} from './remote'

let grid = {span: 8, labelCol: {span: 8}}

export const formItems = function (self) {
  return [
    {type: 'input', name: 'dcCode', label: '所属仓配中心编码', value: '', hidden: true},
    {type: 'input', name: 'dcName', label: '所属仓配中心', value: '', disabled: true},
    // 仓库
    ...genWarehouseAuthSearchModal(
      1,
      true,
      false,
      null,
      function (rowData, form) {
        if (!rowData) {
          form.setFieldsValue({
            dcId: '', dcCode: '', dcName: '',
            warehouseId: '', warehouseCode: '', warehouseName: '',
            bldgName: '', bldgCode: '', bldgId: ''
          })
          self.formData = {...this.formData, dcId: ''}
          return
        }
        form.setFieldsValue({
          dcId: rowData ? rowData[0].dcId : '',
          dcCode: rowData ? rowData[0].dcCode : '',
          dcName: rowData ? rowData[0].dcName : '',
          warehouseId: rowData ? rowData[0].warehouseId : '',
          warehouseCode: rowData ? rowData[0].warehouseCode : '',
          warehouseName: rowData ? rowData[0].warehouseName : '',
          bldgName: '',
          bldgCode: '',
          bldgId: '',
        })
        self.formData = {...this.formData, dcId: rowData[0].dcId}
      },
      grid,
      null),
    // 建筑物
    ...genBldgSearchModal(
      1,
      true,
      false,
      null,
      function (rowData, form) {
        if (!rowData) {
          form.setFieldsValue({
            bldgName: '', bldgCode: '', bldgId: ''
          })
          return
        }
        form.setFieldsValue({
          dcId: rowData ? rowData[0].dcId : '',
          dcCode: rowData ? rowData[0].dcCode : '',
          dcName: rowData ? rowData[0].dcName : '',
          warehouseId: rowData ? rowData[0].warehouseId : '',
          warehouseCode: rowData ? rowData[0].warehouseCode : '',
          warehouseName: rowData ? rowData[0].warehouseName : '',
          bldgName: rowData ? rowData[0].bldgName : '',
          bldgCode: rowData ? rowData[0].bldgCode : '',
          bldgId: rowData ? rowData[0].bldgId : '',
        })
      },
      grid,
      null
    ),
    {type: 'input', name: 'warehouseLogicCode', label: '逻辑区编码', required: true, value: ''},
    {type: 'input', name: 'warehouseLogicName', label: '逻辑区名称', required: true, value: ''},
    {
      type: 'select', name: 'warehouseLogicType', label: '逻辑区类型', value: '', required: true, options: [
        {title: '固定', value: '固定'},
        {title: '灵活', value: '灵活'}
      ]
    },
    {type: 'input', name: 'floorNum', label: '所在楼层', value: ''},
    {type: 'switch', name: 'isEnable', label: '是否启用', value: ''},
    {type: 'input', name: 'attribute1', label: '预留字段1', value: ''},
    {type: 'input', name: 'attribute2', label: '预留字段2', value: ''},
    {type: 'input', name: 'attribute3', label: '预留字段3', value: ''},
    {type: 'input', name: 'attribute4', label: '预留字段4', value: ''},
    {type: 'input', name: 'attribute5', label: '预留字段5', value: ''},
    {type: 'input', name: 'attribute6', label: '预留字段6', value: ''},
    {type: 'input', name: 'attribute7', label: '预留字段7', value: ''},
    {type: 'input', name: 'attribute8', label: '预留字段8', value: ''},
    {type: 'input', name: 'attribute9', label: '预留字段9', value: ''},
    {type: 'input', name: 'attribute10', label: '预留字段10', value: ''},
  ]
}

export const addItems1 = [
  {
    type: 'select',
    name: 'warehouseLayoutType',
    label: '仓库布局类型',
    options: [
      {title: '平面', value: '平面'},
      {title: '立体', value: '立体'},
      {title: '自动', value: '自动'}
    ]
  },
  {
    type: 'select',
    name: 'warehouseWorkingMethod',
    label: '拣货方式',
    ...remote2('wms_pickmode')
  },
  {
    type: 'input',
    name: 'attribute1',
    label: '预留字段1'
  },
  {
    type: 'input',
    name: 'attribute2',
    label: '预留字段2'
  },
  {
    type: 'input',
    name: 'attribute3',
    label: '预留字段3'
  },
  {
    type: 'input',
    name: 'attribute4',
    label: '预留字段4'
  }
]
