<template>
  <Dialog
    v-model="dialogVisible"
    title="标本出库申请驳回原因："
    width="800"
    v-loading="formLoading">
    <el-form
      ref="initiativeFormRef"
      v-loading="formLoading"
      v-if="outboundData"
     >
<text>{{ outboundData.processInstanceId }}</text>
    </el-form>
    <template #footer>
      <el-button @click="close">关闭</el-button>
    </template>
  </Dialog>

</template>


<script setup lang="ts">
import {ref} from "vue";
import {SpecimenOutboundApi} from '@/api/museums/specimenoutbound'

defineOptions({name: 'InitiativeProcessInstance'})
const formLoading = ref(false) // 表单的加载中
const dialogVisible = ref(false) // 弹窗的是否展示
const formType = ref('')
const {query} = useRoute() // 查询参数
let outboundData = ref(null)
/** 打开弹窗 */
const open = async (type: string, id?: number) => {
  dialogVisible.value = true
  formType.value = type
  if (id) {
    formLoading.value = true
    try {
      const data = await SpecimenOutboundApi.getSpecimenOutboundPage(id)
      formData.value = data;
      console.log(data)
    } finally {
      formLoading.value = false
    }
  }
}
defineExpose({open}) // 提供 open 方法，用于打开弹窗
/** 关闭弹窗 */
const close = () => {
  dialogVisible.value = false;
};

const formData = ref({
  infoId: undefined,
  processInstanceId: undefined,
})

/**查看驳回信息*/
const fetchData = async () => {
  try {
    console.log(query.dataId)
    let res: any = await SpecimenOutboundApi.getSpecimenOutboundPage(query.dataId)
    console.log(res)
    outboundData.value = res
    console.log(outboundData.value)
  }  finally {
  }
}

// // 在组件加载时获取数据
onMounted(async () => {
  await fetchData()

})
</script>
