<!-- 测试、校准或检定合格通知书详情 -->
<script name="SubpackageInformDetail" lang="ts" setup>
import { ElLoading, ElMessage, ElMessageBox } from 'element-plus'
import filePreview from '@/components/filePreview/index.vue'
import DetailReport from '@/components/detailReport/index.vue'
import { getInfo, sendMessage } from '@/api/business/subpackage/inform'
const loading = ref(false) // 表单加载状态
const infoId = ref('') // id
const row = ref('') // 受检单位名称
const printFileName = ref('') // 文件名
const $route = useRoute()
const $router = useRouter()
// --------------------------------------路由参数----------------------------------------------
// 从路由中获取页面类型参数
if ($route.params) {
  if ($route.params.id) {
    infoId.value = $route.params.id as string
  }
}

const handleSendMessage = (row: any) => {
  getInfo({ id: infoId.value }).then((res) => {
    const params = {
      ...res.data,
      noticeUserId: row.id,
      noticeUserName: row.name,
    }
    sendMessage(params).then((res) => {
      if (res.code === 200) {
      // 提示保存成功
        ElMessage.success(`发送到 ${params.customerName} 的 ${params.noticeUserName} 成功`)
      }
      else {
      // 提示失败信息
        ElMessage.error(`通知单发送至受检单位失败：${res.message}`)
      }
    })
  })
}

onMounted(() => {
  row.value = $route.query.row as string // 受检单位名称
})
</script>

<template>
  <detail-report :need-send="true" title="测试、校准或检定合格通知书" @send-message="handleSendMessage" />
</template>

<style lang="scss" scoped>
// 样式
</style>

