export default function (_height=0) {
  let height=window.innerHeight
  if (height > 1024) {
    height = window.innerHeight*0.88
  }else{
    height = window.innerHeight*0.78
  }
  if (_height>0){
    height=_height
  }
  const options={
    height:height,
    align:'center',
    border: true,
    resizable: true,
    keepSource:true,
    size:'mini',
    showOverflow: true,
    scrollY:{enable:true},
    data:[],
    ycldw:[],
    tlt:[
      {"bmsm": "2跨超长超宽曲板", "bmlb": "QGKW", "bm": "10"},
      {"bmsm": "2跨T型材腹板", "bmlb": "QGKW", "bm": "11"},
      {"bmsm": "2跨激光切割板", "bmlb": "QGKW", "bm": "12"},
      {"bmsm": "3跨曲板", "bmlb": "QGKW", "bm": "13"},
      {"bmsm": "3跨厚板", "bmlb": "QGKW", "bm": "14"},
      {"bmsm": "4跨普通板", "bmlb": "QGKW", "bm": "15"},
      {"bmsm": "7跨型板", "bmlb": "QGKW", "bm": "16"},
      {"bmsm": "光电", "bmlb": "QGKW", "bm": "17"},
      {"bmsm": "2跨T型材面板", "bmlb": "QGKW", "bm": "5"},
      {"bmsm": "3跨平铁", "bmlb": "QGKW", "bm": "6"},
      {"bmsm": "1跨平直大板", "bmlb": "QGKW", "bm": "7"},
      {"bmsm": "1跨进线板", "bmlb": "QGKW", "bm": "8"},
      {"bmsm": "2跨超长超宽板", "bmlb": "QGKW", "bm": "9"}
    ],
    zl:[
      {"name": "小组立", "bm": "1010"},
      {"name": "中大组立", "bm": "1110"},
    ]
  }
  const ext={}
  const setExt=function (key,value){
    ext[key]=value
  }

  const nameFormat=function ({cellValue}){
    const workers=ext.workers
    for (const item of workers) {
      if(item.userCode===cellValue){
        return item.userName
      }
    }
  }

  const gdhFormat=function ({cellValue}){
    if (cellValue){
      return 'PW'+cellValue
    }
    return ''
  }

  const dwFormat=function ({cellValue}){
    for (const item of options.ycldw) {
      if (cellValue===item.id){
        return item.name
      }
    }
  }
  const kwFormat=function ({cellValue}){
    for (const item of options.tlt) {
      if (cellValue===item.bm){
        return item.bmsm
      }
    }
  }

  const zlFormat=function ({cellValue}){
    for (const item of options.zl) {
      if (cellValue===item.bm){
        return item.name
      }
    }
  }
  const columns = [
    { type: 'checkbox', width: 40 },
    { type: 'seq',title:'序号', width: 50 },
    {field: 'dwId', title: '垛位', width: 100,formatter: dwFormat},
    {field: 'ceng', title: '层数', width: 50},
    {field: 'czbh', title: '船号', width: 80,
      filters: [{ data: { checks: [], sVal: '', sMenu: '', fType1: '', fVal1: '', fMode: 'and', fType2: '', fVal2: '' } }],
      filterRender: { name: 'FilterCombination', },
    },
    {field: 'pl', title: '批量', width: 70,
      filters: [{ data: { checks: [], sVal: '', sMenu: '', fType1: '', fVal1: '', fMode: 'and', fType2: '', fVal2: '' } }],
      filterRender: { name: 'FilterCombination', },
    },
    {field: 'djh', title: '工单号', width: 100},
    {field: 'fd', title: '分段',width: 50,visible:false},
    {field: 'tlth', title: '套料图号',width: 120},
    {field: 'wph', title: '材质', width: 60,
      filters: [{ data: { checks: [], sVal: '', sMenu: '', fType1: '', fVal1: '', fMode: 'and', fType2: '', fVal2: '' } }],
      filterRender: { name: 'FilterCombination', },
    },
    {field: 'wpgg', title: '物品规格', width: 120,},
    {field: 'lph', title: '物料号', width: 130,},
    {field: 'kw', title: '垮位',width: 130,formatter: kwFormat},
    {field: 'zl', title: '组立', width: 70,formatter: zlFormat},
    {field: 'nbsbm', title: '入库批号',minWidth: 100,},
    {field: 'lldw', title: '理料垛位',width: 50,visible:false },
    {field: 'llcs', title: '理料层数',width: 50,visible:false },
    {field: 'zt0', title: '状态',width: 50,visible:false },
    {field: 'bz', title: '备注',width: 50,visible:false },
  ]

  return {
    options,
    columns,
    setExt
  }
}
