list.vue 5.7 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 18 19
<template>
  <div class="list-model">
    <div class="table-box">
B
break60 已提交
20
      <table class="fixed">
L
ligang 已提交
21 22
        <tr>
          <th>
G
i18n  
gongzijian 已提交
23
            <span>{{$t('#')}}</span>
L
ligang 已提交
24 25
          </th>
          <th>
G
i18n  
gongzijian 已提交
26
            <span>{{$t('Project Name')}}</span>
L
ligang 已提交
27 28
          </th>
          <th>
G
i18n  
gongzijian 已提交
29
            <span>{{$t('Owned Users')}}</span>
L
ligang 已提交
30
          </th>
31 32 33 34 35 36
          <th>
            <span>{{$t('Process Define Count')}}</span>
          </th>
          <th>
            <span>{{$t('Process Instance Running Count')}}</span>
          </th>
L
ligang 已提交
37
          <th>
G
i18n  
gongzijian 已提交
38
            <span>{{$t('Description')}}</span>
L
ligang 已提交
39 40
          </th>
          <th>
G
i18n  
gongzijian 已提交
41
            <span>{{$t('Create Time')}}</span>
L
ligang 已提交
42 43
          </th>
          <th>
G
i18n  
gongzijian 已提交
44
            <span>{{$t('Update Time')}}</span>
L
ligang 已提交
45 46
          </th>
          <th width="80">
G
i18n  
gongzijian 已提交
47
            <span>{{$t('Operation')}}</span>
L
ligang 已提交
48 49 50 51 52 53 54 55 56 57 58 59 60 61
          </th>
        </tr>
        <tr v-for="(item, $index) in list" :key="$index">
          <td>
            <span>{{parseInt(pageNo === 1 ? ($index + 1) : (($index + 1) + (pageSize * (pageNo - 1))))}}</span>
          </td>
          <td>
            <span>
              <a href="javascript:" @click="_switchProjects(item)" class="links">{{item.name}}</a>
            </span>
          </td>
          <td>
            <span>{{item.userName || '-'}}</span>
          </td>
62 63 64 65 66 67
          <td>
            <span>{{item.defCount}}</span>
          </td>
          <td>
            <span>{{item.instRunningCount}}</span>
          </td>
L
ligang 已提交
68
          <td>
69
            <span v-if="item.description" class="ellipsis" v-tooltip.large.top.start="{text: item.description, maxWidth: '500px'}">{{item.description}}</span>
70
            <span v-else>-</span>
71 72 73 74 75 76 77 78
          </td>
          <td>
            <span v-if="item.createTime">{{item.createTime | formatDate}}</span>
            <span v-else>-</span>
          </td>
          <td>
            <span v-if="item.updateTime">{{item.updateTime | formatDate}}</span>
            <span v-else>-</span>
L
ligang 已提交
79 80 81 82 83 84 85
          </td>
          <td>
            <x-button
                    type="info"
                    shape="circle"
                    size="xsmall"
                    data-toggle="tooltip"
G
i18n  
gongzijian 已提交
86
                    :title="$t('Edit')"
L
ligang 已提交
87
                    @click="_edit(item)"
88
                    icon="ans-icon-edit">
L
ligang 已提交
89 90 91 92 93
            </x-button>
            <x-poptip
                    :ref="'poptip-' + $index"
                    placement="bottom-end"
                    width="90">
G
i18n  
gongzijian 已提交
94
              <p>{{$t('Delete?')}}</p>
L
ligang 已提交
95
              <div style="text-align: right; margin: 0;padding-top: 4px;">
G
i18n  
gongzijian 已提交
96 97
                <x-button type="text" size="xsmall" shape="circle" @click="_closeDelete($index)">{{$t('Cancel')}}</x-button>
                <x-button type="primary" size="xsmall" shape="circle" @click="_delete(item,$index)">{{$t('Confirm')}}</x-button>
L
ligang 已提交
98 99 100 101 102 103 104
              </div>
              <template slot="reference">
                <x-button
                        type="error"
                        shape="circle"
                        size="xsmall"
                        data-toggle="tooltip"
G
i18n  
gongzijian 已提交
105
                        :title="$t('delete')"
106
                        icon="ans-icon-trash">
L
ligang 已提交
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
                </x-button>
              </template>
            </x-poptip>
          </td>
        </tr>
      </table>
    </div>
  </div>
</template>
<script>
  import { mapActions, mapMutations } from 'vuex'
  import localStore from '@/module/util/localStorage'
  import { findComponentDownward } from '@/module/util/'

  export default {
    name: 'projects-list',
    data () {
      return {
        list: []
      }
    },
    props: {
      projectsList: Array,
      pageNo: Number,
      pageSize: Number
    },
    methods: {
      ...mapActions('projects', ['deleteProjects']),
      ...mapMutations('dag', ['setProjectName']),
      _switchProjects (item) {
        this.setProjectName(item.name)
        localStore.setItem('projectName', `${item.name}`)
        localStore.setItem('projectId', `${item.id}`)
        this.$router.push({ path: `/projects/index` })
      },
      _closeDelete (i) {
        this.$refs[`poptip-${i}`][0].doClose()
      },
      /**
       * Delete Project
       * @param item Current record
       * @param i index
       */
      _delete (item, i) {
        this.deleteProjects({
          projectId: item.id
        }).then(res => {
          this.$refs[`poptip-${i}`][0].doClose()
          this.list.splice(i, 1)
          this.$message.success(res.msg)
        }).catch(e => {
          this.$refs[`poptip-${i}`][0].doClose()
          this.$message.error(e.msg || '')
        })
      },
      /**
       * edit project
       * @param item Current record
       */
      _edit (item) {
        findComponentDownward(this.$root, 'projects-list')._create(item)
      }
    },
    watch: {
      projectsList (a) {
        this.list = []
        setTimeout(() => {
          this.list = a
        })
      }
    },
    created () {
    },
    mounted () {
      this.list = this.projectsList
    },
    components: { }
  }
185
</script>