deviceManage.vue 12 KB

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