EnergyConsumptionStatisticsReport.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <template>
  2. <div class="container">
  3. <div class="query-container">
  4. <div>
  5. <span class="formTitle">账期:</span>
  6. <el-date-picker v-model="selectedSMonth" type="month" format="YYYYMM" value-format="YYYYMM" placeholder="请选择账期"
  7. :disabled-date="checkSMonth" />
  8. <el-button type="primary" class="btn" @click="refreshTableData(selectedSMonth)">查询</el-button>
  9. </div>
  10. </div>
  11. <div class="content">
  12. <div>
  13. <div class="contentTitle">节能减排</div>
  14. </div>
  15. <div>
  16. <el-table :data="tableData" stripe style="width: 100%" border class="Ttable"
  17. :cell-style="{ borderColor: '#ebeef5' }" :header-cell-style="{ borderColor: '#ebeef5' }">
  18. <el-table-column prop="month" align="center" label="账期" />
  19. <el-table-column prop="displayName" align="center" label="文件名称" />
  20. <el-table-column label="操作" align="center">
  21. <template #default="scope">
  22. <el-button type="primary" plain size="small" @click="handleDownload(scope)">下载</el-button>
  23. </template>
  24. </el-table-column>
  25. </el-table>
  26. </div>
  27. </div>
  28. </div>
  29. </template>
  30. <script setup>
  31. import { ref, onMounted } from 'vue'
  32. import { ElMessage } from 'element-plus'
  33. import { postForReportInfoBySMonth, postForSMonthAll, postForDownload } from '../request/reportInfo';
  34. // 选中的账期
  35. const selectedSMonth = ref("")
  36. // 允许的账期
  37. const allSMonthSet = ref(new Set())
  38. const tableData = ref([])
  39. const checkSMonth = (time) => {
  40. const month = time.getMonth() < 9 ? `0${time.getMonth() + 1}` : `${time.getMonth() + 1}`
  41. const sMonth = `${time.getFullYear()}${month}`
  42. return !allSMonthSet.value.has(sMonth)
  43. }
  44. const refreshTableData = (month) => {
  45. console.log(month);
  46. postForReportInfoBySMonth(month).then(res => {
  47. console.log(res);
  48. if (res.success) {
  49. tableData.value = res.data
  50. } else {
  51. ElMessage.error("出错了")
  52. }
  53. }).catch(() => ElMessage.error("出错了"))
  54. }
  55. // TODO download还未实现
  56. const handleDownload = (scope) => {
  57. postForDownload(scope.row)
  58. .then(res => console.log(res))
  59. .catch(() => ElMessage.error("出错了"))
  60. }
  61. onMounted(() => {
  62. postForSMonthAll().then(res => {
  63. if (res.success) {
  64. allSMonthSet.value = new Set(res.data)
  65. selectedSMonth.value = res.data[0]
  66. refreshTableData(selectedSMonth.value)
  67. } else {
  68. ElMessage.error("出错了")
  69. }
  70. }).catch(() => ElMessage.error("出错了"))
  71. })
  72. </script>
  73. <style lang="css" scoped>
  74. .container {
  75. /* background-color: #f0f2f5; */
  76. padding: 10px;
  77. }
  78. .query-container {
  79. background-color: #ffffff;
  80. height: 60px;
  81. /* margin: 10px; */
  82. vertical-align: middle;
  83. line-height: 60px;
  84. padding: 0 20px;
  85. }
  86. .query-container .formTitle {
  87. margin-right: 10px;
  88. }
  89. .query-container .btn {
  90. margin-left: 10px;
  91. }
  92. .content {
  93. padding: 0 15px 15px;
  94. }
  95. .contentTitle {
  96. width: 100%;
  97. border-left: 5px solid #409eff;
  98. padding-left: 10px;
  99. height: 20px;
  100. line-height: 20px;
  101. margin: 30px 0 10px;
  102. }
  103. </style>