rturaindata.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. <!--
  2. * @Title:
  3. * @Description: 雨情数据
  4. * @Author: swp
  5. * @Date: 2022-08-24 10:49:21
  6. * @LastEditors:
  7. * @LastEditTime: 2022-08-24 10:49:21
  8. -->
  9. <template>
  10. <view class="wrap">
  11. <view class="container">
  12. <uni-section title="查询" titleFontSize="0.8rem" type="line" style="padding-left: 0px;padding-right: 0px;">
  13. <view class="search-block">
  14. <view class="adcd-adnm">
  15. <uni-data-picker placeholder="请选择地区" popup-title="请选择所在地区" :localdata="regionTree"
  16. v-model="selectedTreeNode" @change="onTreeChange" @nodeclick="onTreeNodeClick"
  17. @popupopened="onTreePopupOpened" @popupclosed="onTreePopupClosed" :clear-icon="false">
  18. </uni-data-picker>
  19. </view>
  20. <view class="rtu-code">
  21. <uni-easyinput :styles="inputStyles" @input="searchRtuCodeValClear" prefixIcon="search"
  22. v-model="searchRtuCodeVal" placeholder="请输入测站编码">
  23. </uni-easyinput>
  24. </view>
  25. <view class="rtu-name">
  26. <uni-easyinput :styles="inputStyles" @input="searchRtuNameValClear" prefixIcon="search"
  27. v-model="searchRtuNameVal" placeholder="请输入测站名称">
  28. </uni-easyinput>
  29. </view>
  30. <view class="submit-btn">
  31. <button type="default" @click="search">查 询</button>
  32. </view>
  33. </view>
  34. </uni-section>
  35. <uni-group>
  36. <!-- <uni-card title="统计时间" :is-shadow="false" style="margin-left: 0px;margin-right: 0px;"> -->
  37. <radio-group @change="onRainCountTypeRadioChange" class="view-flex-rs">
  38. <label style="margin-right: 5px;margin-bottom: 5px;;width:100px;" class="view-flex-inline"
  39. v-for="(item, index) in rainCountType.items" :key="item.id">
  40. <view>
  41. <radio :value="item.id" :checked="index === rainCountType.value" />
  42. </view>
  43. <view style="font-size: 0.7rem;">{{item.dictValue}}</view>
  44. </label>
  45. </radio-group>
  46. <!-- </uni-card> -->
  47. </uni-group>
  48. <uni-table ref="table" :loading="loading" border stripe type="" emptyText="暂无更多数据">
  49. <uni-tr>
  50. <uni-th align="center" width="120">上报时间</uni-th>
  51. <uni-th align="center" width="120">测站名称</uni-th>
  52. <uni-th align="center" width="70">时段长</uni-th>
  53. <uni-th align="center">降水量</uni-th>
  54. </uni-tr>
  55. <uni-tr v-for="(item, index) in tableData" :key="index">
  56. <uni-td align="center">
  57. <view style="text-align: center;">{{ item.tm }}</view>
  58. </uni-td align="center">
  59. <uni-td>
  60. <view style="text-align: center;">
  61. {{ item.rtuName }}/{{ item.rtuCode }}
  62. </view>
  63. </uni-td>
  64. <uni-td align="center">
  65. <!-- <view v-if="item.intv === 1.0" style="text-align: center;color: coral;">1小时</view>
  66. <view v-else style="text-align: center;color: coral;">5分钟</view> -->
  67. <view style="text-align: center;color: coral;">{{item.intvLable}}</view>
  68. </uni-td>
  69. <uni-td align="center">
  70. <view style="text-align: center;color: coral;">{{ item.drp }}</view>
  71. </uni-td>
  72. </uni-tr>
  73. </uni-table>
  74. <view class="pagination-block">
  75. <uni-pagination :page-size="pageSize" :current="pageCurrent" :total="total" @change="pageChange"
  76. prevText="前一页" nextText="后一页" />
  77. </view>
  78. </view>
  79. </view>
  80. </template>
  81. <script>
  82. import http from '@/http/api.js';
  83. export default {
  84. components: {},
  85. onLoad(option) {
  86. },
  87. created() {
  88. this.getRegionTree();
  89. },
  90. data() {
  91. return {
  92. title: '雨水情实时数据',
  93. regionTree: [],
  94. regionCode: '',
  95. selectedTreeNode: '',
  96. searchRtuNameVal: '',
  97. searchRtuCodeVal: '',
  98. query: {},
  99. inputStyles: {
  100. color: '#808080',
  101. borderColor: '#d3d3d3'
  102. },
  103. // 每页数据量
  104. pageSize: 10,
  105. // 当前页
  106. pageCurrent: 1,
  107. // 数据总量
  108. total: 0,
  109. loading: false,
  110. tableData: [],
  111. rainCountType: {
  112. items: [{
  113. 'id': '0',
  114. 'dictValue': '默认'
  115. }, {
  116. 'id': '1',
  117. 'dictValue': '近1小时'
  118. }, {
  119. 'id': '2',
  120. 'dictValue': '近3小时'
  121. }, {
  122. 'id': '3',
  123. 'dictValue': '近6小时'
  124. }, {
  125. 'id': '4',
  126. 'dictValue': '近12小时'
  127. }, {
  128. 'id': '5',
  129. 'dictValue': '近24小时'
  130. }],
  131. value: 0,
  132. }
  133. }
  134. },
  135. computed: {},
  136. onShow() {},
  137. methods: {
  138. toBack() {
  139. uni.navigateBack({
  140. delta: 1
  141. })
  142. },
  143. onBackPress() {
  144. // #ifdef APP-PLUS
  145. plus.key.hideSoftKeybord();
  146. // #endif
  147. },
  148. // 分页触发
  149. pageChange(e) {
  150. this.$refs.table.clearSelection()
  151. //this.selectedIndexs.length = 0
  152. this.pageCurrent = e.current;
  153. this.getPage()
  154. },
  155. onRainCountTypeRadioChange: function(evt) {
  156. for (let i = 0; i < this.rainCountType.items.length; i++) {
  157. if (this.rainCountType.items[i].id === evt.detail.value) {
  158. this.rainCountType.value = i;
  159. this.pageCurrent = 1;
  160. this.getPage();
  161. break;
  162. }
  163. }
  164. },
  165. onTreeNodeClick(node) {
  166. console.log(JSON.stringify(node))
  167. },
  168. onTreePopupOpened(e) {
  169. console.log(JSON.stringify(e))
  170. },
  171. onTreePopupClosed(e) {
  172. console.log(JSON.stringify(e))
  173. },
  174. onTreeChange(e) {
  175. console.log(JSON.stringify(e))
  176. let nodes = e.detail.value;
  177. if (nodes.length > 0) {
  178. let node = nodes[nodes.length - 1];
  179. this.regionCode = node.value;
  180. this.query = {};
  181. this.query['adCode'] = this.regionCode;
  182. this.searchRtuNameVal = '';
  183. this.searchRtuCodeVal = '';
  184. this.pageCurrent = 1;
  185. this.getPage();
  186. } else {
  187. this.regionCode = '';
  188. this.query = {};
  189. this.searchRtuNameVal = '';
  190. this.searchRtuCodeVal = '';
  191. this.pageCurrent = 1;
  192. this.getPage();
  193. }
  194. },
  195. //录入查询
  196. search() {
  197. this.pageCurrent = 1;
  198. // console.log(JSON.stringify(res))
  199. let params = {};
  200. if (this.searchRtuCodeVal.length > 0) {
  201. params['rtuCode'] = this.searchRtuCodeVal;
  202. }
  203. if (this.searchRtuNameVal.length > 0) {
  204. params['rtuName'] = this.searchRtuNameVal;
  205. }
  206. this.getPage(params);
  207. },
  208. searchRtuNameValClear(e) {
  209. if (e == null || e.length == 0) {
  210. this.searchRtuNameVal = '';
  211. if (this.searchRtuNameVal.length == 0) {
  212. let params = {};
  213. if (this.searchRtuCodeVal.length > 0) {
  214. params['rtuCode'] = this.searchRtuCodeVal;
  215. }
  216. this.getPage(params);
  217. }
  218. }
  219. },
  220. searchRtuCodeValClear(e) {
  221. if (e == null || e.length == 0) {
  222. this.searchRtuCodeVal = '';
  223. if (this.searchRtuCodeVal.length == 0) {
  224. let params = {};
  225. if (this.searchRtuNameVal.length > 0) {
  226. params['rtuName'] = this.searchRtuNameVal;
  227. }
  228. this.getPage(params);
  229. }
  230. }
  231. },
  232. // 多选处理
  233. selectedItems() {
  234. return this.selectedIndexs.map(i => this.tableData[i])
  235. },
  236. // 多选
  237. selectionChange(e) {
  238. console.log(e.detail.index)
  239. this.selectedIndexs = e.detail.index
  240. },
  241. //批量删除
  242. delTable() {
  243. //console.log(this.selectedItems())
  244. },
  245. getRegionTree() {
  246. var that = this;
  247. http.request({
  248. url: '/galaxy-business/baseinfo/region/tree',
  249. method: 'GET',
  250. }).then(res => {
  251. if (res.data != null) {
  252. that.regionTree = res.data;
  253. that.selectedTreeNode = that.regionTree[0].value;
  254. that.regionCode = that.regionTree[0].value;
  255. that.query = {};
  256. that.query['adCode'] = that.regionCode;
  257. //that.orgId = that.projectTree[0].orgId;
  258. //that.projectId = that.projectTree[0].projectId;
  259. that.getPage();
  260. //that.getCountInfo(that.regionCode);
  261. }
  262. }).catch(err => {
  263. console.log(err)
  264. })
  265. },
  266. // 获取数据
  267. getPage(params = {}) {
  268. this.loading = true;
  269. const current = this.pageCurrent;
  270. const size = this.pageSize;
  271. const isSubmit = '0';
  272. if (this.rainCountType.value == 1) {
  273. params['rainCountType'] = 1;
  274. } else if (this.rainCountType.value == 2) {
  275. params['rainCountType'] = 3;
  276. } else if (this.rainCountType.value == 3) {
  277. params['rainCountType'] = 6;
  278. } else if (this.rainCountType.value == 4) {
  279. params['rainCountType'] = 12;
  280. } else if (this.rainCountType.value == 5) {
  281. params['rainCountType'] = 24;
  282. } else {
  283. params['rainCountType'] = 0;
  284. }
  285. let postData = Object.assign(params, this.query);
  286. console.log(JSON.stringify(postData))
  287. var that = this;
  288. http.request({
  289. url: '/galaxy-business/rtu/data/rain/page',
  290. method: 'GET',
  291. params: {
  292. current,
  293. size,
  294. isSubmit
  295. },
  296. data: postData,
  297. }).then(res => {
  298. if (res.data.records != null) {
  299. that.tableData = res.data.records;
  300. that.total = res.data.total;
  301. }
  302. this.loading = false
  303. }).catch(err => {
  304. console.log(err)
  305. this.loading = false
  306. })
  307. },
  308. }
  309. }
  310. </script>
  311. <style>
  312. /* page {
  313. background-color: rgb(240, 242, 244);
  314. } */
  315. </style>
  316. <style lang="scss" scoped>
  317. .wrap {
  318. padding: 0 0 100rpx;
  319. }
  320. .container {
  321. background-color: #f7f7f7;
  322. min-height: 100vh;
  323. overflow: hidden;
  324. }
  325. .view-flex-rs {
  326. display: flex;
  327. flex-direction: row;
  328. justify-content: flex-start;
  329. align-items: center;
  330. flex-wrap: wrap;
  331. }
  332. .view-flex-inline {
  333. display: flex;
  334. flex-direction: row;
  335. justify-content: flex-start;
  336. align-items: center;
  337. }
  338. </style>