index.vue 7.78 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.select')" @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="2" :sm="2">
        <el-button type="primary" class="manage-add-btn" @click="addDevice" icon="el-icon-circle-plus-outline">{{$t('button.groupAdd')}}</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="name" :label="$t('table.monitorSiteName')" align="center"></el-table-column>
          <el-table-column prop="name" :label="$t('table.deviceName')" align="center">
            <template slot-scope="scope">
              <div v-if="scope.row.patrolDevice">
                <span>{{scope.row.patrolDevice.name}}</span><span v-if="scope.row.patrolDevice.deviceName">({{scope.row.patrolDevice.deviceName}})</span>
              </div>
            </template>
          </el-table-column>
          <el-table-column prop="deviceSerial" :label="$t('table.deviceSerial')" align="center">
            <template slot-scope="scope">
              <span v-if="scope.row.patrolDevice">{{scope.row.patrolDevice.deviceSerial}}</span>
            </template>
          </el-table-column>
          <el-table-column prop="deviceSerial" :label="$t('table.channelNo')" align="center">
            <template slot-scope="scope">
              <span v-if="scope.row.patrolDeviceChannel">{{scope.row.patrolDeviceChannel.channelName}}</span>
            </template>
          </el-table-column>
          <el-table-column :label="$t('table.operate')" align="center">
            <template slot-scope="scope">
              <!-- <el-button @click="associateSystem(scope.row)" type="text" size="small" class="tab-btn">关联SOP</el-button> -->
              <el-button @click="associatePresetPoint(scope.row)" type="text" size="small" class="tab-btn">{{$t('button.presetPoint')}}</el-button>
              <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>
    <!-- <associate-tree-dialog ref="associateModel"></associate-tree-dialog> -->
    <preset-point-dialog ref='presetPointModel'></preset-point-dialog>
  </div>
</template>

<script>
  import addDeviceDialog from './add.vue'
  // import associateTreeDialog from './associateTree.vue'
  import presetPointDialog from './presetPoint.vue'
  export default{
    data(){
      return {
        mallListForTerm:[],
        tableData: [],
        total: 0,
        pageSize: 10,
        currentPage: 1,
        queryForm:{
          accountId: this.$cookie.get('accountId')
        },
        noDataText:''
      }
    },
    components: {
      "add-device-dialog": addDeviceDialog,
      // 'associate-tree-dialog': associateTreeDialog,
      'preset-point-dialog': presetPointDialog
    },
    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"
            },
            null,
            true
          )
          .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();
          })
          .catch(error => {});
      },
      mallChange() {
        this.setSessionLocal("mallId", this.queryForm.mallId);
        this.getTableData();
      },
      getTableData() {
        this.dataMsg = this.$t("echartsTitle.loading");
        let tabelParams = {
          pageNum: this.currentPage,
          pageSize: this.pageSize,
          ...this.queryForm
        };
        this.$api.videoShopTourReport
          .getPatrolGateList(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();
        }
      },
      associateSystem(row){
        this.$refs.associateModel.dialogInit(row);
      },
      addDevice(){
        this.$refs.adddeviceModel.dialogInit(this.queryForm.mallId,'add');
      },
      editRow(row){
        this.$refs.adddeviceModel.dialogInit(this.queryForm.mallId,'edit',row);
      },
      associatePresetPoint(row){
        this.$refs.presetPointModel.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.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;
    }
  }
</style>