deviceManage.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. <template>
  2. <view class="deviceRegistWrapper" ref="contentWrapper">
  3. <!-- 筛选框start -->
  4. <view>
  5. <view style="height:206rpx"></view>
  6. <view class="ding">
  7. <view class="cu-bar search bg-gray filter-section" style="with:50%;">
  8. <view class="search-form round bg-white">
  9. <select name="" id="" placeholder="">
  10. <option value="">请选择设备类型</option>
  11. <option value="">类型1</option>
  12. <option value="">类型2</option>
  13. </select>
  14. </view>
  15. <view class="search-form round bg-white">
  16. <input type="text" placeholder="选输入设备点位" confirm-type="search"></input>
  17. </view>
  18. </view>
  19. <view class="cu-bar search bg-gray filter-section">
  20. <view class="search-form round bg-white" style="margin-bottom:26rpx">
  21. <input class="" @focus="InputFocus" v-model="siteName" @blur="InputBlur" :adjust-position="false"
  22. type="text" placeholder="选择传输方式" confirm-type="search"></input>
  23. </view>
  24. <view class="action">
  25. <button class="cu-btn bg-blue round" @click="searchData()">查询</button>
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. <!-- 筛选框end -->
  31. <!-- 设备注册列表start -->
  32. <block class="">
  33. <view class="processList deviceRegistList" style="height: calc(100vh - 241px);">
  34. <view class="cu-list menu-avatar ">
  35. <view class="cu-item" :class="modalName=='move-box-'+ index?'move-cur':''"
  36. v-for="(item,index) in newDeviceManage" :key="index" :data-target="'move-box-' + index">
  37. <checkbox-group class="block" @change="CheckboxChange">
  38. <view class="cu-form-group margin-top">
  39. <checkbox class='blue' @click="selectedProduct(item)" :class="{'check':item.checked}" value="A"></checkbox>
  40. </view>
  41. </checkbox-group>
  42. <view class="cu-avatar round lg" style="background-image:url(../../static/device-icon.png)">
  43. </view>
  44. <view class="content" @longpress="showDetail(item)">
  45. <view class="pro-title">
  46. <view class="cut">{{item.title}}</view>
  47. </view>
  48. <view class="pro-des ">
  49. <view class="text-cut">
  50. {{item.des}}
  51. </view>
  52. </view>
  53. <view class="pro-date ">{{item.time}}</view>
  54. <view class="showDetail" v-if="item.isShow">
  55. <view @tap="goDeviceEdit()">修改设备</view>
  56. <view @tap="deleteItem" data-target="DialogModal2">删除设备</view>
  57. </view>
  58. </view>
  59. <view class="nav-right num">
  60. <view class="text-grey">
  61. <span class="online" v-if="item.status==0">在线</span>
  62. <span class="offline" v-if="item.status==1">离线</span>
  63. <span class="error" v-if="item.status==2">故障</span>
  64. <text class="icon iconfont margin-right-xs margin-left-lg">&#xe629;</text>
  65. </view>
  66. </view>
  67. </view>
  68. </view>
  69. </view>
  70. </block>
  71. <!-- 设备注册列表end -->
  72. <view class="share grid col-3 ">
  73. <view class="share-item text-center">
  74. <view><text class="icon iconfont margin-xs" style="color:#19A402">&#xe66d;</text></view>
  75. <view @tap="goDeviceAdd()">新增</view>
  76. </view>
  77. <view class="share-item text-center">
  78. <view><text class="icon iconfont margin-xs" style="color:#FF0303">&#xe66c;</text></view>
  79. <view @tap="deleteItem" data-target="DialogModal2">删除</view>
  80. </view>
  81. <view class="share-item text-center" >
  82. <view><text class="icon iconfont margin-xs" style="color:#FF642E">&#xe66e;</text></view>
  83. <view @tap="showModal" data-target="DialogModal">导出</view>
  84. </view>
  85. <view class="checkAll">
  86. <checkbox-group class="block" @change="CheckboxChange" style="display:inline-block">
  87. <view class="cu-form-group margin-top">
  88. <checkbox class='blue' :class="checkbox[0].checked?'checked':''"
  89. :checked="checkbox[0].checked?true:false" value="A"></checkbox>
  90. </view>
  91. </checkbox-group>
  92. <text class="margin-left-xs">全选</text>
  93. </view>
  94. </view>
  95. <!-- 导出弹框 -->
  96. <view class="cu-modal export-modal" :class="modalName=='DialogModal'?'show':''">
  97. <view class="cu-dialog">
  98. <view class="cu-bar bg-white justify-end">
  99. <view class="action" @tap="hideModal">
  100. <text class="cuIcon-close"></text>
  101. </view>
  102. </view>
  103. <view class="padding-sm bg-white">
  104. <image src="../../static/ok.png" style="width:100rpx;height:100rpx"></image>
  105. <view style="margin:20rpx 0">已导出文件,是否打开?</view>
  106. </view>
  107. <view class="cu-bar operate bg-white" style="min-height: 100rpx;">
  108. <view class="action margin-0 " @tap="hideModal">
  109. 另存为</view>
  110. <view class="action margin-0 solid-left text-blue" @tap="hideModal">打开</view>
  111. </view>
  112. </view>
  113. </view>
  114. <!-- 导出弹框 end -->
  115. <!-- 删除弹框 -->
  116. <view class="cu-modal export-modal" :class="modalName=='DialogModal2'?'show':''">
  117. <view class="cu-dialog">
  118. <view class="cu-bar bg-white justify-end">
  119. <view class="action" @tap="hideModal">
  120. <text class="cuIcon-close"></text>
  121. </view>
  122. </view>
  123. <view class="padding-sm bg-white">
  124. <image src="../../static/chart3-2.png" style="width:100rpx;height:100rpx"></image>
  125. <view style="margin:20rpx 0">确定删除该设备吗?</view>
  126. </view>
  127. <view class="cu-bar operate bg-white" style="min-height: 100rpx;">
  128. <view class="action margin-0 " @tap="hideModal">
  129. 取消</view>
  130. <view class="action margin-0 solid-left text-blue" @tap="openConfirmModal" data-target="DialogModal3">确定</view>
  131. </view>
  132. </view>
  133. </view>
  134. <!-- 删除弹框 end -->
  135. <!-- 再次确认删除弹框 -->
  136. <view class="cu-modal export-modal" :class="modalName=='DialogModal3'?'show':''">
  137. <view class="cu-dialog">
  138. <view class="cu-bar bg-white justify-end">
  139. <view class="action" @tap="hideModal">
  140. <text class="cuIcon-close"></text>
  141. </view>
  142. </view>
  143. <view class="padding-sm bg-white">
  144. <view style="margin:20rpx 0">请输入图片中的验证码</view>
  145. <valid-code :value.sync="validCode"></valid-code>
  146. </view>
  147. <view class="cu-bar operate bg-white" style="min-height: 100rpx;">
  148. <view class="action margin-0 " @tap="hideModal">
  149. 取消</view>
  150. <view class="action margin-0 solid-left text-blue" @tap="hideModal">确定</view>
  151. </view>
  152. </view>
  153. </view>
  154. <!-- 再次确认删除弹框 end -->
  155. </view>
  156. </template>
  157. <script>
  158. import json from '../../data/json.js';
  159. import validCode from './component/validCode/validCode';
  160. export default {
  161. components: {
  162. validCode
  163. },
  164. data() {
  165. return {
  166. validCode:'',
  167. checkbox: [{
  168. value: 'A',
  169. checked: false
  170. }],
  171. deviceManage: json.deviceManage,
  172. siteListRes: 0,
  173. siteName: '',
  174. type: '0',
  175. siteListData: [],
  176. modalName: null,
  177. // modalName2: null,
  178. listTouchStart: 0,
  179. listTouchDirection: null,
  180. CustomBar: this.CustomBar,
  181. };
  182. },
  183. onPullDownRefresh() {
  184. console.log('refresh');
  185. setTimeout(function() {
  186. uni.stopPullDownRefresh();
  187. }, 1000);
  188. },
  189. computed: {
  190. newDeviceManage() {
  191. return this.deviceManage.map(item => {
  192. this.$set(item, "isShow", false)
  193. return item
  194. })
  195. }
  196. },
  197. mounted() {
  198. document.addEventListener('click', (e) => {
  199. if (e.target.className != 'showDetail') {
  200. this.deviceManage.forEach(item => {
  201. item.isShow = false
  202. })
  203. }
  204. })
  205. },
  206. methods: {
  207. selectedProduct:function(item){
  208. console.log(item)
  209. if(typeof item.checked=='undefined'){
  210. this.$set(item,'checked',true);
  211. }else{
  212. item.checked = !item.checked;
  213. }
  214. },
  215. // 页面跳转
  216. goDeviceAdd() {
  217. uni.navigateTo({
  218. url: '/pages/deviceManage/deviceAdd/deviceAdd',
  219. });
  220. },
  221. goDeviceEdit() {
  222. uni.navigateTo({
  223. url: '/pages/deviceManage/deviceEdit/deviceEdit',
  224. });
  225. },
  226. //导出弹框
  227. showModal(e) {
  228. this.modalName = e.currentTarget.dataset.target
  229. },
  230. //关闭弹框
  231. hideModal(e) {
  232. this.modalName = null
  233. },
  234. //删除弹出框操作
  235. deleteItem(e){
  236. this.modalName = e.currentTarget.dataset.target;
  237. },
  238. //再次确认弹框
  239. openConfirmModal(e){
  240. this.modalName = e.currentTarget.dataset.target;
  241. },
  242. CheckboxChange(e) {
  243. var items = this.checkbox,
  244. values = e.detail.value;
  245. for (var i = 0, lenI = items.length; i < lenI; ++i) {
  246. items[i].checked = false;
  247. for (var j = 0, lenJ = values.length; j < lenJ; ++j) {
  248. if (items[i].value == values[j]) {
  249. items[i].checked = true;
  250. break
  251. }
  252. }
  253. }
  254. },
  255. // 隐藏显示
  256. showDetail(e) {
  257. // alert(1)
  258. // 存储点击那一项的状态
  259. const nowStatu = e.isShow;
  260. // 将每一项列表的isShow设置为false,让所有的列表都隐藏
  261. this.deviceManage.forEach(item => {
  262. item.isShow = false
  263. })
  264. // 用于再次点击该项的取反
  265. e.isShow = !nowStatu
  266. },
  267. InputFocus(e) {
  268. this.InputBottom = e.detail.height
  269. },
  270. InputBlur(e) {
  271. this.InputBottom = 0
  272. },
  273. }
  274. }
  275. </script>
  276. <style >
  277. .showDetail {
  278. position: absolute;
  279. background: #fff;
  280. box-shadow: 0 1px 6px 0 rgb(32 33 36 / 28%);
  281. border-radius: 10rpx;
  282. top: 50rpx;
  283. right: 47%;
  284. z-index: 3000000;
  285. font-size: 28rpx;
  286. }
  287. .showDetail view{
  288. padding: 0rpx 20rpx;
  289. }
  290. .showDetail view:first-child{
  291. border-bottom:1px solid #EDEDED;
  292. }
  293. </style>