System.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. <template>
  2. <div>
  3. <el-card>
  4. <div slot="header" class="clearfix">
  5. <span>{{ title }}</span>
  6. <el-button style="float: right; padding: 3px 0" type="text" @click="showEdit">编辑</el-button>
  7. </div>
  8. <el-carousel v-loading="loading" class="system-content" :autoplay="false" arrow="never" trigger="click">
  9. <el-carousel-item v-for="(page, index) in carouselData" :key="'carousel_' + index">
  10. <div class="system-box">
  11. <div v-for="item in page" :key="item.id" class="system-item-box" @click="jumpTo(item.url)">
  12. <el-avatar :size="56" fit="fill" :src="item.icon" />
  13. <div class="system-title">{{ item.systemName }}</div>
  14. </div>
  15. </div>
  16. </el-carousel-item>
  17. </el-carousel>
  18. </el-card>
  19. <system-edit ref="systemEdit" :title="title.startsWith('我的') ? title.substr(2) : title" />
  20. </div>
  21. </template>
  22. <script>
  23. import SystemEdit from './components/SystemEdit'
  24. import { fetchMySystemList } from '@/api/system'
  25. import { isNull, hasValidRecords } from '@/utils/convert'
  26. export default {
  27. components: { SystemEdit },
  28. props: {
  29. title: {
  30. type: String,
  31. default: '我的应用'
  32. },
  33. pageSize: {
  34. type: Number,
  35. default: 5
  36. }
  37. },
  38. data() {
  39. return {
  40. rawData: [],
  41. carouselData2: [],
  42. loading: false
  43. }
  44. },
  45. computed: {
  46. carouselData() {
  47. const result = []
  48. if (!isNull(this.rawData)) {
  49. const len = this.rawData.length
  50. const page = Math.ceil(len / this.pageSize)
  51. for (var i = 0; i < page; i++) {
  52. result.push(this.rawData.slice(i * this.pageSize, (i + 1) * this.pageSize))
  53. }
  54. }
  55. return result
  56. }
  57. },
  58. created() {
  59. this.getMySystemData()
  60. },
  61. methods: {
  62. jumpTo(link) {
  63. window.open(link, '_blank')
  64. },
  65. showEdit() {
  66. this.$refs.systemEdit.open()
  67. },
  68. getMySystemData() {
  69. this.loading = true
  70. const params = {
  71. page: 1,
  72. size: 100,
  73. params: {
  74. delFlag: 0
  75. }
  76. }
  77. fetchMySystemList(params).then(response => {
  78. this.loading = false
  79. if (hasValidRecords(response)) {
  80. this.rawData = response.data.records
  81. } else {
  82. this.rawData = []
  83. }
  84. }).catch(error => {
  85. console.log(error)
  86. this.loading = false
  87. this.$message.error({
  88. type: 'error',
  89. duration: 0,
  90. showClose: true,
  91. message: '获取我的应用出错:' + error.message
  92. })
  93. })
  94. }
  95. }
  96. }
  97. </script>
  98. <style lang="scss" scoped>
  99. .system-content {
  100. ::v-deep {
  101. .el-carousel__container {
  102. height: 100%;
  103. // width: 100%;
  104. }
  105. .el-carousel__button {
  106. background-color: #cccccc;
  107. opacity: 1;
  108. }
  109. .el-carousel__indicator.is-active .el-carousel__button {
  110. background-color: #0056dd;
  111. }
  112. .el-carousel__indicator--horizontal {
  113. padding: 12px 4px 2px 4px;
  114. }
  115. }
  116. .system-box {
  117. display: flex;
  118. flex-wrap: wrap;
  119. // justify-content: space-around;
  120. align-content: space-around;
  121. // width: 790px !important;
  122. // margin: 0 auto;
  123. height: 100%;
  124. padding: 10px 0;
  125. .system-item-box {
  126. width: 170px;
  127. height: 130px;
  128. border: 1px solid rgba(0,0,0,0.09);
  129. border-radius: 10px;
  130. display: flex;
  131. flex-direction: column;
  132. justify-content: center;
  133. align-items: center;
  134. margin: 5px calc(10% - 85px);
  135. cursor: pointer;
  136. .system-title {
  137. font-size: 16px;
  138. color: rgba(0,0,0,0.65);
  139. margin-top: 10px;
  140. text-overflow: ellipsis;
  141. overflow: hidden;
  142. white-space: nowrap;
  143. }
  144. }
  145. }
  146. @media only screen and (min-width: 1680px) {
  147. .system-item-box {
  148. width: 170px !important;
  149. margin: 5px calc(10% - 85px) !important;
  150. }
  151. }
  152. @media only screen and (min-width: 1440px) and (max-width: 1679px) {
  153. .system-item-box {
  154. width: 140px !important;
  155. margin: 5px calc(10% - 70px) !important;
  156. }
  157. }
  158. @media only screen and (max-width: 1439px) {
  159. .system-item-box {
  160. width: 100px !important;
  161. margin: 5px calc(10% - 50px) !important;
  162. }
  163. }
  164. }
  165. </style>