<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 { qualityException } from "@/api/screens";

const config = ref({});
const bigScreenData: any = inject("bigScreenData");
const props = defineProps({
  moduleId: {
    type: String,
    required: true,
  },
});

onMounted(async () => {
  let res = await qualityException();
  if (res.data.length > 0) {
    let dicts = {
      materlName: `<span style='font-size:${bigScreenData.value.fontSize * 2.3}px'>物料名称</span>`,
      // orderCode: "编码",
      materialCode: `<span style='font-size:${bigScreenData.value.fontSize * 2.3}px'>物料编码</span>`,
      workOrderCode: `<span style='font-size:${bigScreenData.value.fontSize * 2.3}px'>工单编号</span>`,
    };

    let bigData: any[] = [];
    res.data.forEach((item: any) => {
      let row = [
        `<span style='font-size:${bigScreenData.value.fontSize * 2}px'>${item.materlName}</span>`,
        `<span style='font-size:${bigScreenData.value.fontSize * 2}px'>${item.materialCode}</span>`,
        `<span style='font-size:${bigScreenData.value.fontSize * 2}px'>${item.workOrderCode}</span>`,
      ];
      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>
