siteManage.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <template>
  2. <view class="site-wrapper">
  3. <!-- 筛选框start -->
  4. <view class="ding">
  5. <view class="cu-bar search bg-gray filter-section">
  6. <view class="search-form round bg-white">
  7. <text class="cuIcon-search"></text>
  8. <input class="" type="text" placeholder="请输入站点名称"
  9. confirm-type="search" v-model="siteName"></input>
  10. </view>
  11. <view class="action">
  12. <button class="cu-btn bg-blue round" @click="searchSiteList">查询</button>
  13. </view>
  14. </view>
  15. </view>
  16. <!-- 筛选框end -->
  17. <!-- 站点列表start -->
  18. <view class="site-items">
  19. <view class="cu-list menu-avatar">
  20. <view class="cu-item" :class="modalName=='move-box-'+ index?'move-cur':''" v-for="(item,index) in siteList" :key="index"
  21. @touchstart="ListTouchStart" @touchmove="ListTouchMove" @touchend="ListTouchEnd" :data-target="'move-box-' + index">
  22. <view class="cu-avatar round lg" style="background-image: url(../../static/site-icon.png);"></view>
  23. <view class="content" @tap="goDeviceManage">
  24. <view class="text-grey site-tit">{{item.siteName}}</view>
  25. </view>
  26. <view class="nav-right num">
  27. <view class="text-grey text-xs">
  28. <image @click="mapLocation(item)" src="../../static/nav-icon.png" style="width:25rpx;height:25rpx;margin-right:26rpx"></image>
  29. </view>
  30. </view>
  31. <view class="move">
  32. <view class="bg-grey" @click.stop="editItem(item)">编辑</view>
  33. <view class="bg-red" @click.stop="deleteItem(item)">删除</view>
  34. </view>
  35. </view>
  36. </view>
  37. <view v-if="!siteList.length&&siteListRes==1" class="text-center margin-top"> 暂无数据</view>
  38. </view>
  39. <!-- 站点列表end -->
  40. <!-- 新增按钮start -->
  41. <view class="plus">
  42. <image src="../../static/plus.png" style="width:125rpx;height:125rpx" @tap="goAddPage()"></image>
  43. </view>
  44. <!-- 新增按钮end -->
  45. </view>
  46. </template>
  47. <script>
  48. export default {
  49. data() {
  50. return {
  51. modalName: null,
  52. listTouchStart: 0,
  53. listTouchDirection: null,
  54. siteName: '',
  55. siteList: [],
  56. siteListRes: 0,
  57. };
  58. },
  59. onLoad: function(option) {
  60. //站点列表渲染
  61. this.getSiteList()
  62. },
  63. methods: {
  64. //筛选
  65. searchSiteList() {
  66. this.getSiteList({
  67. "siteName": this.siteName
  68. })
  69. },
  70. //编辑
  71. editItem(item) {
  72. uni.navigateTo({
  73. url: '/pages/siteAdd/siteAdd?id=' + item.id + '',
  74. });
  75. },
  76. //删除
  77. deleteItem(item) {
  78. uni.showModal({
  79. title: '确认删除吗?',
  80. content: '',
  81. success: function(result) {
  82. if (result.confirm) {
  83. this.setDelSite({
  84. "id": item.id
  85. })
  86. } else if (result.cancel) {
  87. // console.log('用户点击取消');
  88. }
  89. }.bind(this)
  90. });
  91. },
  92. // 打开导航
  93. mapLocation(item) {
  94. uni.openLocation({
  95. latitude: parseInt(item.latitude),
  96. longitude: parseInt(item.longitude),
  97. success: function() {
  98. // console.log('success');
  99. }
  100. });
  101. },
  102. async setDelSite(ming = {}) {
  103. const res = await this.$myRequest({
  104. url: 'SiteManagement/setDelSite',
  105. data: ming
  106. })
  107. if (!res.data.flag) {
  108. uni.showToast({
  109. title: "删除失败",
  110. icon: "none"
  111. });
  112. }else{
  113. uni.showToast({
  114. title: "删除成功",
  115. });
  116. setTimeout(() => {
  117. this.getSiteList()
  118. }, 1000);
  119. }
  120. },
  121. async getSiteList(ming = {}) {
  122. const res = await this.$myRequest({
  123. url: 'SiteManagement/getSiteList',
  124. showLoading: true,
  125. data: ming
  126. })
  127. this.siteListRes = 1;
  128. this.siteList = res.data.data
  129. console.log(res.data.data);
  130. },
  131. // 新增跳转
  132. goAddPage() {
  133. uni.navigateTo({
  134. url: '/pages/siteAdd/siteAdd',
  135. success: res => {},
  136. fail: () => {},
  137. complete: () => {}
  138. });
  139. },
  140. //跳转到设备管理页面
  141. goDeviceManage() {
  142. uni.navigateTo({
  143. url: '/pages/deviceManage/deviceManage',
  144. success: res => {},
  145. fail: () => {},
  146. complete: () => {}
  147. });
  148. },
  149. // ListTouch触摸开始
  150. ListTouchStart(e) {
  151. this.listTouchStart = e.touches[0].pageX
  152. },
  153. // ListTouch计算方向
  154. ListTouchMove(e) {
  155. this.listTouchDirection = e.touches[0].pageX - this.listTouchStart < -80 ? 'left' : 'right'
  156. },
  157. // ListTouch计算滚动
  158. ListTouchEnd(e) {
  159. if (this.listTouchDirection == 'left') {
  160. this.modalName = e.currentTarget.dataset.target
  161. } else {
  162. this.modalName = null
  163. }
  164. this.listTouchDirection = null
  165. }
  166. }
  167. }
  168. </script>
  169. <style>
  170. </style>