reportInfo.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <template>
  2. <view style="overflow-x: auto;">
  3. <template>
  4. <view class="uni-container">
  5. <uni-table ref="table" :style="'width:'+(maxWidth+40)+'px'" :loading="loading" border stripe
  6. :emptyText="$t('base.common.noData')">
  7. <uni-tr>
  8. <uni-th :width="item.width" align="center"
  9. v-for="item in reportTitleList" :key="item.title"><rich-text :nodes="language=='zh-Hans'?item.title:item.languageName"></rich-text></uni-th>
  10. </uni-tr>
  11. <uni-tr v-for="(item, index) in reportDataList" :key="index">
  12. <uni-td v-for="title in reportTitleList" :align="title.align" :key="title.name">
  13. <view class="name">{{ item[title.name] || item[title.defaultValue] }}</view>
  14. </uni-td>
  15. </uni-tr>
  16. </uni-table>
  17. </view>
  18. </template>
  19. </view>
  20. </template>
  21. <script>
  22. import {
  23. showReport, //原料进厂汇总表
  24. } from "../../api/report"
  25. export default {
  26. data() {
  27. return {
  28. reportDataList: [],
  29. reportTitleList: [],
  30. loading: true,
  31. maxWidth: 0,
  32. language:'zh-Hans'
  33. }
  34. },
  35. onLoad(options) {
  36. this.language = uni.getStorageSync('CURRENT_LANG')
  37. console.log(options);
  38. this.getList(options.url, options.data)
  39. },
  40. methods: {
  41. getList(url, data) {
  42. var that = this;
  43. showReport(data).then(res => {
  44. console.log("获取到的报表信息-------------,", res);
  45. if (res.statusCode == 200) {
  46. that.reportDataList = res.data.data.values
  47. that.reportTitleList = res.data.data.columns
  48. if (that.reportTitleList && that.reportTitleList.length == 0) {
  49. wx.showToast({
  50. title: '报表未配置列信息!',
  51. icon: "none",
  52. duration: 1000,
  53. })
  54. return;
  55. }
  56. that.loading = false
  57. that.reportTitleList.forEach(item => {
  58. that.maxWidth = that.maxWidth + (item.width == null || item.width == '' ? 0 :
  59. item.width)
  60. })
  61. }
  62. console.log("获取到的报表信息,", res.data.data);
  63. })
  64. setTimeout(() => {
  65. this.loading = false
  66. }, 2000)
  67. },
  68. }
  69. }
  70. </script>
  71. <style lang="scss" scoped>
  72. /deep/ .uni-table {
  73. position: relative;
  74. border-radius: 5px;
  75. background-color: #fff;
  76. box-sizing: border-box;
  77. display: table;
  78. overflow-x: auto;
  79. word-break: keep-all;
  80. }
  81. .tableHead {
  82. font-weight: bold;
  83. color: #333333;
  84. background: #F4F6FF;
  85. z-index: 20;
  86. position: fixed;
  87. }
  88. .tableBody {
  89. height: 500px;
  90. overflow: scroll;
  91. margin-top: 42px;
  92. }
  93. .li {
  94. height: 30px;
  95. line-height: 30px;
  96. list-style: none;
  97. padding: 0;
  98. margin: 0;
  99. white-space: nowrap;
  100. }
  101. .li span {
  102. display: inline-block;
  103. padding: 6px 8px;
  104. line-height: 1;
  105. text-align: center;
  106. overflow: hidden;
  107. vertical-align: middle;
  108. text-overflow: ellipsis;
  109. white-space: nowrap;
  110. border-right: 1px solid #f2f2f2;
  111. }
  112. /deep/ .uni-table {
  113. position: relative;
  114. border-radius: 5px;
  115. background-color: #fff;
  116. box-sizing: border-box;
  117. display: table;
  118. overflow-x: auto;
  119. word-break:keep-all;
  120. white-space: nowrap
  121. }
  122. /deep/ .uni-table-th {
  123. padding: 16rpx 20rpx;
  124. background-color: #4680F9;
  125. color: #fff;
  126. font-size: 24rpx;
  127. }
  128. /deep/ .uni-table-td {
  129. padding: 16rpx 20rpx;
  130. font-size: 24rpx;
  131. line-height: 32rpx;
  132. }
  133. </style>