<!-- SidePanelItem.vue -->
<template>
  <div>
    <SidePanelItem title="基本情况介绍" :shrink="true">
      <p v-if="title_text" class="basic_body1">{{ title_text }}</p>
      <div v-else class="zanwushujv"><a-empty /></div>
    </SidePanelItem>
  </div>
</template>

<script lang="ts" setup>
import { ref, onMounted, watch } from "vue";

import { useJidiSelectEventStore } from "@/store/modules/jidiSelectEvent";
import SidePanelItem from "@/components/SidePanelItem/index.vue";
import { getBaseWbsb } from "@/api/home";

const JidiSelectEventStore = useJidiSelectEventStore();
// 定义组件名（便于调试和递归）
defineOptions({
  name: "jidiInfoMod",
});
const initText = () => {
  const params = {
    filter: {
      logic: "and",
      filters: [
        {
          field: "wbsCode",
          operator: "eq",
          dataType: "string",
          value: JidiSelectEventStore.selectedItem.wbsCode,
        },
        { field: "wbsType", operator: "eq", dataType: "string", value: "PSB" },
      ],
    },
  };
  getBaseWbsb(params).then((res) => {
    console.log(res);
    title_text.value = res.data.data[0].introduce;
    // debugger
  });
};
const title_text = ref("");
watch(
  () => JidiSelectEventStore.selectedItem,
  (newVal) => {
    initText();
  },
  { deep: true, immediate: true  }
);

// 页面加载时执行的逻辑
onMounted(() => {
  initText();
  console.log(JidiSelectEventStore.selectedItem);
  
});
</script>

<style lang="scss">
.zanwushujv {
  display: flex;
  align-items: center;
  justify-content: center;
}

.basic_body1 {
  width: 100%;
  line-break: anywhere;
}
</style>
