<template>
  <!-- 列表 -->
  <ContentWrap>
    <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
      <el-table-column label="生产线" align="center" prop="pipelineName" />
      <el-table-column label="派工数量" align="center" prop="paigongNum" />
      <el-table-column label="是否试生产" align="center" prop="isPreProduction" >
      <template #default="scope">
          <dict-tag :type="DICT_TYPE.MES_PRE_PRODUCTION" :value="scope.row.isPreProduction" />
        </template>
      </el-table-column> 
      <el-table-column
        label="派工时间"
        align="center"
        prop="paigongTime"
        :formatter="dateFormatter"
        width="180px"
      />
      <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>
</template>

<script setup lang="ts">
import { dateFormatter } from '@/utils/formatTime'
import { PaigongRecordApi, PaigongRecordVO } from '@/api/mes/paigongrecord'
import { DICT_TYPE } from '@/utils/dict'

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

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

const loading = ref(true) // 列表的加载中
const list = ref<PaigongRecordVO[]>([]) // 列表的数据
const total = ref(0) // 列表的总页数
const queryParams = reactive({
  pageNo: 1,
  pageSize: 10,
  planId: undefined,
  pipeline: undefined,
  paigongNum: undefined,
  isPreProduction: undefined,
  paigongTime: [],
  createTime: [],
})


/** 查询列表 */
const getList = async () => {
  loading.value = true
  try {
    list.value = await PaigongRecordApi.getPaigongRecordListByPlanId(props.planId)
  } finally {
    loading.value = false
  }
}



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