<script setup lang="ts">
import { nextTick, onMounted, ref, watch } from "vue";
import contentConfig from "./config/content.config";
import { ElOption } from "element-plus";
import dayjs from "dayjs";

const PageName = "dashboard";

const companies = [
  { value: "", label: "所有公司" },
  { value: "GS2302231125079621", label: "业务公司: 百辰" },
  { value: "GS2302231323386950", label: "业务公司: 泓源" },
  { value: "GS2302231124114965", label: "业务公司: 普润&锦兴&知事" }
];

const companyRef = ref<any>(null);

const monthState = ref({ companyNo: "", daytime: "" });

onMounted(() => {
  const daytime = dayjs(new Date()).format("YYYY-MM-DD");
  monthState.value.daytime = daytime;
  monthState.value.companyNo = companies[0].value;
});

watch(
  () => monthState.value,
  ({ daytime, companyNo }) => {
    nextTick(() => companyRef.value.getPageData({ daytime, companyNo }));
  },
  { deep: true, immediate: true }
);
</script>

<template>
  <div w-full>
    <div
      class="flex justify-between px-[15px] pt-[10px] mt-[10px] mb-[-10px] bg-white"
    >
      月度完成情况-业务公司
      <div class="flex">
        <ElDatePicker
          v-model="monthState.daytime"
          :clearable="false"
          placeholder="选择日期"
          value-format="YYYY-MM-DD"
          format="YYYY-MM-DD"
        />

        <!-- <ElSelect v-model="monthState.companyNo" placeholder="业务公司">
          <ElOption
            v-for="option in companies"
            :key="option.value"
            :label="option.label"
            :value="option.value"
          />
        </ElSelect> -->
      </div>
    </div>
    <PageContainer
      :get-content-ref="ref => (companyRef = ref)"
      :contentConfig="contentConfig"
    />
  </div>
</template>
