nCheckReport.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <template>
  2. <div style="margin-top: -20px">
  3. <div style="margin-bottom:10px;text-align: right">
  4. <el-button icon="Download" @click="exportReport">导出报告</el-button>
  5. </div>
  6. <el-table :data="reportData" style="width: 100%;" border :span-method="spanMethod">
  7. <el-table-column prop="className" label="分类" width="180" align="center"/>
  8. <el-table-column prop="checkName" label="巡检项"/>
  9. <el-table-column label="巡检结果" width="160" align="center" prop="resultL" />
  10. <el-table-column prop="remark" label="备注" align="center" width="160">
  11. <template #default="{row}">
  12. <span :style="`color:${row.resultR === '正常'?'#1ab43f':'#e43'}`">
  13. {{ row.resultR || "-" }}
  14. </span>
  15. </template>
  16. </el-table-column>
  17. </el-table>
  18. </div>
  19. </template>
  20. <script setup lang="ts">
  21. import {chkcResult} from "@/api/check/chkc"
  22. import axios from "axios";
  23. import {onMounted} from "vue";
  24. import { getToken } from '@/utils/auth'
  25. const props = defineProps({
  26. crId: {
  27. type: Number,
  28. default: 0
  29. },
  30. spanMethod:{
  31. type:Function
  32. }
  33. })
  34. const reportData = ref([])
  35. const exportReport=async ()=>{
  36. const response = await axios({
  37. url: import.meta.env.VITE_APP_BASE_API+'/check/chkc/export/' + props.crId,
  38. method: 'GET',
  39. responseType: 'blob',
  40. headers: { 'Authorization': 'Bearer ' + getToken() }
  41. });
  42. const url = window.URL.createObjectURL(new Blob([response.data]));
  43. const link = document.createElement('a');
  44. link.href = url;
  45. link.setAttribute('download', 'report.docx');
  46. document.body.appendChild(link);
  47. link.click();
  48. link.parentNode.removeChild(link);
  49. }
  50. const getReport = async () => {
  51. const res = await chkcResult(props.crId)
  52. reportData.value = res.data.detailList
  53. }
  54. onMounted(()=>{
  55. getReport()
  56. })
  57. </script>
  58. <style scoped lang="scss">
  59. </style>