siteManage.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  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="请输入站点名称" 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 inOneLine" style="display:block">{{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 v-show="isLoadMore&&this.currentPage>1">
  54. <uni-load-more :status="loadStatus"></uni-load-more>
  55. </view>
  56. </view>
  57. <!-- 站点列表end -->
  58. <!-- 新增按钮start -->
  59. <view style="width: 100%;
  60. position: fixed;
  61. bottom: 0px;
  62. right: 0px;
  63. height: 64px;
  64. background: #fff;">
  65. <view class="plus">
  66. <image src="../../static/plus.png" style="width:100rpx;height:100rpx" @tap="goAddPage()"></image>
  67. </view>
  68. </view>
  69. <!-- 新增按钮end -->
  70. </view>
  71. </template>
  72. <!-- <script src="https://res2.wx.qq.com/open/js/jweixin-1.6.0.js"></script> -->
  73. <script>
  74. </script>
  75. <script>
  76. //引入js sdk的封装
  77. import * as jwx from '../../util/jssdk.js'
  78. export default {
  79. data() {
  80. return {
  81. modalName: null,
  82. listTouchStart: 0,
  83. listTouchDirection: null,
  84. siteName: '',
  85. siteList: [],
  86. siteListRes: 0,
  87. router_id: 0,
  88. routeListData: [],
  89. route_name: '',
  90. isShow: false,
  91. formMess: {
  92. "siteName": "",
  93. },
  94. siteItemDataOrigin: [],
  95. siteItemData: [],
  96. currentPage: 1,
  97. size: 10,
  98. loadStatus: 'loading', //加载样式:more-加载前样式,loading-加载中样式,nomore-没有数据样式
  99. isLoadMore: false, //是否加载中
  100. };
  101. },
  102. onReachBottom() { //上拉触底函数
  103. if (!this.isLoadMore) { //此处判断,上锁,防止重复请求
  104. this.isLoadMore = true
  105. this.currentPage += 1;
  106. this.loadData()
  107. }
  108. },
  109. onLoad: function(option) {
  110. //站点列表渲染
  111. this.loadData()
  112. this.getRoutrBox()
  113. },
  114. methods: {
  115. //筛选
  116. searchSiteList() {
  117. this.currentPage = 1;
  118. this.loadData()
  119. },
  120. loadData(){
  121. this.getSiteList({
  122. "siteName": this.siteName,
  123. "route_name": this.formMess.siteName,
  124. currentPage: this.currentPage,
  125. size: this.size,
  126. })
  127. },
  128. //线路名称下拉数据请求
  129. async getRoutrBox(params = {}) {
  130. const res = await this.$myRequest({
  131. url: 'Archives/getRoutrBox',
  132. showLoading: true,
  133. data: params
  134. })
  135. // this.routeListData = res.data.data;
  136. // console.log(this.routeListData)
  137. this.siteItemData = res.data.data;
  138. this.siteItemDataOrigin = res.data.data;
  139. this.siteItemData = this.siteItemDataOrigin;
  140. },
  141. //选中下拉选项,隐藏框,赋值
  142. changeModel: function(item, index) {
  143. this.isShow = false;
  144. this.formMess.siteName = item.route_name;
  145. },
  146. // 输入框点击 显示隐藏下拉框
  147. toggleShow: function() {
  148. this.isShow = !this.isShow;
  149. },
  150. //点击下拉筛选
  151. handleInput() {
  152. //将元素根据搜索内容过滤出来 这里改变了siteItemData
  153. this.siteItemData = this.siteItemDataOrigin;
  154. this.siteItemData = this.siteItemData.filter(item => item.route_name.indexOf(this.formMess.siteName) > -1);
  155. },
  156. focusfns: function(e) {
  157. //将元素根据搜索内容过滤出来 这里改变了siteItemData
  158. this.siteItemData = this.siteItemDataOrigin;
  159. this.siteItemData = this.siteItemData.filter(item => item.route_name.indexOf(this.formMess.siteName) >
  160. -1);
  161. },
  162. //编辑
  163. editItem(item) {
  164. uni.navigateTo({
  165. url: '/pages/siteAdd/siteAdd?id=' + item.id + '',
  166. });
  167. },
  168. //删除
  169. deleteItem(item) {
  170. uni.showModal({
  171. title: '确认删除吗?',
  172. content: '',
  173. success: function(result) {
  174. if (result.confirm) {
  175. this.setDelSite({
  176. "id": item.id
  177. })
  178. } else if (result.cancel) {
  179. // console.log('用户点击取消');
  180. }
  181. }.bind(this)
  182. });
  183. },
  184. // 打开导航
  185. mapLocation(item) {
  186. //h5 地图导航
  187. // window.location.href = 'http://apis.map.qq.com/uri/v1/marker?marker=coord:'+parseFloat(item.latitude)+','+parseFloat(item.longitude)+''
  188. //app导航
  189. // uni.openLocation({
  190. // latitude: parseFloat(item.latitude),
  191. // longitude: parseFloat(item.longitude),
  192. // success: function() {
  193. // // console.log('success');
  194. // }
  195. // });
  196. // 微信公众号导航
  197. jwx.configWeiXin(jweixin => {
  198. let shareInfo = {
  199. latitude: parseFloat(item.latitude), // 纬度,浮点数,范围为90 ~ -90
  200. longitude: parseFloat(item.longitude), // 经度,浮点数,范围为180 ~ -180。
  201. name: item.siteName, // 位置名
  202. address: item.address, // 地址详情说明
  203. scale: 15, // 地图缩放级别,整型值,范围从1~28。默认为最大
  204. };
  205. jweixin.openLocation(shareInfo);
  206. });
  207. },
  208. async setDelSite(ming = {}) {
  209. const res = await this.$myRequest({
  210. url: 'SiteManagement/setDelSite',
  211. data: ming
  212. })
  213. if (!res.data.flag) {
  214. uni.showToast({
  215. title: "删除失败",
  216. icon: "none"
  217. });
  218. } else {
  219. uni.showToast({
  220. title: "删除成功",
  221. });
  222. setTimeout(() => {
  223. this.getSiteList()
  224. }, 1000);
  225. }
  226. },
  227. async getSiteList(ming = {}) {
  228. const res = await this.$myRequest({
  229. url: 'SiteManagement/getSiteList',
  230. showLoading: true,
  231. data: ming
  232. })
  233. this.siteListRes = 1;
  234. if (res.data.total) {
  235. this.siteList = this.siteList.concat(res.data.data)
  236. if (res.data.data.length < this.size) { //判断接口返回数据量小于请求数据量,则表示此为最后一页
  237. this.isLoadMore = true
  238. this.loadStatus = 'nomore'
  239. } else {
  240. this.isLoadMore = false
  241. }
  242. } else {
  243. this.isLoadMore = true
  244. this.loadStatus = 'nomore'
  245. }
  246. },
  247. // 新增跳转
  248. goAddPage() {
  249. uni.navigateTo({
  250. url: '/pages/siteAdd/siteAdd',
  251. success: res => {},
  252. fail: () => {},
  253. complete: () => {}
  254. });
  255. },
  256. //跳转到设备管理页面
  257. goDeviceManage(item) {
  258. uni.navigateTo({
  259. url: '/pages/deviceManage/deviceManage?siteId=' + item.id + '',
  260. success: res => {},
  261. fail: () => {},
  262. complete: () => {}
  263. });
  264. },
  265. // ListTouch触摸开始
  266. ListTouchStart(e) {
  267. this.listTouchStart = e.touches[0].pageX
  268. },
  269. // ListTouch计算方向
  270. ListTouchMove(e) {
  271. this.listTouchDirection = e.touches[0].pageX - this.listTouchStart < -80 ? 'left' : 'right'
  272. },
  273. // ListTouch计算滚动
  274. ListTouchEnd(e) {
  275. if (this.listTouchDirection == 'left') {
  276. this.modalName = e.currentTarget.dataset.target
  277. } else {
  278. this.modalName = null
  279. }
  280. this.listTouchDirection = null
  281. }
  282. }
  283. }
  284. </script>
  285. <style>
  286. </style>