<template>
  <div class="app-container">
    <el-card shadow="never">
      <template #header>
        <div class="card-header">
          <span>督办详情</span>
          <el-button plain icon="ArrowLeft" @click="goBack">返回</el-button>
        </div>
      </template>
      <el-descriptions :column="2" border>
        <el-descriptions-item label="隐患名称" :span="2">{{ form.hiddName }}</el-descriptions-item>
        <el-descriptions-item label="隐患等级">
          <dict-tag :options="hidd_grad" :value="form.hiddGrad" />
        </el-descriptions-item>
        <el-descriptions-item label="隐患状态">
          <dict-tag :options="hidd_stat" :value="form.hiddStat" />
        </el-descriptions-item>
        <el-descriptions-item label="督办文号">{{ form.supLareId }}</el-descriptions-item>
        <el-descriptions-item label="督办日期">{{ form.supDate }}</el-descriptions-item>
        <el-descriptions-item label="督办单位">{{ form.supWiunName || form.supWiunCode }}</el-descriptions-item>
        <el-descriptions-item label="督办负责人">{{ form.supLegPers }}</el-descriptions-item>
        <el-descriptions-item label="整改期限">{{ form.rectPeri }}</el-descriptions-item>
        <el-descriptions-item label="是否挂牌">
          <dict-tag :options="sys_yes_no" :value="form.isList" />
        </el-descriptions-item>
        <el-descriptions-item label="督办意见" :span="2">{{ form.supOpin }}</el-descriptions-item>
        <el-descriptions-item label="备注" :span="2">{{ form.note }}</el-descriptions-item>
        <el-descriptions-item label="督办附件" :span="2">
          <div v-if="form.medGuid">
            <el-link type="primary" :href="`/common/download?fileName=${form.medTitl}&delete=true`">
              <el-icon><Download /></el-icon>
              {{ form.medTitl || '附件' }}
            </el-link>
          </div>
          <span v-else style="color: #909399">暂无附件</span>
        </el-descriptions-item>
      </el-descriptions>
    </el-card>
  </div>
</template>

<script setup name="HiddSupDetail">
import { getBisMajHiddSup } from "@/api/slaj/hidd"
import { getObjHidd } from "@/api/slaj/hidd"

const { proxy } = getCurrentInstance()
const route = useRoute()
const router = useRouter()
const { hidd_grad, hidd_stat, sys_yes_no } = proxy.useDict("hidd_grad", "hidd_stat", "sys_yes_no")

const form = ref({})

function getInfo() {
  const guid = route.query.guid
  if (guid) {
    getBisMajHiddSup(guid).then(response => {
      form.value = response.data
      if (response.data.hiddGuid) {
        getObjHidd(response.data.hiddGuid).then(hiddRes => {
          form.value = { ...form.value, ...hiddRes.data }
        })
      }
    })
  }
}

function goBack() {
  router.push({ path: '/slaj/hidd/supList' })
}

onMounted(() => {
  getInfo()
})
</script>

<style scoped>
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
</style>
