index.vue 6.45 KB
<template>
  <div class="video-container clerk-wrapper">
    <el-row class="manage-head-wrapper">
      <el-button type="primary" class="manage-add-btn" @click="addDevice" icon="el-icon-circle-plus-outline">{{$t('button.groupAdd')}}</el-button>
    </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="name" :label="$t('table.ruleName')" align="center"></el-table-column>
          <!-- <el-table-column prop="mall" label="广场" align="center" show-overflow-tooltip></el-table-column> -->
          <el-table-column prop="relationType" :label="$t('table.routineCheckType')" align="center">
            <template slot-scope="scope">
              {{scope.row.relationType==0?$t('format.byCheckItem'):$t('format.byMonitoringPoint')}}
            </template>
          </el-table-column>
          <!-- <el-table-column prop="sopProjects" label="场景" align="center" show-overflow-tooltip></el-table-column> -->
          <el-table-column prop="cron" :label="$t('table.executionCycle')" align="center"></el-table-column>
          <el-table-column prop="startTime" :label="$t('pholder.startDate')" align="center"></el-table-column>
          <el-table-column prop="endTime" :label="$t('pholder.endDate')" align="center"></el-table-column>
          <el-table-column prop="enable" :label="$t('table.state')" align="center">
            <template slot-scope="scope">
              <el-switch
                v-model="scope.row.enable==1"
                @change = 'switchChange(scope.row)'
                active-color="#13ce66"
                inactive-color="#ff4949">
              </el-switch>
            </template>
          </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-device-dialog ref="adddeviceModel"></add-device-dialog>
  </div>
</template>

<script>
  import addDeviceDialog from './add.vue'
  export default{
    data(){
      return {
        mallListForTerm:[],
        tableData: [],
        total: 0,
        pageSize: 10,
        currentPage: 1,
        noDataText:''
      }
    },
    components: {
      "add-device-dialog": addDeviceDialog,
    },
    mounted(){
      this.getTableData()
    },
    computed: {
      tableHeight() {
        const windowInnerHeight = window.innerHeight;
        return windowInnerHeight - windowInnerHeight * 0.24;
    	}
    },
    methods:{
      getTableData() {
        let tabelParams = {
          pageNum: this.currentPage,
          pageSize: this.pageSize,
          accountId: this.$cookie.get('accountId')
        };
        this.$api.videoShopTourReport.getRuleList(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;
              let arr = [],arr1=[]
              // item.malls.forEach(itemM=>{
              //   arr.push(itemM.name)
              // })
              // item.mall = arr.toString()
              // item.patrolSopProjects.forEach(itemM=>{
              //   arr1.push(itemM.name)
              // })
              // item.sopProjects = arr1.toString()
            });
            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();
        }
      },
      switchChange(row){
        let parmas = {
          id:row.id,
          malls:null,
          enable:row.enable==1?'0':'1'
        }
        this.$api.videoShopTourReport.editRule(parmas)
          .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'
              });
            }
          })
      },
      addDevice(){
        this.$refs.adddeviceModel.dialogInit('add');
      },
      editRow(row){
        this.$refs.adddeviceModel.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.delRule({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'
                });
              }
            })
        })
      }
    }
  }
</script>

<style scoped="scoped" lang="less">
  .manage-container{
    width: 100%;
  }
  .manage-select-box{
    /deep/.el-select{
      width: 180px;
    }
  }
</style>