<template>
  <div class="screen-common-component">
    <ScreenComHeader :module-id="moduleId" title="成品入库情况" />
    <dv-scroll-board
      :config="config"
      style="width: 100%; height: calc(100% - 32px)"
      @mouseover="tableHover"
    />
  </div>
</template>

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

const config = ref({});

const props = defineProps({
  moduleId: {
    type: String,
    required: true,
  },
});
const bigScreenData: any = inject("bigScreenData");
onMounted(async () => {
  let res = await productStorageFinishedSituation();
  if (res.data.length > 0) {
    let dicts = {
      workOrderCode: `<span style='font-size:${bigScreenData.value.fontSize * 1.5}px'>批号</span>`,
      materialModel: `<span style='font-size:${bigScreenData.value.fontSize * 1.5}px'>产品型号</span>`,
      planNum: `<span style='font-size:${bigScreenData.value.fontSize * 1.5}px'>数量</span>`,
      inventoryNum: `<span style='font-size:${bigScreenData.value.fontSize * 1.5}px'>入库数</span>`,
    };

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

const tableHover = (data: any) => {
  // console.log("mouseover", data.row[data.columnIndex]);
};
</script>
