index.vue 6.6 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.
 */
L
ligang 已提交
17
<template>
18
  <div class="wrap-table">
19 20 21
    <m-list-construction :title="$t('Process Instance')">
      <template slot="conditions">
        <m-instance-conditions @on-query="_onQuery"></m-instance-conditions>
L
ligang 已提交
22
      </template>
23 24 25 26 27 28 29 30 31 32 33 34
      <template slot="content">
        <template v-if="processInstanceList.length || total>0">
          <m-list :process-instance-list="processInstanceList" @on-update="_onUpdate" :page-no="searchParams.pageNo" :page-size="searchParams.pageSize">
          </m-list>
          <div class="page-box">
            <x-page :current="parseInt(searchParams.pageNo)" :total="total" show-elevator @on-change="_page" show-sizer :page-size-options="[10,30,50]" @on-size-change="_pageSize"></x-page>
          </div>
        </template>
        <template v-if="!processInstanceList.length && total<=0">
          <m-no-data></m-no-data>
        </template>
        <m-spin :is-spin="isLoading" :is-left="isLeft"></m-spin>
L
ligang 已提交
35
      </template>
36
    </m-list-construction>
37
  </div>
L
ligang 已提交
38 39 40 41 42 43 44 45 46 47 48
</template>
<script>
  import _ from 'lodash'
  import { mapActions } from 'vuex'
  import mList from './_source/list'
  import mSpin from '@/module/components/spin/spin'
  import localStore from '@/module/util/localStorage'
  import { setUrlParams } from '@/module/util/routerUtil'
  import mNoData from '@/module/components/noData/noData'
  import mSecondaryMenu from '@/module/components/secondaryMenu/secondaryMenu'
  import mListConstruction from '@/module/components/listConstruction/listConstruction'
49
  import mInstanceConditions from '@/conf/home/pages/projects/pages/_source/instanceConditions'
L
ligang 已提交
50 51 52 53 54 55 56

  export default {
    name: 'instance-list-index',
    data () {
      return {
        // loading
        isLoading: true,
57
        // total
L
ligang 已提交
58
        total: null,
59
        // data
L
ligang 已提交
60
        processInstanceList: [],
G
i18n  
gongzijian 已提交
61
        // Parameter
L
ligang 已提交
62
        searchParams: {
63
          // Search keywords
L
ligang 已提交
64
          searchVal: '',
65
          // Number of pages
L
ligang 已提交
66
          pageSize: 10,
67
          // Current page
L
ligang 已提交
68 69 70
          pageNo: 1,
          // host
          host: '',
G
i18n  
gongzijian 已提交
71
          // State
L
ligang 已提交
72
          stateType: '',
G
i18n  
gongzijian 已提交
73
          // Start Time
L
ligang 已提交
74
          startDate: '',
G
i18n  
gongzijian 已提交
75
          // End Time
76 77 78
          endDate: '',
          // Exectuor Name
          executorName: ''
B
break60 已提交
79 80
        },
        isLeft: true
L
ligang 已提交
81 82 83 84 85 86
      }
    },
    props: {},
    methods: {
      ...mapActions('dag', ['getProcessInstance']),
      /**
G
i18n  
gongzijian 已提交
87
       * Query
L
ligang 已提交
88 89 90
       */
      _onQuery (o) {
        this.searchParams = _.assign(this.searchParams, o)
91 92
        setUrlParams(this.searchParams)
        this._debounceGET()
L
ligang 已提交
93 94
      },
      /**
95
       * Paging event
L
ligang 已提交
96 97 98
       */
      _page (val) {
        this.searchParams.pageNo = val
99 100
        setUrlParams(this.searchParams)
        this._debounceGET()
L
ligang 已提交
101
      },
B
break60 已提交
102 103 104 105 106
      _pageSize(val) {
        this.searchParams.pageSize = val
        setUrlParams(this.searchParams)
        this._debounceGET()
      },
L
ligang 已提交
107
      /**
108
       * get list data
L
ligang 已提交
109 110 111 112
       */
      _getProcessInstanceListP (flag) {
        this.isLoading = !flag
        this.getProcessInstance(this.searchParams).then(res => {
113 114 115 116 117 118 119 120
          if(this.searchParams.pageNo>1 && res.totalList.length == 0) {
            this.searchParams.pageNo = this.searchParams.pageNo -1
          } else {
            this.processInstanceList = []
            this.processInstanceList = res.totalList
            this.total = res.total
            this.isLoading = false
          }
L
ligang 已提交
121 122 123 124 125
        }).catch(e => {
          this.isLoading = false
        })
      },
      /**
126
       * update
L
ligang 已提交
127 128
       */
      _onUpdate () {
129
        this._debounceGET()
L
ligang 已提交
130 131
      },
      /**
132
       * Routing changes
L
ligang 已提交
133 134 135 136 137
       */
      _routerView () {
        return this.$route.name === 'projects-instance-details'
      },
      /**
138 139
       * Anti shake request interface
       * @desc Prevent functions from being called multiple times
L
ligang 已提交
140 141
       */
      _debounceGET: _.debounce(function (flag) {
B
break60 已提交
142 143 144 145 146
        if(sessionStorage.getItem('isLeft')==0) {
          this.isLeft = false
        } else {
          this.isLeft = true
        }
L
ligang 已提交
147 148 149 150 151 152 153
        this._getProcessInstanceListP(flag)
      }, 100, {
        'leading': false,
        'trailing': true
      })
    },
    watch: {
154
      // Routing changes
L
ligang 已提交
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
      '$route' (a, b) {
        if (a.name === 'instance' && b.name === 'projects-instance-details') {
          this._debounceGET()
        } else {
          // url no params get instance list
          this.searchParams.pageNo = !_.isEmpty(a.query) && a.query.pageNo || 1
        }
      },
      'searchParams': {
        deep: true,
        handler () {
          this._debounceGET()
        }
      }
    },
    created () {
171
      // Delete process definition ID
L
ligang 已提交
172 173
      localStore.removeItem('subProcessId')

174
      // Route parameter merge
L
ligang 已提交
175 176 177 178
      if (!_.isEmpty(this.$route.query)) {
        this.searchParams = _.assign(this.searchParams, this.$route.query)
      }

179
      // Judge the request data according to the route
L
ligang 已提交
180 181 182 183 184
      if (!this._routerView()) {
        this._debounceGET()
      }
    },
    mounted () {
185
      this.$modal.destroy()
186
      // Cycle acquisition status
L
ligang 已提交
187 188 189 190 191
      this.setIntervalP = setInterval(() => {
        this._debounceGET('false')
      }, 90000)
    },
    beforeDestroy () {
192
      // Destruction wheel
L
ligang 已提交
193
      clearInterval(this.setIntervalP)
B
break60 已提交
194
      sessionStorage.setItem('isLeft',1)
L
ligang 已提交
195
    },
196
    components: { mList, mInstanceConditions, mSpin, mListConstruction, mSecondaryMenu, mNoData }
L
ligang 已提交
197 198
  }
</script>
199 200

<style lang="scss" rel="stylesheet/scss">
201 202 203 204 205 206
  .wrap-table {
    .table-box {
      overflow-y: scroll;
    }
    .table-box {
      .fixed {
B
break60 已提交
207
        table-layout: auto;
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225
        tr {
          th:last-child,td:last-child {
            background: inherit;
            width: 230px;
            height: 40px;
            line-height: 40px;
            border-left:1px solid #ecf3ff;
            position: absolute;
            right: 0;
            z-index: 2;
          }
          th:nth-last-child(2) {
            padding-right: 260px;
          }
        }
      }
    }
  }
226
</style>