index.vue 4.3 KB
Newer Older
K
khadgarmage 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
G
gongzijian 已提交
17
<template>
18 19 20
  <m-list-construction :title="$t('Queue manage')">
    <template slot="conditions">
      <m-conditions @on-conditions="_onConditions">
B
break60 已提交
21
        <template slot="button-group" v-if="isADMIN">
22
          <x-button type="ghost" size="small" @click="_create('')">{{$t('Create queue')}}</x-button>
G
gongzijian 已提交
23
        </template>
24 25 26 27
      </m-conditions>
    </template>
    <template slot="content">
      <template v-if="queueList.length">
G
gongzijian 已提交
28 29 30 31 32 33
        <m-list @on-edit="_onEdit"
                :queue-list="queueList"
                :page-no="searchParams.pageNo"
                :page-size="searchParams.pageSize">

        </m-list>
34 35 36 37 38 39 40 41
        <div class="page-box">
          <x-page :current="parseInt(searchParams.pageNo)" :total="total" :page-size="searchParams.pageSize" show-elevator @on-change="_page"></x-page>
        </div>
      </template>
      <template v-if="!queueList.length">
        <m-no-data></m-no-data>
      </template>
      <m-spin :is-spin="isLoading"></m-spin>
G
gongzijian 已提交
42
    </template>
43
  </m-list-construction>
G
gongzijian 已提交
44 45
</template>
<script>
46
  import _ from 'lodash'
G
gongzijian 已提交
47 48
  import { mapActions } from 'vuex'
  import mList from './_source/list'
B
break60 已提交
49
  import store from '@/conf/home/store'
G
gongzijian 已提交
50 51 52
  import mSpin from '@/module/components/spin/spin'
  import mCreateQueue from './_source/createQueue'
  import mNoData from '@/module/components/noData/noData'
53
  import listUrlParamHandle from '@/module/mixin/listUrlParamHandle'
G
gongzijian 已提交
54 55 56 57 58 59 60 61 62
  import mConditions from '@/module/components/conditions/conditions'
  import mListConstruction from '@/module/components/listConstruction/listConstruction'

  export default {
    name: 'queue-index',
    data () {
      return {
        total: null,
        isLoading: true,
63 64 65 66 67
        queueList: [],
        searchParams: {
          pageSize: 10,
          pageNo: 1,
          searchVal: ''
B
break60 已提交
68 69
        },
        isADMIN: store.state.user.userInfo.userType === 'ADMIN_USER'
G
gongzijian 已提交
70 71
      }
    },
72
    mixins: [listUrlParamHandle],
G
gongzijian 已提交
73 74
    props: {},
    methods: {
G
gongzijian 已提交
75
      ...mapActions('security', ['getQueueListP']),
G
gongzijian 已提交
76
      /**
G
i18n  
gongzijian 已提交
77
       * Query
G
gongzijian 已提交
78 79
       */
      _onConditions (o) {
80 81
        this.searchParams = _.assign(this.searchParams, o)
        this.searchParams.pageNo = 1
G
gongzijian 已提交
82 83
      },
      _page (val) {
84
        this.searchParams.pageNo = val
G
gongzijian 已提交
85
      },
G
gongzijian 已提交
86 87 88
      _onEdit (item) {
        this._create(item)
      },
G
gongzijian 已提交
89 90 91 92 93 94 95 96 97 98 99 100
      _create (item) {
        let self = this
        let modal = this.$modal.dialog({
          closable: false,
          showMask: true,
          escClose: true,
          className: 'v-modal-custom',
          transitionName: 'opacityp',
          render (h) {
            return h(mCreateQueue, {
              on: {
                onUpdate () {
101
                  self._debounceGET('false')
G
gongzijian 已提交
102 103 104 105 106 107 108 109 110 111 112 113 114
                  modal.remove()
                },
                close () {
                  modal.remove()
                }
              },
              props: {
                item: item
              }
            })
          }
        })
      },
115
      _getList (flag) {
G
gongzijian 已提交
116
        this.isLoading = !flag
117 118
        this.getQueueListP(this.searchParams).then(res => {
          this.queueList = []
G
gongzijian 已提交
119
          this.queueList = res.totalList
G
gongzijian 已提交
120 121 122 123 124 125 126
          this.total = res.total
          this.isLoading = false
        }).catch(e => {
          this.isLoading = false
        })
      }
    },
127 128 129 130 131 132 133
    watch: {
      // router
      '$route' (a) {
        // url no params get instance list
        this.searchParams.pageNo = _.isEmpty(a.query) ? 1 : a.query.pageNo
      }
    },
G
gongzijian 已提交
134 135 136
    created () {
    },
    mounted () {
137
      this.$modal.destroy()
G
gongzijian 已提交
138
    },
139
    components: { mList, mListConstruction, mConditions, mSpin, mNoData }
G
gongzijian 已提交
140 141
  }
</script>