index.vue 9.03 KB
<template>
    <div class="clerk-wrapper queueManagementContainer">
        <div class="header manage-head-wrapper">
            <el-form ref="form" label-width="100px" inline class="searchForm boxShadow searchFormSocial">
                <el-form-item :label="$t('table.mall')">
                    <el-select v-model="searchForm.mallId" filterable :placeholder="$t('pholder.select')" @change="mallChange">
                      <el-option :label="$t('pholder.all')" value=""></el-option>
                      <el-option v-for="item in mallListForTerm" :key="item.id" :label="item.name" :value="item.id" />
                    </el-select>
                </el-form-item>
                <el-form-item>
                   <el-button type="primary" class="search-btn" size="mini" plain @click="searchFun">{{$t('button.search')}}</el-button>
                </el-form-item>
                <div class="btns">
                    <el-button type="primary" size="mini" class="manage-add-btn fl-btn" @click="addClerk">{{$t('button.groupAdd')}}</el-button>
                </div>
            </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.squareName')" align="center" prop="name">
                  <template slot-scope="{row}">
                    {{mallNameFormat(row.mallId)}}
                  </template>
                </el-table-column>
                <el-table-column :label="$t('table.monday')" align="center" prop="name">
                  <template slot-scope="{row}">
                    {{timeFormat(row.monStartTime)}}-{{timeFormat(row.monEndTime)}}
                  </template>
                </el-table-column>
                <el-table-column :label="$t('table.tuesday')" align="center" prop="name">
                  <template slot-scope="{row}">
                    {{timeFormat(row.tueStartTime)}}-{{timeFormat(row.tueEndTime)}}
                  </template>
                </el-table-column>
                <el-table-column :label="$t('table.wednesday')" align="center" prop="name">
                  <template slot-scope="{row}">
                    {{timeFormat(row.wedStartTime)}}-{{timeFormat(row.wedEndTime)}}
                  </template>
                </el-table-column>
                <el-table-column :label="$t('table.thursday')" align="center" prop="name">
                  <template slot-scope="{row}">
                    {{timeFormat(row.thuStartTime)}}-{{timeFormat(row.thuEndTime)}}
                  </template>
                </el-table-column>
                <el-table-column :label="$t('table.friday')" align="center" prop="name">
                  <template slot-scope="{row}">
                    {{timeFormat(row.friStartTime)}}-{{timeFormat(row.friEndTime)}}
                  </template>
                </el-table-column>
                <el-table-column :label="$t('table.saturday')" align="center" prop="name">
                  <template slot-scope="{row}">
                    {{timeFormat(row.satStartTime)}}-{{timeFormat(row.satEndTime)}}
                  </template>
                </el-table-column>
                <el-table-column :label="$t('table.sunday')" align="center" prop="name">
                  <template slot-scope="{row}">
                    {{timeFormat(row.sunStartTime)}}-{{timeFormat(row.sunEndTime)}}
                  </template>
                </el-table-column>
                <el-table-column :label="$t('table.operate')" align="center" width="120">
                  <template slot-scope="scope">
                    <el-button type="text" class="tab-btn" @click="editHandle(scope.row)">{{$t('button.edit')}}</el-button>
                    <el-button type="text" class="tab-btn" @click="delHandle(scope.row)">{{$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>
            </div>
        </div>
        <add-dialog ref="addModel"></add-dialog>
    </div>
</template>

<script>
    import addDialog from './add.vue'
    import moment from 'moment'
    export default {
        data() {
            return {
              mallListForTerm:[],
              tableData: [],
              total: 0,
              pageSize: 10,
              currentPage: 1,
              pagesizeArr: [10, 20, 50, 100],
              loading: false,
              searchForm:{
                  mallId:'',
              },
            }
        },
        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) {
                        this.mallListForTerm = result.data;
                    }
                    this.getTableData();
                })
            },
            mallNameFormat(val){
              let name = ''
              this.mallListForTerm.forEach(item=>{
                if(item.id==val){
                  name =  item.name
                }
              })
              return name || ''
            },
            mallChange(val) {
                this.getTableData();
            },
            timeFormat(time){
              return moment(time).format('HH:mm:ss')
            },
            addClerk(){
                this.$refs.addModel.dialogInit('add');
            },
            editHandle(row){
                this.$refs.addModel.dialogInit('edit',row);
            },
            delHandle(row) {
              this.$confirm(this.$t("message.delete"), this.$t("message.prompt"), {
                confirmButtonText: this.$t("message.confirm"),
                cancelButtonText: this.$t("message.cancel"),
                type: "warning"
              }).then(() => {
                  this.$api.queueManagementApi.deleteOpentime({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()
            },
            getTableData() {
                this.loading = true;
                this.tableData = [];
                this.$api.queueManagementApi.getOpentimeList({
                    mallId: this.searchForm.mallId,
                    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">
    .btns{
        margin-right: 20px;
        margin-top: 7px;
    }
</style>