<template>
  <MindmapModal
    ref="mindmapModalRef"
    :hide-close="true"
    :default-data="mindmapData"
    defaultOpen
    @refresh="getData"
  />
</template>

<script setup lang="ts">
import { onMounted, ref } from 'vue';
import MindmapModal from '../excel/MindmapModal.vue';
import { useRoute } from 'vue-router';

const mindmapModalRef = ref<InstanceType<typeof MindmapModal>>();
const route = useRoute();
const mindmapData = ref<any>();

const getData = () => {
  if (!route.query?.id) return;
  window.parent?.BpmTools?.program(
    {
      interfaceCode: 'Common.getBOMAiImageData',
      bom_id: route.query.id,
    },
    (res: any) => {
      if (res?.code) {
        mindmapData.value = res?.data;
      }
    }
  );
};

onMounted(() => {
  // 测试接口
  // fetch(`https://sl-yf-bommgr-admin-dev.shalu.com/api/module/Invoke`, {
  //   method: "POST",
  //   headers: {
  //     'Authorization': "bpm_client_1419718313868529664",
  //     "content-type": "application/json;charset=UTF-8",
  //   },
  //   body: JSON.stringify({
  //     interfaceCode: "Common.getBOMAiImageData",
  //     bom_id: "7f492047-5127-45fc-9398-b5effd640f79",
  //   }),
  // })
  //   .then((res) => res.json())
  //   .then((res) => {
  //     console.log("res", res);
  //     mindmapData.value = res.result.data;
  //   });

  getData();
});
</script>

<style scoped></style>
