| | |
| | | <template> |
| | | <ul class="user_Overview flex"> |
| | | <li class="user_Overview-item" style="color: #00fdfa"> |
| | | <div class="user_Overview_nums allnum "> |
| | | <dv-digital-flop :config="onlineconfig" style="width:100%;height:100%;" /> |
| | | </div> |
| | | <br> |
| | | <p>{{stationstate[0].station_state}}</p> |
| | | <p v-if="stationstate[0].station_state == 'æ£ä¿®ä¸'">{{stationstate[0].station_checkName}}</p> |
| | | </li> |
| | | <li class="user_Overview-item" style="color: #07f7a8"> |
| | | <div class="user_Overview_nums online"> |
| | | <dv-digital-flop :config="config" style="width:100%;height:100%;" /> |
| | | </div> |
| | | <br> |
| | | <p>{{stationstate[1].station_state}}</p> |
| | | <p v-if="stationstate[1].station_state == 'æ£ä¿®ä¸'">{{stationstate[1].station_checkName}}</p> |
| | | </li> |
| | | <!-- <li class="user_Overview-item" style="color: #e3b337"> |
| | | <div class="user_Overview_nums offline"> |
| | | <dv-digital-flop :config="offlineconfig" style="width:100%;height:100%;" /> |
| | | </div> |
| | | <p>7å·æ£ä¿®å°</p> |
| | | <br> |
| | | <p>{{stationstate[2].station_state}}</p> |
| | | <p v-if="stationstate[2].station_state == 'æ£ä¿®ä¸'">{{stationstate[2].station_checkName}}</p> |
| | | </li> |
| | | <li class="user_Overview-item" style="color: #e3b337"> |
| | | <div class="user_Overview_nums offline"> |
| | | <dv-digital-flop :config="offlineconfig" style="width:100%;height:100%;" /> |
| | | </div> |
| | | <p>8å·æ£ä¿®å°</p> |
| | | <br> |
| | | <p>{{stationstate[3].station_state}}</p> |
| | | <p v-if="stationstate[3].station_state == 'æ£ä¿®ä¸'">{{stationstate[3].station_checkName}}</p> |
| | | </li> --> |
| | | </ul> |
| | | </template> |
| | | |
| | | <script> |
| | | let style = { |
| | | fontSize: 24 |
| | | } |
| | | export default { |
| | | data() { |
| | | return { |
| | | stationstate: [ |
| | | { station_state: 'å
¥åºé', station_checkName: '' }, |
| | | { station_state: 'åºåºé', station_checkName: '' }, |
| | | { station_state: 'å¾
æºä¸', station_checkName: '' }, |
| | | { station_state: 'æ
éä¸', station_checkName: '' } |
| | | ], |
| | | config: { |
| | | number: [7], |
| | | content: '{nt}', |
| | | style: { |
| | | ...style, |
| | | fill: "#00fdfa", |
| | | }, |
| | | }, |
| | | onlineconfig: { |
| | | number: [1], |
| | | content: '{nt}', |
| | | style: { |
| | | ...style, |
| | | fill: "#07f7a8", |
| | | }, |
| | | }, |
| | | offlineconfig: { |
| | | number: [4], |
| | | content: '{nt}', |
| | | style: { |
| | | ...style, |
| | | fill: "#e3b337", |
| | | }, |
| | | }, |
| | | }; |
| | | <div class="table-container"> |
| | | <table class="data-table"> |
| | | <thead> |
| | | <tr> |
| | | <th v-for="(header, index) in headers" :key="index"> |
| | | {{ header }} |
| | | </th> |
| | | </tr> |
| | | </thead> |
| | | <tbody ref="tableBody"> |
| | | <tr v-for="(row, rowIndex) in visibleData" :key="rowIndex"> |
| | | <td v-for="(cell, cellIndex) in row" :key="cellIndex"> |
| | | {{ cell }} |
| | | </td> |
| | | </tr> |
| | | </tbody> |
| | | </table> |
| | | <div v-if="loading" class="loading">å è½½ä¸...</div> |
| | | <div v-if="error" class="error">{{ error }}</div> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | import axios from 'axios'; |
| | | |
| | | export default { |
| | | data() { |
| | | return { |
| | | headers: ['车å', 'è½®å', 'æ°é'], |
| | | tableData: [], // åå¨APIè¿åçæææ°æ® |
| | | visibleData: [], // å½åæ¾ç¤ºçæ°æ® |
| | | loading: false, |
| | | error: null, |
| | | currentIndex: 0, // å½åæ¾ç¤ºæ°æ®çèµ·å§ç´¢å¼ |
| | | visibleRows: 12, // æ¯æ¬¡æ¾ç¤ºçè¡æ° |
| | | scrollInterval: null, // æ»å¨å®æ¶å¨ |
| | | scrollSpeed: 5000 // æ»å¨é度(毫ç§) |
| | | } |
| | | }, |
| | | created() { |
| | | this.fetchData(); |
| | | }, |
| | | mounted() { |
| | | this.startAutoScroll(); |
| | | }, |
| | | beforeDestroy() { |
| | | this.stopAutoScroll(); |
| | | }, |
| | | methods: { |
| | | fetchData() { |
| | | this.loading = true; |
| | | axios.post("http://127.0.0.1:5000/api/Dt_WheelsStock/InventoryStatistics", null) |
| | | .then((response) => { |
| | | this.tableData = []; |
| | | response.data.data.slice(13, 24).forEach(item => { |
| | | this.tableData.push([ |
| | | item.wheels_CarType, |
| | | item.wheels_ldxh, |
| | | item.count |
| | | ]); |
| | | }); |
| | | this.updateVisibleData(); |
| | | this.loading = false; |
| | | }) |
| | | .catch((error) => { |
| | | console.error("请æ±å¤±è´¥:", error); |
| | | this.tableData = [ |
| | | ['ææ æ°æ®', 'ææ æ°æ®', 'ææ æ°æ®'], |
| | | ]; |
| | | this.error = "æ°æ®å 载失败"; |
| | | this.loading = false; |
| | | }); |
| | | }, |
| | | filters: { |
| | | numsFilter(msg) { |
| | | return msg || 0; |
| | | }, |
| | | startAutoScroll() { |
| | | this.stopAutoScroll(); // å
忢已æç宿¶å¨ |
| | | this.scrollInterval = setInterval(() => { |
| | | if (this.tableData.length > this.visibleRows) { |
| | | this.currentIndex = (this.currentIndex + 1) % this.tableData.length; |
| | | this.updateVisibleData(); |
| | | } |
| | | }, this.scrollSpeed); |
| | | }, |
| | | }; |
| | | </script> |
| | | |
| | | <style lang='scss' scoped> |
| | | .user_Overview { |
| | | li { |
| | | flex: 1; |
| | | |
| | | p { |
| | | text-align: center; |
| | | height: 16px; |
| | | font-size: 16px; |
| | | } |
| | | |
| | | .user_Overview_nums { |
| | | width: 100px; |
| | | height: 100px; |
| | | text-align: center; |
| | | line-height: 100px; |
| | | font-size: 22px; |
| | | margin: 50px auto 30px; |
| | | background-size: cover; |
| | | background-position: center center; |
| | | position: relative; |
| | | |
| | | &::before { |
| | | content: ''; |
| | | position: absolute; |
| | | width: 100%; |
| | | height: 100%; |
| | | top: 0; |
| | | left: 0; |
| | | } |
| | | |
| | | &.bgdonghua::before { |
| | | animation: rotating 14s linear infinite; |
| | | } |
| | | } |
| | | |
| | | .allnum { |
| | | &::before { |
| | | background-image: url("../../assets/img/left_top_lan.png"); |
| | | } |
| | | } |
| | | |
| | | .online { |
| | | &::before { |
| | | background-image: url("../../assets/img/left_top_lv.png"); |
| | | } |
| | | } |
| | | |
| | | .offline { |
| | | &::before { |
| | | background-image: url("../../assets/img/left_top_huang.png"); |
| | | } |
| | | } |
| | | |
| | | .laramnum { |
| | | &::before { |
| | | background-image: url("../../assets/img/left_top_hong.png"); |
| | | } |
| | | } |
| | | stopAutoScroll() { |
| | | if (this.scrollInterval) { |
| | | clearInterval(this.scrollInterval); |
| | | this.scrollInterval = null; |
| | | } |
| | | }, |
| | | updateVisibleData() { |
| | | if (this.tableData.length === 0) return; |
| | | |
| | | // è·åå½åå¯è§çæ°æ® |
| | | const endIndex = this.currentIndex + this.visibleRows; |
| | | if (endIndex <= this.tableData.length) { |
| | | this.visibleData = this.tableData.slice(this.currentIndex, endIndex); |
| | | } else { |
| | | // å¤çå¾ªç¯æ»å¨ |
| | | const firstPart = this.tableData.slice(this.currentIndex); |
| | | const secondPart = this.tableData.slice(0, endIndex - this.tableData.length); |
| | | this.visibleData = [...firstPart, ...secondPart]; |
| | | } |
| | | } |
| | | } |
| | | </style> |
| | | } |
| | | </script> |
| | | |
| | | <style scoped> |
| | | .table-container { |
| | | width: 100%; |
| | | overflow-x: auto; |
| | | position: relative; |
| | | min-height: 200px; |
| | | max-height: 700px; /* éå¶å®¹å¨é«åº¦ */ |
| | | overflow-y: hidden; /* éèåç´æ»å¨æ¡ */ |
| | | } |
| | | |
| | | .data-table { |
| | | width: 100%; |
| | | border-collapse: collapse; |
| | | margin: 20px 0; |
| | | font-family: Arial, sans-serif; |
| | | } |
| | | |
| | | .data-table th { |
| | | font-weight: bold; |
| | | padding: 12px 15px; |
| | | text-align: left; |
| | | border-bottom: 2px solid #c5c5c5; |
| | | |
| | | position: sticky; |
| | | top: 0; |
| | | } |
| | | |
| | | .data-table td { |
| | | padding: 10px 15px; |
| | | height: 25px; |
| | | border-bottom: 1px solid #696969; |
| | | } |
| | | |
| | | |
| | | .loading, .error { |
| | | padding: 20px; |
| | | text-align: center; |
| | | color: #666; |
| | | } |
| | | |
| | | .error { |
| | | color: #f56c6c; |
| | | } |
| | | |
| | | /* æ·»å å¹³æ»æ»å¨ææ */ |
| | | .data-table tbody { |
| | | transition: transform 1s ease-in-out; |
| | | } |
| | | </style> |