over.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <template>
  2. <view>
  3. <qiun-title-bar title="超标区域分析" />
  4. <view class="charts-box"><qiun-data-charts type="column" canvasId="chart1" :canvas2d="isCanvas2d" :opts="{ dataLabel: false, xAxis: { boundaryGap: 'center' }, extra: { column: { type: 'stack', width: 15, activeBgColor: '#000000', activeBgOpacity: 0.08, linearType: 'custom', seriesGap: 5, linearOpacity: 0.5, barBorderCircle: true } } }" :chartData="data1" /></view>
  5. <qiun-title-bar :title="`超标商户概览 (${overTotal})`" />
  6. <scroll-view :scroll-y="overTotal > 0" @scroll="scroll" :scroll-top="scrollTop" style="height: 390px;">
  7. <view class="over-list_none" v-if="overTotal == 0">
  8. <text>没有超标商户</text>
  9. <image src="/static/image/no-data.png"></image>
  10. </view>
  11. <view class="over-list" v-if="overTotal > 0">
  12. <view class="over-list_item" v-for="(item, index) in overList" :key="index" @click="jump(item.companyId, item.name)">
  13. <view class="left">
  14. <text class="name">{{ item.name }}</text>
  15. <text class="address">{{ item.address }}</text>
  16. </view>
  17. <view class="right">
  18. <text class="num">{{ item.times }}</text>
  19. <text>次</text>
  20. </view>
  21. </view>
  22. </view>
  23. </scroll-view>
  24. </view>
  25. </template>
  26. <script>
  27. import api from "@/common/api.js";
  28. import { log } from "@/utils/base.js";
  29. export default {
  30. name: "over",
  31. data() {
  32. return {
  33. needQuery: true,
  34. isQuerying: false,
  35. overList: [],
  36. overTotal: 0,
  37. scrollTop: 0,
  38. oldScrollTop: 0,
  39. data1: { categories: [], series: [] },
  40. search: {
  41. pageIndex: 1,
  42. pageSize: 10,
  43. params: { type: 0 },
  44. },
  45. //#ifndef MP-WEIXIN
  46. isCanvas2d: false,
  47. //#endif
  48. //#ifdef MP-WEIXIN
  49. isCanvas2d: true,
  50. //#endif
  51. };
  52. },
  53. mounted() {
  54. //console.log(this.isCanvas2d);
  55. this.getInfo();
  56. this.query();
  57. },
  58. methods: {
  59. jump(id, name) {
  60. uni.navigateTo({
  61. url: `/pages_company/company?id=${id}&name=${name}`,
  62. });
  63. },
  64. getInfo() {
  65. api.getOverdueByOrg(0).then(({ data }) => {
  66. data = data.chartData[0];
  67. this.data1.categories = data.categories;
  68. this.data1.series = data.series;
  69. // .map(v => {
  70. // return {
  71. // name: v.name.replace("排放总量", ""),
  72. // data: v.data,
  73. // };
  74. // });
  75. //console.log("=========>>>>", this.data1);
  76. });
  77. },
  78. query(nextPage) {
  79. if (this.needQuery || !nextPage) {
  80. if (!nextPage) {
  81. this.overList = [];
  82. this.goTop();
  83. }
  84. api.getOverCompany(this.search).then(({ rows, total }) => {
  85. this.$emit("changeOver", total);
  86. this.$store.commit("setOverNum", total);
  87. this.overTotal = total;
  88. if ((this.search.pageIndex - 1) * this.search.pageSize < total) {
  89. this.overList.push(...rows);
  90. this.isQuerying = false;
  91. } else {
  92. this.needQuery = false;
  93. }
  94. });
  95. }
  96. },
  97. scroll(e) {
  98. this.oldScrollTop = e.detail.scrollTop;
  99. //console.log(e.detail.scrollHeight - e.detail.scrollTop, e.detail.scrollHeight, e.detail.scrollTop);
  100. if (e.detail.scrollHeight - e.detail.scrollTop <= 500 && !this.isQuerying) {
  101. log("到达底部");
  102. this.isQuerying = true;
  103. this.search.pageIndex++;
  104. this.query(true);
  105. }
  106. },
  107. goTop() {
  108. this.scrollTop = this.oldScrollTop;
  109. this.$nextTick(() => {
  110. this.scrollTop = 0;
  111. });
  112. },
  113. },
  114. };
  115. </script>
  116. <style lang="scss">
  117. .charts-box {
  118. width: 100%;
  119. height: 230px;
  120. }
  121. .over-list {
  122. border: 1px solid $uni-color-primary;
  123. border-radius: 5px;
  124. margin: 5px 10px;
  125. &_none {
  126. margin-top: 10%;
  127. display: flex;
  128. flex-direction: column;
  129. justify-content: center;
  130. align-items: center;
  131. font-size: 20px;
  132. color: $uni-color-primary;
  133. }
  134. &_item {
  135. &:not(:last-child) {
  136. border-bottom: 1px dashed $uni-color-primary;
  137. }
  138. display: flex;
  139. padding: 10px 15px;
  140. justify-content: space-between;
  141. align-items: center;
  142. color: lighten($uni-color-primary, 15%);
  143. .left {
  144. display: flex;
  145. flex-direction: column;
  146. .name {
  147. font-weight: 600;
  148. }
  149. }
  150. .right {
  151. .num {
  152. font-weight: 600;
  153. margin-right: 10px;
  154. }
  155. }
  156. }
  157. }
  158. </style>