<!-- 检定记录 -->
<script lang="ts" setup name="MeasureRecords">
import type { TableColumn } from '@/components/NormalTable/table_interface'
import { measureRecordsById } from '@/api/business/schedule/task'

const props = defineProps({
  // 样品id
  sampleId: {
    type: String,
    required: true,
  },
  // 客户id
  customerId: {
    type: String,
    required: true,
  },
})

// 查询条件
const searchQuery = ref({
  sampleId: props.sampleId,
  customerId: props.customerId,
})

// 检定记录
interface SimpleMeasureRecord {
  orderCode: string // 委托单编号
  orderTime: string // 委托单日期
  customerCode: string // 委托人代码
  customerName: string // 委托人名称
  deliverer: string // 送检人
  deliverTime: string // 送检日期
}

// 表格表头
const columns = ref<TableColumn[]>([
  { text: '委托单编号', value: 'orderCode', align: 'center' },
  { text: '委托单日期', value: 'orderTime', align: 'center' },
  { text: '委托方代码', value: 'customerCode', align: 'center' },
  { text: '委托方名称', value: 'customerName', align: 'center' },
  { text: '送检人', value: 'deliverer', align: 'center' },
  { text: '送检日期', value: 'deliverTime', align: 'center' },
])

// 证书列表
const list = ref<SimpleMeasureRecord[]>([])
const total = ref(0)
// 加载状态
const loading = ref(false)
// 查找证书状态及列表
function fetchData() {
  loading.value = true
  list.value = []
  measureRecordsById({ ...searchQuery.value }).then((res) => {
    list.value = res.data.rows
  })
  loading.value = false
}
fetchData()
</script>

<template>
  <div>
    <normal-table :data="list" :total="total" :columns="columns" :list-loading="loading" :pagination="false" />
  </div>
</template>
