<template>
  <div class="screen-common-component">
    <ScreenComHeader
      :module-id="moduleId"
      align="start"
      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 { productionPlan } from "@/api/screens";
import { useDictionaryStore } from "@/store";
const bigScreenData: any = inject("bigScreenData");
const config = ref({});
const dictS = useDictionaryStore();

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

onMounted(async () => {
  let res = await productionPlan();
  if (res.data.length > 0) {
    let dicts = {
      orderName: `<span style='font-size:${bigScreenData.value.fontSize * 2.3}px'>订单名称</span>`,
      orderNum: `<span style='font-size:${bigScreenData.value.fontSize * 2.3}px'>订单数量</span>`,
      orderState: `<span style='font-size:${bigScreenData.value.fontSize * 2.3}px'>订单状态</span>`,
      materialName: `<span style='font-size:${bigScreenData.value.fontSize * 2.3}px'>物料名称</span>`,
      projectCode: `<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.orderName}</span>`,
        `<span style='font-size:${bigScreenData.value.fontSize * 2}px'>${item.orderNum}</span>`,
        `<span style='font-size:${bigScreenData.value.fontSize * 2}px'>${dictS.getLableByValue("plan_order_state", item.orderState)}</span>`,
        `<span style='font-size:${bigScreenData.value.fontSize * 2}px'>${item.materialName}</span>`,
        `<span style='font-size:${bigScreenData.value.fontSize * 2}px'>${item.projectCode}</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>
