fuliqi
2024-09-13 e80067335467ca48cb94f03de3794ad93a45ad5d
src/views/system/monitor/recovery/index.vue
@@ -1,6 +1,16 @@
<template>
  <div class="app-container">
    <el-card class="box-card" >
    <div
      style="display: flex;flex-direction: row;min-width: 158px;max-width: 158px;margin-bottom: 5px;border-radius: 1px; user-select: none"
    >
      <div @click="clickTab(null)" class="tab"
           :class="{tabActive: null == queryParams.provinceTag, tabInactive: null != queryParams.provinceTag}">全部
      </div>
      <div @click="clickTab(0)" class="tab"
           :class="{tabActive: 0 === queryParams.provinceTag, tabInactive: 0 !== queryParams.provinceTag}">省厅考核
      </div>
    </div>
    <el-card class="box-card">
      <el-row type="flex" align="middle" justify="space-between">
        <el-col :span="4">
          <div class="icon-container" style="background-color: #1890FF">
@@ -11,19 +21,19 @@
          <div class="dashboard">
            <div class="dashboard-item">
              <h3 style="color: #5C9BF8">{{ count.totalPosts }}</h3>
              <p>设备总数</p >
              <p>设备总数</p>
            </div>
            <div class="dashboard-item">
              <h3 style="color: #3eba45">{{ count.totalMembers }}</h3>
              <p>正常数</p >
              <p>正常数</p>
            </div>
            <div class="dashboard-item">
              <h3 style="color: #fe640d">{{ count.postsPercentage }}</h3>
              <p>异常数</p >
              <p>异常数</p>
            </div>
            <div class="dashboard-item">
              <h3>{{ count.viewsPercentage }}%</h3>
              <p>设备运行率</p >
              <p>设备运行率</p>
            </div>
          </div>
        </el-col>
@@ -46,7 +56,7 @@
          clearable
          @change="handleQuery"
        >
        <el-option
          <el-option
            v-for="dept in deptList"
            :key="dept.deptId"
            :label="dept.area"
@@ -54,7 +64,7 @@
          />
        </el-select>
      </el-form-item>
      <el-form-item label="监控类型" prop="onState">
      <el-form-item label="监控类型" prop="cameraFunType">
        <el-select
          v-model="queryParams.cameraFunType"
          placeholder="请选择监控类型"
@@ -70,40 +80,33 @@
        <el-button type="primary" icon="el-icon-search" size="small" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="small" @click="resetQuery">重置</el-button>
      </el-form-item>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
    </el-form>
    <el-row :gutter="10" class="mb8">
      <!-- <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
        >导出</el-button>
      </el-col> -->
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
    </el-row>
    <el-table v-loading="loading" :data="monitorList" @selection-change="handleSelectionChange">
      <el-table-column label="设备名称" align="center" prop="name" />
      <el-table-column label="设备编码" align="center" prop="serialNumber" width="180px" />
      <el-table-column label="标签" align="center" v-if="columns[0].visible">
      <el-table-column label="设备名称" align="center" prop="name" width="280" fixed show-overflow-tooltip/>
      <el-table-column label="设备编码" align="center" prop="serialNumber" width="180px"/>
      <el-table-column label="设备类型" align="center" prop="cameraFunType" width="180px">
        <template slot-scope="scope">
          {{ translateCameraFunType(scope.row.cameraFunType) }}
        </template>
      </el-table-column>
      <el-table-column label="标签" align="center" width="180px" v-if="columns[0].visible">
        <template slot-scope="scope">
          <div>{{ scope.row.provinceTag == 0 ? "省厅" : "市局" }}</div>
        </template>
      </el-table-column>
      <el-table-column label="区域" align="center" prop="area" v-if="columns[1].visible"/>
      <el-table-column label="设备状态" align="center" prop="onState" v-if="columns[2].visible">
      <template slot-scope="scope">
        <dict-tag :options="dict.type.camera_state" :value="scope.row.onState"/>
      </template>
      <el-table-column label="设备状态" align="center" width="180px" prop="onState" v-if="columns[2].visible">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.camera_state" width="180px" :value="scope.row.onState"/>
        </template>
      </el-table-column>
      <el-table-column label="是否生成异常工单" align="center" prop="error" v-if="columns[3].visible" />
      <el-table-column label="异常原因" align="center" prop="reason" v-if="columns[4].visible" />
      <el-table-column label="异常恢复时间" align="center" prop="recoveryTime" width="180" v-if="columns[5].visible">
      <el-table-column label="是否生成异常工单" align="center" prop="error" width="180px" v-if="columns[3].visible"/>
      <el-table-column label="异常原因" align="center" prop="reason" width="180px" v-if="columns[4].visible"/>
      <el-table-column label="异常恢复时间" align="center" prop="recoveryTime" width="180px" v-if="columns[5].visible">
      </el-table-column>
      <el-table-column label="管理单位" align="center" prop="unitName" v-if="columns[6].visible" />
      <el-table-column label="管理单位" align="center" prop="unitName" width="180px" v-if="columns[6].visible"/>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
@@ -111,7 +114,8 @@
            type="text"
            icon="el-icon-view"
            @click="handleView(scope.row,scope.index)"
          >详细</el-button>
          >详细
          </el-button>
        </template>
      </el-table-column>
    </el-table>
@@ -130,8 +134,8 @@
        <el-row>
          <el-col :span="12">
            <el-form-item label="设备编码:">{{ form.serialNumber }}</el-form-item>
            <el-form-item label="设备名称:">{{ form.name }} </el-form-item>
            <el-form-item label="标签:">{{ form.deptName }} </el-form-item>
            <el-form-item label="设备名称:">{{ form.name }}</el-form-item>
            <el-form-item label="标签:">{{ form.deptName }}</el-form-item>
            <el-form-item label="设备状态:">
              <div v-if="form.onState === 1">可用</div>
              <div v-else-if="form.onState === 2">不可用</div>
@@ -163,23 +167,31 @@
</template>
<script>
import { recoveryException, listMonitor, getMonitor, delMonitor, addMonitor, updateMonitor } from "@/api/platform/monitor";
import { listDept } from "@/api/system/dept";
import {
  recoveryException,
  listMonitor,
  getMonitor,
  delMonitor,
  addMonitor,
  updateMonitor
} from "@/api/platform/monitor";
import {listDept} from "@/api/system/dept";
export default {
  name: "Monitor",
  dicts: ['sys_normal_disable','platform_yes_no','camera_state'],
  dicts: ['sys_normal_disable', 'platform_yes_no', 'camera_state'],
  data() {
    return {
      deptList: [],
      // 列信息
      columns: [
        { key: 0, label: `标签`, visible: true },
        { key: 1, label: `区域`, visible: true },
        { key: 2, label: `设备状态`, visible: true },
        { key: 3, label: `是否生成异常工单`, visible: true },
        { key: 4, label: `异常原因`, visible: true },
        { key: 5, label: `异常恢复时间`, visible: true },
        { key: 6, label: `管理单位`, visible: true },
        {key: 0, label: `标签`, visible: true},
        {key: 1, label: `区域`, visible: true},
        {key: 2, label: `设备状态`, visible: true},
        {key: 3, label: `是否生成异常工单`, visible: true},
        {key: 4, label: `异常原因`, visible: true},
        {key: 5, label: `异常恢复时间`, visible: true},
        {key: 6, label: `管理单位`, visible: true},
      ],
      count: {
        totalPosts: 0,
@@ -226,16 +238,16 @@
      // 表单校验
      rules: {
        serialNumber: [
          { required: true, message: "设备编码不能为空", trigger: "blur" }
          {required: true, message: "设备编码不能为空", trigger: "blur"}
        ],
        name: [
          { required: true, message: "设备名称不能为空", trigger: "blur" }
          {required: true, message: "设备名称不能为空", trigger: "blur"}
        ],
        onState: [
          { required: true, message: "设备状态", trigger: "blur" }
          {required: true, message: "设备状态", trigger: "blur"}
        ],
        address: [
          { required: true, message: "地址不能为空", trigger: "blur" }
          {required: true, message: "地址不能为空", trigger: "blur"}
        ],
      }
    };
@@ -243,11 +255,40 @@
  created() {
    this.getList();
    this.getVideoCount();
    listDept({ status: 0 }).then(response => {
    listDept({status: 0}).then(response => {
      this.deptList = response.data.filter(item => item.area);
    });
  },
  methods: {
    translateCameraFunType(cameraFunType) {
      // 校验输入是否为字符串
      if (typeof cameraFunType !== 'string') {
        return "";
      }
      // 分割字符串为数组,并去除空字符串
      const types = cameraFunType.split('/').filter(type => type);
      // 校验并转换每个类型
      const translatedTypes = types.map(type => {
        switch (type) {
          case '1':
            return '视频';
          case '2':
            return '车辆';
          case '3':
            return '人脸';
          default:
            return ''
        }
      });
      return translatedTypes.join(', ');
    },
    clickTab(active) {
      this.queryParams.provinceTag = active
      this.getList()
      this.getVideoCount()
    },
    /** 查询设备资产列表 */
    getList() {
      this.loading = true;
@@ -259,7 +300,7 @@
    },
    /** 查询异常恢复设备统计数 */
    getVideoCount() {
      recoveryException().then(response => {
      recoveryException(this.queryParams).then(response => {
        this.count = response.data;
      });
    },
@@ -302,7 +343,7 @@
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
@@ -344,12 +385,13 @@
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除设备资产编号为"' + ids + '"的数据项?').then(function() {
      this.$modal.confirm('是否确认删除设备资产编号为"' + ids + '"的数据项?').then(function () {
        return delMonitor(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
      }).catch(() => {
      });
    },
    /** 导出按钮操作 */
    handleExport() {
@@ -362,6 +404,30 @@
</script>
<style lang="scss" scoped>
.tab {
  padding: 5px 15px;
}
.tab:hover {
  cursor: pointer;
  user-select: none;
}
.tabActive {
  color: white;
  background-color: #409eff;
  border: none;
  border-radius: 1px;
}
.tabInactive {
  background-color: #edf2f6;
  color: #409eff;
}
.tabInactive:hover {
  background-color: #edf2f6;
}
.box-card {
  background-color: #ffffff;
@@ -369,6 +435,7 @@
  margin-bottom: 20px;
  height: 120px
}
.icon-container {
  display: flex;
  justify-content: center;
@@ -378,6 +445,7 @@
  height: 80px;
  margin-left: 5%;
}
.el-icon-refresh-left {
  font-size: 50px;
  color: #FFFFFF;