siteManage.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <template>
  2. <view class="site-wrapper">
  3. <!-- 筛选框start -->
  4. <view style="height:200rpx"></view>
  5. <view class="ding">
  6. <view class="cu-bar search bg-gray filter-section" style="padding-top:10rpx">
  7. <view class="search-form round bg-white" style="position:relative;overflow:auto">
  8. <input name="siteName" v-model="formMess.siteName" @click="toggleShow" @focus="focusfns"
  9. @input="handleInput()" placeholder="请输入或选择所属线路"></input>
  10. </view>
  11. </view>
  12. <view class="cu-bar search bg-gray filter-section">
  13. <view class="search-form round bg-white">
  14. <text class="cuIcon-search"></text>
  15. <input class="" type="text" placeholder="请输入站点名称" confirm-type="search" v-model="siteName"></input>
  16. </view>
  17. <view class="action">
  18. <button class="cu-btn bg-blue round" @click="searchSiteList">查询</button>
  19. </view>
  20. </view>
  21. </view>
  22. <view class="siteItems" v-if="isShow" style="max-height:60vh;overflow:auto;position:absolute;z-index:999; margin: 0 32rpx;
  23. width: calc(100% - 64rpx);top:100rpx">
  24. <view class=" site-item" v-if="!siteItemData.length">暂无结果</view>
  25. <view class="site-item" v-for="(item,index) in siteItemData" @click="changeModel(item,index)" :key="index" style="padding:16rpx 22rpx">
  26. {{item.route_name}}
  27. </view>
  28. </view>
  29. <!-- 筛选框end -->
  30. <!-- 站点列表start -->
  31. <view class="site-items" style="margin-top:0;height: calc(100vh - 380rpx);">
  32. <view class="cu-list menu-avatar">
  33. <view class="cu-item" :class="modalName=='move-box-'+ index?'move-cur':''"
  34. v-for="(item,index) in siteList" :key="index" @touchstart="ListTouchStart"
  35. @touchmove="ListTouchMove" @touchend="ListTouchEnd" :data-target="'move-box-' + index">
  36. <view class="cu-avatar round lg" style="background-image: url(../../static/site-icon.png);"></view>
  37. <view class="content" @tap="goDeviceManage(item)">
  38. <view class="text-grey site-tit">{{item.siteName}}</view>
  39. </view>
  40. <view class="nav-right num">
  41. <view class="text-grey text-xs">
  42. <image @click="mapLocation(item)" src="../../static/nav-icon.png"
  43. style="width:25rpx;height:25rpx;margin-right:26rpx"></image>
  44. </view>
  45. </view>
  46. <view class="move">
  47. <view class="bg-grey" @click.stop="editItem(item)">编辑</view>
  48. <view class="bg-red" @click.stop="deleteItem(item)">删除</view>
  49. </view>
  50. </view>
  51. </view>
  52. <view v-if="!siteList.length&&siteListRes==1" class="text-center margin-top"> 暂无数据</view>
  53. </view>
  54. <!-- 站点列表end -->
  55. <!-- 新增按钮start -->
  56. <view class="plus">
  57. <image src="../../static/plus.png" style="width:100rpx;height:100rpx" @tap="goAddPage()"></image>
  58. </view>
  59. <!-- 新增按钮end -->
  60. </view>
  61. </template>
  62. <!-- <script src="https://res2.wx.qq.com/open/js/jweixin-1.6.0.js"></script> -->
  63. <script>
  64. </script>
  65. <script>
  66. //引入js sdk的封装
  67. import * as jwx from '../../util/jssdk.js'
  68. export default {
  69. data() {
  70. return {
  71. modalName: null,
  72. listTouchStart: 0,
  73. listTouchDirection: null,
  74. siteName: '',
  75. siteList: [],
  76. siteListRes: 0,
  77. router_id: 0,
  78. routeListData: [],
  79. route_name: '',
  80. isShow: false,
  81. formMess: {
  82. "siteName": "",
  83. },
  84. siteItemDataOrigin: [],
  85. siteItemData: [],
  86. };
  87. },
  88. onLoad: function(option) {
  89. //站点列表渲染
  90. this.getSiteList()
  91. this.getRoutrBox()
  92. },
  93. methods: {
  94. //线路名称下拉数据请求
  95. async getRoutrBox(params = {}) {
  96. const res = await this.$myRequest({
  97. url: 'Archives/getRoutrBox',
  98. showLoading: true,
  99. data: params
  100. })
  101. // this.routeListData = res.data.data;
  102. // console.log(this.routeListData)
  103. this.siteItemData = res.data.data;
  104. this.siteItemDataOrigin = res.data.data;
  105. this.siteItemData = this.siteItemDataOrigin;
  106. },
  107. //选中下拉选项,隐藏框,赋值
  108. changeModel: function(item, index) {
  109. this.isShow = false;
  110. this.formMess.siteName = item.route_name;
  111. },
  112. // 输入框点击 显示隐藏下拉框
  113. toggleShow: function() {
  114. this.isShow = !this.isShow;
  115. },
  116. //点击下拉筛选
  117. handleInput() {
  118. //将元素根据搜索内容过滤出来 这里改变了siteItemData
  119. this.siteItemData = this.siteItemDataOrigin;
  120. this.siteItemData = this.siteItemData.filter(item => item.route_name.indexOf(this.formMess.siteName) > -1);
  121. },
  122. focusfns: function(e) {
  123. //将元素根据搜索内容过滤出来 这里改变了siteItemData
  124. this.siteItemData = this.siteItemDataOrigin;
  125. this.siteItemData = this.siteItemData.filter(item => item.route_name.indexOf(this.formMess.siteName) >
  126. -1);
  127. },
  128. //筛选
  129. searchSiteList() {
  130. this.getSiteList({
  131. "siteName": this.siteName,
  132. "route_name": this.formMess.siteName
  133. })
  134. },
  135. //编辑
  136. editItem(item) {
  137. uni.navigateTo({
  138. url: '/pages/siteAdd/siteAdd?id=' + item.id + '',
  139. });
  140. },
  141. //删除
  142. deleteItem(item) {
  143. uni.showModal({
  144. title: '确认删除吗?',
  145. content: '',
  146. success: function(result) {
  147. if (result.confirm) {
  148. this.setDelSite({
  149. "id": item.id
  150. })
  151. } else if (result.cancel) {
  152. // console.log('用户点击取消');
  153. }
  154. }.bind(this)
  155. });
  156. },
  157. // 打开导航
  158. mapLocation(item) {
  159. //h5 地图导航
  160. // window.location.href = 'http://apis.map.qq.com/uri/v1/marker?marker=coord:'+parseFloat(item.latitude)+','+parseFloat(item.longitude)+''
  161. //app导航
  162. // uni.openLocation({
  163. // latitude: parseFloat(item.latitude),
  164. // longitude: parseFloat(item.longitude),
  165. // success: function() {
  166. // // console.log('success');
  167. // }
  168. // });
  169. // 微信公众号导航
  170. jwx.configWeiXin(jweixin => {
  171. let shareInfo = {
  172. latitude: parseFloat(item.latitude), // 纬度,浮点数,范围为90 ~ -90
  173. longitude: parseFloat(item.longitude), // 经度,浮点数,范围为180 ~ -180。
  174. name: item.siteName, // 位置名
  175. address: item.address, // 地址详情说明
  176. scale: 15, // 地图缩放级别,整型值,范围从1~28。默认为最大
  177. };
  178. jweixin.openLocation(shareInfo);
  179. });
  180. },
  181. async setDelSite(ming = {}) {
  182. const res = await this.$myRequest({
  183. url: 'SiteManagement/setDelSite',
  184. data: ming
  185. })
  186. if (!res.data.flag) {
  187. uni.showToast({
  188. title: "删除失败",
  189. icon: "none"
  190. });
  191. } else {
  192. uni.showToast({
  193. title: "删除成功",
  194. });
  195. setTimeout(() => {
  196. this.getSiteList()
  197. }, 1000);
  198. }
  199. },
  200. async getSiteList(ming = {}) {
  201. const res = await this.$myRequest({
  202. url: 'SiteManagement/getSiteList',
  203. showLoading: true,
  204. data: ming
  205. })
  206. this.siteListRes = 1;
  207. this.siteList = res.data.data
  208. console.log(res.data.data);
  209. },
  210. // 新增跳转
  211. goAddPage() {
  212. uni.navigateTo({
  213. url: '/pages/siteAdd/siteAdd',
  214. success: res => {},
  215. fail: () => {},
  216. complete: () => {}
  217. });
  218. },
  219. //跳转到设备管理页面
  220. goDeviceManage(item) {
  221. uni.navigateTo({
  222. url: '/pages/deviceManage/deviceManage?siteId=' + item.id + '',
  223. success: res => {},
  224. fail: () => {},
  225. complete: () => {}
  226. });
  227. },
  228. // ListTouch触摸开始
  229. ListTouchStart(e) {
  230. this.listTouchStart = e.touches[0].pageX
  231. },
  232. // ListTouch计算方向
  233. ListTouchMove(e) {
  234. this.listTouchDirection = e.touches[0].pageX - this.listTouchStart < -80 ? 'left' : 'right'
  235. },
  236. // ListTouch计算滚动
  237. ListTouchEnd(e) {
  238. if (this.listTouchDirection == 'left') {
  239. this.modalName = e.currentTarget.dataset.target
  240. } else {
  241. this.modalName = null
  242. }
  243. this.listTouchDirection = null
  244. }
  245. }
  246. }
  247. </script>
  248. <style>
  249. </style>