import { genWarehouseAuthSearchModal, genCargoownerAuthSearchModal } from '@/views/kzyWMS/SearchModal'
import { handleShowProductionDate } from '../script/lineHandleLogic'

let grid = {
  labelCol: { span: 8 },
  span: 8
}
export function setFormItems(self) {
  let _this = self
  return [
    {
      type: 'input',
      hidden: true,
      name: 'spanId',
      label: 'spanId',
      value: ''
    },
    ...genWarehouseAuthSearchModal(1, true, false, null, null, grid),
    ...genCargoownerAuthSearchModal(1, true, false, null, null, grid),
    {
      type: 'input',
      name: 'warehouseId',
      label: '仓库ID',
      hidden: true,
      value: ''
    },
    {
      type: 'input',
      name: 'manufacturerLotNum',
      label: '商品批号',
      value: ''
    },
    {
      type: 'input',
      name: 'itemCode',
      label: '商品编码',
      value: ''
    },

    {
      type: 'input',
      name: 'itemZjm',
      label: '商品助记码',
      value: ''
    },
    {
      // span: 24,
	  grid,
      type: 'buttonGroup',
      style: { textAlign: 'center' },
      options: [
        {
          value: '查询',
          icon: 'search',
          btnType: 'primary',
          style: 'margin-right:10px',
          htmlType: 'submit'
        },
        {
          value: '重置',
          icon: 'redo',
          on: {
            click: () => {
              self.$refs.formTarget.form.resetFields()
            }
          }
        }
      ]
    }
  ]
}
const columns = [
  // {
  //   title: '序号',
  //   ellipsis: true,
  //   dataIndex: 'index',
  //   key: 'index',
  //   scopedSlots: { customRender: 'index' }
  // },
  {
    title: '仓库名称',
    ellipsis: true,
    dataIndex: 'warehouseId'
  },
  {
    title: '货主编号',
    ellipsis: true,
    dataIndex: 'cargoOwnerCode'
  },
  {
    title: '货主名称',
    ellipsis: true,
    dataIndex: 'cargoOwnerName'
  },
  {
    title: '商品名称',
    ellipsis: true,
    dataIndex: 'itemName'
  },
  {
    title: '商品编号',
    ellipsis: true,
    dataIndex: 'itemCode'
  },
  {
    title: '商品规格',
    ellipsis: true,
    dataIndex: 'specification'
  },
  {
    title: '商品助记码',
    ellipsis: true,
    dataIndex: 'itemZjm'
  },
  {
    title: '生产日期',
    ellipsis: true,
    dataIndex: 'batchProductionShowNew'
  },
//   {
//     title: '老生产日期',
//     ellipsis: true,
//     dataIndex: 'batchProductionShow'
//   },
  {
    title: '有效期至',
    ellipsis: true,
    dataIndex: 'batchExpiredShowNew'
  },
//   {
//     title: '老有效期至',
//     ellipsis: true,
//     dataIndex: 'batchExpiredShow'
//   },
  
  {
    title: '包装单位',
    ellipsis: true,
    dataIndex: 'uom'
  },
  {
    title: '生产厂家',
    ellipsis: true,
    dataIndex: 'manufacturerName'
  },
  {
    title: ' 包装含量',
    ellipsis: true,
    dataIndex: 'conversionRate'
  },
  {
    title: '批号',
    ellipsis: true,
    dataIndex: 'manufacturerLotNum'
  },
//   {
//     title: '商品批号(新)',
//     ellipsis: true,
//     dataIndex: 'manufacturerLotNumNew'
//   },
  {
    title: '批准文号',
    ellipsis: true,
    dataIndex: 'approvalNo'
  },
  // {
  //   title: '生产日期',
  //   ellipsis: true,
  //   dataIndex: 'batchProductionShowNew'
  // },
  // {
  //   title: '有效期至',
  //   ellipsis: true,
  //   dataIndex: 'batchExpiredShowNew'
  // },
  {
    title: '外箱码(最大包装)',
    ellipsis: true,
    dataIndex: 'caseBarcode'
  },
  {
    title: '条码(最小包装)',
    ellipsis: true,
    dataIndex: 'registerNo'
  },
  {
    title: '产地',
    ellipsis: true,
    dataIndex: 'countryOrigin'
  },
  {
    title: '灭菌批号',
    ellipsis: true,
    dataIndex: 'SIPNo'
  },
  {
    title: '分装批号',
    ellipsis: true,
    dataIndex: 'spiltNo'
  },

  {
    title: '收货时间',
    ellipsis: true,
    dataIndex: ''
  },
  {
    title: '操作',
    key: 'operate',
    align: 'center',
    fixed: 'right',
    width: '120px',
    scopedSlots: { customRender: 'action' }
  }
]
export function deitalFormItems(self) {
  let _this = self
  return [
    {
      label: '注册证号',
      // disabled: true,
      value: '',
      type: 'input',
      name: 'billId'
    },
    {
      label: '商品名称',
      // disabled: true,
      value: '',
      type: 'input',
      name: 'itemName'
    },
    {
      label: '商品规格',
      // disabled: true,
      value: '',
      type: 'input',
      name: 'specification'
    },
    {
      label: '生产厂家',
      // disabled: true,
      value: '',
      type: 'input',
      name: 'manufacturerName'
    },
    {
      label: '产地',
      // disabled: true,
      value: '',
      type: 'input',
      name: 'countryOrigin'
    },
    {
      type: 'input',
      label: '显示生产日期',
      name: "batchProductionShowNew",
      rules: [{ required: true, message: '数据不能为空' },
        {
          validator: (rule, value, callback) => {
            // var reg = /^[A-Za-z0-9]+$/ //数字和英文
            // if (!reg.test(value) && value) {
            //   callback('请输入正确的格式')
            // }
            let t = handleShowProductionDate(value)
            if (!t || t == 'Invalid date') {
              callback('请输入正确的日期格式')
              
            }
            callback()
          }
        }
      ],
      value: "",
    },
    {
      type: "input",
      label: '显示有效期至',
      name: "batchExpiredShowNew",
      rules: [{ required: true, message: '数据不能为空' },
        {
          validator: (rule, value, callback) => {
            // var reg = /^[A-Za-z0-9]+$/ //数字和英文
            // if (!reg.test(value) && value) {
            //   callback('请输入正确的格式')
            // }
            let t = handleShowProductionDate(value)
            if (!t || t == 'Invalid date') {
              callback('请输入正确的日期格式')
              
            }
            callback()
          }
        }
      ],
      value: "",
    },
    {
      label: '批准文号',
      // disabled: true,
      value: '',
      type: 'input',
      name: 'approvalNo',
    },
    {
      label: '灭菌批号',
      // disabled: true,
      value: '',
      type: 'input',
      name: 'SIPNo',
    },
    {
      label: '商品批号',
      // disabled: true,
      value: '',
      type: 'input',
      name: 'manufacturerLotNum',
    },
    
    
    {
      label: '调整原因',
      // disabled: false,
      value: '',
      type: 'input',
      name: 'adjustReason',
    }
    // {
    //   span: 24,
    //   type: 'buttonGroup',
    //   style: { textAlign: 'right' },
    //   options: [
    //     {
    //       value: '查询',
    //       icon: 'search',
    //       btnType: 'primary',
    //       style: 'margin-right:10px',
    //       htmlType: 'submit'
    //     },
    //     {
    //       value: '重置',
    //       icon: 'redo',
    //       on: {
    //         click: () => {
    //           self.$refs.formTarget.form.resetFields()
    //         }
    //       }
    //     }
    //   ]
    // }
  ]
}

export { columns }
