import store from '@/store'
import { genWarehouseAuthSearchModal, genBldgSearchModal,genCargoownerAuthSearchModal } from '@/views/kzyWMS/SearchModal'
import { upcloud_base_wh } from "@/config/serviceSettings";

const grid = { span: 8, labelCol: { span: 6 } }

const items = [
  // 仓库
  ...genWarehouseAuthSearchModal(1, true, false, null, null, grid),
  // 货主(与账户权限关联)
  ...genCargoownerAuthSearchModal(1, true, false,
   		function(vn,p){
   			console.log('remoteBefore参数回调：',vn,p);
   		},null,grid,
   	),
  {
    type: 'searchModal',
    name: 'bldgName',
    label: '源建筑物',
    // required: true,
    remoteUrl: { url: upcloud_base_wh+'/wmsWhBldg/v1/page', method: 'get' },
    rowKey: 'bldgId',
    targetValueKey: 'bldgName',
	...grid,
    toolBar: {
      items: [
        {
          type: 'input',
          name: 'bldgName',
          label: '建筑物名称',
          value: ''
        },
        {
          type: 'input',
          name: 'bldgCode',
          label: '建筑物编号',
          value: ''
        }
      ]
    },
    tableConfig: {
      columns: [
        {
          dataIndex: 'bldgName',
          title: '建筑物名称'
        },
        {
          dataIndex: 'bldgCode',
          title: '建筑物编号'
        }
      ]
    },
    on: {
      ok(event, value, rowData, form) {
        form.setFieldsValue({
			srcBldgCode: `${rowData[0].bldgCode}`
        })
      }
    }
  },
  {
    type: 'searchModal',
    name: 'destBldgName',
    label: '目标建筑物',
    // required: true,
    remoteUrl: { url: upcloud_base_wh+'/wmsWhBldg/v1/page', method: 'get' },
    rowKey: 'bldgId',
    targetValueKey: 'bldgName',
	...grid,
    toolBar: {
      items: [
        {
          type: 'input',
          name: 'bldgName',
          label: '建筑物名称',
          value: ''
        },
        {
          type: 'input',
          name: 'bldgCode',
          label: '建筑物编号',
          value: ''
        }
      ]
    },
    tableConfig: {
      columns: [
        {dataIndex: 'bldgName',title: '建筑物名称'},
        {dataIndex: 'bldgCode',title: '建筑物编号'}
      ]
    },
    on: {
      ok(event, value, rowData, form) {
        form.setFieldsValue({
			destBldgCode: `${rowData[0].bldgCode}`
        })
      }
    }
  },
  {type: 'input',name: 'srcBldgCode',hidden: true,label: '源建筑物编码',value: '',...grid},
  {type: 'input',name: 'destBldgCode',hidden: true,label: '目标建筑物编码',value: '',...grid},
  {type: 'input',name: 'waveId',label: '波次编号',value: '',...grid},
  {
  		type: 'select',
  		name: 'status',
  		label: '状态',
  		value: '',
				options:[
					// 0:新生成 1:下架 2:上架
					{label:'新生成',value:'0'},
					{label:'下架',value:'1'},
					{label:'上架',value:'2'},
				],
  			...grid
  },
  {
   		type: 'select',
   		name: 'moveType',
   		label: '补货类型',
   		value: '',
  			options:[
  				// 补货类型 1主动补货 2紧急补货 3波次补货 4被动补货
  				{label:'主动补货',value:'1'},
  				{label:'紧急补货',value:'2'},
  				{label:'波次补货',value:'3'},
  				{label:'被动补货',value:'4'},
  			],
  			...grid
   },
  {
    ...grid, 
    type: 'buttonGroup',
    style: { textAlign: 'center' },
    options: [
      { value: '查询', icon: 'search', btnType: 'primary', style: 'margin-right:16px', htmlType: 'submit' },
      {
        value: '重置',
        name: 'ccz',
        icon: 'redo',
        on: {
          click(event, form) {
            form.resetFields()
            form.setFieldsValue({
              warehouseName: '',
              warehouseId: ''
            })
          }
        }
      }
    ]
  }
]

const columns = [
  // { dataIndex: 'consignorname', title: '货主名称' },
  { dataIndex: 'waveId', title: '波次编号' },
  { dataIndex: 'srcCode', title: '订单编码' },
  { dataIndex: 'itemName', title: '商品名称' },
  { dataIndex: 'pieceQty', title: '数量' },
  { dataIndex: 'caseqty', title: '件数' },
  { dataIndex: 'conversionRate', title: '包装数量' },
  { dataIndex: 'uom', title: '单位' },
  { dataIndex: 'pieceUom', title: '最小单位' },
  { dataIndex: 'specification', title: '规格' },
  { dataIndex: 'srcWarehouseAreaCode', title: '源库区' },
  { dataIndex: 'srcLocatorCode', title: '源货位' },
  { dataIndex: 'destWarehouseAreaCode', title: '目标库区' },
  { dataIndex: 'destLocatorCode', title: '目标货位' },
  { dataIndex: 'manufacturerLotNum', title: '批号' },
	// '创建',value:'CREATE'},{label:'下架',value:'OUT'},{label:'上架',value:'IN'},{label:'取消',value:'CANCEL'}
  { dataIndex: 'status', title: '状态', customRender:text=>{
							// 0:新生成 1:下架 2:上架
							switch(text){
								case '0':
									return	'新生成';
									break;
								case '1':
									return	'下架';
									break;
								case '2':
									return	'上架';
									break;
							} 
				}
		},
  { dataIndex: 'moveType', title: '补货类型', customRender:(text,rows,index)=>{
	  // 补货类型 1主动补货 2紧急补货 3波次补货 4被动补货
				switch(text){
					case '1':
						return "主动补货";
								break;
					case '2':
						return "紧急补货";
							break;
					case '3':
						return "波次补货";
								break;
					case '4':
						return "被动补货";
								break;
				}
			}
   
   },
  { dataIndex: 'contactName', title: '联系人' },
  { dataIndex: 'srcBldgCode', title: '源建筑物编号' },
  { dataIndex: 'destBldgCode', title: '目标建筑物编号' },
  { dataIndex: 'gmtCreate', title: '创建时间' },
  
]
export { items, columns }
