import API from '../api/api'
import { genWarehouseAuthSearchModal, genCargoownerAuthSearchModal } from '../../../SearchModal'
import { changecargoOwnerfun } from '@/views/kzyWMS/utils/setCargoOwner'
const span8 = { span: 6, labelCol: { span: 5 } }
const searchItems = function(that) {
  return [
    {
      type: 'input',
      name: 'condition',
      label: '查询条件',
      span: 6,

      labelCol: {
        span: 5
      },
      wrapperCol: {
        span: 19
      },
      placeholder: '请输入单位编号/单位名称/助记码',
      value: ''
    },
    ...genWarehouseAuthSearchModal(1, false, false, null, changecargoOwnerfun, span8),
    ...genCargoownerAuthSearchModal(1, false, false, null, null, span8),

    {
      type: 'buttonGroup',
      style: { textAlign: 'left' },
      options: [
        {
          value: that.$lang('查询'),
          icon: 'search',
          btnType: 'primary',
          style: 'margin-left:30px;margin-right:10px;',
          on: {
            click: (event, form) => {
              let p = form.getForm().getFieldsValue()
              Object.keys(p).forEach(k => {
                if (typeof p[k] === 'string' && !p[k]) p[k] = null
              })
              that.remoteParams = {
                ...p,
                warehouseId: that.warehouse.warehouseId,
                cargoOwnerId: that.cargoOwner.cargoOwnerId
              }
            }
          }
        },
        {
          value: that.$lang('重置'),
          name: 'ccz',
          icon: 'redo',
          on: {
            click: (event, form) => {
              form.resetFields()
              let p = form.getForm().getFieldsValue()
              Object.keys(p).forEach(k => {
                if (typeof p[k] === 'string' && !p[k]) p[k] = null
              })
              that.remoteParams = {
                ...p
              }
            }
          }
        }
      ]
    }
    // {
    //   type: 'buttonGroup',
    //   style: { textAlign: 'center' },
    //   options: [
    //     {
    //       value: '查询',
    //       icon: 'search',
    //       btnType: 'primary',
    //       style: 'margin-right:10px',
    //       // htmlType: '',
    //       on: {
    //         click(event, form) {
    //           // console.log(that)
    //           console.log(form.getForm().getFieldsValue())
    //           that.remoteParams = form.getForm().getFieldsValue()
    //         }
    //       }
    //     },
    //     {
    //       value: '重置',
    //       name: 'ccz',
    //       icon: 'redo',
    //       on: {
    //         click(event, form) {
    //           // form.hiddenItem('field-number')
    //           console.log(form)
    //           // console.log(form.getForm().resetFields())
    //           form.getForm().resetFields()
    //         }
    //       }
    //     }
    //   ]
    // }
  ]
}
export default searchItems
