// import { genWarehouseAuthSearchModal, genCargoownerAuthSearchModal } from '../../../SearchModal'
import { genWarehouseAuthSearchModal, genCargoownerAuthSearchModal } from '@/views/kzyWMS/SearchModal/index'
import { warehouseCategoryCode } from './modal-form'
import { api } from '@/views/kzyWMS/api/common/dictionaries-type'
import { changecargoOwnerfun } from '@/views/kzyWMS/utils/setCargoOwner'
const span8 = { span: 8, labelCol: { span: 6 } }
// let changecargoOwnerfun= function(e, form){
//     form.setFieldsValue({
//         cargoOwnerCode:null ,
//         cargoOwnerId: null,
//         cargoOwnerName: null
//          })
//         }
export let itemHealthCategory = {
  type: 'select',
  name: 'itemHealthCategory',
  label: '商品大类',
  value: '',
  autoLoad: true,
  remoteUrl: { url: api.queryDictList + '?dicttypeCodes=item_health_category', method: 'post' },
  replaceFields: {
    value: 'dictCode',
    label: 'dictName'
  }
}

export const searchItems = function(self) {
  return [
    ...genWarehouseAuthSearchModal(1, true, false, null, changecargoOwnerfun, span8),
    ...genCargoownerAuthSearchModal(1, true, false, null, null, span8),
    warehouseCategoryCode(),
    //商品大类
    { ...itemHealthCategory, ...span8 },
    {
      type: 'input',
      name: 'itemCondition',
      label: '商品编码助记码',
      value: '',
      ...span8
    },
    {
      type: 'buttonGroup',
      ...span8,
      style: { textAlign: 'center' },
      options: [
        {
          value: '查询',
          icon: 'search',
          btnType: 'primary',
          style: 'margin-right:10px;margin-left:20px',
          on: {
            click: (event, form) => {
              form.getForm().validateFields(function(err, vals) {
                if (err) return
                self.remoteParams = vals
              })
              // let p = form.getForm().getFieldsValue();
              // self.remoteParams = p;
            }
          }
        },
        {
          value: '重置',
          name: 'ccz',
          icon: 'redo',
          on: {
            click: (event, form) => {
              form.resetFields()
              self.remoteParams = {}
            }
          }
        }
      ]
    }
  ]
}
