deviceManage.vue 11 KB

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