index.vue 9.23 KB
<template>
  <div class="video-container clerk-wrapper">
    <el-row class="manage-head-wrapper">
      <el-col :xs="22" :sm="22">
        <div class="manage-select-box">
          <el-select v-model="queryForm.mallIds" multiple collapse-tags filterable :placeholder="$t('pholder.shopSelect')" clearable>
            <el-option v-for="item in mallListForTerm" :key="item.id" :label="item.name" :value="item.id" />
          </el-select>
        </div>
        <div class="manage-select-box">
          <el-input class="search-inp" :placeholder="$t('pholder.sopType')" v-model="queryForm.sop" @focus="openAssociateTreeModel"></el-input>
        </div>
        <div class="manage-select-box">
          <el-select v-model="queryForm.ruleId" filterable :placeholder="$t('pholder.captureRule')"  clearable>
            <el-option v-for="item in ruleList" :key="item.id" :label="item.name" :value="item.id" />
          </el-select>
        </div>
        <div class="manage-select-box">
          <el-select v-model="queryForm.status" :placeholder="$t('pholder.checkStatus')" clearable>
            <el-option :label="$t('pholder.all')" value=""/>
            <el-option :label="$t('format.nospotChecked')" :value="0" />
            <el-option :label="$t('format.spotChecked')" :value="1" />
          </el-select>
        </div>
        <div class="manage-select-box">
          <el-date-picker
            v-model="queryForm.time"
            type="daterange"
            range-separator="-"
            size='small'
            :start-placeholder="$t('table.startTime')"
            :end-placeholder="$t('table.endTime')">
          </el-date-picker>
        </div>
        <el-button type="primary" class="search-btn" plain  @click="searchFun">{{$t('button.search')}}</el-button>
      </el-col>
    </el-row>
    <el-row class="manage-content">
      <el-table
        ref="row_table"
        class="gate-table"
        :data="tableData"
        :max-height="tableHeight"
        style="width: 100%"
        header-row-class-name="manage-tab-head"
      >
        <el-table-column prop="order" :label="$t('table.order')" align="center" width="100"></el-table-column>
        <el-table-column prop="mallId" :label="$t('table.mall')" align="center">
          <template slot-scope="scope">
            {{formatMall(scope.row.mallId)}}
          </template>
        </el-table-column>
        <el-table-column prop="gateName" :label="$t('table.notifyKpiGate')" align="center"></el-table-column>
        <el-table-column prop="status" :label="$t('table.state')" align="center">
          <template slot-scope="scope">
            {{scope.row.status==0?$t('format.nospotChecked'):$t('format.spotChecked')}}
          </template>
        </el-table-column>
        <el-table-column prop="createTime" :label="$t('table.captureTime')" align="center"> </el-table-column>
        <el-table-column prop="picUrl" :label="$t('table.capturePictures')" align="center">
          <template slot-scope='scope'>
            <el-image :src='scope.row.picUrl' style='width: 120px;height: 80px;' @click='getDetail(item)'></el-image>
          </template>
        </el-table-column>
        <el-table-column :label="$t('table.operate')" align="center">
          <template slot-scope="scope">
            <el-button @click="getDetail(scope.row)" type="text" size="small" class="tab-btn">{{$t('button.spotCheck')}}</el-button>
            <el-button @click="delRow(scope.row)" type="text" size="small" class="tab-btn">{{$t('button.delete')}}</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        class="manage-pagination-box"
        background
        :current-page="currentPage"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="pageSize"
        @size-change="sizeChange"
        @current-change="cerrentChange"
        layout="sizes, prev, pager, next, slot"
        :total="total"
      >
        <span
          class="slot-ele-total"
        >{{$t('table.pageHead')}} {{ total }} {{$t('table.pageTail')}}</span>
      </el-pagination>
    </el-row>
    <associateTree ref='associateTreeModel' @getSop='getSop'></associateTree>
    <detailDialog ref='detailModel'></detailDialog>
  </div>
</template>

<script>
  import moment from 'moment'
  import associateTree from '../captureConfiguration/associateTree'
  import detailDialog from './detail.vue'
  export default{
    components: { associateTree,detailDialog },
    data(){
      return {
        mallListForTerm:[],
        tableData: [],
        ruleList:[],
        total: 0,
        pageSize: 10,
        currentPage: 1,
        queryForm:{
          accountId: this.$cookie.get('accountId'),
          ruleId:'',
          status:'',
          time:[new Date(), new Date()]
        },
      }
    },
    mounted(){
      this.getMallListForTerm()
      this.getRuleList()
    },
    computed: {
      tableHeight() {
        const windowInnerHeight = window.innerHeight;
        return windowInnerHeight - windowInnerHeight * 0.24;
    	}
    },
    methods:{
      formatMall(id){
        let objVal = this.mallListForTerm.filter(item=>item.id==id);
        return objVal[0].name
      },
      getMallListForTerm() {
        this.mallListForTerm = [];
        this.$api.base.mall({ accountId: this.$cookie.get('accountId'),status_arr: "1,3"}).then(data => {
          let result = data.data;
          if (result.data.length) {
            this.mallListForTerm = result.data;
          }
          this.getTableData();
        })
      },
      getRuleList() {
        let tabelParams = {
          pageNum: 1,
          pageSize: 9999999,
          accountId: this.$cookie.get('accountId')
        };
        this.$api.videoShopTourReport.getRuleList(tabelParams, null, true).then(data => {
            this.ruleList = [];
            var result = data.data;
            this.ruleList = result.data.list;
          })
      },
      openAssociateTreeModel(e){
        e.target.blur();
        this.$refs.associateTreeModel.dialogInit(this.queryForm.patrolSopProjects,1)
      },
      getSop(val){
        let arr = [],arrId = []
        this.queryForm.sopArr =[]
        val.forEach(item=>{
          arr.push(item.name)
          arrId.push({
            id:item.id
          })
          this.queryForm.sopArr.push(item.id)
        })
        this.queryForm.patrolSopProjects = arrId
        this.queryForm.sop = arr.toString()
        this.$forceUpdate()
      },
      getDetail(row){
        this.$refs.detailModel.dialogInit(row)
      },
      delRow(row){
        this.$confirm(this.$t('message.confirDelete'), this.$t('message.prompt'), {
          confirmButtonText: this.$t('message.confirm'),
          cancelButtonText: this.$t('message.cancel'),
          type: 'warning'
        }).then(() => {
          this.$api.videoShopTourReport.delPatrolCaptureRecord({id:row.id})
            .then((res) => {
              let result = res.data;
              if(result.code==200){
                this.$message({
                  message: result.msg,
                  type: 'success'
                });
                this.getTableData();
              }else{
                this.$message({
                  message: result.msg,
                  type: 'error'
                });
              }
            })
        })
      },
      getTableData() {
        this.queryForm.startDate = this.queryForm.time?moment(this.queryForm.time[0]).format('YYYY-MM-DD'):''
        this.queryForm.endDate = this.queryForm.time?moment(this.queryForm.time[1]).format('YYYY-MM-DD'):''
        let parmas = {
          sops:this.queryForm.sopArr?this.queryForm.sopArr.toString():'',
          startDate:this.queryForm.startDate,
          endDate:this.queryForm.endDate,
          accountId: this.$cookie.get('accountId'),
          mallIds:this.queryForm.mallIds?this.queryForm.mallIds.toString():'',
          status:this.queryForm.status,
          ruleId:this.queryForm.ruleId,
        }
        let tabelParams = {
          pageNum: this.currentPage,
          pageSize: this.pageSize,
          ...parmas
        };
        this.$api.videoShopTourReport.getPatrolCaptureRecordList(tabelParams, null, true).then(data => {
          this.tableData = [];
          var result = data.data;
          if(result.data.list && result.data.list.length>0){
            result.data.list.forEach((item, index) => {
              item.order = (this.currentPage - 1) * this.pageSize + index + 1;
              item.picUrl = window._vionConfig.picUrl + item.pic
            });
          }
          this.tableData = result.data.list;
          this.total = result.data.total;
        })
      },
      sizeChange(val) {
        this.pageSize = val;
        this.getTableData();
      },
      cerrentChange(val) {
        if (this.currentPage != val) {
          this.currentPage = val;
          this.getTableData();
        }
      },
      searchFun(){
        this.currentPage = 1;
        this.getTableData();
      }
    }
  }
</script>

<style scoped="scoped" lang="less">
  .manage-container{
    width: 100%;
  }
  .colItem{
    margin-bottom: 15px;
    cursor: pointer;
  }
  .manage-select-box{
    /deep/.el-select{
      width: 180px;
    }
    /deep/.el-range-input{
      height: 28px;
    }
    /deep/.el-date-editor.el-input__inner{
      width: 350px;
      padding: 0 10px;
      height: 30px !important;
    }
  }
</style>