index.vue 6.23 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.mallId" filterable :placeholder="$t('pholder.shopSelect')" @change="mallChange">
            <el-option v-for="item in mallListForTerm" :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="addProject" icon="el-icon-circle-plus-outline">{{$t('button.groupAdd')}}</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="name" :label="$t('table.presetPointName')" align="center"></el-table-column>
          <el-table-column prop="deviceName" :label="$t('table.deviceName')" align="center"></el-table-column>
          <el-table-column prop="deviceSerial" :label="$t('table.deviceSerial')" align="center"> </el-table-column>
          <el-table-column prop="channelNo" :label="$t('table.channelNo')" 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>
  </div>
</template>

<script>
  import addProjectDialog from './addProject.vue'
  export default{
    data(){
      return {
        mallListForTerm:[],
        tableData: [],
        total: 0,
        pageSize: 10,
        currentPage: 1,
        queryForm:{
          accountId: this.$cookie.get('accountId'),
          mallId:''
        },
        noDataText:''
      }
    },
    components: {
      "add-project-dialog": addProjectDialog
    },
    mounted(){
      this.getMallListForTerm()
    },
    computed: {
      tableHeight() {
        const windowInnerHeight = window.innerHeight;
        return windowInnerHeight - windowInnerHeight * 0.24;
    	}
    },
    methods:{
      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.mallListForTerm = result.data;
          }
          this.getTableData();
        })
      },
      mallChange() {
        this.setSessionLocal("mallId", this.queryForm.mallId);
        this.getTableData();
      },
      getTableData() {
        let tabelParams = {
          pageNum: this.currentPage,
          pageSize: this.pageSize,
          ...this.queryForm
        };
        this.$api.videoShopTourReport.getPresetList(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();
        }
      },
      addProject(){
        this.$refs.addProjectModel.dialogInit('add',this.queryForm.mallId);
      },
      editRow(row){
        this.$refs.addProjectModel.dialogInit('edit',this.queryForm.mallId,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.delPreset({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;
    }
  }
  .btns{
    text-align: right;
    .manage-add-btn{
      float: none;
    }
  }
</style>