wangyimeng
2022-05-06 c8831bc58fd967a4215cbe3ea8c89d753b4d31f7
web_src/src/components/DeviceList.vue
@@ -1,14 +1,10 @@
<template>
   <div id="app">
      <el-container>
         <el-header>
            <uiHeader></uiHeader>
         </el-header>
         <el-main>
            <div style="background-color: #FFFFFF; margin-bottom: 1rem; position: relative; padding: 0.5rem; text-align: left;">
               <span style="font-size: 1rem; font-weight: bold;">设备列表</span>
               <div style="position: absolute; right: 1rem; top: 0.3rem;">
                  <el-button icon="el-icon-refresh-right" circle size="mini" :loading="getDeviceListLoading" @click="getDeviceList()"></el-button>
  <div id="app" style="width: 100%">
    <div class="page-header">
      <div class="page-title">设备列表</div>
      <div class="page-header-btn">
        <el-button icon="el-icon-refresh-right" circle size="mini" :loading="getDeviceListLoading"
                   @click="getDeviceList()"></el-button>
               </div>
            </div>
            <!-- <devicePlayer ref="devicePlayer"></devicePlayer> -->
@@ -57,10 +53,16 @@
               <el-table-column label="操作" width="450" align="center" fixed="right">
                  <template slot-scope="scope">
                     <el-button size="mini" :ref="scope.row.deviceId + 'refbtn' "  v-if="scope.row.online!=0" icon="el-icon-refresh"  @click="refDevice(scope.row)">刷新</el-button>
          <el-button size="mini" v-if="scope.row.online!=0" icon="el-icon-refresh" @click="refDevice(scope.row)"
                     @mouseover="getTooltipContent(scope.row.deviceId)">刷新
          </el-button>
                     <el-button-group>
                <el-button size="mini" icon="el-icon-video-camera-solid" v-bind:disabled="scope.row.online==0"  type="primary" @click="showChannelList(scope.row)">通道</el-button>
                <el-button size="mini" icon="el-icon-location" v-bind:disabled="scope.row.online==0"  type="primary" @click="showDevicePosition(scope.row)">定位</el-button>
            <el-button size="mini" icon="el-icon-video-camera-solid" v-bind:disabled="scope.row.online==0"
                       type="primary" @click="showChannelList(scope.row)">通道
            </el-button>
            <el-button size="mini" icon="el-icon-location" v-bind:disabled="scope.row.online==0" type="primary"
                       @click="showDevicePosition(scope.row)">定位
            </el-button>
                <el-button size="mini" icon="el-icon-edit" type="primary" @click="edit(scope.row)">编辑</el-button>
                <el-button size="mini" icon="el-icon-delete" type="danger" @click="deleteDevice(scope.row)">删除</el-button>
                     </el-button-group>
@@ -78,19 +80,21 @@
               :total="total">
            </el-pagination>
        <deviceEdit ref="deviceEdit" ></deviceEdit>
         </el-main>
      </el-container>
    <syncChannelProgress ref="syncChannelProgress"></syncChannelProgress>
   </div>
</template>
<script>
   import uiHeader from './UiHeader.vue'
import uiHeader from '../layout/UiHeader.vue'
   import deviceEdit from './dialog/deviceEdit.vue'
import syncChannelProgress from './dialog/SyncChannelProgress.vue'
   export default {
      name: 'app',
      components: {
         uiHeader,
      deviceEdit
    deviceEdit,
    syncChannelProgress,
      },
      data() {
         return {
@@ -104,7 +108,7 @@
            currentPage:1,
            count:15,
            total:0,
            getDeviceListLoading: false
      getDeviceListLoading: false,
         };
      },
      computed: {
@@ -117,8 +121,6 @@
               });
               this.currentDeviceChannelsLenth = channels.length;
            }
            console.log("数据:" + JSON.stringify(channels));
            return channels;
         }
      },
@@ -153,13 +155,11 @@
                  count: that.count
               }
            }).then(function (res) {
               console.log(res);
               console.log(res.data.list);
               that.total = res.data.total;
               that.deviceList = res.data.list;
               that.getDeviceListLoading = false;
            }).catch(function (error) {
               console.log(error);
        console.error(error);
               that.getDeviceListLoading = false;
            });
@@ -182,7 +182,7 @@
          }).then((res)=>{
            this.getDeviceList();
          }).catch((error) =>{
            console.log(error);
          console.error(error);
          });
        }).catch(() => {
@@ -191,24 +191,21 @@
         },
         showChannelList: function(row) {
            console.log(JSON.stringify(row))
            this.$router.push(`/channelList/${row.deviceId}/0/15/1`);
         },
         showDevicePosition: function(row) {
            console.log(JSON.stringify(row))
            this.$router.push(`/devicePosition/${row.deviceId}/0/15/1`);
      this.$router.push(`/map?deviceId=${row.deviceId}`);
         },
         //gb28181平台对接
         //刷新设备信息
         refDevice: function(itemData) {
            console.log("刷新对应设备:" + itemData.deviceId);
            var that = this;
            that.$refs[itemData.deviceId + 'refbtn' ].loading = true;
      let that = this;
            this.$axios({
               method: 'post',
               url: '/api/device/query/devices/' + itemData.deviceId + '/sync'
            }).then(function(res) {
      }).then((res) => {
               console.log("刷新设备结果:"+JSON.stringify(res));
               if (res.data.code !==0) {
                  that.$message({
@@ -217,23 +214,43 @@
                     type: 'error'
                  });
               }else{
                  that.$message({
                     showClose: true,
                     message: res.data.msg,
                     type: 'success'
                  });
          // that.$message({
          //    showClose: true,
          //    message: res.data.msg,
          //    type: 'success'
          // });
          this.$refs.syncChannelProgress.openDialog(itemData.deviceId)
               }
               that.initData()
               that.$refs[itemData.deviceId + 'refbtn' ].loading = false;
            }).catch(function(e) {
      }).catch((e) => {
               console.error(e)
          that.$message({
            showClose: true,
            message: e,
            type: 'error'
          });
               that.$refs[itemData.deviceId + 'refbtn' ].loading = false;
            });
    },
    getTooltipContent: async function (deviceId) {
      let result = "";
      await this.$axios({
        method: 'get',
        async: false,
        url: `/api/device/query/${deviceId}/sync_status/`,
      }).then((res) => {
        if (res.data.code == 0) {
          if (res.data.data.errorMsg !== null) {
            result = res.data.data.errorMsg
          } else if (res.data.msg !== null) {
            result = res.data.msg
          } else {
            result = `同步中...[${res.data.data.current}/${res.data.data.total}]`;
          }
        }
      })
      return result;
         },
         //通知设备上传媒体流
         sendDevicePush: function(itemData) {
@@ -251,7 +268,6 @@
            // });
         },
      transportChange: function (row) {
        console.log(row);
        console.log(`修改传输方式为 ${row.streamMode}:${row.deviceId} `);
        let that = this;
        this.$axios({
@@ -263,7 +279,6 @@
        });
      },
      edit: function (row) {
        console.log(row);
        this.$refs.deviceEdit.openDialog(row, ()=>{
          this.$refs.deviceEdit.close();
          this.$message({