index.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <template>
  2. <div class="table-box">
  3. <div class="card table-main">
  4. <!-- 表格头部 操作按钮 -->
  5. <div class="table-header">
  6. <div class="header-button-lf">
  7. <el-form :model="queryParams" label-width="auto" :inline="true">
  8. <el-form-item label="自动站:">
  9. <el-select v-model="queryParams.code" filterable placeholder="请选择" clearable style="width: 200px">
  10. <el-option label="RS0001" value="RS0001" />
  11. <el-option label="RS0002" value="RS0002" />
  12. </el-select>
  13. </el-form-item>
  14. <el-form-item>
  15. <el-button type="primary" @click="handleQuery"> 查询 </el-button>
  16. <el-button style="margin-left: 10px" @click="resetQuery"> 重置 </el-button>
  17. </el-form-item>
  18. </el-form>
  19. </div>
  20. </div>
  21. <!-- 表格主体 -->
  22. <el-table stripe ref="tableRef" :border="true" :data="processTableData" size="small" class="el-table--small">
  23. <el-table-column align="center" width="50">
  24. <template #header>
  25. <div class="group-bias-divide">
  26. <div class="top">日</div>
  27. <div class="bottom">时</div>
  28. </div>
  29. </template>
  30. <template #default="scope">
  31. {{ (scope.$index).toString().padStart(2, '0') }}
  32. </template>
  33. </el-table-column>
  34. <template v-for="item in columns" :key="item">
  35. <el-table-column v-bind="item" :align="item.align ?? 'center'">
  36. <template #default="scope">
  37. <img class="img-documented" src="@/assets/images/documented.png">
  38. </template>
  39. </el-table-column>
  40. </template>
  41. <!-- 无数据 -->
  42. <template #empty>
  43. <div class="table-empty">
  44. <slot name="empty">
  45. <img src="@/assets/images/notData.png" alt="notData" />
  46. <div>暂无数据</div>
  47. </slot>
  48. </div>
  49. </template>
  50. </el-table>
  51. </div>
  52. </div>
  53. </template>
  54. <script setup lang="ts" name="useProTable">
  55. import { ref, reactive } from "vue";
  56. import { ColumnProps } from "@/components/ProTable/interface";
  57. const pageable = ref<any>({
  58. pageNum: 1,
  59. pageSize: 20,
  60. total: 1
  61. });
  62. const queryParams = ref({
  63. code: ''
  64. });
  65. // 查询功能
  66. const handleQuery = () => {
  67. };
  68. //搜索功能
  69. const resetQuery = () => {
  70. };
  71. const processTableData = ref(processTableDatas());
  72. function processTableDatas(){
  73. const datas = [];
  74. for (let i = 1; i <= 24; i++) {
  75. const datas2 = [];
  76. datas2.push({day1 : "1"})
  77. datas2.push({day2 : "1"})
  78. datas2.push({day3 : "1"})
  79. datas2.push({day4 : "1"})
  80. datas2.push({day5 : "1"})
  81. datas2.push({day6 : "1"})
  82. datas2.push({day7 : "1"})
  83. datas2.push({day8 : "1"})
  84. datas2.push({day9 : "1"})
  85. datas2.push({day10 : "1"})
  86. datas2.push({day11 : "1"})
  87. datas2.push({day12 : "1"})
  88. datas2.push({day13 : "1"})
  89. datas.push(datas2)
  90. }
  91. return datas;
  92. }
  93. // 假设当前月份为5月
  94. const month = 5;
  95. // 表格配置项
  96. const columns = reactive<ColumnProps[]>(generateColumns(month));
  97. function generateColumns(month: number): ColumnProps[] {
  98. const daysInMonth = new Date(new Date().getFullYear(), month, 0).getDate();
  99. const columns = [];
  100. for (let i = 1; i <= daysInMonth; i++) {
  101. columns.push({ prop: `day${i}`, label: i.toString().padStart(2, '0'),width:51});
  102. }
  103. console.log(columns)
  104. return columns;
  105. }
  106. </script>
  107. <style scoped>
  108. :deep .el-table--small .el-table__row {
  109. height: 29px !important;
  110. font-size: 13px !important;
  111. }
  112. :deep .el-table--small .el-table__header th {
  113. height: 40px !important;
  114. font-size: 14px !important;
  115. }
  116. :deep .el-table--small .cell {
  117. line-height: 22px!important;
  118. }
  119. </style>
  120. <style lang='scss' scoped>
  121. :deep(.group-bias-divide) {
  122. .top {
  123. text-align: right;
  124. padding-right: 0px;
  125. box-sizing: border-box;
  126. line-height: 9px;
  127. font-size: 11px;
  128. }
  129. .bottom {
  130. text-align: left;
  131. padding-left: 0px;
  132. padding-top: 1px;
  133. box-sizing: border-box;
  134. line-height: 10px;
  135. font-size: 11px;
  136. &::before {
  137. content: "";
  138. position: absolute;
  139. width: 1px !important;
  140. height: 90px !important;
  141. top: auto !important;
  142. left: auto !important;
  143. bottom: 0 !important;
  144. right: 0 !important;
  145. background-color: #C7E2FF;
  146. display: block;
  147. transform: rotate(309deg);
  148. transform-origin: bottom;
  149. }
  150. }
  151. }
  152. .img-documented{
  153. width: 15px;
  154. height: 15px;
  155. }
  156. </style>