Procházet zdrojové kódy

设备管理页面提交

xujie před 1 rokem
rodič
revize
4e739b11c1

+ 16 - 0
src/api/iot/deviceInfo.js

@@ -0,0 +1,16 @@
+import request from '@/utils/request'
+
+export function list(query) {
+  return request({
+    url: '/iot/deviceInfo/page',
+    method: 'get',
+    params: query
+  })
+}
+
+export function getDetailById(id) {
+  return request({
+    url: '/iot/deviceInfo/detail/'+id,
+    method: 'get',
+  })
+}

+ 164 - 0
src/views/iot/deviceInfo/detailDialog.vue

@@ -0,0 +1,164 @@
+
+<template>
+  <div class="edu-training-edit">
+    <DialogCom title="设备详情" :visible.sync="isShow" width="1200px" >
+      <div class="page-body">
+        <el-descriptions class="margin-top" :column="2" size="medium" border :label-style="labelStyle" :contentStyle="content_style">
+          <el-descriptions-item span="2" labelClassName="gx_info_label" label="组织机构">
+            {{ formData.firstOrgName }}-{{ formData.secondOrgName }}-{{ formData.orgName }}
+          </el-descriptions-item>
+          <el-descriptions-item labelClassName="gx_info_label" label="设备名称" >
+            {{ formData.deviceName }}
+          </el-descriptions-item>
+          <el-descriptions-item labelClassName="gx_info_label" label="设备类型" >
+            {{formData.deviceTypeName}}
+          </el-descriptions-item>
+          <el-descriptions-item v-if="formData.deviceType === '1' || formData.deviceType === '4' || formData.deviceType === '5'" labelClassName="gx_info_label" label="设备IP" >
+            {{formData.deviceAddress}}
+          </el-descriptions-item>
+          <el-descriptions-item v-if="formData.deviceType === '1' || formData.deviceType === '4' || formData.deviceType === '5'" labelClassName="gx_info_label" label="设备端口" >
+            {{formData.devicePort}}
+          </el-descriptions-item>
+          <el-descriptions-item labelClassName="gx_info_label" label="网络状态" >
+            {{ getNetStatusDesc(formData.netStatus)}}
+          </el-descriptions-item>
+          <el-descriptions-item v-if="formData.parentName" labelClassName="gx_info_label" label="所属主机" >
+            {{
+              formData.parentName
+            }}
+          </el-descriptions-item>
+        </el-descriptions>
+        <div class="extend_mod" v-if="formData.deviceType === '1' || formData.deviceType === '5'" style="max-height: 500px;">
+          <el-table :data="childrenInfos" border style="width: 100%;max-height: 500px;overflow-y: auto;">
+            <el-table-column
+              type="index"
+              label="序号"
+              width="60"
+              align="center"
+            ></el-table-column>
+            <el-table-column
+              prop="deviceTypeName"
+              label="设备类型"
+              align="center"
+            ></el-table-column>
+            <el-table-column
+              prop="deviceName"
+              label="设备名称"
+              align="center"
+            >
+            </el-table-column>
+            <el-table-column
+              align="center"
+              prop="netStatus"
+              label="网络状态"
+            >
+              <template slot-scope="scope">
+                {{ getNetStatusDesc(scope.row.netStatus)}}
+              </template>
+            </el-table-column>
+          </el-table>
+        </div>
+      </div>
+
+      <div slot="footer" class="dialog-footer">
+        <el-button @click="onHide">关闭</el-button>
+      </div>
+    </DialogCom>
+  </div>
+</template>
+
+<script>
+import { mapState, mapMutations } from "vuex";
+import {
+  getDetailById,
+} from "@/api/iot/deviceInfo";
+
+export default {
+  name: "IotDeviceDetailInfo",
+  components: {},
+  dicts: [],
+  data() {
+    const params = this.$route.params;
+    return {
+      id: params ? params.id : null,
+      isShow: false,
+      formData: this.reset(),
+      childrenInfos: [],
+      // signImageListValue: null,
+      labelStyle: {
+        'color': '#000',
+        'text-align': 'center',
+        'height': '40px',
+        'min-width': '150px',
+        'word-break': 'keep-all'
+      },
+      content_style: {
+        'text-align': 'left',
+        'min-width': '300px',
+        'word-break': 'break-all'
+      },
+    };
+  },
+  props: {},
+  watch: {},
+  computed: {
+    ...mapState(["loginUser"]),
+  },
+  methods: {
+    ...mapMutations([]),
+    reset() {
+      return {
+        id: null,
+        firstOrgName: null,
+        secondOrgName: null,
+        orgName: null,
+        deviceType: null,
+        deviceTypeName: null,
+        deviceName: null,
+        netStatus: null,
+        deviceProduct: null,
+        deviceModel: null,
+        hostCode: null,
+        iotCode: null,
+        parentName: null,
+        deviceAddress:null,
+        devicePort: null,
+        childrenInfos: [],
+      };
+    },
+    getNetStatusDesc(val){
+      if (val === '0'){
+        return "未知";
+      }else if(val === '1'){
+        return "在线";
+      }else if(val === '2'){
+        return "离线";
+      }else if(val === '3'){
+        return "异常";
+      }
+    },
+    async refresh(id) {
+      getDetailById(id).then(response => {
+        this.formData = response.data;
+        this.childrenInfos = this.formData.childrenInfos;
+        this.loading = false;
+      })
+    },
+    async show(id) {
+      this.id = id;
+      // this.isSignType = isSignType;
+      // this.showSignBtn = showSignBtn;
+      await this.refresh(id);
+      this.isShow = true;
+    },
+    // 事件
+    onHide() {
+      this.isShow = false;
+    },
+  },
+  mounted() {
+  },
+};
+</script>
+<style lang="scss">
+</style>

+ 360 - 0
src/views/iot/deviceInfo/index.vue

@@ -0,0 +1,360 @@
+<template>
+  <div class="app-container">
+      <div class="main-right-box">
+        <div class="main-search-box">
+          <el-tabs v-model="activeName" @tab-click="handleClick">
+            <el-tab-pane label="监控主机" name="dvs"></el-tab-pane>
+            <el-tab-pane label="报警主机" name="alarmHost"></el-tab-pane>
+            <el-tab-pane label="动环主机" name="fsu"></el-tab-pane>
+          </el-tabs>
+          <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
+            <el-form-item label="组织机构">
+              <org-tree
+                v-model="queryParams.orgId"
+                @defaultOrg="getDefaultOrg"
+                @checkChange="checkChange"
+                @click="clickTreeNode"
+                ref="orgTree"
+              ></org-tree>
+            </el-form-item>
+
+            <el-form-item label="设备名称" prop="deviceName">
+              <el-input clearable v-model="queryParams.deviceName" placeholder="请输入关键字" maxlength="50"
+                        @keyup.enter.native="handleQuery" />
+            </el-form-item>
+
+            <el-form-item label="设备类型" prop="deviceType" label-width="80">
+              <el-select style="width: 100%;"  v-model="queryParams.deviceType" placeholder="设备类型"
+                         @change="searchChangeSelectDeviceType" clearable>
+                <el-option v-for="dict in deviceTypeSelectList" :key="dict.value" :label="dict.label"
+                           :value="`${dict.value}`"></el-option>
+              </el-select>
+            </el-form-item>
+
+            <el-form-item label="网络状态" prop="netStatus" label-width="80">
+              <el-select style="width: 100%;"  v-model="queryParams.netStatus" placeholder="网络状态"
+                         @change="searchChangeSelectNetStatus" clearable>
+                <el-option v-for="dict in netStatusList" :key="dict.value" :label="dict.label"
+                           :value="`${dict.value}`"></el-option>
+              </el-select>
+            </el-form-item>
+          </el-form>
+          <el-row :gutter="10">
+            <el-col :span="1.5">
+              <el-button
+                type="primary"
+                icon="el-icon-search"
+                size="mini"
+                @click="handleQuery"
+              >搜索</el-button
+              >
+            </el-col>
+            <el-col :span="1.5">
+              <el-button
+                type="primary"
+                icon="el-icon-refresh"
+                size="mini"
+                @click="resetQuery"
+
+              >重置</el-button
+              >
+            </el-col>
+            <right-toolbar
+              :showSearch.sync="showSearch"
+              @queryTable="getList"
+            ></right-toolbar>
+          </el-row>
+        </div>
+        <el-table
+          border
+          height="646"
+          size="small"
+          v-loading="loading"
+          :data="deviceInfoList"
+          @selection-change="handleSelectionChange"
+
+        >
+          <!-- :header-cell-style="{backgroundColor:'#CCE8F7'}" -->
+          <!--<el-table-column type="selection" width="55" align="center" />-->
+          <el-table-column label="序号" align="center" min-width="50">
+            <template v-slot:default="scope">
+              <span v-text="getPageIndex(scope.$index)"> </span>
+            </template>
+          </el-table-column>
+          <el-table-column label="地区" align="center" prop="firstOrgName" />
+          <el-table-column label="行社" align="center" prop="secondOrgName" />
+          <el-table-column label="所属机构" align="center" prop="orgName" />
+          <el-table-column label="设备类型" align="center" prop="deviceTypeName"  />
+          <el-table-column label="设备名称" align="center" prop="deviceName"  />
+          <el-table-column
+            label="网络状态"
+            align="center"
+            prop="netStatus"
+          >
+            <template slot-scope="scope">
+              {{ getNetStatusDesc(scope.row.netStatus)}}
+            </template>
+          </el-table-column>
+          <el-table-column
+            label="操作"
+            align="center"
+            class-name="small-padding fixed-width"
+          >
+            <template slot-scope="scope">
+              <el-button
+                size="mini"
+                type="text"
+                icon="el-icon-edit-outline"
+                @click="showDetail(scope.row.id)"
+              >详情</el-button>
+            </template>
+          </el-table-column>
+        </el-table>
+        <pagination
+          :total="total"
+          :page.sync="queryParams.pageNum"
+          :limit.sync="queryParams.pageSize"
+          @pagination="getList"
+        />
+      </div>
+    <detail-info-page ref="detailInfo"></detail-info-page>
+  </div>
+</template>
+
+<script>
+import OrgTree from "@/components/orgTree/orgQuerySelector.vue";
+import detailInfoPage from "./detailDialog.vue"
+import { deptTreeSelect } from "@/api/system/public";
+import {
+  list,
+} from "@/api/iot/deviceInfo";
+export default {
+  name: "IotDeviceInfo",
+  components: { OrgTree, detailInfoPage },
+  data() {
+    return {
+      checkList: [],
+      roleOptions: [],
+      defaultKeys: [],
+      //是否关联下级
+      checked: false,
+      defaultProps: {
+        children: "children",
+        label: "name",
+      },
+      deviceTypeSelectList:[],
+      //0:未知,1:在线,2:离线,3:异常
+      netStatusList: [
+        { label: "未知", value: "0"},
+        { label: "在线", value: "1"},
+        { label: "离线", value: "2"},
+        { label: "异常", value: "3"},
+      ],
+      //监控主机下拉查询
+      DvsDeviceTypeList: [
+        { label: "监控主机", value: "1"},
+        { label: "模拟摄像头", value: "2"},
+        { label: "数字摄像头", value: "3"}
+      ],
+      //报警主机主机下拉查询
+      AlarmHostDeviceTypeList: [
+        { label: "报警主机", value: "4"},
+      ],
+      //动环主机下拉查询
+      FsuDeviceTypeList: [
+        { label: "动环主机", value: "5"},
+        { label: "烟雾传感器", value: "6"},
+        { label: "红外传感器", value: "7"},
+        { label: "温湿度传感器", value: "8"},
+        { label: "门磁传感器", value: "9"},
+        { label: "燃气传感器", value: "10"},
+        { label: "卷帘门传感器", value: "11"},
+        { label: "水浸传感器", value: "12"},
+        { label: "智能电表", value: "13"},
+        { label: "空调", value: "14"},
+        { label: "UPS", value: "15"},
+        { label: "DO8小时控电", value: "16"},
+        { label: "三相电电压传感器", value: "17"},
+      ],
+      // 遮罩层
+      loading: true,
+      // 选中数组
+      ids: [],
+      // 非单个停用
+      single: true,
+      //搜索tree
+      deptName: null,
+      // 非多个停用
+      multiple: true,
+      // 显示搜索条件
+      showSearch: true,
+      // 总条数
+      total: 0,
+      inparm: 0,
+      // 【请填写功能名称】表格数据
+      deviceInfoList: [],
+      //主机集合
+      hostList: [],
+      activeName: "dvs",
+      // 弹出层标题
+      title: "",
+      // 是否显示弹出层
+      open: false,
+      // 查询参数
+      dept: {
+        id: null,
+      },
+      queryParams: {
+        pageNum: 1,
+        pageSize: 10,
+        orgId: null,
+        orgName: null,
+        deviceName: null,
+        netStatus: null,
+        deviceType: null,
+        deviceTypeList: [],
+        checkSub: true,
+      },
+      //修改新增中的机构树
+      deptOptions: [],
+      selectOrgId: null,
+    };
+  },
+  created() {
+    this.getDeptTree();
+    this.queryParams.deviceType = null;
+    this.queryParams.deviceTypeList = ["1","2","3"];
+    this.deviceTypeSelectList = this.DvsDeviceTypeList;
+  },
+
+  watch: {
+    // 根据名称筛选部门树
+    deptName(val) {
+      this.$refs.tree.filter(val);
+    },
+  },
+
+  methods: {
+    getNetStatusDesc(val){
+      if (val === '0'){
+        return "未知";
+      }else if(val === '1'){
+        return "在线";
+      }else if(val === '2'){
+        return "离线";
+      }else if(val === '3'){
+        return "异常";
+      }
+    },
+    onOrgSelect(node) {
+      this.form.orgPath = node.path;
+      this.form.orgName = node.name;
+    },
+    //切换tab栏刷新数据
+    handleClick() {
+      this.queryParams.deviceType = null;
+      if ("dvs" === this.activeName){
+        this.queryParams.deviceTypeList = ["1","2","3"];
+        this.deviceTypeSelectList = this.DvsDeviceTypeList;
+      }else if ("alarmHost" === this.activeName){
+        this.queryParams.deviceTypeList = ["4"];
+        this.deviceTypeSelectList = this.AlarmHostDeviceTypeList;
+      }else if ("fsu" === this.activeName){
+        this.queryParams.deviceTypeList = ["5","6","7","8","9","10","11","12","13","14","15","16","17"];
+        this.deviceTypeSelectList = this.FsuDeviceTypeList;
+      }
+      this.getList();
+    },
+
+    getDefaultOrg(node) {
+      this.queryParams.orgId = node.id;
+      this.getList();
+    },
+    //单选框状态改变
+    checkChange(state) {
+      this.queryParams.checkSub = state;
+      this.getList();
+    },
+    // 节点单击事件
+    clickTreeNode(data) {
+      if(data==null){
+        return;
+      }
+      this.queryParams.orgId = data.id;
+      this.getList();
+    },
+
+    getPageIndex($index) {
+      //表格序号
+      return (
+        (this.queryParams.pageNum - 1) * this.queryParams.pageSize + $index + 1
+      );
+    },
+    /** 查询【请填写功能名称】列表 */
+    getList() {
+      console.log(this.queryParams)
+      console.log(this.queryParams.deviceType)
+      console.log(this.queryParams.deviceTypeList)
+      this.loading = true;
+      list(this.queryParams).then((response) => {
+        this.deviceInfoList = response.rows;
+        this.total = response.total;
+        this.loading = false;
+      });
+    },
+
+    /** 查询部门下拉树结构 */
+    getDeptTree() {
+      deptTreeSelect().then((response) => {
+        this.deptOptions = response.data;
+        this.defaultKeys.push(response.data[0].id);
+        this.queryParams.orgId = response.data[0].id;
+        this.selectOrgId = response.data[0].id;
+
+        this.handleQuery();
+      });
+    },
+    // 取消按钮
+    cancel() {
+      this.open = false;
+    },
+    /** 搜索按钮操作 */
+    handleQuery() {
+      this.queryParams.pageNum = 1;
+      this.getList();
+    },
+    /** 重置按钮操作 */
+    resetQuery() {
+      this.queryParams.deviceType = null;
+      this.resetForm("queryForm");
+      this.handleClick();
+      this.handleQuery();
+    },
+    // 多选框选中数据
+    handleSelectionChange(selection) {
+      this.ids = selection.map((item) => item.id);
+      this.names = selection.map((item) => item.deviceName);
+      this.single = selection.length !== 1;
+      this.multiple = !selection.length;
+    },
+    searchChangeSelectDeviceType(val) {
+      if (val) {
+        this.queryParams.deviceType = val;
+      }
+    },
+    searchChangeSelectNetStatus(val) {
+      if (val) {
+        this.queryParams.netStatus = val;
+      }
+    },
+    showDetail(deviceId){
+      this.$refs.detailInfo.show(deviceId);
+    },
+  },
+};
+</script>
+<style lang="scss">
+.el-checkbox {
+  display: -webkit-box !important;
+}
+</style>