import request from '@/utils/request'
import {getSumAdd} from "@/utils/rpkj";

const 预切板统计=()=>{
  const butClick=()=>{
    预切板统计查询(data.formData).then(res=>{
      data.options.data=res.data
    })
  }

  const countGroup=[]
  countGroup.push('批量板数','预切板数','上料完成','一跨龙门板数','龙门1预切板数')
  countGroup.push('一跨龙门板数','龙门1预切板数')
  countGroup.push('一跨数控板数','数1预切板数')
  countGroup.push('二跨平铁板数','平铁预切板数')
  countGroup.push('二跨数控板数','数控预切板数')
  countGroup.push('三跨曲板板数','曲版预切板数')
  countGroup.push('三跨厚板板数','厚板预切板数')
  countGroup.push('四区腹板板数','腹板预切板数')
  countGroup.push('四区数控板数','数4预切板数')
  countGroup.push('七跨面板板数','面板预切板数')
  countGroup.push('光电板数','光电预切板数')

  const footerMethod=({ columns, data })=>{
    return [
      columns.map((column, columnIndex) => {
        if (countGroup.includes(column.property)) {
          return getSumAdd(data, column.property)
        }
        if (columnIndex === 1) {
          return '合计'
        }
        return null
      })
    ]
  }

  const data={
    formData:{
      dcCh:'',
      dcPl0:'',
      dcPl1:'',
    },
    formItems:[
      { field: 'dcCh', title: '船号', span: 4,
        itemRender: {
          name: '$select', props: { options:[],placeholder: '船号' }
        }
      },
      // { field: 'dcPl0', title: '批量', span: 3 ,
      //   itemRender: { name: '$input', }
      // },
      // { field: 'dcPl1', title: '批量', span: 3 ,
      //   itemRender: { name: '$input', }
      // },
      {span: 20 ,align:'right',
        itemRender: {
          name: '$button', props: {content:'查询',status:'primary'},events:{click:butClick}
        }
      },
    ],
    options:{
      height:400,
      align:'center',
      border: true,
      resizable: true,
      keepSource:true,
      size:'mini',
      showOverflow: true,
      scrollY:{enable:true},
      editConfig:{trigger: 'click', mode: 'cell', showStatus: true},
      highlightCurrentRow:true,
      showFooter:true,
      footerMethod:footerMethod,
      data:[],
    },
    columns:[
      { type: 'seq', width: 60, title: '序号' },
      { field: 'dcCh', title: '产品',
        filters: [{ data: { checks: [], sVal: '', sMenu: '', fType1: '', fVal1: '', fMode: 'and', fType2: '', fVal2: '' } }],
        filterRender: { name: 'FilterCombination', },
      },
      { field: 'dcPl', title: '批量',
        filters: [{ data: { checks: [], sVal: '', sMenu: '', fType1: '', fVal1: '', fMode: 'and', fType2: '', fVal2: '' } }],
        filterRender: { name: 'FilterCombination', },
      },
      { field: 'fds', title: '分段',
        filters: [{ data: { checks: [], sVal: '', sMenu: '', fType1: '', fVal1: '', fMode: 'and', fType2: '', fVal2: '' } }],
        filterRender: { name: 'FilterCombination', },
      },
      { field: '批量板数', title: '批量板数',
        filters: [{ data: { checks: [], sVal: '', sMenu: '', fType1: '', fVal1: '', fMode: 'and', fType2: '', fVal2: '' } }],
        filterRender: { name: 'FilterCombination', },
      },
      { field: '预切板数', title: '预切板数',
        filters: [{ data: { checks: [], sVal: '', sMenu: '', fType1: '', fVal1: '', fMode: 'and', fType2: '', fVal2: '' } }],
        filterRender: { name: 'FilterCombination', },
      },
      { field: '上料完成', title: '上料完成',
        filters: [{ data: { checks: [], sVal: '', sMenu: '', fType1: '', fVal1: '', fMode: 'and', fType2: '', fVal2: '' } }],
        filterRender: { name: 'FilterCombination', },
      },
      { field: '一跨龙门板数', title: '一跨龙门板数',
        filters: [{ data: { checks: [], sVal: '', sMenu: '', fType1: '', fVal1: '', fMode: 'and', fType2: '', fVal2: '' } }],
        filterRender: { name: 'FilterCombination', },
      },
      { field: '龙门1预切板数', title: '龙门1预切板数',
        filters: [{ data: { checks: [], sVal: '', sMenu: '', fType1: '', fVal1: '', fMode: 'and', fType2: '', fVal2: '' } }],
        filterRender: { name: 'FilterCombination', },
      },
      { field: '一跨数控板数', title: '一跨数控板数',
        filters: [{ data: { checks: [], sVal: '', sMenu: '', fType1: '', fVal1: '', fMode: 'and', fType2: '', fVal2: '' } }],
        filterRender: { name: 'FilterCombination', },
      },
      { field: '数1预切板数', title: '数1预切板数',
        filters: [{ data: { checks: [], sVal: '', sMenu: '', fType1: '', fVal1: '', fMode: 'and', fType2: '', fVal2: '' } }],
        filterRender: { name: 'FilterCombination', },
      },
      { field: '二跨平铁板数', title: '二跨平铁板数',
        filters: [{ data: { checks: [], sVal: '', sMenu: '', fType1: '', fVal1: '', fMode: 'and', fType2: '', fVal2: '' } }],
        filterRender: { name: 'FilterCombination', },
      },
      { field: '平铁预切板数', title: '平铁预切板数',
        filters: [{ data: { checks: [], sVal: '', sMenu: '', fType1: '', fVal1: '', fMode: 'and', fType2: '', fVal2: '' } }],
        filterRender: { name: 'FilterCombination', },
      },
      { field: '二跨数控板数', title: '二跨数控板数',
        filters: [{ data: { checks: [], sVal: '', sMenu: '', fType1: '', fVal1: '', fMode: 'and', fType2: '', fVal2: '' } }],
        filterRender: { name: 'FilterCombination', },
      },
      { field: '数控预切板数', title: '数控预切板数',
        filters: [{ data: { checks: [], sVal: '', sMenu: '', fType1: '', fVal1: '', fMode: 'and', fType2: '', fVal2: '' } }],
        filterRender: { name: 'FilterCombination', },
      },
      { field: '三跨曲板板数', title: '三跨曲板板数',
        filters: [{ data: { checks: [], sVal: '', sMenu: '', fType1: '', fVal1: '', fMode: 'and', fType2: '', fVal2: '' } }],
        filterRender: { name: 'FilterCombination', },
      },
      { field: '曲版预切板数', title: '曲版预切板数',
        filters: [{ data: { checks: [], sVal: '', sMenu: '', fType1: '', fVal1: '', fMode: 'and', fType2: '', fVal2: '' } }],
        filterRender: { name: 'FilterCombination', },
      },
      { field: '三跨厚板板数', title: '三跨厚板板数',
        filters: [{ data: { checks: [], sVal: '', sMenu: '', fType1: '', fVal1: '', fMode: 'and', fType2: '', fVal2: '' } }],
        filterRender: { name: 'FilterCombination', },
      },
      { field: '厚板预切板数', title: '厚板预切板数',
        filters: [{ data: { checks: [], sVal: '', sMenu: '', fType1: '', fVal1: '', fMode: 'and', fType2: '', fVal2: '' } }],
        filterRender: { name: 'FilterCombination', },
      },
      { field: '四区腹板板数', title: '四区腹板板数',
        filters: [{ data: { checks: [], sVal: '', sMenu: '', fType1: '', fVal1: '', fMode: 'and', fType2: '', fVal2: '' } }],
        filterRender: { name: 'FilterCombination', },
      },
      { field: '腹板预切板数', title: '腹板预切板数',
        filters: [{ data: { checks: [], sVal: '', sMenu: '', fType1: '', fVal1: '', fMode: 'and', fType2: '', fVal2: '' } }],
        filterRender: { name: 'FilterCombination', },
      },
      { field: '四区数控板数', title: '四区数控板数',
        filters: [{ data: { checks: [], sVal: '', sMenu: '', fType1: '', fVal1: '', fMode: 'and', fType2: '', fVal2: '' } }],
        filterRender: { name: 'FilterCombination', },
      },
      { field: '数4预切板数', title: '数4预切板数',
        filters: [{ data: { checks: [], sVal: '', sMenu: '', fType1: '', fVal1: '', fMode: 'and', fType2: '', fVal2: '' } }],
        filterRender: { name: 'FilterCombination', },
      },
      { field: '七跨面板板数', title: '七跨面板板数',
        filters: [{ data: { checks: [], sVal: '', sMenu: '', fType1: '', fVal1: '', fMode: 'and', fType2: '', fVal2: '' } }],
        filterRender: { name: 'FilterCombination', },
      },
      { field: '面板预切板数', title: '面板预切板数',
        filters: [{ data: { checks: [], sVal: '', sMenu: '', fType1: '', fVal1: '', fMode: 'and', fType2: '', fVal2: '' } }],
        filterRender: { name: 'FilterCombination', },
      },
      { field: '光电板数', title: '光电板数',
        filters: [{ data: { checks: [], sVal: '', sMenu: '', fType1: '', fVal1: '', fMode: 'and', fType2: '', fVal2: '' } }],
        filterRender: { name: 'FilterCombination', },
      },
      { field: '光电预切板数', title: '光电预切板数',
        filters: [{ data: { checks: [], sVal: '', sMenu: '', fType1: '', fVal1: '', fMode: 'and', fType2: '', fVal2: '' } }],
        filterRender: { name: 'FilterCombination', },
      },
    ]
  }

  return data
}

const 预切板统计查询=(data)=>{
  return request({
    url: "/ydjhzz/yqbtjcx",
    method: "post",
    data,
  });
}

export default 预切板统计
