TabulateStatisticsList.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <template>
  2. <view class="u-content">
  3. <section style="margin-top: 1.5em; overflow-x: auto;">
  4. <table style="min-width: 400px;" cellspacing="0" cellpadding="5">
  5. <thead>
  6. <tr>
  7. <th colspan="3" style="text-align: center; font-size: 20px; font-weight: bold;">
  8. 各村垃圾清运汇总统计表
  9. </th>
  10. </tr>
  11. <tr>
  12. <th v-for="(header, index) in tableHeaders" :key="index">{{ header }}</th>
  13. </tr>
  14. </thead>
  15. <tbody>
  16. <tr v-for="(row, rowIndex) in tableData" :key="rowIndex" :style="rowIndex % 2 === 1 ? 'background-color: #f6f8fa;' : ''">
  17. <td
  18. v-for="(cell, cellIndex) in row.slice(0, 3)"
  19. :key="cellIndex"
  20. align="center"
  21. >
  22. <!-- 根据 cellIndex 来判断显示内容 -->
  23. <template v-if="cellIndex === 0 && row[0] !== '汇总'">
  24. <a href="#" @click.prevent="detail(row[3])">{{ cell }}</a> <!-- 使用 row[3] 传递 officeId -->
  25. </template>
  26. <template v-else>
  27. {{ cell }}
  28. </template>
  29. </td>
  30. </tr>
  31. </tbody>
  32. </table>
  33. </section>
  34. </view>
  35. </template>
  36. <script>
  37. import disposeRubbishService from '@/api/garbageClearance/disposeRubbishService'
  38. export default {
  39. data() {
  40. return {
  41. id: '',
  42. // 表格的头部
  43. tableHeaders: ["村级名称", "清运总数", "当前月清运数"], // 去掉了 "officeId"
  44. // 表格的数据,二维数组表示每一行
  45. tableData: []
  46. };
  47. },
  48. onLoad(val) {
  49. this.id = val.id;
  50. this.load();
  51. },
  52. methods: {
  53. load() {
  54. // 根据所属村落id将所有清运数据进行统计展示
  55. disposeRubbishService.getAllOfficeDetailCollect(this.id).then((data) => {
  56. console.log(data);
  57. this.tableData = data.map(item => [
  58. item.officeName, // 第 0 列:村级名称
  59. item.all, // 第 1 列:清运总数
  60. item.month, // 第 2 列:当前月清运数
  61. item.officeId // 第 3 列:officeId 作为隐藏的参数
  62. ]);
  63. }).catch(error => {
  64. console.error('数据加载失败:', error);
  65. });
  66. },
  67. detail(officeId) {
  68. console.log('查看详情', officeId)
  69. uni.navigateTo({
  70. url: `/pages/edt/TabulateStatisticsDetail?id=${officeId}`, // 使用 officeId 作为参数
  71. success: function(res) {
  72. console.log('跳转成功');
  73. },
  74. fail: function(err) {
  75. console.log('跳转失败', err);
  76. },
  77. complete: function() {
  78. console.log('跳转完成');
  79. }
  80. })
  81. },
  82. }
  83. };
  84. </script>
  85. <style lang="scss">
  86. .u-content {
  87. padding: 24rpx;
  88. font-size: 32rpx;
  89. color: #333;
  90. line-height: 1.6;
  91. }
  92. table {
  93. box-sizing: border-box;
  94. border-top: 1px solid #dfe2e5;
  95. border-left: 1px solid #dfe2e5;
  96. }
  97. th {
  98. border-right: 1px solid #dfe2e5;
  99. border-bottom: 1px solid #dfe2e5;
  100. }
  101. td {
  102. border-right: 1px solid #dfe2e5;
  103. border-bottom: 1px solid #dfe2e5;
  104. }
  105. a {
  106. color: rgb(41, 121, 255); /* 设置默认链接颜色 */
  107. text-decoration: none; /* 可选: 去掉下划线 */
  108. font-size: 16px; /* 设置所有链接的字体大小 */
  109. }
  110. a:hover {
  111. color: rgb(41, 121, 255); /* 鼠标悬停时的颜色,与默认颜色一致 */
  112. }
  113. a:visited {
  114. color: rgb(41, 121, 255); /* 已访问链接的颜色,与默认颜色一致 */
  115. }
  116. a:active {
  117. color: rgb(41, 121, 255); /* 点击链接时的颜色,与默认颜色一致 */
  118. }
  119. </style>