index.vue 10.4 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.mallId" filterable :placeholder="$t('pholder.shopSelect')" @change="mallChange" 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-select v-model="queryForm.gateId" filterable :placeholder="$t('pholder.site')" clearable>
            <el-option v-for="item in monitorList" :key="item.id" :label="item.name" :value="item.id" />
          </el-select>
        </div>
        <div class="manage-select-box">
          <el-select v-model="queryForm.status" filterable :placeholder="$t('pholder.workOrderStatus')" clearable>
            <el-option v-for="item in orderStatusList" :key="item.value" :label="item.name" :value="item.value" />
          </el-select>
        </div>
        <div class="manage-select-box">
          <el-input v-model="queryForm.sn" class="search-inp" :placeholder="$t('pholder.workOrderNumber')" clearable/>
        </div>
        <div class="manage-select-box">
          <el-select v-model="queryForm.createBy" filterable :placeholder="$t('pholder.shopInspector')" clearable>
            <el-option v-for="item in userList" :key="item.id" :label="item.realName" :value="item.loginName"/>
          </el-select>
        </div>
        <div class="manage-select-box">
          <el-select v-model="queryForm.handler" filterable :placeholder="$t('pholder.handler')" clearable>
            <el-option :label="$t('pholder.all')" value="-1"/>
            <el-option v-for="item in userList" :key="item.id" :label="item.realName" :value="item.loginName"/>
          </el-select>
        </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-col :span="24">
        <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="sn" :label="$t('table.workOrderNum')" align="center"></el-table-column>
          <el-table-column prop="gateName" :label="$t('table.notifyKpiGate')" align="center"> </el-table-column>
          <el-table-column prop="createByName" :label="$t('table.shopInspector')" align="center"></el-table-column>
          <el-table-column prop="status" :label="$t('table.workOrderStatus')" align="center">
            <template slot-scope="scope">
              <span class="status" :class="'status'+scope.row.status">{{formatStatus(scope.row.status)}}</span>
            </template>
          </el-table-column>
          <el-table-column prop="handlerName" :label="$t('table.handler')" align="center"></el-table-column>
          <el-table-column prop="hadScore" :label="$t('table.scoreTotal')" align="center">
            <template slot-scope="scope">
              <span>{{scope.row.hadScore}}/{{scope.row.totalScore}}</span>
            </template>
          </el-table-column>
          <el-table-column prop="qualified" :label="$t('table.qualifiedTtotal')" align="center">
            <template slot-scope="scope">
              <span>{{scope.row.qualified}}/{{scope.row.total}}</span>
            </template>
          </el-table-column>
          <el-table-column prop="createTime" :label="$t('table.CreatTime')" width="160"  align="center"></el-table-column>
          <el-table-column prop="modifyTime" :label="$t('table.updateTime')" align="center" width="160"></el-table-column>
          <el-table-column :label="$t('table.operate')" align="center">
            <template slot-scope="scope">
              <el-button @click="editRow(scope.row)" type="text" size="small" class="tab-btn">{{$t('button.look')}}</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-col>
    </el-row>
    <detail-dialog ref='dialogModel'></detail-dialog>
  </div>
</template>

<script>
  import detailDialog from '../InspectionRecord/detail.vue'
  export default{
    components:{
      detailDialog
    },
    data(){
      return {
        mallListForTerm:[],
        monitorList:[],
        tableData: [],
        total: 0,
        pageSize: 10,
        currentPage: 1,
        queryForm:{
          accountId: this.$cookie.get('accountId'),
          patrolType: 2,
        },
        userList:[],
        orderStatusList:[
          {
            name:this.$t('pholder.all'),
            value:''
          },
          {
            name:this.$t('dictionary.pending'),
            value:'1'
          },
          {
            name:this.$t('dictionary.reexamine'),
            value:'2'
          },
          {
            name:this.$t('dictionary.completed'),
            value:'3'
          }
        ]
      }
    },
    mounted(){
      this.getMallListForTerm()
    },
    computed: {
      tableHeight() {
        const windowInnerHeight = window.innerHeight;
        return windowInnerHeight - windowInnerHeight * 0.24;
    	}
    },
    methods:{
      formatStatus(cellValue){
        const formaterVal = this.orderStatusList.find(item => item.value == cellValue)
        return formaterVal && formaterVal.name || '--'
      },
      formatUser(cellValue){
        const formaterVal = this.userList.find(item => item.loginName == cellValue)
        return formaterVal && formaterVal.realName || '--'
      },
      getUserList(){
        this.userList = []
        this.$api.videoShopTourReport.getUsers({mallId: this.queryForm.mallId}).then(data => {
          let result = data.data
          this.userList = result.data
        })
      },
      getMallListForTerm() {
        this.mallListForTerm = [];
        this.queryForm.mallId = "";
        this.$api.base.mall({ accountId: this.$cookie.get('accountId'),status_arr: "1,3"}).then(data => {
          let result = data.data;
          if (result.data.length) {
            if (this.getSessionLocal("mallId")) {
              this.queryForm.mallId = Number(this.getSessionLocal("mallId"));
            } else {
              this.queryForm.mallId = result.data[0].id;
              this.setSessionLocal("mallId", this.queryForm.mallId);
            }
            this.getUserList()
            this.getMonitorList();
            this.mallListForTerm = result.data;
          }
          this.getTableData();
        })
      },
      mallChange() {
        this.setSessionLocal("mallId", this.queryForm.mallId);
        this.queryForm.gateId = ''
        this.getMonitorList();
      },
      getMonitorList() {
        this.monitorList = []
        let tabelParams = {
          pageNum: 1,
          pageSize: 99999,
          mallId:this.queryForm.mallId
        };
        this.$api.videoShopTourReport.getPatrolGateList(tabelParams, null, true)
          .then(data => {
            let result = data.data;
            if(result.data.list.length){
              this.monitorList = result.data.list
            }
          })
      },
      getTableData() {
        let tabelParams = {
          pageNum: this.currentPage,
          pageSize: this.pageSize,
          ...this.queryForm
        };
        Object.keys(tabelParams).map(key =>{
         if(key== 'handler'){
           if(tabelParams[key]=='-1'){
             delete tabelParams[key]
           }
         }else{
           !tabelParams[key] ? delete tabelParams[key] : ''
         }
        });
        this.$api.videoShopTourReport
          .getPatrolRecordList(tabelParams, null, true)
          .then(data => {
            this.tableData = [];
            var result = data.data;
            result.data.list.forEach((item, index) => {
              item.order = (this.currentPage - 1) * this.pageSize + index + 1;
            });
            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();
        }
      },
      editRow(row){
        this.$refs.dialogModel.dialogInit(row.id,'detail');
      },
      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.deletePatrolRecord({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'
                });
              }
            })
        })
      },
      searchFun(){
        this.currentPage = 1;
        this.getTableData();
      }
    }
  }
</script>

<style scoped="scoped" lang="less">
  .manage-container{
    width: 100%;
  }
  .manage-select-box{
    /deep/.el-select{
      width: 180px;
    }
  }
  .status{
    &:before{
      content: ' ';
      display: inline-block;
      width: 10px;
      height: 10px;
      border-radius: 50%;
      background-color: #E02020;
      margin-right: 5px;
    }
  }
  .status2{
    &:before{
      background-color: #F7B500;
    }
  }
  .status3{
    &:before{
      background-color: #6DD400;
    }
  }
</style>