<template>
  <!-- 列表 -->
  <ContentWrap>
    <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
      <el-table-column label="合格数量" prop="num" align="center"/>
      <el-table-column label="不合格数量" prop="noPassNum" align="center"/>
      <el-table-column label="原因" prop="remark" align="center"/>
      <el-table-column
        label="报工时间"
        align="center"
        prop="baogongTime"
        :formatter="dateFormatter"
        width="180px"
      />
      <el-table-column label="报工人" prop="creator" align="center"/>
      <!-- <el-table-column
        label="创建时间"
        align="center"
        prop="createTime"
        :formatter="dateFormatter"
        width="180px"
      /> -->
    </el-table>
    <!-- 分页 -->
    <Pagination
      :total="total"
      v-model:page="queryParams.pageNo"
      v-model:limit="queryParams.pageSize"
      @pagination="getList"
    />
  </ContentWrap>

  <!-- 表单弹窗：添加/修改 -->
  <BaogongRecordForm ref="formRef" @success="getList" />
</template>

<script setup lang="ts">
import { dateFormatter } from '@/utils/formatTime'
import { BaogongRecordApi, BaogongRecordVO } from '@/api/mes/baogongrecord'

/** 报工 列表 */
defineOptions({ name: 'BaogongRecordList' })


const props = defineProps<{
  planId?: number // 计划ID（主表的关联字段）
}>()

const message = useMessage() // 消息弹窗
const { t } = useI18n() // 国际化

const loading = ref(true) // 列表的加载中
const list = ref<BaogongRecordVO[]>([]) // 列表的数据
const total = ref(0) // 列表的总页数
const queryParams = reactive({
  pageNo: 1,
  pageSize: 10,
  planId: props.planId,
  num: undefined,
  baogongTime: [],
  createTime: [],
})

/** 查询列表 */
const getList = async () => {
  loading.value = true
  try {
    const data = await BaogongRecordApi.getBaogongRecordPage(queryParams)
    list.value = data.list
    total.value = data.total
  } finally {
    loading.value = false
  }
}



/** 初始化 **/
onMounted(() => {
  getList()
})
</script>