import { remote } from './remote'
import { genWarehouseSearchModal,
		  genContainerSearchModal,
		} from "@/views/kzyWMS/SearchModal";
let grid = {
  span: 8,
  labelCol: { span: 8 },
  // wrapperCol: { span: 16 },
};

const items = [
	// 仓库
	...genWarehouseSearchModal(1, true, false,null, 
			function (rowData, form) {
				if (!rowData) {
					form.setFieldsValue({
						warehouseId: '',
						warehouseCode:'',
						warehouseName:''
					})
				} else {
					form.setFieldsValue({
						warehouseId: rowData[0].warehouseId,
						warehouseCode: rowData[0].warehouseCode,
						warehouseName: rowData[0].warehouseName,
					})
				}
			},
			{ span: 8, labelCol: { span: 8 } }
		),
  /* ...genwarehouse({
    ...grid,
    required: true
  }), */
  {
    type: 'input',
    name: 'stationCode',
    label: '工作站编号',
    ...grid,
  },
  {
    type: 'input',
    name: 'stationName',
    label: '工作站名称',
    ...grid
  },
  {
    type: 'select',
    name: 'isEnable',
    label: '状态',
	value: 1,
    options: [
      { label: '启用', value: 1 },
      { label: '禁用', value: 0 }
    ],
    ...grid
  },
  {
    span: 8,
    type: 'buttonGroup',
    style: { textAlign: 'left' },
    options: [
      {
        value: '查询',
        icon: 'search',
        btnType: 'primary',
        style: 'margin-left:50px;margin-right:10px;',
        htmlType: 'submit'
      },
      {
        value: '重置',
        icon: 'redo',
        on: {
          click(event, form) {
            form.resetFields()
          }
        }
      }
    ]
  }
]

let warehouseId = null;
const modalItems = function (self){ 
  return [
	// 仓库
	...genWarehouseSearchModal(1, true, false,null, 
			function (rowData, form) {
        form.setFieldsValue({
          warehouseId: rowData?rowData[0].warehouseId:'',
          warehouseCode: rowData?rowData[0].warehouseCode:'',
          warehouseName: rowData?rowData[0].warehouseName:'',
          containerCode: '',
          containerName: '',
        })
			},
			{ span: 8, labelCol: { span: 9 } }
		),
  {
    type: 'input',
    name: 'stationCode',
    label: '工作站编号',
    required: true
  },
  {
    type: 'input',
    name: 'stationName',
    label: '工作站名称',
    required: true
  },
  {
    type: 'select',
    name: 'stationType',
    label: '工作站类型',
    required: true,
    ...remote('stationtype')
  },
  {
    type: 'select',
    name: 'stageType',
    label: '复核台类型',
    required: true,
    ...remote('stationattr1')
  },
  {
    type: 'select',
    name: 'stageGroup',
    label: '复核台类别',
    required: true,
    ...remote('stationattr2')
  },
  // 容器
  ...genContainerSearchModal(1, false, true,
		function(vNode,p){
      let vals = self.$refs.modelForm.form.getFieldsValue();
      p.params.warehouseId = vals.warehouseId
      return p;
		}, 
    null/* function (rowData, form) {
  		} */,
  		{ span: 8, labelCol: { span: 9 } }
  	),
  {
    type: 'input',
    name: 'ceilingtasknum',
    label: '任务上限',
    required: true,
  },
  {
    type: 'input',
    name: 'groupCode',
    label: '分组号',
    required: true,
  },
  {
    type: 'select',
    name: 'abnormalFlag',
    label: '异常处理工作站',
    required: true,
    options: [
      {
        label: '是',
        value: 1
      },
      {
        label: '否',
        value: 0
      }
    ]
  },
  {
    type: 'switch',
    name: 'isEnable',
    label: '状态',
    value: true
  },
]
}

const columns = [
  {
    dataIndex: 'stationCode',
    title: '工作站编号'
  },
  {
    dataIndex: 'stationName',
    title: '工作站名称'
  },
  {
    dataIndex: 'groupCode',
    title: '分组号'
  },
  {
    dataIndex: 'ceilingtasknum',
    title: '任务上限'
  },
  {
    dataIndex: 'stationTypeName',
    title: '工作站类型'
  },
  {
    dataIndex: 'abnormalFlag',
    title: '异常处理工作站',
    customRender: text => {
      return text ? '是' : '否'
    }
  },
  {
    dataIndex: 'isEnable',
    title: '状态',
    customRender: text => {
      return text ? '启用' : '禁用'
    }
  },
  {
    dataIndex: 'action',
    title: '操作',
    scopedSlots: { customRender: 'action' },
    width: 80
  }
]

export { items, modalItems, columns }

export const whAreaColumns = [
  { dataIndex: 'warehouseAreaId', title: '库区ID', hidden: true },
  { dataIndex: 'warehouseAreaCode', title: '库区编码' },
  { dataIndex: 'warehouseAreaName', title: '库区名称' },
];

export const whSlideColumns = [
  { dataIndex: 'stationId', title: 'ID', hidden: true },
  { dataIndex: 'slidewayNum', title: '滑道编号' },
  { dataIndex: 'capacity', title: '滑道容量' },
  {
    dataIndex: 'isMix', title: '是否混放', customRender: text => {
      return text ? '是' : '否'
    }
  },
  {
    dataIndex: 'action',
    title: '操作',
    scopedSlots: { customRender: 'action' },
    width: 80
  }
];
export const whSlideItems = [
  { type: 'input', name: 'slidewayNum', label: '滑道编号', required: true, },
  { type: 'input', name: 'capacity', label: '滑道容量', required: true, },
  {
    type: 'select', name: 'isMix', label: '是否混放', required: true, options: [
      { label: '是', value: true },
      { label: '否', value: false }
    ],
  }
]
