<!--算法日志-->
<template>
  <div class="app-container algorithmLogs">
    <div class="page-container algorithmLogsPage" v-if="pageType == 1">
      <div class="page-form-title-box">
        <el-form :model="queryParams" class="form-box" ref="queryForm" :inline="true">
          <el-form-item label="" prop="searchValue" label-width="80px">
            <el-input
              maxLength="30"
              v-model="queryParams.searchValue"
              placeholder="请输入实验室名称"
              clearable
              style="width: 200px"
            />
          </el-form-item>
          <el-form-item label="" prop="dateRange">
            <el-date-picker
              :clearable="false"
              v-model="dateRange"
              size="small"
              style="width: 240px"
              value-format="yyyy-MM-dd"
              type="daterange"
              range-separator="-"
              start-placeholder="请求时间"
              end-placeholder="请求时间"
            ></el-date-picker>
          </el-form-item>
          <el-form-item label="" prop="state">
            <el-select v-model="queryParams.state" clearable placeholder="请选择处理状态" style="width: 200px">
              <el-option label="已处理" :value="true"></el-option>
              <el-option label="未处理" :value="false"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="" prop="isPass">
            <el-select v-model="queryParams.isPass" clearable placeholder="请选择是否通过" style="width: 200px">
              <el-option label="通过" :value="true"></el-option>
              <el-option label="未通过" :value="false"></el-option>
            </el-select>
          </el-form-item>
          <p class="page-inquire-common-style-button" @click="handleQuery">查询</p>
          <p class="page-reset-common-style-button" @click="resetQuery">重置</p>
        </el-form>
      </div>
      <div class="page-content-box">
        <el-table class="table-box" v-loading="loading" border :data="tableList" ref="multipleTable">
          <el-table-column label="实验室" align="center" prop="subName" show-overflow-tooltip/>
          <el-table-column label="识别名称" align="center" prop="checkName" show-overflow-tooltip/>
          <el-table-column label="识别类型" align="center" prop="ipAddr" show-overflow-tooltip width="100">
            <template slot-scope="scope">
              {{scope.row.algorithmType == 'image'?'图片':'视频'}}
            </template>
          </el-table-column>
          <el-table-column label="原文件" align="center" prop="originalFile" show-overflow-tooltip width="139">
            <template slot-scope="scope">
              <img style="width:118px;cursor: pointer" :src="scope.row.originalFile" @click="lookImg(scope.row.originalFile,'原文件')">
            </template>
          </el-table-column>
          <el-table-column label="识别结果" align="center" prop="checkResult" show-overflow-tooltip width="139">
            <template slot-scope="scope">
              <img style="width:118px;cursor: pointer" :src="scope.row.checkResult" @click="lookImg(scope.row.checkResult,'识别结果')">
            </template>
          </el-table-column>
          <el-table-column label="处理状态" align="center" prop="state" show-overflow-tooltip width="100">
            <template slot-scope="scope">
              {{scope.row.state?'已处理':'未处理'}}
            </template>
          </el-table-column>
          <el-table-column label="是否通过" align="center" prop="isPass" show-overflow-tooltip width="100">
            <template slot-scope="scope">
              {{scope.row.isPass?'通过':'未通过'}}
            </template>
          </el-table-column>
          <el-table-column label="请求时间" align="center" prop="createTime" show-overflow-tooltip width="170">
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.createTime,"{y}-{m}-{d} {h}:{i}:{s}") }}</span>
            </template>
          </el-table-column>
          <el-table-column label="处理耗时（ms)" align="center" prop="costTime" show-overflow-tooltip width="120">
            <template slot-scope="scope">
              <span>{{ scope.row.costTime?scope.row.costTime+'ms':'--' }}</span>
            </template>
          </el-table-column>
          <el-table-column label="操作" align="center" prop="deptName" width="170" v-if="tableButtonType">
            <template slot-scope="scope">
              <div class="table-button-box">
                <p class="table-button-null"></p>
                <p class="table-button-p"
                   @click="tableButton(scope.row)"
                   v-hasPermiRouter="['system:alg:detail']"
                >详情</p>
                <p class="table-button-null"></p>
              </div>
            </template>
          </el-table-column>
        </el-table>
        <pagination :page-sizes="[20, 30, 40, 50]"
                    v-show="total>0"
                    :total="total"
                    :page.sync="queryParams.page"
                    :limit.sync="queryParams.pageSize"
                    @pagination="getList"
        />
      </div>
    </div>
    <infoPage v-if="pageType == 2" :propsData="propsData"></infoPage>
    <!--单张图片预览-->
    <fullScreenView :fullScreenViewProps="fullScreenViewProps" ref="fullScreenView"></fullScreenView>
  </div>
</template>

<script>
  import { algorithmList,algorithmDetail } from "@/api/serviceCenter/index";
  import infoPage from "./infoPage.vue";
  import fullScreenView from "@/components/fullScreenView/fullScreenView.vue";
  export default {
    name: 'algorithmLogs',
    components: {
      fullScreenView,
      infoPage
    },
    data(){
      return{
        tableButtonType:this.hasPermiDom(['system:alg:detail']),
        pageType:1,
        loading:false,
        dateRange:[],
        queryParams:{
          page:1,
          pageSize:20,
          state:"",
          searchValue:"",
          isPass:"",
        },
        tableList:[],
        total:0,
        propsData:{},
        fullScreenViewProps:[],
      }
    },
    created(){

    },
    mounted(){
      this.getList();
    },
    methods:{
      //查看图片
      lookImg(url,name){
        if(url){
          this.$set(this,'fullScreenViewProps',[url]);
          this.$refs['fullScreenView'].initialize();
        }
      },
      goPage(type){
        if(this.pageType!=type){
          this.$set(this,'pageType',type)
          this.getList();
        }
      },
      //详情按钮
      tableButton(row){
        algorithmDetail({logId:row.logId}).then(response => {
          this.$set(this,'propsData',response.data);
          this.$set(this,'pageType',2);
        });
      },
      //查询按钮
      handleQuery(){
        this.$set(this.queryParams,'page',1);
        this.getList();
      },
      //重置按钮
      resetQuery(){
        this.$set(this,'dateRange',[])
        this.$set(this,'queryParams',{
          page:1,
          pageSize:20,
          state:"",
          isPass:"",
          searchValue:"",
        });
        this.getList();
      },
      //获取数据列表
      getList(){
        this.$set(this,'loading',true);
        let obj = JSON.parse(JSON.stringify(this.queryParams))
        if(this.dateRange[0]){
          obj.startTime = this.dateRange[0]+'T00:00:00'
          obj.endTime = this.dateRange[1]+'T23:59:59'
        }else{
          obj.startTime = "";
          obj.endTime = "";
        }
        algorithmList(obj).then(response => {
          this.$set(this,'loading',false);
          this.$set(this,'tableList',response.data.records);
          this.$set(this,'total',response.data.total);
        });
      },
    }
  }
</script>

<style scoped lang="scss">
  .algorithmLogs{
    .algorithmLogsPage{
    }
  }
</style>
