<template>
  <div class="screen-common-component">
    <ScreenComHeader :module-id="moduleId" align="start" title="生产计划情况" />
    <dv-scroll-board
      :config="config"
      style="width: calc(100% - 40px); height: calc(100% - 32px)"
    />
  </div>
</template>

<script lang="ts" setup>
import ScreenComHeader from "@/views/screens/configs/screenComHeader.vue";
import { productionPlan, productionPlanList } from "@/api/screens";
import { useDictionaryStore } from "@/store";
const bigScreenData: any = inject("bigScreenData");
const config = ref({});
const dictS = productionPlanList();

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

onMounted(async () => {
  let res = await productionPlan();
  if (res.data.length > 0) {
    let dicts = {
      workOrderCode: `<span style='font-size:${bigScreenData.value.fontSize * 1.5}px'>生产批号</span>`,
      materialName: `<span style='font-size:${bigScreenData.value.fontSize * 1.5}px'>物料名称</span>`,
      materialCode: `<span style='font-size:${bigScreenData.value.fontSize * 1.5}px'>物料型号</span>`,
      number: `<span style='font-size:${bigScreenData.value.fontSize * 1.5}px'>生产数量</span>`,
      operationName: `<span style='font-size:${bigScreenData.value.fontSize * 1.5}px'>工序名称</span>`,
      stationName: `<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.materialName}</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.number}</span>`,
        `<span style='font-size:${bigScreenData.value.fontSize * 1.5}px'>${item.operationName}</span>`,
        `<span style='font-size:${bigScreenData.value.fontSize * 1.5}px'>${item.stationName}</span>`,
      ];
      bigData.push(row);
    });

    config.value = {
      header: Object.values(dicts),
      data: bigData,
      index: true,
      rowNum: 10,
      columnWidth: [50],
      align: ["left"],
      carousel: "page",
    };
  }
});
</script>

<style lang="scss" scoped>
:deep(.ceil) {
  .index {
    background-color: red;
  }
}
</style>
