index.vue 11.7 KB
<template>
    <div class="clerk-wrapper queueManagementContainer">
        <div class="header manage-head-wrapper">
            <el-form ref="form" class="boxShadow searchFormSocial" inline>
                <el-form-item :label="$t('table.mall')">
                    <el-select v-model="searchForm.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>
                </el-form-item>
                <el-form-item :label="$t('table.areaName')">
                    <el-select v-model="searchForm.cashierAreaId" :placeholder="$t('pholder.areaSelect')" @change="areaChange">
                        <el-option v-for="item in areaListData" :key="item.id" :label="item.name" :value="item.id" />
                    </el-select>
                </el-form-item>
                <el-form-item :label="$t('table.laneName')">
                    <el-select v-model="searchForm.cashierChannelId" clearable :placeholder="$t('pholder.selectLane')">
                       <el-option :label="$t('pholder.all')" value="" />
                        <el-option v-for="item in channelListData" :key="item.id" :label="item.name" :value="item.id" />
                    </el-select>
                </el-form-item>
                <!--< el-form-item :label="$t('table.alarmType')">
                    <el-select v-model="searchForm.messageType" clearable :placeholder="$t('pholder.selectLane')">
                       <el-option :label="$t('pholder.all')" value="" />
                        <el-option v-for="item in messageTypetData" :key="item.id" :label="item.name" :value="item.id" />
                    </el-select>
                </el-form-item> -->
                <el-form-item :label="$t('table.date')">
                  <el-date-picker
                        v-model="searchForm.countDate"
                        type="daterange"
                        range-separator="至"
                        start-placeholder="开始日期"
                        end-placeholder="结束日期">
                      </el-date-picker>
                    <!-- <el-date-picker type="date" :placeholder="$t('pholder.date')" v-model="searchForm.countDate" style="width: 100%;"></el-date-picker> -->
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" class="search-btn" size="mini" plain @click="searchFun">{{$t('button.search')}}</el-button>
                    <el-button type="primary" class="search-btn" size="mini" plain @click="alarmRulesFun">{{$t('button.alarmRules')}}</el-button>
                </el-form-item>
            </el-form>
        </div>
        <div class="manage-content">
            <div class="asis-table-content boxShadow" v-loading="loading">
              <el-table
                :data="tableData"
                :max-height="tableHeight"
                style="width: 100%;"
                ref="row_table"
                v-loading="loading"
                class="clerk-manage-table"
                header-row-class-name="manage-tab-head"
              >
                <el-table-column :label="$t('table.order')" align="center" type="index" width="100"></el-table-column>
               <!-- <el-table-column :label="$t('table.alarmType')" align="center" prop="messageType" width="160">
                  <template slot-scope="scope">
                      <span>{{scope.row.messageType==0?$t('table.queueLengthAlert'):$t('table.waitTimeAlert')}}</span>
                  </template>
                </el-table-column> -->
                <el-table-column :label="$t('table.laneName')" width="160" align="center" prop="cashierChannelId" :formatter="landFormat"></el-table-column>
                <el-table-column :label="$t('table.messageContent')" align="center" prop="messageContent" show-overflow-tooltip></el-table-column>
                <el-table-column :label="$t('table.sentDate')" align="center" prop="createTime" width="160"></el-table-column>
                <el-table-column :label="$t('table.state')" align="center" prop="status" width="100">
                    <template slot-scope="scope">
                        <span>{{scope.row.status==1?$t('table.sendSuccess'):$t('table.sendFail')}}</span>
                    </template>
                </el-table-column>
                <el-table-column :label="$t('table.recipient')" align="center" prop="sendEmail">
                </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>
            </div>
        </div>
        <add-dialog ref="addModel"></add-dialog>
    </div>
</template>

<script>
    import moment from 'moment'
    import addDialog from './addRule.vue'
    export default {
        data() {
            return {
              mallListForTerm:[],
              channelListData:[],
              areaListData:[],
              tableData: [],
              total: 0,
              pageSize: 10,
              currentPage: 1,
              pagesizeArr: [10, 20, 50, 100],
              loading: false,
              searchForm: {
                 mallId: '',
                 cashierAreaId: '',
                 cashierChannelId: '',
                 // messageType:'',
                 countDate: [new Date(),new Date()],
              },
              messageTypetData:[{
                name:this.$t('table.queueLengthAlert'),
                id:'0'
              },{
                name:this.$t('table.waitTimeAlert'),
                id:'1'
              }]
            }
        },
        components:{
            addDialog,
        },
        mounted() {
            this.getMallListForTerm()
        },
        computed: {
            tableHeight() {
                const windowInnerHeight = window.innerHeight;
                return windowInnerHeight - windowInnerHeight * 0.24;
            },
        },
        methods: {
            // 广场
            getMallListForTerm() {
                this.mallListForTerm = [];
                this.searchForm.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.searchForm.mallId = Number(this.getSessionLocal("mallId"));
                        } else {
                            this.searchForm.mallId = result.data[0].id;
                            this.setSessionLocal("mallId", this.searchForm.mallId);
                        }
                        this.mallListForTerm = result.data;
                    }
                    this.getAreaList();
                })
            },
            mallChange(val) {
                this.setSessionLocal("mallId", val);
                this.searchForm.cashierAreaId = ''
                this.searchForm.cashierChannelId = ''
                this.areaListData = [];
                this.channelListData = [];
                this.getAreaList(val)
            },
            // 区域
            getAreaList(val) {
                this.areaListData = [];
                this.$api.queueManagementApi.getAreaList({
                    mallId: this.searchForm.mallId,
                    pageNum: 1,
                    pageSize: 999999
                }).then(res => {
                    let result = res.data;
                    if (result.code == 200) {
                        if (result.data.list && result.data.list.length > 0) {
                            this.searchForm.cashierAreaId = result.data.list[0].id
                            this.areaListData = result.data.list;
                            this.getChannelList()
                        }
                    }
                })
            },
            areaChange() {
                this.searchForm.cashierChannelId = ''
                this.getChannelList()
            },
            // 通道
            getChannelList() {
                this.channelListData = [];
                this.$api.queueManagementApi.getChannelList({
                    areaId: this.searchForm.cashierAreaId,
                    pageNum: 1,
                    pageSize: 999999
                }).then(res => {
                    let result = res.data;
                    if (result.code == 200) {
                        if (result.data.list && result.data.list.length > 0) {
                            this.channelListData = result.data.list;
                            this.getTableData()
                        }
                    }
                })
            },
            landFormat(row, column, cellValue){
                let result = ''
                this.channelListData.forEach(item=>{
                  if(item.id==cellValue){
                    result = item.name
                  }
                })
                return result
            },
            alarmRulesFun(){
              this.$api.queueManagementApi.getAlarmRulesList({
                  mallId: this.searchForm.mallId,
                  areaId: this.searchForm.cashierAreaId,
                  pageNum: 1,
                  pageSize: 999999
              }).then(res => {
                  let result = res.data;
                  if (result.code == 200) {
                    this.$refs.addModel.dialogInit(result.data.list,this.searchForm.mallId,this.searchForm.cashierAreaId);
                  }
              })
            },
            searchFun(){
                this.currentPage = 1;
                this.getTableData()
            },
            getTableData() {
                this.loading = true;
                this.tableData = [];
                this.$api.queueManagementApi.getAlarmMessageList({
                    mallId: this.searchForm.mallId,
                    cashierAreaId: this.searchForm.cashierAreaId,
                    cashierChannelId: this.searchForm.cashierChannelId,
                    // messageType: this.searchForm.messageType,
                    startDate: moment(this.searchForm.countDate[0]).format('YYYY-MM-DD'),
                    endDate:moment(this.searchForm.countDate[1]).format('YYYY-MM-DD'),
                    pageNum: this.currentPage,
                    pageSize: this.pageSize
                }).then(res => {
                    let result = res.data;
                    if(result.code==200){
                       this.tableData = result.data.list;
                       this.total = result.data.total;
                    }
                    this.loading = false;
                })
            },
            sizeChange(val) {
              this.pageSize = val;
              this.getTableData();
            },
            cerrentChange(val) {
              if (this.currentPage != val) {
                this.currentPage = val;
                this.getTableData();
              }
            },
        }
    }
</script>

<style scoped="scoped" lang="less">
  /deep/.el-select{
    width: 180px;
  }
  /deep/.el-form-item__label{
    width: auto !important;
    min-width: 60px;
  }
  /deep/.el-date-editor{
    width: 250px !important;
  }
</style>