liuxiaolong
2019-05-06 8700cf1dc46c350371d865532c2914595187788e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
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
<template>
  <div>
    <h3 class="row align-items-center font-weight-bold py-4 mb-4">
 
      <div class="col py-2 px-5">
        应用中心
        <!-- <div class="text-muted text-tiny font-weight-light pt5">用户系统目录</div> -->
      </div>
      <!-- <div class="col-sm-6 col-md-4 col-xl-3 mt-4 mt-sm-0">
        <b-input size="lg" v-model="searchName" placeholder="输入以搜索系统..." />
      </div> -->
    </h3>
    <!-- <hr class="border-light container-m--x my-0"> -->
 
    <!-- <div class="row row-bordered my-4"> -->
      <div style="float:right; width:85%;" class="row  my-4">
      <div style="margin:10px 10px"
        class="col-6 col-sm-4 col-md-3 col-lg-4 col-xl-3"
        v-for="(iteam,index) in searchList"
        :key="index"
      >
        <a href="javascript:void(0)"
          @click="openModule(iteam)"
          :class="iteam.state === 1?'card card-hover text-dark my-2':'card my-2 disabled'"
        >
          <div class="text-center " style="background-color:white;height:220px;width:100%">
            <div class="display-3 img-box">
              <img
                style="height:60%;width:60%;margin:50px 0px"
                :src="`/static/img/application_center_icon/${iteam.state === 1?iteam.module:iteam.module+'_disabled'}.png`"
                :alt="iteam.module"
                :onerror="noneImg"
               >
            </div>
            <h5 title="iteam.module">{{iteam.name}}</h5>
          </div>
        </a>
      </div>
 
    </div>
    <hr class="border-light container-m--x my-0">
  </div>
</template>
 
<script>
import { mapActions } from 'vuex'
import { getApplicationList } from '@/server/common.js'
export default {
  name: 'application-center',
  metaInfo: {
    title: '应用中心'
  },
  data() {
    return {
      noneImg: 'this.src="' + require('@/assets/img/noneImg.png') + '"',
      userInfo: this.$store.getters.basicUserInfo,
      applicationList: [],
      searchName: ''
    }
  },
  computed: {
    searchList() {
      const searchName = this.searchName.replace(/\s/g, '').toUpperCase()
      if (!searchName) {
        return this.applicationList
      }
      let searchList = []
      this.applicationList.map(item => {
        if (
          item.name.indexOf(searchName) !== -1 ||
          item.module.indexOf(searchName) !== -1
        ) {
          searchList.push(item)
        }
      })
      return searchList
    },
    newList() {
      let list = []
      this.applicationList.map(item => {
        if (item.state === 1) {
          list.push(item)
        }
      })
      return list
    }
  },
  methods: {
    ...mapActions(['openNewWindowtab']),
    /* 获取应用列表 */
    async getApplicationList() {
      let result = await getApplicationList({
        orgId: this.userInfo.orgId,
        userId: this.userInfo.id
      })
      if (result && !result.error) {
        let nums = new Array(99)
        for (let mm = 0; mm < result.length; mm++) {
          if (result[mm].state === 1) {
            if (nums[result[mm].id] === result[mm].id) {
 
            } else {
              this.applicationList.push(result[mm])
              nums[result[mm].id] = result[mm].id
            }
          }
        }
        // this.applicationList = result
      } else if (result && result.message) {
        this.$toast({
          message: result.message ? result.message : '报错了',
          type: 'error'
        })
      }
    },
    openModule(data) {
      if (!data || data.state !== 1) {
        // this.$toast({
        //   message: '这个系统您目前还不能使用!',
        //   type: 'error'
        // })
        return false
      }
      this.openNewWindowtab(data.url)
    }
  },
  created() {
    this.getApplicationList()
  },
  watch: {
    newList(val, oldVal) {
      if (val !== oldVal && val.length === 1) {
        this.openNewWindowtab({ urlStr: val[0].url, isblank: true })
      }
    }
  }
}
</script>
<style lang="scss">
.img-box {
  display: inline-block;
  width: 140px;
  height: 140px;
  img {
    width: 100%;
  }
}
.card.disabled {
  background: transparent !important;
  border: 0;
  color: #a3a4a6 !important;
  cursor: no-drop;
}
</style>