<template>
  <w-splitter :model-value="46" horizontal disable reverse unit="px" style="height: 100%">
    <template #before>
      <Layout class="h-full"></Layout>
    </template>

    <template #after>
      <div class="p-1 flex justify-end gap-x-4">
        <AnnotationButton></AnnotationButton>
        <!-- <TestCalcButton></TestCalcButton> -->
        <NextButton></NextButton>
        <WorkflowButton></WorkflowButton>
      </div>
    </template>
  </w-splitter>
</template>
<script setup lang="ts">
import { VueTools } from 'platform-core';
import { getCurrentInstance, onMounted, provide } from 'vue';
import NextButton from '@/views/custRating/company/components/buttons/NextButton.vue';
import Layout from './Layout.vue';
import TestCalcButton from '@/views/custRating/company/components/buttons/TestCalcButton.vue';
import { Rating } from '@/views/custRating/company/ts/Rating';
import WorkflowButton from '@/views/custRating/company/components/buttons/WorkflowButton.vue';
import AnnotationButton from '@/views/custRating/company/components/buttons/AnnotationButton.vue';

const props = defineProps({
  ratingData: {
    type: Object,
    default: () => {
      return {};
    },
  },
  readMode: {
    type: Boolean,
    default: false,
  },
});
const emit = defineEmits(['afterComplete']);

const rating = new Rating(props.ratingData, props.readMode);
await rating.dictionary.load();
await rating.enum.load();
await rating.systemParameter.load();

onMounted(() => {
  rating.step.setCurrStep(rating.ratingData.value['currentStep']);
});

// 获得自身实例
const instance = getCurrentInstance();
// 将对外暴露API添加至自身实例中
VueTools.expose2Instance(instance);
// 设置到评级类中
rating.setInstance(instance);

provide('rating', rating);
</script>
