فهرست منبع

设备注销功能

wzh 2 سال پیش
والد
کامیت
4be7b07fe8
7فایلهای تغییر یافته به همراه441 افزوده شده و 14 حذف شده
  1. 18 0
      api/device/device.js
  2. 12 0
      pages.json
  3. 30 0
      pages/device/detail.vue
  4. 158 0
      pages/device/reset/reset.vue
  5. 194 0
      pages/device/reset/resetrecord.vue
  6. 29 14
      pages/work/index.vue
  7. BIN
      static/images/icons/reset.png

+ 18 - 0
api/device/device.js

@@ -113,6 +113,13 @@ export function reportError(err){
         method: 'post',
     })
 }
+
+/**
+ * 主动上报列表
+ * @param pageNum
+ * @param pageSize
+ * @returns {*}
+ */
 export function errorList(pageNum,pageSize){
     let url = '/iot/desc/list?pageNum='+pageNum+'&pageSize='+pageSize;
     return request({
@@ -120,4 +127,15 @@ export function errorList(pageNum,pageSize){
         method: 'get',
     })
 }
+//设备注销记录
+export function resetList(pageNum,pageSize,deviceName){
+    let url = '/iot/reset/list?pageNum='+pageNum+'&pageSize='+pageSize;
+    if(deviceName){
+        url  = url +"&deviceName="+encodeURIComponent(deviceName)
+    }
+    return request({
+        url: url,
+        method: 'get',
+    })
+}
 

+ 12 - 0
pages.json

@@ -126,6 +126,18 @@
       "style": {
         "navigationBarTitleText": "异常列表"
       }
+    },
+    {
+      "path": "pages/device/reset/reset",
+      "style": {
+        "navigationBarTitleText": "设备注销"
+      }
+    },
+    {
+      "path": "pages/device/reset/resetrecord",
+      "style": {
+        "navigationBarTitleText": "注销记录"
+      }
     }
   ],
   "tabBar": {

+ 30 - 0
pages/device/detail.vue

@@ -18,6 +18,34 @@
                 v-model="deviceInfo.deviceName"
       ></u--input>
     </u-form-item>
+    <u-form-item   style="border:0px"
+                   label="所属机构:"
+                   labelWidth="auto"
+                   :borderBottom="false"
+    >
+      <u--input v-if="sysDept != null" disabled
+                placeholder="请选择分组22"
+                border="none"
+                color="gray"
+                disabledColor="white"
+                :value="sysDept.deptName"
+      ></u--input>
+
+      <u--input v-else-if="deviceInfo.deptId == -1" disabled
+                placeholder="请选择分组11"
+                border="none"
+                color="gray"
+                disabledColor="white"
+                value="已注销"
+      ></u--input>
+      <u--input v-else disabled
+                placeholder="未绑定"
+                border="none"
+                color="gray"
+                disabledColor="white"
+                value="未绑定"
+      ></u--input>
+    </u-form-item>
 
     <u-form-item   style="border:0px"
                    label="设备编号:"
@@ -253,6 +281,7 @@ export default {
         watchProp:[],
         columns:[],
         location:{},
+        sysDept:null,
       }
   },
   onLoad: function(opt) {
@@ -343,6 +372,7 @@ export default {
         self.location = {
           latitude: self.deviceInfo.latitude,
           longitude: self.deviceInfo.longitude};
+        self.sysDept = self.deviceInfo.sysDept;
         self.parseSummay(res.data.summary)
         self.mqttSubscribe(res.data);
         self.getDeviceStatus();

+ 158 - 0
pages/device/reset/reset.vue

@@ -0,0 +1,158 @@
+<template>
+  <view class="work-container">
+    <view style="margin-top: 10px">
+      <u-cell @click="resetUser"  title="扫码注销" :isLink="true" arrow-direction="left"></u-cell>
+      <u-cell  title="注销记录" :isLink="true" url="/pages/device/reset/resetrecord" arrow-direction="left"></u-cell>
+      <u-cell  title="已注销列表" :isLink="true" url="/pages/device/index?deptId=-1" arrow-direction="left"></u-cell>
+
+    </view>
+    <u-modal :show="show" :title="dlgTitle" @cancel="cancel" :showCancelButton="true" @confirm="bingDevice" >
+      <view class="slot-content">
+
+        <view>设备名称:{{ scanDevice.deviceName }}</view>
+        <view>产品名称:{{ scanDevice.productName }}</view>
+        <view>设备编号:{{ scanDevice.serialNumber }}</view>
+        <view>激活日期:{{ scanDevice.activeTime }}</view>
+
+      </view>
+    </u-modal>
+  </view>
+
+</template>
+
+<script>
+import {getDevcieByQrcode,bingDeviceDept} from '@/api/device/device';
+export default {
+  data() {
+    return {
+      dlgTitle:"",
+      current: 0,
+      swiperDotIndex: 0,
+      show:false,
+      scanDevice:{},
+    }
+  },
+  onLoad(){
+  },
+  methods: {
+    bingDevice(){
+      this.show = false;
+      bingDeviceDept(this.scanDevice).then(res=>{
+        if(res.code == 200){
+          this.$modal.showToast('操作成功')
+        }else{
+          this.$modal.showToast(res.msg);
+        }
+
+      })
+    },
+    cancel(){
+      this.show = false;
+      this.scanDevice = {};
+    },
+    resetUser(){
+      let self = this;
+      uni.scanCode({
+        success: function (res) {
+          console.log('条码内容:' + res.result);
+          getDevcieByQrcode(res.result).then(res=>{
+            let device = res.data;
+            if(!device){
+              self.$modal.showToast('未查到设备信息')
+            }else{
+              if(device.deptId == null){
+                self.$modal.showToast('该设备未绑定用户')
+              }else{
+                self.scanDevice = device;
+                self.dlgTitle = "解绑设备";
+                device.deptId = -1;
+                self.show = true;
+              }
+            }
+          });
+        }
+      });
+    },
+  }
+}
+</script>
+
+<style lang="scss">
+/* #ifndef APP-NVUE */
+.u-collapse-content{
+  display: flex;
+  flex-direction: column;
+}
+page {
+  display: flex;
+  flex-direction: column;
+  box-sizing: border-box;
+  background-color: #fff;
+  min-height: 100%;
+  height: auto;
+}
+
+view {
+  font-size: 14px;
+  line-height: inherit;
+}
+
+/* #endif */
+
+.text {
+  text-align: center;
+  font-size: 26rpx;
+  margin-top: 10rpx;
+}
+
+.grid-item-box {
+  flex: 1;
+  /* #ifndef APP-NVUE */
+  display: flex;
+  /* #endif */
+  flex-direction: column;
+  align-items: center;
+  justify-content: center;
+  padding: 15px 0;
+}
+
+.uni-margin-wrap {
+  width: 690rpx;
+  width: 100%;
+;
+}
+
+.swiper {
+  height: 300rpx;
+}
+
+.swiper-box {
+  height: 150px;
+}
+
+.swiper-item {
+  /* #ifndef APP-NVUE */
+  display: flex;
+  /* #endif */
+  flex-direction: column;
+  justify-content: center;
+  align-items: center;
+  color: #fff;
+  height: 300rpx;
+  line-height: 300rpx;
+}
+
+@media screen and (min-width: 500px) {
+  .uni-swiper-dot-box {
+    width: 400px;
+    /* #ifndef APP-NVUE */
+    margin: 0 auto;
+    /* #endif */
+    margin-top: 8px;
+  }
+
+  .image {
+    width: 100%;
+  }
+}
+</style>

+ 194 - 0
pages/device/reset/resetrecord.vue

@@ -0,0 +1,194 @@
+<template>
+  <view class="work-container">
+    <view class="header">
+      <u-search placeholder="请输入设备名称" :clearabled="true" @clear="searchDevice" @custom="searchDevice" v-model="search.deviceName" @search="searchDevice"></u-search>
+    </view>
+    <view style="margin-top: 10px">
+      <uni-card v-for="item in resetList" :title="item.deviceName" :extra="item.createTime">
+
+        <view style="position: relative">
+          <view>设备编号:{{item.deviceNo}}</view>
+          <view>操作人:{{item.userName}}</view>
+          <view>原机构:{{item.oriDeptName}}</view>
+<!--          <view v-if="item.status != 3" style="width: 50px;position: absolute;right:-10px;bottom:0px"><u-button @click="handle(item)" type="error" :plain="true" size="mini" text="处理"></u-button>-->
+<!--          </view>-->
+
+        </view>
+      </uni-card>
+      <uni-load-more @clickLoadMore="getMore" :contentText="contenText" :status="loadStatus"></uni-load-more>
+
+      <u-modal :show="showErrDlg" title="处理结果" @confirm="close" >
+        <view class="slot-content">
+
+          <u--textarea style="width:500rpx" autoheight v-model="chooseItem.result" disabled="" ></u--textarea>
+
+        </view>
+      </u-modal>
+    </view>
+  </view>
+</template>
+
+<script>
+import {resetList} from '@/api/device/device';
+export default {
+  data() {
+    return {
+      show:true,
+      resetList:[],
+      search:{
+        deviceName:""
+      },
+      pageNum:1,
+      pageSize:10,
+      chooseItem: {},
+      contenText:{contentdown: "点击加载更多",contentrefresh: "正在加载...",contentnomore: "没有更多数据了"},
+      loadStatus:"more",
+      showErrDlg:false,
+    }
+  },
+  onLoad(){
+    this.getresetList();
+  },
+  methods: {
+    searchDevice(){
+      this.pageNum =1;
+      this.resetList=[];
+      this.getresetList();
+    },
+    getMore(){
+      this.pageNum ++;
+      this.getresetList();
+    },
+    open(item) {
+      this.chooseItem = item;
+      this.showErrDlg = true;
+    },
+    close() {
+      this.chooseItem = {};
+      this.showErrDlg = false;
+    },
+    confirm(text){
+
+      if(!text){
+        uni.showToast({
+          icon:"error",
+          title:"请输入内容"
+        })
+        return;
+      }
+      let item = this.chooseItem;
+      item.remark = text;
+      this.close();
+      handleAlert(item).then(res=>{
+        if(res.code == 200){
+          item.status = 3;
+        }
+      })
+    },
+    searchDept(){
+      this.getDeptList();
+    },
+    watchResult(item){
+      this.open(item);
+    },
+    handle(item){
+      this.open(item);
+    },
+    getresetList(){
+      this.loadStatus = "loading"
+      resetList(this.pageNum,this.pageSize,this.search.deviceName).then(res=>{
+        if(res.total == this.resetList.length){
+          uni.showToast({
+            icon:"none",
+            title:"没有更多了"
+          })
+          this.loadStatus = "noMore"
+          return;
+        }
+        this.loadStatus = "more"
+        this.resetList = this.resetList.concat(res.rows);
+      });
+    }
+  }
+}
+</script>
+
+<style lang="scss">
+/* #ifndef APP-NVUE */
+.u-collapse-content{
+  display: flex;
+  flex-direction: column;
+}
+page {
+  display: flex;
+  flex-direction: column;
+  box-sizing: border-box;
+  background-color: #fff;
+  min-height: 100%;
+  height: auto;
+}
+
+view {
+  font-size: 14px;
+  line-height: inherit;
+}
+
+/* #endif */
+
+.text {
+  text-align: center;
+  font-size: 26rpx;
+  margin-top: 10rpx;
+}
+
+.grid-item-box {
+  flex: 1;
+  /* #ifndef APP-NVUE */
+  display: flex;
+  /* #endif */
+  flex-direction: column;
+  align-items: center;
+  justify-content: center;
+  padding: 15px 0;
+}
+
+.uni-margin-wrap {
+  width: 690rpx;
+  width: 100%;
+;
+}
+
+.swiper {
+  height: 300rpx;
+}
+
+.swiper-box {
+  height: 150px;
+}
+
+.swiper-item {
+  /* #ifndef APP-NVUE */
+  display: flex;
+  /* #endif */
+  flex-direction: column;
+  justify-content: center;
+  align-items: center;
+  color: #fff;
+  height: 300rpx;
+  line-height: 300rpx;
+}
+
+@media screen and (min-width: 500px) {
+  .uni-swiper-dot-box {
+    width: 400px;
+    /* #ifndef APP-NVUE */
+    margin: 0 auto;
+    /* #endif */
+    margin-top: 8px;
+  }
+
+  .image {
+    width: 100%;
+  }
+}
+</style>

+ 29 - 14
pages/work/index.vue

@@ -70,15 +70,15 @@
         </uni-grid-item>
 
         <uni-grid-item v-if="hasRole(['admin'])">
-          <view class="grid-item-box" @click="scanCode()">
-            <u--image :showLoading="true" src="/static/images/icons/scan.png" width="50rpx" height="50rpx" ></u--image>
+          <view class="grid-item-box" @click="goPage('reset')">
+            <u--image :showLoading="true" src="/static/images/icons/reset.png" width="50rpx" height="50rpx" ></u--image>
             <text class="text">注销设备</text>
           </view>
         </uni-grid-item>
 
       </uni-grid>
 
-      <u-modal :show="show" title="绑定设备" :showCancelButton="true" @confirm="bingDevice" >
+      <u-modal :show="show" :title="dlgTitle" @cancel="cancel" :showCancelButton="true" @confirm="bingDevice" >
         <view class="slot-content">
 
           <view>设备名称:{{ scanDevice.deviceName }}</view>
@@ -100,6 +100,7 @@ export default {
   components: {UImage},
   data() {
       return {
+        dlgTitle:"",
         current: 0,
         swiperDotIndex: 0,
         show:false,
@@ -121,7 +122,7 @@ export default {
           this.show = false;
         bingDeviceDept(this.scanDevice).then(res=>{
           if(res.code == 200){
-            this.$modal.showToast('绑定成功')
+            this.$modal.showToast('操作成功')
           }else{
             this.$modal.showToast(res.msg);
           }
@@ -129,8 +130,8 @@ export default {
         })
       },
       cancel(){
-        this.scanDevice = {};
         this.show = false;
+        this.scanDevice = {};
       },
       clickBannerItem(item) {
         console.log();
@@ -151,6 +152,13 @@ export default {
             console.log('条码内容:' + res.result);
             getDevcieByQrcode(res.result).then(res=>{
               let device = res.data;
+              if(!self.hasRole(['admin'])){
+                if(device.deptId == null || device.deptId == 0){
+                  self.$modal.showToast('设备不存在或无权限')
+                  return;
+                }
+              }
+
               if(device != null){
                 uni.navigateTo({
                   url: '/pages/device/detail?id='+device.deviceId
@@ -169,21 +177,23 @@ export default {
           success: function (res) {
             console.log('条码内容:' + res.result);
             getDevcieByQrcode(res.result).then(res=>{
-                let device = res.data;
-                if(!device){
-                  self.$modal.showToast('未查到设备信息')
+              let device = res.data;
+              if(!device){
+                self.$modal.showToast('未查到设备信息')
+              }else{
+                if(device.deptId != null){
+                  self.$modal.showToast('该设备已经绑定了用户')
                 }else{
-                  if(device.deptId != null){
-                    self.$modal.showToast('该设备已经绑定了用户')
-                  }else{
-                    self.scanDevice = device;
-                    self.show = true;
-                  }
+                  self.dlgTitle = "绑定设备";
+                  self.scanDevice = device;
+                  self.show = true;
                 }
+              }
             });
           }
         });
       },
+
       goPage(path){
         if('device' == path){
           uni.navigateTo({
@@ -215,6 +225,11 @@ export default {
             url: '/pages/device/error'
           });
         }
+        if('reset' == path){
+          uni.navigateTo({
+            url: '/pages/device/reset/reset'
+          });
+        }
 
       }
     }

BIN
static/images/icons/reset.png