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 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
| <template> <Container title="应用复制状态监控" center='true'> <template v-slot:box-content> <el-carousel trigger="click" :interval='5000' v-show="appList.length !== 0" :initial-index="0" @change="pageChange" indicator-position="none" ref="carouselRef" > <el-carousel-item v-for="(item, index) in visibleList" :key="index" > <div class="apps"> <App v-for="(app, ind) in item" :key="ind" :item='app' > </App> </div> </el-carousel-item> <ul class="el-carousel__indicators el-carousel__indicators--horizontal"> <li class="el-carousel__indicator el-carousel__indicator--horizontal" v-for="(item, idx) of appList" :key="idx" :class="{ 'is-active': idx === currentIdx }" @click="goToPage(idx)" > <button class="el-carousel__button"></button> </li> </ul> </el-carousel> </template> </Container> </template>
<script> import Container from '../container.vue'; import App from '../application.vue';
export default { name: 'Footer', props: { data: { required: true, type: Object, default: () => ({}) } }, data() { return { appList: [], currentIdx: 0, prevIndex: 0, toIndex: 0, customSwiper: false } }, computed: { visibleList() { const ls = []; ls[this.prevIndex] = this.appList[this.currentIdx]; const prev = this.appList[this.currentIdx - 1] || ''; const next = this.appList[this.currentIdx + 1] || ''; if (this.prevIndex === 0) { ls[1] = next; ls[2] = prev; } else if (this.prevIndex === 2) { ls[1] = prev; ls[0] = next; } else { ls[0] = prev; ls[2] = next; } return ls; } }, watch: { data() { this.appList = this.data.applicationMonitorList.length <= 24 ? [this.data.applicationMonitorList] : this.sliceArray(this.data.applicationMonitorList, 24); } }, methods: { sliceArray(array, chunkSize) { const result = []; for (let i = 0; i < array.length; i += chunkSize) { result.push(array.slice(i, i + chunkSize)); } return result; }, pageChange(index, oldIdx) { if (this.customSwipe) { this.currentIdx = this.toIndex; this.customSwipe = false; } else { if (index - this.prevIndex === 1 || index - this.prevIndex === -2) { if (this.currentIdx === this.appList.length - 1) { this.currentIdx = 0; } else { ++this.currentIdx; } } if (index - this.prevIndex === -1 || index - this.prevIndex === 2) { if (this.currentIdx === 0) { this.currentIdx = this.appList.length - 1; } else { --this.currentIdx; } } } this.prevIndex = index; }, goToPage(idx) { if (this.currentIdx < idx) { this.$refs.carouselRef.next(); } if (this.currentIdx > idx) { this.$refs.carouselRef.prev(); } this.customSwipe = true; this.toIndex = idx; } }, components: { Container, App } } </script>
<style lang="scss" scoped> @import '../../../../../assets/css/hatech';
/deep/ .el-carousel--horizontal { position: absolute; height: 100%; } /deep/ .el-carousel__container { height: 94%; } /deep/ .el-carousel__button { width: ha-px-vw(25px); } .apps { width: 98%; height: 100%; display: flex; padding: ha-px-vh(20px) ha-px-vw(15px); justify-content: space-between; align-content: space-around; flex-wrap: wrap; }
.el-carousel { position: relative; } </style>
|