import  moment   from   'moment';
import { remote } from './remote';
import store  from '@/store';
//  // 状态 0：待索取 1：待确认 2：待复核 3：已完成"
import { genWarehouseAuthSearchModal,genContainerSearchModal } from  '@/views/kzyWMS/SearchModal';

let warehouseId = null;

function items(self) {
	return [
		// 仓库
		  ...genWarehouseAuthSearchModal(1, true, false,null,
				  null,
				  { span: 8, labelCol: { span: 6 } }
			  ),
		// 容器
		  ...genContainerSearchModal(1, false, false,
				  function(vn,p){
					  console.log(self.$refs.search.form.getFieldsValue(),'self.$refs.search.form.getFieldsValue()')
					  p.params.warehouseId = self.$refs.search.form.getFieldsValue().warehouseId;
					  return p;
				  },
				  null,
				  { span: 8, labelCol: { span: 6 } },
			  ),
			  {

					type: 'input',
					name: 'pickTaskId',
					label: '任务编号',
					value: '',
			},
			{
					type: 'input',
					name: 'srcCode',
					label: '订单编号',
					value: '',
			},
			{
					type: 'input',
					name: 'waveId',
					label: '波次编号',
					value: '',
			},
            {
                type: 'input',
                name: 'shippername',
                label: '客户名称',
                value: '',
        },

			{
					type: 'select',
					name: 'status',
					label: '状态',
					value: '10',
				  // 状态 0：带索取 1：待拣选 2：待复核索取 3.待复核确认 10：完成
				  options:[
					  { label:'待索取', value:'0'},
					  { label:'待拣选', value:'1'},
					  { label:'待复核索取', value:'2'},
					  { label:'待复核确认', value:'3'},
					  { label:'完成', value:'10'},
				  ]
			},
			{
					type: "date",
					name: "startTime",
					label:'开始日期',
					placeholder: "请输入开始日期",
					format: "YYYY-MM-DD 00:00:00",
					value: moment().format("YYYY-MM-DD 00:00:00"),
			},
			{
			  type: "date",
			  name: "endTime",
			  label:'结束日期',
			  placeholder: "请输入结束日期",
			  format: "YYYY-MM-DD 23:59:59",
			  value: moment().format("YYYY-MM-DD 23:59:59"),
			},

		 {
			  type: 'buttonGroup',
			  style: { textAlign: 'center'},
			  // labelCol: { span: 8 },	//标签布局 如：{span: 3, offset: 12}
			  // wrapperCol: { span: 12 },  // 输入控件布局+标签布局=span
			  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:'',
							  containerId:'',
							  containerCode:''
					   });
						  }
					  }
				  }
		   ]}
	  ];
}


const columns = [
	{ dataIndex:'srcCode', title:'订单编号',sorter:(a,b)=>a.srcCode.localeCompare(b.srcCode) },
	{ dataIndex:'shippername', title:'客户名称',sorter:(a,b)=>a.shippername.localeCompare(b.shippername) },
	{ dataIndex:'remark', title:'备注',sorter:(a,b)=>a.remark.localeCompare(b.remark) },
	{ dataIndex:'pickTaskType', title:'拣货类型',sorter:(a,b)=>a.pickTaskType-(b.pickTaskType), customRender:(text,record,index)=>text?(text==1?'零货拣货':text==2?'功能库房拣货':'整单拣选'):'整货拣货' },
	{ dataIndex:'status', title:'状态',customRender:(text,record,index)=>{
			switch(text){
					  case '0':
						return  '待索取';
						break;
					  case '1':
						return '待拣选';
						break;
					  case '2':
						return '待复核索取';
						break;
					  case '3':
						return '待复核确认';
						break;
					  case '10':
						return '完成';
						break;
					  default:
					  return	'';
			 }
			} ,sorter:(a,b)=>a.status-(b.status)
	},
	{ dataIndex:'warehouseAreaCode', title:'库区',sorter:(a,b)=>a.warehouseAreaCode.localeCompare(b.warehouseAreaCode) },
	{ dataIndex:'stationName', title:'工作站名称',sorter:(a,b)=>a.stationName.localeCompare(b.stationName)},
	{ dataIndex:'gmtCreate', title:'创建时间',sorter:(a,b)=>a.gmtCreate.localeCompare(b.gmtCreate)},
	{ dataIndex:'pickTaskId', title:'任务编号',sorter:(a,b)=>a.pickTaskId.localeCompare(b.pickTaskId) },
	// 状态 0：带索取 1：待拣选 2：待复核索取 3.待复核确认 10：完成

	// type  --类型：0，拣货任务,1 补货任务
	{ dataIndex:'type', title:'任务类型',customRender:text=>text?'补货任务':'拣货任务',sorter:(a,b)=>a.type-(b.type) },
	{ dataIndex:'containerCode', title:'容器编号',sorter:(a,b)=>a.containerCode-(b.containerCode) },
	{ dataIndex:'stageCodes', title:'暂存区',sorter:(a,b)=>a.containerCode-(b.containerCode) },
	{ dataIndex:'waveId', title:'波次编号',sorter:(a,b)=>a.waveId.localeCompare(b.waveId) },
	{ dataIndex:'warehouseName', title:'仓库名称',sorter:(a,b)=>a.warehouseName.localeCompare(b.warehouseName)},
	{ dataIndex:'cargoOwnerName', title:'货主',sorter:(a,b)=>a.cargoOwnerName.localeCompare(b.cargoOwnerName) },
	{ dataIndex:'operatorCode', title:'拣货人',sorter:(a,b)=>a.operatorCode.localeCompare(b.operatorCode) },
	{ dataIndex:'pickPieceGroup', title:'拣选分组',sorter:(a,b)=>a.pickPieceGroup.localeCompare(b.pickPieceGroup)},
	{ dataIndex:'paymenttype', title:'账期类型',sorter:(a,b)=>a.paymenttype.localeCompare(b.paymenttype)},
	{ dataIndex:'createby', title:'开单员',sorter:(a,b)=>a.createby.localeCompare(b.createby)},
	{ dataIndex:'salespersonName', title:'业务员',sorter:(a,b)=>a.salespersonName.localeCompare(b.salespersonName)},
];

const columns2 = [
	{ dataIndex:'srcCode', title:'订单编号' },
	{ dataIndex:'manufacturerLotNum', title:'批号'},
	{ dataIndex:'warehouseAreaCode', title:'货区' },
	{ dataIndex:'locatorCode', title:'货位' },
	{ dataIndex:'itemCode', title:'商品编号' },
	{ dataIndex:'itemName', title:'商品名称' },
	{ dataIndex:'itemSpecs', title:'商品规格' },
	{ dataIndex:'uom', title:'单位' },
	{ dataIndex:'caseConversionRate', title:'包装数量' },
	{ dataIndex:'qty', title:'数量' },
	{ dataIndex:'pickQty', title:'已拣数量' },
	{ dataIndex:'checkQty', title:'复核数量' },
	{ dataIndex:'pickerNo', title:'拣选人工号' },
	{ dataIndex:'pickerName', title:'拣选人' },
	{ dataIndex:'operation',title:'操作',scopedSlots:{customRender:'operation'},fixed:'right'}
];

 export { items,columns,columns2 }
