dev.vue 7.34 KB
<template>
    <div class="template-box content_div_main">
        <div>
            <el-form :inline="true" class="search-form" size="small">
              <el-form-item label="组织:">
                <el-input type="text" class="bra" v-model="search.org_name" placeholder="组织名"></el-input>
              </el-form-item>
                <el-form-item label="地点:">
                <el-input type="text" class="bla" placeholder="相机名称" v-model="search.address_name"></el-input>
              </el-form-item>
              <el-form-item label="相机:">
                <el-input type="text" class="bla" placeholder="相机名称" v-model="search.name__like"></el-input>
              </el-form-item>
              <el-form-item>
                  <el-button class="search-btn" icon="el-icon-search" @click="searchVchan">查询</el-button>
                  <el-button class="search-btn" @click="addvchan()" icon="el-icon-plus">添加</el-button>
              </el-form-item>
            </el-form>
        <el-table :data="tableData"  v-loading.body="loading" class="table_m_type" height="730">
            <el-table-column label="序号" type="index" width="120" align="center"></el-table-column>
            <el-table-column label="相机编号" property="vchan_refid"> </el-table-column>
            <el-table-column label="相机名称" property="vchan_name"> </el-table-column>
            <el-table-column label="相机属性">
              <template slot-scope="scope">
                <span>{{showent(scope.row)}}</span>
              </template>
            </el-table-column>
            <el-table-column label="相机状态">
              <template slot-scope="scope">
                <span>在线</span>
              </template>
            </el-table-column>
            <el-table-column label="IP" property="vchan_prop.ip" align="center"> </el-table-column>
            <el-table-column label="安装地点" property="address_name" align="center"> </el-table-column>
        </el-table>
        <el-pagination class="mt10" @current-change="handleCurrentChange" :current-page.sync="page.currentPage"
          :page-size="page.limit" layout="total,prev, pager, next, jumper" :total="page.total" background >
        </el-pagination>
      <!-- <infoDialog ref='infoDialog' @refresh='refreshInfo'></infoDialog> -->
        </div>
    <el-row>
      <addvchan ref="vchan" :addvdialog="addvdialog" :state="state" :editData="editData" @closedialog="closedialog"></addvchan>
    </el-row>
  </div>
</template>

<script>
import { mapState } from "vuex";
import addvchan from "./adddev";
export default {
  data() {
    return {
      height: 900,
      tableData: [],
      loading: false,
      orgunid: "",
      addressunid: "",
      addvdialog: false,
      state:'add',
      editData: "",
      defaultProps: {
        children: "childs",
        label: "org_name"
      },
      orgData: [],
      search:{
        org_name:'',
        address_name:'',
        name__like:''
      },
      page: {
        offset: 0,
        limit: 18,
        total: 0,
        currentPage: 0
      }
    };
  },
  methods: {
      handleCurrentChange(val) {
        this.page.offset = (val - 1) * this.page.limit;
        this.getvchanlist();
      },
    closedialog(state) {
      this.addvdialog = false;
      if (state == 1) {
        this.getOrgData();
        this.getvchanlist();
      }
    },
    addvchan(){
      this.addvdialog = true;
      this.state = 'add';
    },
    showent(val){
      let result = '';
      if(val.vchan_prop){
        if(val.vchan_prop.ent_prop == 1){
           result = "入口"
        }
        if(val.vchan_prop.ent_prop == 2){
           result = "出口"
        }
      }
      return result
    },
    editvchan(index, row) {
      this.editData = row;
      this.$refs.vchan.editvchan();
      this.addvdialog = true;
      this.state = 'edit';
    },
    deletevchan(index, row) {
      this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          this.axios
            .delete(this.API.org.getvchan, {
              data: {
                id: row.id
              }
            })
            .then(response => {
              this.$message({
                type: "success",
                message: "删除成功!"
              });
              this.getvchanlist();
              this.getOrgData();
            });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除"
          });
        });
    },
    getvchanlist() {
      this.axios
        .get(this.API.org.getvchanList, {
          params:{
            org_name:this.search.org_name,
            address_name:this.address_name,
            name__like:this.name__like,
            offset: this.page.offset,
            limit: this.page.limit,
            vchan_type:'vchan'
        }
        })
        .then(response => {
          this.tableData = response.data.list_data;
          this.page.total = response.data.total_num;
        });
    },
    buildTree(data){
      if(data) {
        data.forEach(el => {
          if(el.org_type == 'vchan'){
            el.org_name = el.vchan_name
          }
          if(el.childs){
            this.buildTree(el.childs);
          }
        });
      }
      return data
    },
    renderContent(h, { node, data, store }){
        var html = <span>{data.org_name}</span>;
        if (data.org_type == "address") {
          html = <span class="">{data.org_name}</span>;
        }
        if (data.org_type == "vchan") {
          if(data.vchan_prop.is_dome){
           html = (
             <span>
              <i class="el-icon-plate-shebeileiqiuji"></i> <span style="padding-left:10px;">{data.vchan_name}</span>
            </span>);
          } else {
          html = (
             <span>
              <i class="el-icon-plate-qiangji"></i> <span style="padding-left:10px;">{data.vchan_name}</span>
            </span>);
          }
        }
        if (data.org_type == "horn") {
          html = (
             <span>
              <i class="el-icon-fa-volume-up fz20"></i> <span style="padding-left:10px;">{data.vchan_name}</span>
            </span>);
        }
        return (
          <span>
            <span>{html}</span>
          </span>
        );
      },
    getOrgData() {
      this.axios
        .get(this.API.org.getorgtree, {
          params: {
            "vchan_source":'internal',
            "vchan_type":'vchan'
          },
          hedader: {
            authorization: localStorage.getItem("atoken")
          }
        })
        .then(response => {
          this.orgData = this.buildTree(response.data);
        });
    },
    handleNodeClick(){
    },
    searchVchan() {
      this.getvchanlist();
    }
  },
  computed: {
    ...mapState(["initinfo"])
  },
  components: {
    addvchan
  },
  created() {
    this.getOrgData();
    this.getvchanlist();
  }
};
</script>

<style scoped lang="stylus">
.orgbox{
  display flex
}
.left-box {
  margin: 5px;
  width: 230px;
  height: calc(100vh - 130px);
  box-shadow: 0px 0px 2px 1px rgba(0, 0, 0, 0.1);
  background: #ffffff;
  border-radius: 5px;
  overflow: hidden;
  font-size 14px
}
.org-right-box {
  width: calc(100vw - 220px);
  margin: 5px;
  box-shadow: 0px 0px 2px 1px rgba(0, 0, 0, 0.1);
}
</style>