浏览代码

掉线日志

chenrui 4 年之前
父节点
当前提交
29f697d132
共有 3 个文件被更改,包括 41 次插入31 次删除
  1. 11 0
      src/api/device.js
  2. 4 4
      src/views/equipmentManage/equipment/equipment.vue
  3. 26 27
      src/views/equipmentManage/equipment/logModal.vue

+ 11 - 0
src/api/device.js

@@ -47,3 +47,14 @@ export const deviceUpdateDeviceType = (params) => {
     method: 'get'
   })
 }
+// 设备日志列表
+export const deviceLogList = (params) => {
+  const url = `/deviceLog/query/${params.pageNo}/${params.pageSize}`
+  delete params.pageNo
+  delete params.pageSize
+  return axios.request({
+    url: url,
+    data: params,
+    method: 'post'
+  })
+}

+ 4 - 4
src/views/equipmentManage/equipment/equipment.vue

@@ -52,7 +52,7 @@
       </template>
     </s-table>
     <!-- 掉线日志 -->
-    <equipment-log-modal :openModal="openLogModal" :equipmentId="equipmentId" @close="openLogModal=false" />
+    <equipment-log-modal :openModal="openLogModal" :srcDeviceCode="srcDeviceCode" @close="openLogModal=false" />
   </a-card>
 </template>
 
@@ -79,7 +79,7 @@ export default {
         { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
         { title: '网点名称', dataIndex: 'stationName', width: 200, align: 'center' },
         { title: '地址', dataIndex: 'stationAddress', width: 200, align: 'center' },
-        { title: '设备编号', dataIndex: 'deviceNo', width: 200, align: 'center' },
+        { title: '设备编号', dataIndex: 'srcDeviceCode', width: 200, align: 'center' },
         { title: '箱体类型', dataIndex: 'deviceTypeName', width: 200, align: 'center' },
         { title: '内置箱体数', dataIndex: 'boxNum', width: 200, align: 'center' },
         { title: '内置各箱体已投放比例(%)',
@@ -111,7 +111,7 @@ export default {
       },
       orderTotal: '', // 合计开单数量
       openLogModal: false, //  掉线日志 弹框
-      equipmentId: null //  设备id
+      srcDeviceCode: null //  设备编号
     }
   },
   methods: {
@@ -123,7 +123,7 @@ export default {
     },
     //  查看掉线日志
     checkLog (row) {
-      this.equipmentId = row ? row.id : null
+      this.srcDeviceCode = row ? row.srcDeviceCode : null
       this.openLogModal = true
     }
   }

+ 26 - 27
src/views/equipmentManage/equipment/logModal.vue

@@ -46,6 +46,7 @@
 import getDate from '@/libs/getDate.js'
 import moment from 'moment'
 import { STable } from '@/components'
+import { deviceLogList } from '@/api/device'
 export default {
   name: 'EquipmentModal',
   components: { STable },
@@ -54,14 +55,14 @@ export default {
       type: Boolean,
       default: false
     },
-    equipmentId: {
+    srcDeviceCode: {
       type: [Number, String],
       default: ''
     }
   },
   computed: {
     modalTit () {
-      return this.equipmentId + '-掉线日志'
+      return this.srcDeviceCode + '-掉线日志'
     }
   },
   data () {
@@ -86,27 +87,29 @@ export default {
       // 表头
       columns: [
         { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
-        { title: '离线时间', dataIndex: 'orderDate', width: 200, align: 'center' }
+        { title: '离线时间', dataIndex: 'createDate', width: 200, align: 'center' }
       ],
       // 加载数据方法 必须为 Promise 对象
       loadData: parameter => {
-        // return getTenantsList(Object.assign(parameter, this.queryParam)).then(res => {
-        //   if (res.status == 200) {
-        //     const no = (res.data.pageNo - 1) * res.data.pageSize
-        //     for (let i = 0; i < res.data.list.length; i++) {
-        //       const _item = res.data.list[i]
-        //       _item.no = no + i + 1
-        //       _item.status = _item.status + '' === '1'
-        //     }
-        //     return res.data
-        //   }
-        // })
-        return new Promise((resolve) => {
-          const data = [
-            { id: 1, no: 1, orderDate: '2020-10-30 09:14' },
-            { id: 2, no: 2, orderDate: '2020-10-30 09:14' }
-          ]
-          resolve(data)
+        const searchData = Object.assign(parameter, this.queryParam)
+        if (this.time && this.time.length) {
+          searchData.beginDate = moment(this.time[0]).format('YYYY-MM-DD')
+          searchData.endDate = moment(this.time[1]).format('YYYY-MM-DD')
+        } else {
+          searchData.beginDate = ''
+          searchData.endDate = ''
+        }
+        searchData.srcDeviceCode = this.srcDeviceCode
+        return deviceLogList(searchData).then(res => {
+          if (res.status == 200) {
+            const no = (res.data.pageNo - 1) * res.data.pageSize
+            for (let i = 0; i < res.data.list.length; i++) {
+              const _item = res.data.list[i]
+              _item.no = no + i + 1
+              _item.status = _item.status + '' === '1'
+            }
+            return res.data
+          }
         })
       }
     }
@@ -123,9 +126,7 @@ export default {
         this.queryParam.beginDate = dateStrings[0]
         this.queryParam.endDate = dateStrings[1]
       }
-    },
-    //  获取详情
-    getDetails () {}
+    }
   },
   watch: {
     //  父页面传过来的弹框状态
@@ -138,10 +139,8 @@ export default {
         this.$emit('close')
       }
     },
-    equipmentId (newValue, oldValue) {
-      if (this.isShow && newValue) {
-        this.getDetails()
-      }
+    srcDeviceCode (newValue, oldValue) {
+      this.$refs.table.refresh(true)
     }
   }
 }