algo_tem[late_back.vue 4.82 KB
<template>
    <div class="innnerBox">
    <el-col :span="22">
      <el-form ref="form" label-width="80px" inline>
				 <el-form-item label="模板类型">
          <span class="selectBox">
          <el-select v-model="algoSet" placeholder="请选择算法类型" @change="refreshAlgo" class="algo-header-left">
            <el-option value="picture" label="图片模板"></el-option>
            <el-option value="video" label="视频模板"></el-option>
          </el-select>
          </span>
        </el-form-item>
      </el-form>
    </el-col>
		 <el-col :span="2">
				<el-button class="" type="primary" @click="createTpl">添加</el-button>
        <el-button class="mt10" @click="refreshAlgo">刷新</el-button>
    </el-col>
    <div class="table-box mt10" >
      <el-table :data="tableData" tooltip-effect="dark" ref="multipleTable" height="700" style="width: 100%"  @selection-change="handleSelectionChange" v-loading="loading">
        <el-table-column type="index" width="55">
        </el-table-column>
        <el-table-column prop="unid" align="center" label="模板编号">
        </el-table-column>
        <el-table-column prop="name" align="center" label="模板编号">
        </el-table-column>
        <el-table-column align="center" label="模板类型">
          <template slot-scope="scope">
            <div>
              {{filterAlgoName(scope.row.cate) ? filterAlgoName(scope.row.cate) : '无'}}
            </div>
          </template>
        </el-table-column>
        <el-table-column align="center" label="创建时间">
          <template slot-scope="scope">
            <div>
              {{scope.row.create_dt ? scope.row.create_dt : '无'}}
            </div>
          </template>
        </el-table-column>
        <el-table-column align="center" label="操作">
          <template slot-scope="scope">
            <div>
              <span class="det-btn" @click="tpdetail(scope.row)">详情</span>
              <span class="del-btn"  @click="deltem(scope.row)">删除</span>
            </div>
          </template>
        </el-table-column>
      </el-table>
      <div>
          <el-pagination   style="float: right;" class="mt10" @size-change="handleSizeChange" @current-change="handleCurrentChange"
          :current-page="search.currentPage" :page-sizes="[20,100, 200, 300, 400]" :page-size="search.size"
          layout="total, sizes, prev, pager, next, jumper" :total="search.total">
        </el-pagination>
      </div>
    </div>
    <div>
      <addTemplate ref="addtpl"></addTemplate>
    </div>
    <div>
      <tplDetails :tplData="tplData" ref="tpldetail"></tplDetails>
    </div>
  </div>
</template>
<script>
import tplDetails from "./temDetail";
import addTemplate from "./addTpl";
  export default {
    data() {
      return {
        algoSet: 'picture',
        addalgoSet:'video',
        tableData: [],
        isShow: false,
        details: [],
        fileList:[],
        tplData:[],
        search:{
          size:20,
          limit:20,
          offset:0,
          currentPage:0,
          total:0
        }
      }
    },
    components: {
        tplDetails,
        addTemplate,
    },
    methods: {
      handlePreview(){},
      submitUpload() {
        this.$refs.upload.submit();
      },
      addalgomanage(){
        this.isShow = true;
      },
      handleSelectionChange(){
        this.refreshAlgo();
      },
      refreshAlgo() {
        this.getData();
        this.search.offset = 0;
        this.search.currentPage = 1;
      },
      getData() {
        this.loading = true
        this.$api.device.combs(
          {
            offset: 0,
            limit: 20,
            algo_set: this.algoSet
        }).then(m => {
          this.tableData = m.list_data;
          this.search.total = m.total_num
          this.loading = false
        })
      },
      handleSizeChange(val){
        this.search.limit = val
        this.getData()
      },
      handleCurrentChange(val){
        this.search.currentPage = val;
        this.search.offset = (val-1)*this.search.size
        this.getData()
      },
      filterAlgoName: function (str) {
				var zhType = '';
				switch (str) {
					case 'traffic':
						zhType ='交通';
						break;
					case 'Safety':
						zhType ='安防';
						break;
					case 'FlowCount':
						zhType ='客流';
						break;
					default:
						break;
				}
				return zhType;
      },
      createTpl: function () {
            this.$refs.addtpl.tplInit(this.templateType);
      },
      tpdetail(data){
          this.tplData = data
          setTimeout(()=>{
            this.$refs.tpldetail.init();
          },0)
      },
    },
    created() {
      this.getData()
    },
  }

</script>
<style lang="stylus" scoped>
.search-item{
  overflow hidden
}
.det-btn{
  padding 0 10px
  color #409EFF
  cursor pointer
}
.del-btn{
  padding 0 10px
  color #F56C6C
  cursor pointer
}
</style>