<template>
  <div class="mainContentBox">
    <el-row :gutter="20">
      <el-col :span="6" class="elColClasss">
        <Orders :ordersSum="ordersSum" @getindex="setSelectOrderIndex" />
      </el-col>
      <el-col :span="6" class="elColClasss">
        <div class="grid-content ep-bg-purple">
          <Processes />
        </div>
      </el-col>
      <el-col :span="12" class="elColClasss">
        <div class="grid-content ep-bg-purple">
          <CurrentProduction />
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script lang="ts" setup>
import { onMounted, provide, ref } from "vue";
import Orders from "@/views/process/orders.vue";
import Processes from "@/views/process/processes.vue";
import CurrentProduction from "@/views/process/currentProduction.vue";
import { getOrders } from "@/api/process";

defineOptions({ name: "ProcessMain" });
//未完成订单数组
const ordersDataArray = ref([]);
//未完成任务总数
const ordersSum = ref(0);
// 获取选中的Index
const selectOrderIndex = ref(NaN);
const setSelectOrderIndex = (value: number) => {
  selectOrderIndex.value = value;
};
provide("ordersDataArray", ordersDataArray);
provide("selectOrderIndex", selectOrderIndex);
//获取未完成订单的参数
const ordersQuery = ref({
  orders: [],
  pageNo: 1,
  pageSize: 9999,
});

//获取未完成订单Data
const getOrdersData = async () => {
  const { code, data } = await getOrders(ordersQuery.value);
  if (code == "200") {
    ordersDataArray.value = data.records;
    ordersSum.value = data.totalCount;
  }
};
onMounted(() => {
  getOrdersData();
});
</script>

<style lang="scss" scoped>
.elColClasss {
  height: calc(100vh - 130px);
}
</style>
