/*
 * @Company: 沈阳信诚科技
 * @Email: html_venustar@163.com
 * @Author: Liuqiming
 * @Description: 生产信息录入固定项配置
 * @LastEditors: Liuqiming
 * @LastEditTime: 2024-03-15 16:01:01
 * @Date: 2024-02-04 14:51:31
 */
const feedEditFn = ref(null)
const feedDeleteFn = ref(null)
const materialChargingType = ref([])
const materialFillChargingType = ref([])
const materialCastingType = ref([])
const qualityViewFn = ref(null)
const qualityEditFn = ref(null)
const qualityDeleteFn = ref(null)
const abnormalViewFn = ref(null)
const abnormalEditFn = ref(null)
const abnormalDeleteFn = ref(null)
const castTimesNoListData = ref(null)
const materialListData = ref(null)
const materialItemData = ref(null)
const qualityLevel = ref(null)
const defectType = ref(null)
const prdNoListData = ref(null)

export const init = ({
  feedDelete,
  feedEdit,
  material_charging_type,
  material_fill_charging_type,
  material_casting_type,
  qualityView,
  qualityEdit,
  qualityDelete,
  abnormalView,
  abnormalEdit,
  abnormalDelete,
  castTimesNoList,
  materialList,
  materialItem,
  quality_level,
  defect_type,
  prdNoList
}) => {
  feedEditFn.value = feedEdit
  feedDeleteFn.value = feedDelete
  materialChargingType.value = material_charging_type
  materialFillChargingType.value = material_fill_charging_type
  materialCastingType.value = material_casting_type
  qualityViewFn.value = qualityView
  qualityEditFn.value = qualityEdit
  qualityDeleteFn.value = qualityDelete
  abnormalViewFn.value = abnormalView
  abnormalEditFn.value = abnormalEdit
  abnormalDeleteFn.value = abnormalDelete
  castTimesNoListData.value = castTimesNoList
  materialListData.value = materialList
  materialItemData.value = materialItem
  qualityLevel.value = quality_level
  defectType.value = defect_type
  prdNoListData.value = prdNoList
  // feed 开头为加料信息页面用配置
  const feedSearchList = ref([
    {
      label: '浇次',
      field: 'castTimesNo',
      // type: 'select',
      clearable: true,
      width: '340px',
      placeholder: '请输入浇次',
      // options: castTimesNoListData.value
    },
    {
      label: '加料类型',
      field: 'chargingTypes',
      type: 'select',
      width: '340px',
      clearable: true,
      multiple: true,
      placeholder: '请选择加料类型',
      options: materialChargingType.value
    },
    {
      label: '厂家',
      field: 'manufacturer',
      width: '340px',
      clearable: true,
      placeholder: '请输入厂家',
    },
    {
      label: '记录员',
      field: 'operator',
      width: '340px',
      clearable: true,
      placeholder: '请输入记录员',
    },
    {
      label: '加料日期',
      field: 'chargingTimeRange',
      width: '340px',
      type: 'date',
      enum: 'daterange', // 其他类型枚举 week, month, year, date, daterange
      placeholder: '开始日期-结束日期' // 若选择框枚举类型为daterange， 此值接受 a-b 式截取提示内容展示
    }
  ])
  const feedBtnList = ref([
    { label: '加料录入', type: 'primary', icon:'Plus', met: 'addFeed', hasPermi:'chargingIn:information:add' },
    { label: '批量删除', type: 'danger', icon:'Delete', met: 'feedBatchDelete', hasPermi:'chargingIn:information:remove'  },
  ])
  const feedColumns = ref([
    {
      label: "加料类型",
      prop: "chargingTypeName",
      minWidth: 120
    },
    {
      label: "铸坯号",
      prop: "prdNo",
      minWidth: 200
    },
    {
      label: "浇次",
      prop: "castTimesNo",
      minWidth: 100
    },
    {
      label: "铸流号",
      prop: "prdStrandNo",
      minWidth: 100
    },
    {
      label: "投料量（KG）",
      prop: "chargingAmount",
      minWidth: 120
    },
    {
      label: "物料编码",
      prop: "materialCode",
      minWidth: 110
    },
    {
      label: "物料名称",
      prop: "materialName",
      minWidth: 120
    },
    {
      label: "厂家",
      prop: "manufacturer",
      minWidth: 120
    },
    {
      label: "牌号",
      prop: "brand",
      minWidth: 100
    },
    {
      label: "记录员",
      prop: "operator",
      minWidth: 110
    },
    {
      label: "加料时间",
      prop: "chargingTime",
      sort: true,
      minWidth: 160
    },
    {
      label: "创建时间",
      prop: "createTime",
      sort: true,
      minWidth: 160
    },
    {
      label: "最后修改时间",
      prop: "updateTime",
      sort: true,
      minWidth: 160
    },
    {
      label: "操作",
      minWidth: 150,
      fixed:'right',
      slots: (row) => {
        return <>
          <el-button type="primary" link onClick={() => feedEditFn.value(row)} v-hasPermi={['chargingIn:information:edit']}>修改</el-button>
          <el-button type="danger" link onClick={() => feedDeleteFn.value(row)} v-hasPermi={['chargingIn:information:remove']}>删除</el-button>
        </>
      }
    },
  ])
  const feedPageSet = ref({
    pageNum: 1,
    pageSize: 10,
    total:0
  })
  const feedFieldList = ref([
    {
      label: '记录员',
      field: 'operator',
      width: '300px',
      disabled: true,
      placeholder: '请输入记录员'
    },
    {
      label: '加料类型',
      field: 'chargingType',
      type: 'radio',
      radioButton: true,
      width: '300px',
      clearable: false,
      rules: [{required: true,message: '请选择加料类型',trigger: 'change'}],
      placeholder: '请选择加料类型',
      options: materialFillChargingType.value
    },
    {
      label: '浇次',
      field: 'castTimesNo',
      type: 'select',
      clearable: true,
      width: '300px',
      rules: [{required: true,message: '请选择浇次',trigger: 'change'}],
      placeholder: '请选择浇次',
      options: castTimesNoListData.value
    },
    {
      label: '铸流号',
      field: 'prdStrandNo',
      type: 'select',
      width: '300px',
      hidden: true,
      clearable: true,
      rules: [{required: true,message: '请选择铸流号',trigger: 'change'}],
      placeholder: '请选择铸流号',
      options: materialCastingType.value
    },
    {
      label: '投料量',
      field: 'chargingAmount',
      append: 'KG',
      rules: [
        {required: true,message: '请输入投料量',trigger: 'blur'},
        {pattern: /(^[+]?[0-9]{1,5})(?!0+$)+(\.[0-9]{1,2})?$/, message: '请输入十万以内的正数，最多保留两位小数',trigger: 'blur'},
      ],
      width: '300px',
      placeholder: '请输入投料量'
    },
    {
      label: '物料编码',
      field: 'materialCode',
      type: 'select',
      width: '300px',
      filterable: true,
      clearable: true,
      rules: [{required: true,message: '请选择物料编码',trigger: 'change'}],
      placeholder: '请选择物料编码',
      options: materialListData.value
    },
    {
      label: '物料名称',
      field: 'materialName',
      disabled: true,
      width: '300px',
      placeholder: '根据物料编码带出'
    },
    {
      label: '厂家',
      field: 'manufacturer',
      type: 'select',
      width: '300px',
      clearable: true,
      disabled: true,
      // rules: [{required: true,message: '请选择物料厂家',trigger: 'change'}],
      placeholder: '根据物料编码带出后选择',
      // options: materialItemData.value
    },
    {
      label: '牌号',
      field: 'brand',
      type: 'select',
      width: '300px',
      clearable: true,
      disabled: true,
      // rules: [{required: true,message: '请选择物料厂家',trigger: 'change'}],
      placeholder: '根据物料编码带出后选择',
      // options: materialItemData.value
    },
    {
      label: '加料时间',
      field: 'chargingTime',
      type: 'date',
      enum: 'datetime',
      width: '300px',
      clearable: true,
      rules: [{required: true,message: '请输入加料时间',trigger: 'change'}],
      placeholder: '请输入加料时间',
    },
  ])
  // quality 开头为质量信息页面用配置
  const qualitySearchList = ref([
    {
      label: '铸坯编号',
      field: 'prdNo',
      // type: 'select',
      // filterable: true,
      clearable: true,
      width: '340px',
      placeholder: '请输入铸坯编号',
      // options: prdNoListData.value
    },
    {
      label: '质量等级',
      field: 'qualityLevel',
      type: 'select',
      width: '340px',
      clearable: true,
      placeholder: '请选择质量等级',
      options: qualityLevel.value
    },
    {
      label: '缺陷类型',
      field: 'defectType',
      type: 'select',
      width: '340px',
      clearable: true,
      placeholder: '请选择缺陷类型',
      options: defectType.value
    },
    {
      label: '记录员',
      field: 'operator',
      width: '340px',
      clearable: true,
      placeholder: '请输入记录员',
    },
    {
      label: '质检时间',
      field: 'qualityControlTimeRange',
      width: '340px',
      type: 'date',
      enum: 'daterange', // 其他类型枚举 week, month, year, date, daterange
      placeholder: '开始日期-结束日期' // 若选择框枚举类型为daterange， 此值接受 a-b 式截取提示内容展示
    }
  ])
  const qualityBtnList = ref([
    { label: '质量信息录入', type: 'primary', icon:'Plus', met: 'addQuality', hasPermi:'quality:information:add' },
    { label: '批量删除', type: 'danger', icon:'Delete', met: 'qualityBatchDelete', hasPermi:'quality:information:remove' },
  ])
  const qualityColumns = ref([
    {
      label: "铸坯编号",
      prop: "prdNo",
      minWidth: 100
    },
    {
      label: "质量等级",
      prop: "qualityLevelName",
      minWidth: 100
    },
    {
      label: "缺陷类型",
      prop: "defectTypeName",
      minWidth: 100
    },
    {
      label: "缺陷长度",
      prop: "defectLength",
      minWidth: 100
    },
    {
      label: "缺陷深度",
      prop: "defectDepth",
      minWidth: 100
    },
    {
      label: "缺陷宽度",
      prop: "defectWidth",
      minWidth: 100
    },
    {
      label: "缺陷位置",
      prop: "defectLocation",
      minWidth: 100
    },
    {
      label: "缺陷描述",
      prop: "defectDesc",
      tooltip:true,
      minWidth: 140
    },
    {
      label: "记录员",
      prop: "operator",
      tooltip:true,
      minWidth: 100
    },
    {
      label: "质检时间",
      prop: "qualityControlTime",
      minWidth: 160
    },
    {
      label: "创建时间",
      prop: "createTime",
      sort: true,
      minWidth: 160
    },
    {
      label: "最后修改时间",
      prop: "updateTime",
      sort: true,
      minWidth: 160
    },
    {
      label: "操作",
      minWidth: 220,
      fixed:'right',
      slots: (row) => {
        return <>
          <el-button type="primary" link onClick={() => qualityViewFn.value(row)} v-hasPermi={['quality:information:view']}>详情</el-button>
          <el-button type="primary" link onClick={() => qualityEditFn.value(row)} v-hasPermi={['quality:information:edit']}>修改</el-button>
          <el-button type="danger" link onClick={() => qualityDeleteFn.value(row)} v-hasPermi={['quality:information:remove']}>删除</el-button>
        </>
      }
    },
  ])
  const qualityPageSet = ref({
    pageNum: 1,
    pageSize: 10,
    total:0
  })
  const qualityFieldList = ref([
    {
      label: '记录员',
      field: 'operator',
      width: '300px',
      disabled: true,
      placeholder: '请输入记录员'
    },
    {
      label: '铸坯编号',
      field: 'prdNo',
      type: 'select',
      filterable: true,
      clearable: true,
      width: '300px',
      rules: [{required: true,message: '请选择铸坯编号',trigger: 'change'}],
      placeholder: '请选择铸坯编号',
      options: prdNoListData.value
    },
    {
      label: '质量等级',
      field: 'qualityLevel',
      type: 'select',
      clearable: true,
      width: '300px',
      rules: [{required: true,message: '请选择质量等级',trigger: 'change'}],
      placeholder: '请选择质量等级',
      options: qualityLevel.value
    },
    {
      label: '质检时间',
      field: 'qualityControlTime',
      type: 'date',
      enum: 'datetime',
      width: '300px',
      clearable: true,
      rules: [{required: true,message: '请输入质检时间',trigger: 'change'}],
      placeholder: '请输入质检时间',
    },
    {
      label: '缺陷类型',
      field: 'defectType',
      type: 'select',
      clearable: true,
      width: '300px',
      rules: [{required: true,message: '请选择缺陷类型',trigger: 'change'}],
      placeholder: '请选择缺陷类型',
      options: defectType.value
    },
    {
      label: '缺陷长度',
      field: 'defectLength',
      append: 'mm',
      width: '300px',
      rules: [{pattern: /(^[+]?[0-9]{1,5})(?!0+$)+(\.[0-9]{1,2})?$/, message: '请输入十万以内的正数，最多保留两位小数',trigger: 'blur'}],
      placeholder: '请输入缺陷长度'
    },
    {
      label: '缺陷深度',
      field: 'defectDepth',
      append: 'mm',
      width: '300px',
      rules: [{pattern: /(^[+]?[0-9]{1,5})(?!0+$)+(\.[0-9]{1,2})?$/, message: '请输入十万以内的正数，最多保留两位小数',trigger: 'blur'}],
      placeholder: '请输入缺陷深度'
    },
    {
      label: '缺陷宽度',
      field: 'defectWidth',
      append: 'mm',
      width: '300px',
      rules: [{pattern: /(^[+]?[0-9]{1,5})(?!0+$)+(\.[0-9]{1,2})?$/, message: '请输入十万以内的正数，最多保留两位小数',trigger: 'blur'}],
      placeholder: '请输入缺陷宽度'
    },
    {
      label: '缺陷位置',
      field: 'defectLocation',
      append: 'mm',
      tooltip: '此处指缺陷距离头部位置',
      rules: [
        {required: true,message: '请输入缺陷位置',trigger: 'blur'},
        {pattern: /(^[+]?[0-9]{1,5})(?!0+$)+(\.[0-9]{1,2})?$/, message: '请输入十万以内的正数，最多保留两位小数',trigger: 'blur'}
      ],
      width: '300px',
      placeholder: '请输入缺陷位置'
    },
    {
      label: '缺陷描述',
      field: 'defectDesc',
      type: 'textarea',
      width: '690px',
      max: 200,
      placeholder: '请输入缺陷描述'
    },
    {
      label: '缺陷图片',
      type: 'imageUpload',
      field: 'imgInfos',
      limit: 10,
      uploadType: 'picture-card', // 上传组件的展示类型
      width: '690px',
    },
  ])
  // abnormal 开头为异常事件记录页面用配置
  const abnormalSearchList = ref([
    {
      label: '浇次',
      field: 'castTimesNo',
      // type: 'select',
      clearable: true,
      width: '340px',
      placeholder: '请输入浇次',
      // options: castTimesNoListData.value
    },
    {
      label: '事件标题',
      field: 'abnormalEventTitle',
      width: '340px',
      clearable: true,
      placeholder: '请输入事件标题'
    },
    {
      label: '记录员',
      field: 'operator',
      width: '340px',
      clearable: true,
      placeholder: '请输入记录员',
    },
    {
      label: '事件时刻',
      field: 'abnormalEventTimeRange',
      width: '340px',
      type: 'date',
      enum: 'daterange', // 其他类型枚举 week, month, year, date, daterange
      placeholder: '开始日期-结束日期' // 若选择框枚举类型为daterange， 此值接受 a-b 式截取提示内容展示
    }
  ])
  const abnormalBtnList = ref([
    { label: '异常事件录入', type: 'primary', icon:'Plus', met: 'addAbnormal', hasPermi:'business:eventInformation:add' },
    { label: '批量删除', type: 'danger', icon:'Delete', met: 'abnormalBatchDelete', hasPermi:'business:eventInformation:remove' },
  ])
  const abnormalColumns = ref([
    {
      label: "浇次",
      prop: "castTimesNo",
      minWidth: 100
    },
    {
      label: "铸流号",
      prop: "prdStrandNo",
      minWidth: 100
    },
    {
      label: "事件时刻",
      prop: "abnormalEventTime",
      minWidth: 160,
      sort: true,
      slots: (row) => {
        let arr = row.abnormalEventTime.split(':')
        arr.pop()
        return <span>{ arr.join(':') }</span>
      }
    },
    {
      label: "事件标题",
      prop: "abnormalEventTitle",
      minWidth: 160
    },
    {
      label: "事件描述",
      prop: "abnormalEventDesc",
      tooltip:true,
      minWidth: 160
    },
    {
      label: "记录员",
      prop: "operator",
      minWidth: 100
    },
    {
      label: "创建时间",
      prop: "createTime",
      sort: true,
      minWidth: 160
    },
    {
      label: "最后修改时间",
      prop: "updateTime",
      sort: true,
      minWidth: 160
    },
    {
      label: "操作",
      minWidth: 220,
      fixed:'right',
      slots: (row) => {
        return <>
          <el-button type="primary" link onClick={() => abnormalViewFn.value(row)} v-hasPermi={['business:eventInformation:view']}>详情</el-button>
          <el-button type="primary" link onClick={() => abnormalEditFn.value(row)} v-hasPermi={['business:eventInformation:edit']}>修改</el-button>
          <el-button type="danger" link onClick={() => abnormalDeleteFn.value(row)} v-hasPermi={['business:eventInformation:remove']}>删除</el-button>
        </>
      }
    },
  ])
  const abnormalPageSet = ref({
    pageNum: 1,
    pageSize: 10,
    total:0
  })
  const abnormalFieldList = ref([
    {
      label: '记录员',
      field: 'operator',
      width: '300px',
      disabled: true,
      placeholder: '请输入记录员'
    },
    {
      label: '浇次',
      field: 'castTimesNo',
      type: 'select',
      clearable: true,
      width: '300px',
      rules: [{required: true,message: '请选择浇次',trigger: 'change'}],
      placeholder: '请选择浇次',
      options: castTimesNoListData.value
    },
    {
      label: '铸流号',
      field: 'prdStrandNo',
      type: 'select',
      clearable: true,
      width: '300px',
      // rules: [{required: true,message: '请选择铸流号',trigger: 'change'}],
      placeholder: '请选择铸流号',
      options: materialCastingType.value
    },
    {
      label: '事件时刻',
      field: 'abnormalEventTime',
      type: 'date',
      enum: 'datetime',
      valueFormat: 'YYYY-MM-DD HH:mm',
      format: 'YYYY-MM-DD HH:mm',
      width: '300px',
      rules: [{required: true,message: '请选择事件时刻',trigger: 'change'}],
      placeholder: '请选择事件时刻'
    },
    {
      label: '事件标题',
      field: 'abnormalEventTitle',
      width: '690px',
      max: 20,
      rules: [{required: true,message: '请输入事件标题',trigger: 'change'}],
      placeholder: '请输入事件标题'
    },
    {
      label: '事件描述',
      field: 'abnormalEventDesc',
      type: 'textarea',
      width: '690px',
      max: 200,
      placeholder: '请输入事件描述'
    },
    {
      label: '图片',
      field: 'imgInfos',
      type: 'imageUpload',
      uploadType: 'picture-card', // 上传组件的展示类型
      width: '690px',
    },
  ])

  // 表格表单公共配置
  const tableOption = ref({
    checkbox: true, // 是否展示多选框
    index: false, // 是否展示序号
    fixed: "left", // 是否将多选框及序号列固定在最左侧
    stripe: true, // 是否斑马纹表格
    border: false, // 是否表格边框
    pageHidden: false, // 是否隐藏分页
    maxHeight: '58vh'
  })
  const formOption = ref({
    inline: true,  // 是否行内模式表单
    labelPosition: 'top',
    labelWidth: '100px',  // 表单标签宽度
    scrollToError: true,  // 自动滚动到校验失败的第一项
    btnCenter: true, // 表单的查询提交等按钮是否展示在中间，弹窗通用展示中间
    btn: [ 'submit', 'cancel' ] // 按钮展示组
  })
  return {
    feedSearchList,
    feedBtnList,
    feedColumns,
    feedPageSet,
    feedFieldList,
    qualitySearchList,
    qualityBtnList,
    qualityColumns,
    qualityPageSet,
    qualityFieldList,
    abnormalSearchList,
    abnormalBtnList,
    abnormalColumns,
    abnormalPageSet,
    abnormalFieldList,
    tableOption,
    formOption
  }
}
