<template>
  <el-dialog title="历史记录" v-model="visible" width="800px" append-to-body draggable>
    <el-form ref="dialogForm" class="master-container" :model="queryParams" style="align-items: center;">
      <div style="display: flex;">
      </div>
    </el-form>
    <el-table v-loading="loading" row-key="deptId" :data="dataList" height="400px">
      <el-table-column label="行号" type="index" width="50" align="center" />
      <el-table-column label="生成日期" prop="printDate" width="150" align="center" />
      <el-table-column label="部门名称" prop="deptName" width="150" align="center" />
      <el-table-column label="包装线名" prop="packageResourceGroupName" align="center" />
      <el-table-column label="包装线号" prop="packageLineNo" width="150" align="center" />
      <el-table-column label="开始编码" prop="startCode" width="150" align="center" />
      <el-table-column label="结束编码" prop="endCode" width="150" align="center" />
      <el-table-column label="包装箱号" prop="packageCode" width="150" align="center" />
      <el-table-column label="包装规格" prop="packageStandard" width="150" align="center" />
      <el-table-column label="打印时间" prop="printTime" width="150" align="center" />
    </el-table>
  </el-dialog>
</template>
<script setup>
import { listCertificate, getDayworkList } from '@/api/business/certificate'
const emit = defineEmits(['multipleChoice', 'singleChoice'])
const { proxy } = getCurrentInstance()
const props = defineProps({
  multiple: {
    default: false,
    type: Boolean
  }
})

const { multiple } = toRefs(props)

const loading = ref(false)
const visible = ref(false)

const dataList = ref([])

/** 设备档案 查询对象 */
const queryParams = ref({
})
/***********************  方法区  ****************************/
/** 打开抽屉 */
const open = (data) => {
  visible.value = true
  if (data) {
    queryParams.value = { ...queryParams.value, ...data }
  }
  loadData()
}

const loadData = () => {
  loading.value = true
  listCertificate(queryParams.value).then((res) => {
    dataList.value = res.rows
    //dataTotal.value = res.total
    loading.value = false
  })
}

const handleRefreshDetail = () => {
  loadData()
}

const handleSelectDept = (data) => {
  if (multiple.value) {
    emit('multipleChoice', data)
  }
  else {
    emit('singleChoice', data)
  }

  proxy.$refs.dialogForm.resetFields()
  visible.value = false
}
const handleSearch = () => {
  loadData()
}

/** 暴露给父组件的方法 */
defineExpose({
  open
})
</script>
