ReportVue.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <template>
  2. <div>
  3. <div class="bigBox">
  4. <div class="tableBox">
  5. <el-table :data="reportList" style="width: 100%;height: calc(100vh - 240px);position: relative;"
  6. :stripe="true">
  7. <el-table-column label="序号" width="auto">
  8. <template #default="{ $index }">{{ $index + 1 }}</template>
  9. </el-table-column>
  10. <el-table-column prop="name" label="任务名称" width="auto" />
  11. <el-table-column prop="station_name" label="变电站" width="auto" />
  12. <el-table-column prop="scd_name" label="SCD名称" width="auto" />
  13. <el-table-column prop="start_time" label="检测日期" width="auto" />
  14. <el-table-column fixed="right" label="操作" width="auto">
  15. <template #default="scope">
  16. <el-button text type="primary" size="small" @click="lookReport(scope.row)"><el-icon>
  17. <View />
  18. </el-icon>查看</el-button>
  19. <el-button text type="primary" size="small" @click="downFile(scope.row)"><el-icon>
  20. <Download />
  21. </el-icon>报告下载</el-button>
  22. </template>
  23. </el-table-column>
  24. </el-table>
  25. </div>
  26. <!-- 分页组件 -->
  27. <div class="pageBox">
  28. <Pagination style="position: relative;" :totals="totals" @pageBack="pageBack"></Pagination>
  29. </div>
  30. </div>
  31. </div>
  32. </template>
  33. <script>
  34. import { ref, onMounted, watch } from 'vue'
  35. import Pagination from './components/Pagination.vue'
  36. import report from "@/api/report"
  37. import task from '@/api/task'
  38. import system from "@/api/system"
  39. import { useRouter, useRoute } from "vue-router"
  40. import { ElMessage } from 'element-plus'
  41. export default {
  42. setup() {
  43. let route = useRoute()//路由信息
  44. let router = useRouter()//路由跳转api
  45. let reportList = ref([
  46. ])//报告列表
  47. let totals = ref(0)//总条数
  48. // 初始化组件
  49. function reload() {
  50. // 2为完成检测
  51. task.getTask({ pageno: 1, pagesize: 10, state: 2 }).then(res => {
  52. if (res.data == null) {
  53. reportList.value = []
  54. return
  55. } else {
  56. reportList.value = res.data
  57. totals.value = res.count
  58. }
  59. })
  60. }
  61. // 跳转到查看详情页面
  62. function lookReport(row) {
  63. console.log(row, 'rows');
  64. // router.push('/home/report/details')
  65. router.push({
  66. path: "/home/report/details",
  67. query: {
  68. reportId: row.id,
  69. scdId: row.scd_id,
  70. stationName: row.station_name,
  71. names: row.name
  72. }
  73. })
  74. }
  75. // 分页组件返回数据
  76. function pageBack(size, index) {
  77. report.allReport({ pageno: index - 0, pagesize: size - 0 }).then(res => {// 获取所有报告
  78. // console.log(res, 'res');
  79. if (res.data != null) {
  80. reportList.value = res.data
  81. totals.value = res.data.length
  82. } else {
  83. ElMessage({
  84. message: "暂无数据",
  85. type: "info"
  86. })
  87. }
  88. })
  89. }
  90. // 下载报告
  91. function downFile(row){
  92. console.log(row,'row');
  93. system.downLoad({
  94. ids:row.report_id
  95. }).then(res=>{
  96. console.log(res,'down');
  97. })
  98. }
  99. onMounted(() => {
  100. reload()
  101. })
  102. return {
  103. reportList,//报告列表
  104. reload,//初始化组件
  105. lookReport,// 跳转到查看详情页面
  106. totals,//总条数
  107. pageBack,//分页组件返回数据
  108. downFile,//下载报告
  109. }
  110. },
  111. components: {
  112. Pagination
  113. }
  114. }
  115. </script>
  116. <style scoped>
  117. .bigBox {
  118. width: 98%;
  119. height: calc(100vh - 240px);
  120. margin: 0 auto;
  121. }
  122. .tableBox {
  123. width: 100%;
  124. height: calc(100vh - 240px);
  125. }
  126. .pageBox {
  127. width: 420px;
  128. height: auto;
  129. position: absolute;
  130. bottom: 20px;
  131. right: 30px;
  132. }
  133. :deep(.el-scrollbar__view) {
  134. width: 100%;
  135. }
  136. </style>