index.vue 7.24 KB
<template>
  <div class="video-container clerk-wrapper">
    <el-row class="manage-head-wrapper">
      <el-col :xs="12" :sm="12">
        <div class="manage-select-box">
          <el-select v-model="queryForm.sopTypeId" filterable :placeholder="$t('pholder.select')" @change="handleChange" clearable>
            <el-option v-for="item in sopTypeList" :key="item.id" :label="item.name" :value="item.id" />
          </el-select>
        </div>
        <el-button type="primary" class="search-btn" plain  @click="searchFun">{{$t('button.search')}}</el-button>
      </el-col>
      <el-col :xs="12" :sm="12">
        <div class="btns">
          <el-button type="primary" class="manage-add-btn" @click="addType" icon="el-icon-circle-plus-outline">{{$t("button.newType")}}</el-button>
          <el-button type="primary" class="manage-add-btn" @click="getTypeListDialog" icon="el-icon-collection">{{$t("button.typeManagement")}}</el-button>
          <el-button type="primary" class="manage-add-btn" @click="addProject" icon="el-icon-circle-plus-outline">{{$t("button.newItem")}}</el-button>
        </div>
      </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="industryValue" :label="$t('table.industry')" align="center"></el-table-column>
          <el-table-column prop="sopTypeId" :label="$t('table.type')" align="center">
            <template slot-scope="scope">
              {{typeFormatter(scope.row.sopTypeId)}}
            </template>
          </el-table-column>
          <el-table-column prop="name" :label="$t('VideoShopTour.checkItems')" align="center"></el-table-column>
          <el-table-column prop="score" :label="$t('VideoShopTour.scoreNum')" align="center"> </el-table-column>
          <el-table-column prop="intro" :label="$t('VideoShopTour.introduction')" align="center"> </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.edit')}}</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>
    <add-project-dialog ref="addProjectModel"></add-project-dialog>
    <add-type-dialog ref="addTypeModel"></add-type-dialog>
    <type-list-dialog ref="getTypeListModel"></type-list-dialog>
  </div>
</template>

<script>
  import addProjectDialog from './addProject.vue'
  import typeListDialog from './typeManagement.vue'
  import addTypeDialog from './addType.vue'
  export default{
    data(){
      return {
        sopTypeList:[],
        tableData: [],
        total: 0,
        pageSize: 10,
        currentPage: 1,
        queryForm:{
          system:1,
          sopTypeId:''
        },
        noDataText:'',
      }
    },
    components: {
      "add-project-dialog": addProjectDialog,
      'add-type-dialog': addTypeDialog,
      'type-list-dialog': typeListDialog
    },
    mounted(){
      this.getSopTypeList()
    },
    computed: {
      tableHeight() {
        const windowInnerHeight = window.innerHeight;
        return windowInnerHeight - windowInnerHeight * 0.24;
    	}
    },
    methods:{
      typeFormatter(cellValue) {
        const formaterVal = this.sopTypeList.find(item => item.id === cellValue)
        return formaterVal && formaterVal.name || '--'
      },
      getSopTypeList() {
        this.sopTypeList = [];
        this.$api.videoShopTourReport.getPatrolSopType(
            {
              system: 1,
              pageNum:1,
              pageSize:9999999
            },
            null,
            true
          )
          .then(data => {
            let result = data.data;
            if(result.code == '200'){
              if (result.data.list.length) {
                this.sopTypeList = result.data.list;
                this.getTableData();
              }
            }
          })
      },
      handleChange() {
        this.getTableData();
      },
      getTableData() {
        this.dataMsg = this.$t("echartsTitle.loading");
        let tabelParams = {
          pageNum: this.currentPage,
          pageSize: this.pageSize,
          ...this.queryForm
        };
        this.$api.videoShopTourReport
          .getPatrolSopProject(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();
        }
      },
      addType(){
        this.$refs.addTypeModel.dialogInit();
      },
      getTypeListDialog(){
        this.$refs.getTypeListModel.dialogInit();
      },
      addProject(){
        this.$refs.addProjectModel.dialogInit('add');
      },
      editRow(row){
        this.$refs.addProjectModel.dialogInit('edit',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.delPatrolGate(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;
    }
  }
  .btns{
    text-align: right;
    .manage-add-btn{
      float: none;
    }
  }
</style>