onlineData.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. <template>
  2. <view>
  3. <qiun-title-bar title="7天排放趋势" />
  4. <view class="charts-box">
  5. <view class="charts-box">
  6. <qiun-data-charts
  7. type="area"
  8. :canvas2d="isCanvas2d"
  9. canvasId="chart51"
  10. :opts="{
  11. dataLabel: false,
  12. xAxis: {
  13. boundaryGap: 'justify',
  14. },
  15. extra: { area: { type: 'curve', addLine: true, gradient: true } },
  16. }"
  17. :chartData="data1"
  18. />
  19. </view>
  20. </view>
  21. <view style="position: relative;">
  22. <qiun-title-bar :title="`企业监控列表 (${companyTotal})`" />
  23. <view class="org-name" @click="showOrgSelect">
  24. <text>{{ orgName }}</text>
  25. <u-icon class="icon" name="arrow-down-fill" color="#2979ff" size="18" customStyle="position: absolute; top: 0;right: 0;"></u-icon>
  26. </view>
  27. <tki-tree ref="tkitree" :selectParent="true" :range="orgData" :rangeKey="'label'" :idKey="'key'" confirmColor="#4e8af7" title="请选择区域" @confirm="orgSelectConfirm" @cancel="orgSelectCancel" />
  28. <scroll-view class="" :scroll-y="companyTotal > 0" @scroll="scroll" :scroll-top="scrollTop" style="height: 420px;">
  29. <view class="company-list_none" v-if="companyTotal == 0">
  30. <text>{{ noDataText }}</text>
  31. <image src="/static/image/no-data.png"></image>
  32. </view>
  33. <view v-if="companyTotal > 0" class="company-list">
  34. <view class="company-list_item" v-for="(item, index) in companyList" :key="index" @click="jump(item.company_id, item.name)">
  35. <!-- <view class="img" @click="jumpMap(item.company_id)"><image style="width: 100%;height: 100%;" src="/static/image/blue-location.png"></image></view> -->
  36. <view class="left">
  37. <text class="name">{{ item.name }}</text>
  38. <text class="address">{{ item.address }}</text>
  39. </view>
  40. <text class="right">
  41. 设施:
  42. <text class="num">{{ item.monitor1.length }}</text>
  43. </text>
  44. </view>
  45. </view>
  46. </scroll-view>
  47. </view>
  48. <tabbar :currentTab="2"></tabbar>
  49. </view>
  50. </template>
  51. <script>
  52. import api from "@/common/api.js";
  53. import { log } from "@/utils/base.js";
  54. import tabbar from "@/components/tabbar";
  55. import tkiTree from "@/components/tki-tree/tki-tree.vue";
  56. export default {
  57. components: {
  58. tabbar,
  59. tkiTree,
  60. },
  61. data() {
  62. return {
  63. data1: { categories: [], series: [] },
  64. orgData: [],
  65. orgId: "",
  66. orgName: "",
  67. needQuery: true,
  68. isQuerying: false,
  69. companyList: [],
  70. companyTotal: 0,
  71. noDataText: "",
  72. scrollTop: 0,
  73. oldScrollTop: 0,
  74. search: {
  75. pageIndex: 1,
  76. pageSize: 10,
  77. params: {
  78. org_id: "",
  79. },
  80. },
  81. //#ifndef MP-WEIXIN
  82. isCanvas2d: false,
  83. //#endif
  84. //#ifdef MP-WEIXIN
  85. isCanvas2d: true,
  86. //#endif
  87. };
  88. },
  89. mounted() {
  90. this.getInfo();
  91. this.getOrg();
  92. },
  93. watch: {
  94. orgId(newV, oldV) {
  95. this.getCompany(newV);
  96. },
  97. },
  98. methods: {
  99. jump(id, name) {
  100. uni.navigateTo({
  101. url: `/pages_company/company?id=${id}&name=${name}`,
  102. });
  103. },
  104. jumpMap(id) {
  105. uni.navigateTo({
  106. url: `/pages_map/map?id=${id}`,
  107. });
  108. },
  109. getInfo() {
  110. api.getSmokeTendency(0).then(({ data }) => {
  111. //this.data1 = { categories: [], series: [] };
  112. data = data.chartData[0];
  113. this.data1.categories = data.categories.slice(-7).map(v => {
  114. return v.substr(5);
  115. });
  116. this.data1.series = data.series.map(v => {
  117. return {
  118. name: v.name.replace("排放总量", ""),
  119. data: v.data.slice(-7),
  120. };
  121. });
  122. //console.log("=========>>>>", this.data1);
  123. });
  124. },
  125. getOrg() {
  126. api.getOrgList().then(({ data }) => {
  127. this.orgData = data;
  128. this.orgName = data[0].label;
  129. this.orgId = data[0].key;
  130. //console.log(this.orgData);
  131. });
  132. },
  133. getCompany(id) {
  134. this.noDataText = "";
  135. if (this.needQuery || id) {
  136. if (id) {
  137. this.companyList = [];
  138. this.search.pageIndex = 1;
  139. this.needQuery = true;
  140. this.goTop();
  141. }
  142. id = id || this.orgId;
  143. this.search.params.org_id = id;
  144. api.getCompanyListByOrg(this.search).then(({ rows, total }) => {
  145. //console.log("=====>", rows, total);
  146. this.companyTotal = total;
  147. if (total == 0) {
  148. this.goTop();
  149. this.noDataText = "未查询到企业";
  150. }
  151. if ((this.search.pageIndex - 1) * this.search.pageSize < total) {
  152. this.companyList.push(...rows);
  153. this.isQuerying = false;
  154. } else {
  155. this.needQuery = false;
  156. }
  157. });
  158. }
  159. },
  160. scroll(e) {
  161. this.oldScrollTop = e.detail.scrollTop;
  162. //console.log(e.detail.scrollHeight - e.detail.scrollTop, e.detail.scrollHeight, e.detail.scrollTop);
  163. if (e.detail.scrollHeight - e.detail.scrollTop <= 550 && !this.isQuerying) {
  164. log("到达底部");
  165. this.isQuerying = true;
  166. this.search.pageIndex++;
  167. this.getCompany();
  168. }
  169. },
  170. goTop() {
  171. this.scrollTop = this.oldScrollTop;
  172. this.$nextTick(() => {
  173. this.scrollTop = 0;
  174. });
  175. },
  176. showOrgSelect() {
  177. this.$refs.tkitree._show();
  178. },
  179. orgSelectCancel() {
  180. this.$refs.tkitree._hide();
  181. },
  182. orgSelectConfirm(e) {
  183. this.orgId = e[0].key;
  184. this.orgName = getOrgName(e[0]);
  185. function getOrgName(data) {
  186. let str = `${data.label}${str ? `/${str}` : ""}`;
  187. let str1 = "";
  188. if (data.parents && data.parents.length) {
  189. data.parents.forEach(v => {
  190. str1 += `${v.label}/`;
  191. });
  192. }
  193. return `${str1}${str}`;
  194. }
  195. console.log(e);
  196. },
  197. },
  198. };
  199. </script>
  200. <style lang="scss">
  201. .charts-box {
  202. width: 100%;
  203. height: 230px;
  204. }
  205. .org-name {
  206. position: absolute;
  207. top: 12px;
  208. right: 20px;
  209. color: #666;
  210. font-size: 14px;
  211. color: $uni-color-primary;
  212. padding-right: 23px;
  213. .icon {
  214. position: absolute;
  215. top: 0;
  216. right: 0;
  217. }
  218. }
  219. .company-list {
  220. border: 1px solid $uni-color-primary;
  221. border-radius: 5px;
  222. margin: 5px 10px;
  223. &_none {
  224. margin-top: 10%;
  225. display: flex;
  226. justify-content: center;
  227. align-items: center;
  228. font-size: 20px;
  229. color: $uni-color-primary;
  230. flex-direction: column;
  231. }
  232. &_item {
  233. &:not(:last-child) {
  234. border-bottom: 1px dashed $uni-color-primary;
  235. }
  236. display: flex;
  237. cursor: pointer;
  238. padding: 10px 15px;
  239. justify-content: space-between;
  240. align-items: center;
  241. color: lighten($uni-color-primary, 15%);
  242. position: relative;
  243. .img {
  244. position: absolute;
  245. top: 5px;
  246. right: 10px;
  247. width: 25px;
  248. height: 25px;
  249. border-radius: 50%;
  250. }
  251. .left {
  252. display: flex;
  253. flex-direction: column;
  254. .name {
  255. font-weight: 600;
  256. }
  257. }
  258. .right {
  259. min-width: 100px;
  260. text-align: right;
  261. .num {
  262. font-weight: 600;
  263. margin: 0 8px;
  264. }
  265. }
  266. }
  267. }
  268. </style>