<template>
  <div>
    <div class="container">
      <div class="handle-box">
        <selectoption></selectoption>
        <el-cascader :options="options" size="small" class="handle-input mb-1" :props="{ checkStrictly: true }" v-model="query.roomId"
          @change="checkNode" :clearable="true">
        </el-cascader>
        <el-input v-model="query.roomName" size="small" placeholder="房间名称" :clearable="true" class="handle-input mr10 mb-1">
        </el-input>
        <el-date-picker v-model="query.startTime" class="handle-input mr10 mb-1" size="small" type="datetime" clearable
          placeholder="选择开始日期时间" default-time="00:00:00">
        </el-date-picker>
        <el-date-picker v-model="query.endTime" class="handle-input mr10 mb-1" size="small" type="datetime" clearable
          placeholder="选择结束日期时间" default-time="00:00:00">
        </el-date-picker>
        <el-input v-model="query.deviceNum" size="small" placeholder="设备号" :clearable="true" class="handle-input mb-1 mr10">
        </el-input>
        <el-input v-model="query.cardName" size="small" placeholder="租客" :clearable="true" class="handle-input mb-1 mr10">
        </el-input>
        <el-input v-model="query.operateName" size="small" placeholder="操作员" :clearable="true" class="handle-input mb-1 mr10">
        </el-input>
        <el-select v-model="query.command" size="small" placeholder="操作类型" :clearable="true" class="handle-select mb-1 mr10">
          <el-option :label="item.desc" :value="item.code" :key="item.code" v-for="(item,index) in DeviceFeedbackLog">
          </el-option>
        </el-select>
        <el-select v-model="query.result" size="small" placeholder="状态" class="handle-select mr10 mb-1" :clearable="true">
          <el-option label="下发中" value="0" key="0"></el-option>
          <el-option label="下发成功" value="1" key="1"></el-option>
          <el-option label="下发失败" value="702" key="702"></el-option>
          <el-option label="下发超时" value="704" key="704"></el-option>
        </el-select>
        <el-button type="primary" class="mb-1" size="small" icon="el-icon-search" @click="handleSearch" style="background: #FA8E00; border: none;">搜索</el-button>
        <el-button type="primary" class="mb-1" size="small" @click="resting" style="background: #FA8E00; border: none;">重置</el-button>
      </div>
      <el-table :data="tableData" border class="table" ref="multipleTable" header-cell-class-name="table-header"
        height="600">
        <el-table-column prop="deviceNum" label="设备号"></el-table-column>
        <el-table-column prop="roomName" label="房间名称"></el-table-column>
        <el-table-column prop="operationType" label="操作类型"></el-table-column>
        <el-table-column prop="statusText" label="命令状态"></el-table-column>
        <el-table-column prop="cardName" label="锁用户"></el-table-column>
        <el-table-column prop="operateName" label="操作员"></el-table-column>
        <el-table-column prop="serial" label="流水号"></el-table-column>
        <el-table-column prop="createTime" label="生效时间"></el-table-column>
        <el-table-column prop="createTime" label="操作" v-if="userInfo.type==0">
          <template slot-scope="scope">
            <el-button type="primary" size="mini" @click="cancelDistribution(scope.$index,scope.row)"
							v-if="scope.row.result==704 && scope.row.serial">作废</el-button>
            <el-button type="primary" size="mini" @click="reissueMethods(scope.$index,scope.row)" v-if="scope.row.result==704 && (scope.row.command==6216 || scope.row.command==6210 || scope.row.command==6207 || scope.row.command==6213)">重新下发</el-button>
          </template>
        </el-table-column>
      </el-table>
      <div class="pagination">
        <el-pagination background layout="total, sizes, prev, pager, next, jumper" :current-page="pageNum"
          :page-size="pageSize" :total="pageTotal" @current-change="handlePageChange"
          @size-change="handleSizeChange"></el-pagination>
      </div>
    </div>
  </div>
</template>

<!--组件逻辑-->
<script>
  import {
    httpGet,
    httpPost
  } from "../api";
  import utils from "../utils/util.js";
  import {
    ztreeToElementTree,
    uniqueArray,
  } from "../utils/index";
  import ICINLocker from "../utils/equipment.js"
  import moment from "moment"
  export default {
    inject: ['reload'],
    name: "warningLog",
    data() {
      return {
        selectoption: [],
        selectoptionValue: '',
        query: {
          command: "",
          deviceNum: "",
          operModul: "",
          result: '',
          cardName:'',
          operateName:'',
          roomId:'',
          roomName:'',
          roomIds:'',
          startTime:'',
          endTime:''
        },
          pageNum: 1,
          pageSize: 10,
        pageIndex: 1,
        query1: {
          command: "",
          deviceNum: "",
          status: ""
        },
        activeName: "first",
        tableData: [],
        tableData1: [],
        multipleSelection: [],
        delList: [],
        editVisible: false,
        pageTotal: 0,
        pageTotal1: 0,
        form: {},
        idx: -1,
        id: -1,
        AboutDevice: [],
        userInfo: {
          type: ''
        },
        DeviceFeedbackLog: [],
        options:[],
        checkNodeId:[]
      };
    },
    beforeCreate() {
      // var tenantId = JSON.parse(localStorage.getItem('tenantId'))
      // if (tenantId == 400) {
      //   this.$store.commit('defaultsettenantid')
      // }
    },
    created() {
      this.getalllist()
      this.DeviceFeedbackLog = this.$MANUFACTURER.DeviceFeedbackLog
      this.userInfo = JSON.parse(localStorage.getItem('info'))
      this.getAboutDevice()
      this.selectoption = JSON.parse(localStorage.getItem('selectoption'))
      this.selectoptionValue = localStorage.getItem('tenantId')
    },
    mounted() {
      document.addEventListener('keydown', this.keyDown)
      this.getOperates();
    },
    methods: {
      //获取房源筛选列表
      getalllist() {
        var data = {};
        httpGet(data, this.$api.getTree).then((res) => {
          var list = res.data.sort((pre, cur) => pre.id - cur.id)
          var array = uniqueArray(list, "id");
          this.options = ztreeToElementTree(array, {});
        });
      },
      // 选择房源
      checkNode(e) {
        console.log(e)
        // this.checkNodeId = e[e.length-1]
        var options = this.options
        if(e){
          var arr = this.getId(options, e[e.length - 1])
          var listarr = [arr[0]]
          var obj = this.getNodeId(listarr)
          console.log(obj)
          this.checkNodeId = obj
          this.query.roomIds=obj
        }
      },
      getParentId(list, id) {
        for (let i in list) {
          if (list[i].id == id) {
            return [list[i]]
          }
          if (list[i].children) {
            let node = this.getParentId(list[i].children, id);
            if (node !== undefined) {
              return node.concat(list[i])
            }
          }
        }
      },
      getId(list, id) {
        for (let i in list) {
          if (list[i].id == id) {
            return [list[i]]
          }
          if (list[i].children) {
            let node = this.getParentId(list[i].children, id);
            if (node !== undefined) {
              return node;
            }
          }
        }
      },
      getNodeId(list, newNodeId = []) {
        for (let i in list) {
          newNodeId.push(list[i].id)
          if (list[i].children) {
            this.getNodeId(list[i].children, newNodeId);
          }
        }
        return newNodeId;
      },
      keyDown(e) {
        //如果是回车则执行登录方法
        if (e.keyCode == 13) {
          if (this.$route.name == 'DeviceFeedbackLog') {
            if (!this.drawer) {
              this.handleSearch();
            }
          }
        }
      },
      selectTenantId(e) {
        localStorage.setItem('tenantId', e)
        this.reload()
      },
      // 取消下发
      cancelDistribution(index, row) {
        // var data = [row.id]
        // httpPost(data, this.$api.cancelDistribution).then(res => {
        //   if (res.success) {
        //     this.$message.success("取消成功")
        //   } else {
        //     this.$message.error("取消失败")
        //   }
        // })
        httpGet("",`/v1/device/editStatus/bySerial/${703}/${row.serial}`).then(res=>{
          if(res.code==200){
            this.$message.success("操作成功")
          }else{
            this.$message.error("操作失败")
          }
        })
      },
      // 重新下发
      reissueMethods(index, row) {
        var data = {
          pageNum: 0,
          pageSize: 0,
          orderBy: "create_at desc",
          q: {
            serial: row.serial
          },
        };
        httpGet(data, this.$api.getCertificates).then((res) => {
          if (res.code == 200) {
              let dataresult=utils.zlib_unzip(res.data)
            if (res.data.total > 0) {
              var dataOne = {
                pageNum: 0,
                pageSize: 0,
                q: JSON.stringify({
                  deviceNum: dataresult[0].deviceNum
                })
              }
              httpPost(dataOne, this.$api.getDeviceItems).then((resOne) => {
                if (resOne.code == 200) {
                  if (resOne.data.total > 0) {
                    this.sendAginMethods(resOne.data.list[0], dataresult[0], row)
                  } else {
                    this.$message.error("未发现对应门锁，操作失败")
                  }
                } else {
                  this.$message.error("操作失败")
                }
              })
            } else {
              this.$message.error("未发现对应凭证记录，操作失败")
            }
          } else {
            this.$message.error("操作失败")
          }
        })
      },
      sendAginMethods(deviceData, certificates, row) {
        this.$confirm("是否重新下发！", "提示", {
          type: "warning",
        }).then(() => {
          if (deviceData.manufactureId == 101) {
            var content = JSON.parse(certificates.content)
            if (row.command == 6226) {
              var str1 = {
                imei: certificates.imei,
                deviceNum: certificates.deviceNum,
                userTelephone: content.userTelephone,
                userPassword: content.userPassword,
                password: content.password,
                operateMode: 26,
                order: 6226,
                passwordStartTime: content.passwordStartTime,
                passwordEndTime: content.passwordEndTime,
                is: false,
                cardName: row.cardName,
                roomName: row.roomName,
              };
              httpPost(str1, this.$api.getDeviceOperateUserInfo).then((res2) => {
                if (res2.code == 200) {
                  this.$message.success("发送成功")
                  var datafidOne = {
                    cardId: certificates.cardId,
                    content: certificates.content, //operateMode:NFC-10、把人员添加到凭证-1
                    type: certificates.type,
                    startTime: certificates.startTime,
                    endTime: certificates.endTime,
                    serial: res2.data.serialNumber
                  };
                  httpPost(datafidOne, this.$api.addCertificates).then((resThree) => {
                    if (resThree.code == 200) {
                      this.$message.success("重新下发成功")
                      this.handleSearch()
                    }
                  })
                }
              })
            } else if (row.command == 6207) {
              var str1 = {
                imei: certificates.imei,
                deviceNum: certificates.deviceNum,
                userTelephone: content.userTelephone,
                userPassword: content.userPassword,
                password: content.password,
                operateMode: 7,
                order: 6207,
                passwordStartTime: content.passwordStartTime,
                passwordEndTime: content.passwordEndTime,
                is: false,
                cardName: row.cardName,
                roomName: row.roomName,
              };
              httpPost(str1, this.$api.getDeviceOperateUserInfo).then((res2) => {
                if (res2.code == 200) {
                  this.$message.success("发送成功")
                  var datafidOne = {
                    cardId: certificates.cardId,
                    content: certificates.content, //operateMode:NFC-10、把人员添加到凭证-1
                    type: certificates.type,
                    startTime: certificates.startTime,
                    endTime: certificates.endTime,
                    serial: res2.data.serialNumber
                  };
                  httpPost(datafidOne, this.$api.addCertificates).then((resThree) => {
                    if (resThree.code == 200) {
                      this.$message.success("重新下发成功")
                      this.handleSearch()
                    }
                  })
                }
              })
            } else if (row.command == 6216) {
              var fpId = new Date();
              var str1 = {
                imei: certificates.imei,
                deviceNum: certificates.deviceNum,
                fingerprintAlias: content.fingerprintAlias,
                length: content.fingerprint.length / 2,
                fpTimeId: fpId.getTime(),
                fingerprint: content.fingerprint,
                userTelephone: content.userTelephone,
                userPassword: content.userPassword,
                password: content.password,
                operateMode: 16,
                order: 6216,
                type: 1,
                fingerprintStartTime: content.passwordStartTime,
                fingerprintEndTime: content.passwordEndTime,
                is: false,
                cardName: row.cardName,
                roomName: row.roomName
              };
              httpPost(str1, this.$api.fingerprintTransfer).then((res2) => {
                if (res2.code == 200) {
                  this.$message.success("发送成功")
                  var datafidOne = {
                    cardId: certificates.cardId,
                    content: certificates.content, //operateMode:NFC-10、把人员添加到凭证-1
                    type: certificates.type,
                    startTime: certificates.startTime,
                    endTime: certificates.endTime,
                    serial: res2.data.serialNumber
                  };
                  httpPost(datafidOne, this.$api.addCertificates).then((resThree) => {
                    if (resThree.code == 200) {
                      this.$message.success("重新下发成功")
                      this.handleSearch()
                    }
                  })
                }
              })
            } else if (row.command == 6213) {
              var str1 = {
                imei: certificates.imei,
                deviceNum: certificates.deviceNum,
                userTelephone: content.userTelephone,
                userPassword: content.userPassword,
                password: content.password,
                operateMode: 13,
                order: 6213,
                type: 2,
                passwordStartTime: content.passwordStartTime,
                passwordEndTime: content.passwordEndTime,
                is: false,
                cardName: row.cardName,
                roomName: row.roomName,
              };
              httpPost(str1, this.$api.getDeviceOperateUserInfo).then((res2) => {
                if (res2.code == 200) {
                  this.$message.success("发送成功")
                  var datafidOne = {
                    cardId: certificates.cardId,
                    content: certificates.content, //operateMode:NFC-10、把人员添加到凭证-1
                    type: certificates.type,
                    startTime: certificates.startTime,
                    endTime: certificates.endTime,
                    serial: res2.data.serialNumber
                  };
                  httpPost(datafidOne, this.$api.addCertificates).then((resThree) => {
                    if (resThree.code == 200) {
                      this.$message.success("重新下发成功")
                      this.handleSearch()
                    }
                  })
                }
              })
            } else if (row.command == 6210) {
              var str1 = {
                imei: certificates.imei,
                deviceNum: certificates.deviceNum,
                userTelephone: content.userTelephone,
                userPassword: content.userPassword,
                password: content.password,
                operateMode: 10,
                order: 6210,
                type: 3,
                passwordStartTime: content.passwordStartTime,
                passwordEndTime: content.passwordEndTime,
                is: false,
                cardName: row.cardName,
                roomName: row.roomName,
              };
              httpPost(str1, this.$api.getDeviceOperateUserInfo).then((res2) => {
                if (res2.code == 200) {
                  this.$message.success("发送成功")
                  var datafidOne = {
                    cardId: certificates.cardId,
                    content: certificates.content, //operateMode:NFC-10、把人员添加到凭证-1
                    type: certificates.type,
                    startTime: certificates.startTime,
                    endTime: certificates.endTime,
                    serial: res2.data.serialNumber
                  };
                  httpPost(datafidOne, this.$api.addCertificates).then((resThree) => {
                    if (resThree.code == 200) {
                      this.$message.success("重新下发成功")
                      this.handleSearch()
                    }
                  })
                }
              })
            }
          } else if (deviceData.manufactureId == 201||deviceData.manufactureId == 221) {
            var content = JSON.parse(certificates.content)
            if (row.command == 6226) {
              var data = {
                lockerId: certificates.deviceNum,
                imei: certificates.imei,
                lockerUserId: content.userPassword,
                keyId: content.userPassword,
                role: 0,
                action: 1,
                order: 6226,
                cardName: row.cardName,
                roomName: row.roomName
              };
              ICINLocker.addUserToLock(data.lockerId, data.imei, data.lockerUserId, data.role, data.action, data
                .order, data.cardName, data.roomName, (callback1) => {
                  if (callback1.code == 200) {
                    var datafidOne = {
                      cardId: certificates.cardId,
                      content: certificates.content, //operateMode:NFC-10、把人员添加到凭证-1
                      type: certificates.type,
                      startTime: certificates.startTime,
                      endTime: certificates.endTime,
                      serial: callback1.data.serialNumber
                    };
                    httpPost(datafidOne, this.$api.addCertificates).then((resThree) => {
                      if (resThree.code == 200) {
                        this.$message.success("重新下发成功")
                        this.handleSearch()
                      }
                    })
                  }
                })
            } else if (row.command == 6207) {
              var str = {
                lockerId: certificates.deviceNum,
                imei: certificates.imei,
                order: 6207,
                passwordCount: 255,
                lockerUserId: content.userPassword,
                keyId: content.userPassword,
                startTime: content.passwordStartTime,
                endTime: content.passwordEndTime,
                action: 1,
                password: content.password,
                cardName: row.cardName,
                roomName: row.roomName
              };
              ICINLocker.addForeverPassword(str.lockerId, str.imei, str.lockerUserId, 1, str.password, 255, str
                .startTime, str.endTime, 6207, str.cardName, str.roomName, (callback1) => {
                  if (callback1.success) {
                    var datafidOne = {
                      cardId: certificates.cardId,
                      content: certificates.content, //operateMode:NFC-10、把人员添加到凭证-1
                      type: certificates.type,
                      startTime: certificates.startTime,
                      endTime: certificates.endTime,
                      serial: callback1.data.serialNumber
                    };
                    httpPost(datafidOne, this.$api.addCertificates).then((resThree) => {
                      if (resThree.code == 200) {
                        this.$message.success("重新下发成功")
                        this.handleSearch()
                      }
                    })
                  }
                })
            } else if (row.command == 6216) {
              var str = {
                lockerId: certificates.deviceNum,
                imei: certificates.imei,
                order: 6216,
                lockerUserId: content.userPassword,
                keyId: content.userPassword,
                fingerType: 0,
                file: content.fingerprint,
                startTime: content.passwordStartTime,
                endTime: content.passwordEndTime,
                cardName: row.cardName,
                roomName: row.roomName
              };lockId, _imei, _userId, _fingerType, _file, _startTime, _endTime, _cardName,
    _roomName, callback
              ICINLocker.addFingerPrints(str.lockerId, str.imei, str.lockerUserId, str.fingerType, str.file, str
                .startTime, str.endTime, str.cardName, str.roomName, (callback1) => {
                  if (callback1.success) {
                    var datafidOne = {
                      cardId: certificates.cardId,
                      content: certificates.content, //operateMode:NFC-10、把人员添加到凭证-1
                      type: certificates.type,
                      startTime: certificates.startTime,
                      endTime: certificates.endTime,
                      serial: callback1.data.serialNumber
                    };
                    httpPost(datafidOne, this.$api.addCertificates).then((resThree) => {
                      if (resThree.code == 200) {
                        this.$message.success("重新下发成功")
                        this.handleSearch()
                      }
                    })
                  }
                })
            } else if (row.command == 6213) {
              var data3 = {
                lockerId: certificates.deviceNum,
                imei: certificates.imei,
                lockerUserId: content.userPassword,
                keyId: content.userPassword,
                action: 1,
                taskStatus: 1,
                order: 6213,
                startTime: content.passwordStartTime,
                endTime: content.passwordEndTime,
                cardType: 36,
                cardName: row.cardName,
                roomName: row.roomName,
                cardNo: content.password
              };
              ICINLocker.RfCardRegister(data3.lockerId, data3.imei, data3.keyId, data3.action, data3.taskStatus,
                data3.cardNo, data3.cardType, data3.startTime, data3.endTime, data3.order, data3.cardName, data3
                .roomName, (callback1) => {
                  if (callback1.success) {
                    var datafidOne = {
                      cardId: certificates.cardId,
                      content: certificates.content, //operateMode:NFC-10、把人员添加到凭证-1
                      type: certificates.type,
                      startTime: certificates.startTime,
                      endTime: certificates.endTime,
                      serial: callback1.data.serialNumber
                    };
                    httpPost(datafidOne, this.$api.addCertificates).then((resThree) => {
                      if (resThree.code == 200) {
                        this.$message.success("重新下发成功")
                        this.handleSearch()
                      }
                    })
                  }
                })
            } else if (row.command == 6210) {
              var data3 = {
                lockerId: certificates.deviceNum,
                imei: certificates.imei,
                lockerUserId: content.userPassword,
                keyId: content.userPassword,
                action: 1,
                taskStatus: 1,
                order: 6210,
                startTime: content.passwordStartTime,
                endTime: content.passwordEndTime,
                cardType: 50,
                cardName: row.cardName,
                roomName: row.roomName,
                cardNo: content.password
              };
              ICINLocker.RfCardRegister(data3.lockerId, data3.imei, data3.keyId, data3.action, data3.taskStatus,
                data3.cardNo, data3.cardType, data3.startTime, data3.endTime, data3.order, data3.cardName, data3
                .roomName, (callback1) => {
                  if (callback1.success) {
                    var datafidOne = {
                      cardId: certificates.cardId,
                      content: certificates.content, //operateMode:NFC-10、把人员添加到凭证-1
                      type: certificates.type,
                      startTime: certificates.startTime,
                      endTime: certificates.endTime,
                      serial: callback1.data.serialNumber
                    };
                    httpPost(datafidOne, this.$api.addCertificates).then((resThree) => {
                      if (resThree.code == 200) {
                        this.$message.success("重新下发成功")
                        this.handleSearch()
                      }
                    })
                  }
                })
            }
          }
        })
      },
      // 重置
      resting() {
        this.query = {
          command: "",
          deviceNum: "",
          result: "",
          cardName:'',
          operateName:'',
          roomName:'',
          roomId:'',
          roomIds:'',
          startTime:'',
          endTime:''
        }
        this.handleSearch()
      },
      // 查询和房间相关的设备
      getAboutDevice() {
        var data = {
          pageNum: 0,
          pageSize: 0,
          q: JSON.stringify({
            lockType: 1
          })
        };
        httpPost(data, this.$api.getDeviceItems).then((res) => {
          this.AboutDevice = res.data.list
        })
      },
      time(time = +new Date()) {
        var date = new Date(time + 8 * 3600 * 1000); // 增加8小时
        return date.toJSON().substr(0, 19).replace("T", " ");
      },
      searchParaProcess(obj) {
        var myObj = obj;
        for(var i in myObj){
          if(myObj[i]==''||myObj[i]==null||myObj[i]==undefined||myObj[i]=='Invalid date'||i=='roomId'){
            delete myObj[i]
          }
        }
        return JSON.stringify(myObj);
      },
      //   获取操作日志
      getOperates() {
        var data = {
          pageNum: 1,
          pageSize: this.pageSize,
          orderType: "desc",
          orderBy: "createTime",
        };
        httpPost(data, this.$api.getDeviceResult).then((res) => {
          var AboutDevice = this.AboutDevice
          let datalist=utils.zlib_unzip(res.data)
          datalist.map((li) => {
            if ((li.command == 6204 || li.command == 6207 || li.command == 6210 || li
                .command == 6213) && li.result == 702) {
              li['reStatus'] = true
            } else {
              li['reStatus'] = false
            }
            li.createTime = this.time(+new Date(li.createTime));
            var resultArr = AboutDevice.filter(_item => _item.imei == li.imei)[0]
            li['operationType'] = ''
            var operationType = this.DeviceFeedbackLog.filter(item => item.code == li.command)[
              0]
            if (operationType) {
              li['operationType'] = operationType.desc
            }
            li['statusText'] = utils.statusCode(li.result)
            if (resultArr) {
              li.roomId = resultArr.id
              li.roomName = resultArr.roomName
            }
            if(li.command==61101){
              var commandContent=JSON.parse(li.content)
              if(commandContent.opendDoorType==1){
                li.operationType=li.operationType+'-开启'
              }else if(commandContent.opendDoorType==0){
                li.operationType=li.operationType+'-关闭'
              }
            }
          });
          console.log(datalist)
          this.tableData = datalist;
          this.pageTotal = res.data.total;
        });
      },
      // 触发搜索按钮
      handleSearch() {
        var q = JSON.parse(JSON.stringify(this.query))
        q.startTime= moment(q.startTime).format("YYYY-MM-DD HH:mm:ss")
        q.endTime= moment(q.endTime).format("YYYY-MM-DD HH:mm:ss")
        var data = {
          pageNum: 1,
          pageSize: this.pageSize,
          q: this.searchParaProcess(q),
          orderType: "desc",
          orderBy: "createTime",
        };
        this.pageNum=1
        httpPost(data, this.$api.getDeviceResult).then((res) => {
          var AboutDevice = this.AboutDevice
          let dataOne=utils.zlib_unzip(res.data)
          console.log(dataOne)
          dataOne.map((li) => {
            if ((li.command == 6204 || li.command == 6207 || li.command == 6210 || li
                .command == 6213) && li.result == 702) {
              li['reStatus'] = true
            } else {
              li['reStatus'] = false
            }
            li['operationType'] = ''
            var operationType = this.DeviceFeedbackLog.filter(item => item.code == li.command)[
              0]
            if (operationType) {
              li['operationType'] = operationType.desc
            }
            if(li.command==61101){
              var commandContent=JSON.parse(li.content)
              if(commandContent.opendDoorType==1){
                li.operationType=li.operationType+'-开启'
              }else if(commandContent.opendDoorType==0){
                li.operationType=li.operationType+'-关闭'
              }
            }
            li['statusText'] = utils.statusCode(li.result)
            li.createTime = this.time(+new Date(li.createTime));
            var resultArr = AboutDevice.filter(_item => _item.imei == li.imei)[0]
            if (resultArr) {
              li.roomId = resultArr.id
              li.roomName = resultArr.roomName
            }
          });
          this.tableData = dataOne;
          this.pageTotal = res.data.total;
          // this.$store.commit('increment', 1)
        });
        //   this.$set(this.query, "pageIndex", 1);
      },
      getSearchList() {
        var q=JSON.parse(JSON.stringify(this.query))
        // var q = {
        //   command: this.query.command,
        //   deviceNum: this.query.deviceNum,
        //   result: this.query.result
        // };
        q.startTime= moment(q.startTime).format("YYYY-MM-DD HH:mm:ss")
        q.endTime= moment(q.endTime).format("YYYY-MM-DD HH:mm:ss")
        var data = {
          pageNum: this.pageNum,
          pageSize: this.pageSize,
          q: this.searchParaProcess(q),
          orderType: "desc",
          orderBy: "createTime",
        };
        httpPost(data, this.$api.getDeviceResult).then((res) => {
          var AboutDevice = this.AboutDevice
          let dataOne=utils.zlib_unzip(res.data)
          dataOne.map((li) => {
            li['statusText'] = utils.statusCode(li.result)
            var resultArr = AboutDevice.filter(_item => _item.imei == li.imei)[0]
            li.createTime = this.time(+new Date(li.createTime));
            if ((li.command == 6204 || li.command == 6207 || li.command == 6210 || li
                .command == 6213) && li.result == 702) {
              li['reStatus'] = true
            } else {
              li['reStatus'] = false
            }
            if (resultArr) {
              li.roomId = resultArr.id
              li.roomName = resultArr.roomName
            }
            li['operationType'] = ''
            var operationType = this.DeviceFeedbackLog.filter(item => item.code == li.command)[
              0]
            if (operationType) {
              li['operationType'] = operationType.desc
            }
            if(li.command==61101){
              var commandContent=JSON.parse(li.content)
              if(commandContent.opendDoorType==1){
                li.operationType=li.operationType+'-开启'
              }else if(commandContent.opendDoorType==0){
                li.operationType=li.operationType+'-关闭'
              }
            }
          });
          this.tableData = dataOne;
          this.pageTotal = res.data.total;
        });
      },
      // 分页导航
      handlePageChange(val) {
        this.pageNum = val
        this.getSearchList()
      },
      handleSizeChange(val) {
        this.pageNum = 1
        this.pageSize = val
        this.getSearchList()
      },
    },
  };
</script>


<!--样式描述-->
<style scoped>
  .mb-1{
    margin-bottom: 10px;
  }
  .handle-box {
    margin-bottom: 20px;
  }
  .w-200{
    width: 200px;
  }
  .handle-select {
    width: 120px;
  }

  .handle-input {
    width: 150px;
    display: inline-block;
  }

  .table {
    width: 100%;
    font-size: 14px;
  }

  .red {
    color: #ff0000;
  }

  .mr10 {
    margin-right: 10px;
  }

  .table-td-thumb {
    display: block;
    margin: auto;
    width: 40px;
    height: 40px;
  }
</style>
