
export default function () {
  const options={
    height:215,
    align:'center',
    border: true,
    resizable: true,
    keepSource:true,
    size:'mini',
    showOverflow: true,
    scrollY:{enable:true},
    highlightCurrentRow:true,
    data:[],
    ycldw:null,
  }
  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 'QG'+cellValue
    }
    return ''
  }

  const dwFormat=function ({cellValue}){
    for (const item of options.ycldw) {
      for (const item of options.ycldw) {
        if (cellValue===item.id+''){
          return item.name
        }
      }
    }
  }

  const formatLx=function ({cellValue}){
    if (cellValue==='1'){
      return '一垮'
    }
    if (cellValue==='2'){
      return '二垮'
    }
    if (cellValue==='3'){
      return '三垮'
    }
    if (cellValue==='4'){
      return '四五六垮'
    }
    return ''
  }

  const formatKw=function ({cellValue}){
    for (const item of ycldw) {
      if (cellValue===item.bm){
        return item.bmsm
      }
    }
    return cellValue;
  }

  const columns = [
    { type: 'checkbox', width: 40 },
    { type: 'seq',title:'序号', width: 50 },
    { field: 'djh',title:'派工单号', width: 120,},
    // {field: 'lldw', title: '垛位', width: 80,formatter: dwFormat},
    // {field: 'llcs', title: '层数', width: 60},
    {field: 'dcCh', title: '船号', width: 80,
      filters: [{ data: { checks: [], sVal: '', sMenu: '', fType1: '', fVal1: '', fMode: 'and', fType2: '', fVal2: '' } }],
      filterRender: { name: 'FilterCombination', },
    },
    {field: 'dcPl', title: '批量', width: 80,
      filters: [{ data: { checks: [], sVal: '', sMenu: '', fType1: '', fVal1: '', fMode: 'and', fType2: '', fVal2: '' } }],
      filterRender: { name: 'FilterCombination', },
    },
    {field: 'dcFd', title: '分段', width: 80},
    {field: 'wpgg', title: '材质', width: 80},
    {field: 'wpxh', title: '规格', width: 70},
    {field: 'sllph', title: '炉批号', width: 100},
    {field: 'zl', title: '组立', width: 100,
      filters: [{ data: { checks: [], sVal: '', sMenu: '', fType1: '', fVal1: '', fMode: 'and', fType2: '', fVal2: '' } }],
      filterRender: { name: 'FilterCombination', },
    },
    {field: 'kw', title: '流向', width: 80,formatter:formatKw,
      filters: [{ data: { checks: [], sVal: '', sMenu: '', fType1: '', fVal1: '', fMode: 'and', fType2: '', fVal2: '' } }],
      filterRender: { name: 'FilterCombination', },
    },
    {field: 'tzbh', title: '套料图号', width: 100,
      filters: [{ data: { checks: [], sVal: '', sMenu: '', fType1: '', fVal1: '', fMode: 'and', fType2: '', fVal2: '' } }],
      filterRender: { name: 'FilterCombination', },
    },
    {field: 'qgry', title: '接收人', width: 80,formatter: nameFormat},
    {field: 'qgfkry', title: '报工人', width: 80,formatter:nameFormat},
    {field: 'qgfkrq', title: '报工时间', width: 100},
    {field: 'qgpgry', title: '派工人', width: 80,formatter: nameFormat},
    {field: 'qgpgrq', title: '派工时间', width: 100},
  ]

  const ycldw=[
    {"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"}
  ]


  return {
    options,
    columns,
    setExt
  }
}
