<template>
  <a-modal
    ref="theModal"
    v-model:visible="visible"
    title="报告说明信息页"
    okText="确定"
    @ok="visible = false"
  >
    <a-form>
      <a-form-item label="报告类别">
        <a-input disabled :value="keyName"></a-input>
      </a-form-item>
      <a-form-item label="系统说明">
        <a-textarea readonly :value="keyDetail"></a-textarea>
      </a-form-item>
    </a-form>
  </a-modal>
</template>

<script setup lang="ts">
import { getRootOrgSettingsOfKey } from "@/api/rootOrgPage";
import { ORG_GLOSSARY } from "@/constants/constants";
import EventBus from "@/plugins/eventBus";
import { useMainStore } from "@/store";
import { watch } from "vue";

const store = useMainStore();
// const { keyCode } = defineProps<{ keyCode: string }>();
let keyCode = $ref("");
EventBus.on("SHOW_SETTING", (e) => {
  keyCode = e as string;
  keyName = ORG_GLOSSARY[keyCode as keyof typeof ORG_GLOSSARY];
  visible = true;
});
let keyName = $ref("");
let keyDetail = $ref("");
let theModal = $ref(null);

let visible = $ref(false);

watch(
  () => keyCode,
  async () => {
    const res = await getRootOrgSettingsOfKey(
      store.userInfo.rootOrgId,
      keyCode
    );
    keyDetail = res.data;
    visible = true;
  }
);
</script>
