rtugrounddata.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  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">
  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-table ref="table" :loading="loading" border stripe type="" emptyText="暂无更多数据">
  36. <uni-tr>
  37. <uni-th width="120" align="center">上报时间</uni-th>
  38. <uni-th align="center">测站名称</uni-th>
  39. <uni-th width="120" align="center">墒情数据</uni-th>
  40. </uni-tr>
  41. <uni-tr v-for="item in tableData" :key="item.id">
  42. <uni-td>
  43. <view style="text-align: center;">{{ item.tm }}</view>
  44. </uni-td>
  45. <uni-td>
  46. <view style="text-align: center;">
  47. {{ item.rtuName }}/{{ item.rtuCode }}
  48. </view>
  49. </uni-td>
  50. <uni-td align="center">
  51. <view class="uni-group">
  52. <button class="uni-button" size="mini" type="default"
  53. @click="onGroundInfoClick(item)">墒情</button>
  54. </view>
  55. </uni-td>
  56. </uni-tr>
  57. </uni-table>
  58. <view class="pagination-block">
  59. <uni-pagination :page-size="pageSize" :current="pageCurrent" :total="total" @change="pageChange"
  60. prev-text="前一页" next-text="后一页" />
  61. </view>
  62. </view>
  63. </view>
  64. </template>
  65. <script>
  66. import http from '@/http/api.js';
  67. export default {
  68. components: {},
  69. onLoad(option) {
  70. this.selectedIndexs = [];
  71. },
  72. created() {
  73. this.getRegionTree();
  74. },
  75. data() {
  76. return {
  77. title: '墒情实时数据',
  78. regionTree: [],
  79. regionCode: '',
  80. selectedTreeNode: '',
  81. searchRtuNameVal: '',
  82. searchRtuCodeVal: '',
  83. query: {},
  84. inputStyles: {
  85. color: '#808080',
  86. borderColor: '#d3d3d3'
  87. },
  88. // 每页数据量
  89. pageSize: 10,
  90. // 当前页
  91. pageCurrent: 1,
  92. // 数据总量
  93. total: 0,
  94. loading: false,
  95. selectedIndexs: [],
  96. tableData: [],
  97. }
  98. },
  99. computed: {
  100. },
  101. onShow() {},
  102. methods: {
  103. toBack() {
  104. uni.navigateBack({
  105. delta: 1
  106. })
  107. },
  108. onBackPress() {
  109. // #ifdef APP-PLUS
  110. plus.key.hideSoftKeybord();
  111. // #endif
  112. },
  113. // 分页触发
  114. pageChange(e) {
  115. this.$refs.table.clearSelection()
  116. //this.selectedIndexs.length = 0
  117. this.pageCurrent = e.current;
  118. this.getPage()
  119. },
  120. onTreeNodeClick(node) {
  121. console.log(JSON.stringify(node))
  122. },
  123. onTreePopupOpened(e) {
  124. console.log(JSON.stringify(e))
  125. },
  126. onTreePopupClosed(e) {
  127. console.log(JSON.stringify(e))
  128. },
  129. onTreeChange(e) {
  130. console.log(JSON.stringify(e))
  131. let nodes = e.detail.value;
  132. if (nodes.length > 0) {
  133. let node = nodes[nodes.length - 1];
  134. this.regionCode = node.value;
  135. this.query = {};
  136. this.query['adCode'] = this.regionCode;
  137. this.searchRtuNameVal = '';
  138. this.searchRtuCodeVal = '';
  139. this.pageCurrent = 1;
  140. this.getPage();
  141. } else {
  142. this.regionCode = '';
  143. this.query = {};
  144. this.searchRtuNameVal = '';
  145. this.searchRtuCodeVal = '';
  146. this.pageCurrent = 1;
  147. this.getPage();
  148. }
  149. },
  150. //录入查询
  151. search() {
  152. this.pageCurrent = 1;
  153. // console.log(JSON.stringify(res))
  154. let params = {};
  155. if (this.searchRtuCodeVal.length > 0) {
  156. params['rtuCode'] = this.searchRtuCodeVal;
  157. }
  158. if (this.searchRtuNameVal.length > 0) {
  159. params['rtuName'] = this.searchRtuNameVal;
  160. }
  161. this.getPage(params);
  162. },
  163. searchRtuNameValClear(e) {
  164. if (e == null || e.length == 0) {
  165. this.searchRtuNameVal = '';
  166. if (this.searchRtuNameVal.length == 0) {
  167. let params = {};
  168. if (this.searchRtuCodeVal.length > 0) {
  169. params['rtuCode'] = this.searchRtuCodeVal;
  170. }
  171. this.getPage(params);
  172. }
  173. }
  174. },
  175. searchRtuCodeValClear(e) {
  176. if (e == null || e.length == 0) {
  177. this.searchRtuCodeVal = '';
  178. if (this.searchRtuCodeVal.length == 0) {
  179. let params = {};
  180. if (this.searchRtuNameVal.length > 0) {
  181. params['rtuName'] = this.searchRtuNameVal;
  182. }
  183. this.getPage(params);
  184. }
  185. }
  186. },
  187. // 多选处理
  188. selectedItems() {
  189. return this.selectedIndexs.map(i => this.tableData[i])
  190. },
  191. // 多选
  192. selectionChange(e) {
  193. console.log(e.detail.index)
  194. this.selectedIndexs = e.detail.index
  195. },
  196. //批量删除
  197. delTable() {
  198. //console.log(this.selectedItems())
  199. },
  200. getRegionTree() {
  201. var that = this;
  202. http.request({
  203. url: '/galaxy-business/baseinfo/region/tree',
  204. method: 'GET',
  205. }).then(res => {
  206. if (res.data != null) {
  207. that.regionTree = res.data;
  208. that.selectedTreeNode = that.regionTree[0].value;
  209. that.regionCode = that.regionTree[0].value;
  210. that.query = {};
  211. that.query['adCode'] = that.regionCode;
  212. //that.orgId = that.projectTree[0].orgId;
  213. //that.projectId = that.projectTree[0].projectId;
  214. that.getPage();
  215. //that.getCountInfo(that.regionCode);
  216. }
  217. }).catch(err => {
  218. console.log(err)
  219. })
  220. },
  221. // 获取数据
  222. getPage(params = {}) {
  223. this.loading = true
  224. const current = this.pageCurrent;
  225. const size = this.pageSize;
  226. const isSubmit = '0';
  227. let postData = Object.assign(params, this.query);
  228. var that = this;
  229. http.request({
  230. url: '/galaxy-business/rtu/data/ground/page',
  231. method: 'GET',
  232. params: {
  233. current,
  234. size,
  235. isSubmit
  236. },
  237. data: postData,
  238. }).then(res => {
  239. if (res.data.records != null) {
  240. that.tableData = res.data.records;
  241. that.total = res.data.total;
  242. }
  243. this.loading = false
  244. }).catch(err => {
  245. console.log(err)
  246. this.loading = false
  247. })
  248. },
  249. onGroundInfoClick(item) {
  250. console.log(item.id + " " + item.rtuName)
  251. uni.navigateTo({
  252. url: '/pages/realdata/rtugrounddatadetail?id=' + item.id
  253. })
  254. },
  255. }
  256. }
  257. </script>
  258. <style>
  259. /* page {
  260. background-color: rgb(240, 242, 244);
  261. } */
  262. </style>
  263. <style lang="scss" scoped>
  264. .wrap {
  265. padding: 0 0 100rpx;
  266. }
  267. .container {
  268. background-color: #f7f7f7;
  269. min-height: 100vh;
  270. overflow: hidden;
  271. }
  272. </style>