TabulateStatisticsDetail.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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="4" 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"
  19. :key="cellIndex"
  20. align="center"
  21. :style="cellIndex === 1 ? '' : ''"
  22. >
  23. <!-- 根据 cellIndex 来判断显示内容 -->
  24. <template v-if="cellIndex === 0 && cell !== '汇总'">
  25. <!--<u-link href="#" :text="cell" @click="handleLinkClick(cell)"></u-link>-->
  26. <a href="#" @click.prevent="handleLinkClick(cell)">{{ cell }}</a>
  27. </template>
  28. <template v-else>
  29. {{ cell }}
  30. </template>
  31. </td>
  32. </tr>
  33. </tbody>
  34. </table>
  35. </section>
  36. </view>
  37. </template>
  38. <script>
  39. import disposeRubbishService from '@/api/garbageClearance/disposeRubbishService'
  40. export default {
  41. data() {
  42. return {
  43. id:'',
  44. // 表格的头部
  45. tableHeaders: ["月份", "清运次数", "清运量(t)", "补贴(元)"],
  46. // 表格的数据,二维数组表示每一行
  47. tableData: []
  48. };
  49. },
  50. onLoad(val) {
  51. this.id = val.id;
  52. this.load();
  53. },
  54. methods: {
  55. load() {
  56. // 根据所属村落id将所有清运数据进行统计展示
  57. disposeRubbishService.getDetailCollectByOfficeId(this.id).then((data) => {
  58. console.log(data);
  59. this.tableData = data.map(item => [
  60. item.createDateStr,
  61. item.count,
  62. item.weight,
  63. item.subsidy
  64. ]);
  65. }).catch(error => {
  66. console.error('数据加载失败:', error);
  67. });
  68. },
  69. handleLinkClick(cell) {
  70. console.log('查看详情',cell)
  71. uni.navigateTo({
  72. url: `/pages/edt/DisposeRubbishListDetail?id=`+this.id + `&yearMonth=`+cell,
  73. success: function(res) {
  74. // 跳转成功后的处理
  75. console.log('跳转成功');
  76. },
  77. fail: function(err) {
  78. // 跳转失败后的处理
  79. console.log('跳转失败', err);
  80. },
  81. complete: function() {
  82. // 无论跳转成功还是失败都会执行
  83. console.log('跳转完成');
  84. }
  85. })
  86. }
  87. }
  88. };
  89. </script>
  90. <style lang="scss">
  91. .u-content {
  92. padding: 24rpx;
  93. font-size: 32rpx;
  94. color: #333;
  95. line-height: 1.6;
  96. }
  97. table {
  98. box-sizing: border-box;
  99. border-top: 1px solid #dfe2e5;
  100. border-left: 1px solid #dfe2e5;
  101. }
  102. th {
  103. border-right: 1px solid #dfe2e5;
  104. border-bottom: 1px solid #dfe2e5;
  105. }
  106. td {
  107. border-right: 1px solid #dfe2e5;
  108. border-bottom: 1px solid #dfe2e5;
  109. }
  110. a {
  111. color: rgb(41, 121, 255); /* 设置默认链接颜色 */
  112. text-decoration: none; /* 可选: 去掉下划线 */
  113. font-size: 16px; /* 设置所有链接的字体大小 */
  114. }
  115. a:hover {
  116. color: rgb(41, 121, 255); /* 鼠标悬停时的颜色,与默认颜色一致 */
  117. }
  118. a:visited {
  119. color: rgb(41, 121, 255); /* 已访问链接的颜色,与默认颜色一致 */
  120. }
  121. a:active {
  122. color: rgb(41, 121, 255); /* 点击链接时的颜色,与默认颜色一致 */
  123. }
  124. </style>