<template>
  <div class="screen-common-component">
    <ScreenComHeader :module-id="moduleId" title="今日检验任务" />
    <dv-scroll-board
      :config="config"
      style="width: 100%; height: calc(100% - 32px)"
    />
  </div>
</template>

<script lang="ts" setup>
import ScreenComHeader from "@/views/screens/configs/screenComHeader.vue";
import { todayInspectionDetail } from "@/api/screens";

const config = ref({});

const props = defineProps({
  moduleId: {
    type: String,
    required: true,
  },
});

onMounted(async () => {
  let res = await todayInspectionDetail();
  if (res.data.length > 0) {
    let dicts = {
      formName: "检验名称",
      materialCode: "产品编号",
      materialName: "产品名称",
      passNum: "合格数量",
      unPassNum: "不合格数量",
      workOrderCode: "工单编号",
    };

    let bigData: any[] = [];
    res.data.forEach((item: any) => {
      let row: any[] = [];
      Object.keys(dicts).forEach((key) => {
        row.push(item[key]);
      });

      bigData.push(row);
    });

    config.value = {
      header: Object.values(dicts),
      data: bigData,
      // index: true,
      // columnWidth: [50],
      align: ["left"],
      carousel: "page",
      click: (row: any, index: number) => {
        console.log("mouseover", row, index);
      },
    };
  }
});
</script>
