deviceManage.vue 9.2 KB

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