

<template>
  <n-card>
    <n-card style="margin: 12px 0px">
      <n-grid :cols="2" style="margin: 10px">
        <n-gi>
          <span class="pgClass">物料名称：</span>
          <span>{{props.baseInfo.materialName}}</span>
        </n-gi>
        <n-gi>
          <span class="pgClass">物料编号：</span>
          <span>{{props.baseInfo.materialCode}}</span>
        </n-gi>
      </n-grid>
      <n-grid :cols="2" style="margin: 10px">
        <n-gi>
          <span class="pgClass">工序名称：</span>
          <span>{{props.baseInfo.processName}}</span>
        </n-gi>
        <n-gi>
          <span class="pgClass">派工编号：</span>
          <span>{{props.baseInfo.assingCode}}</span>
        </n-gi>
      </n-grid>
    </n-card>
    <n-data-table
        :columns="reportRecordsColums"
        size="small"
        :data="props.submitLogList"
        remote
        :scroll-x="600"
    />

  </n-card>
</template>
<script setup lang="ts">
import { NCard, NDataTable, NGi,NTag, NGrid,DataTableColumns} from "naive-ui";
import {onMounted, ref,h} from "vue";
import { dictDataApi } from '@/api/org'
import { SubmitLog } from '@/api/submitLog'

const props =defineProps(
    {
      submitLogList:Object,
      baseInfo:Object
    }
)

//汇报状态字典
const submitStatusOptions = ref<{ label: string; value: any ;class:any}[]>([])


//汇报信息表格
const reportRecordsColums:DataTableColumns<SubmitLog> = [

  { title: '汇报数量', key: 'quantity',align: 'center'},
  { title: '汇报人', key: 'userName',align: 'center' },
  { title: '派工状态', key: 'submitStatus',align: 'center',
    render: (row) => {
      const val = row.submitStatus
      const opt = submitStatusOptions.value.find(o => o.value === val || String(o.value) === String(val))
      if (!opt) return val ?? '-'

      return h(NTag, { type: opt.class, size: 'small' }, { default: () => opt.label })
    }
  }
]

// 加载字典选项
async function loadDictOptions() {
  try {
    const data = await dictDataApi.listByType('submit_status')
    submitStatusOptions.value = data.map(d => ({ label: d.dictLabel, value: (Number(d.dictValue) || d.dictValue),class:d.listClass }))
  }catch {}
}



onMounted(()=>{
  loadDictOptions()
})
</script>
<style scoped>

</style>