<template>
  <a-modal
    v-model:visible="visible"
    title="选择对比项目"
    okText="确定"
    cancelText="取消"
    @ok="handleOk"
  >
    <a-form :labelCol="{ span: 4 }">
      <a-form-item>
        <ProjectsSelect
          v-model:value="projectId"
          :rootOrgId="rootOrgId"
          placeholder="请选择对比项目"
          style="width: 400px"
        />
      </a-form-item>
    </a-form>
  </a-modal>
</template>

<script setup lang="ts">
import { useMainStore } from "@/store";
import { onMounted } from "vue";

const emit = defineEmits(["confirm"]);

let rootOrgId = $ref(undefined as unknown as number);
const store = useMainStore();

let visible = $ref<boolean>(false);
let projectId = $ref<number>();

const showModal = () => {
  visible = true;
};
defineExpose({ showModal });

onMounted(() => {
  rootOrgId = store.userInfo.rootOrgId;
});

function handleOk() {
  emit("confirm", projectId);
  visible = false;
}
</script>
