| | |
| | | </div> |
| | | <div class="table-container flex-1"> |
| | | <div class="table-content"> |
| | | <el-table class="data-table" ref="dataTable" :data="tableData" :highlight-current-row="false" :stripe="true" |
| | | |
| | | <el-table class="data-table body-table" ref="scrollTableOne" :data="tableData" :highlight-current-row="false" |
| | | :stripe="true" |
| | | :header-cell-style="{ backgroundColor: 'transparent', color: '#79A5E9', borderColor: '#29466A' }" |
| | | :cell-style="{ color: '#79A5E9', borderColor: '#29466A', paddingTop: '10px', paddingBottom: '10px' }" |
| | | :row-style="{ backgroundColor: 'transparent' }"> |
| | | <el-table-column prop="street" label="镇/街道" align="center" /> |
| | | <el-table-column label="发现数量" align="center"> |
| | | |
| | | <template #default="scope"> |
| | | <div style="color: #6289E6;"> |
| | | {{ scope.row.num1 }} |
| | |
| | | </el-table-column> |
| | | |
| | | <el-table-column label="下发通知书" align="center"> |
| | | |
| | | <template #default="scope"> |
| | | <div style="color: #CFB249;"> |
| | | {{ scope.row.num2 }} |
| | |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="处置数量" align="center"> |
| | | |
| | | <template #default="scope"> |
| | | <div style="color: #2BB06D;"> |
| | | {{ scope.row.num3 }} |
| | |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { ref, onMounted, onUnmounted, nextTick, inject, watch } from 'vue'; |
| | | import { ref, onUnmounted, inject, nextTick, watch, watchEffect } from 'vue'; |
| | | |
| | | const tableState = inject('tableState'); |
| | | |
| | |
| | | num2: 5, |
| | | num3: 2 |
| | | }, |
| | | { |
| | | street: '奎光塔街道', |
| | | num1: 12, |
| | | num2: 5, |
| | | num3: 2 |
| | | }, |
| | | ]; |
| | | |
| | | const changeSelect = (selectItem) => { |
| | |
| | | selectItem.isActive = true; |
| | | } |
| | | |
| | | let scrollTableOne = ref(""); |
| | | |
| | | // 处理表格滚动 |
| | | let timer = null; |
| | | const dataTable = ref(null); |
| | | const tableNode = ref(null); |
| | | const scrollHeight = ref(null); |
| | | const scrollTop = ref(null); |
| | | |
| | | // const clearScroll = () => { |
| | | // clearInterval(timer); |
| | | // timer = null; |
| | | // } |
| | | let scrollTimer = null; |
| | | |
| | | // const createScroll = () => { |
| | | // clearScroll(); |
| | | // const table = dataTable.value.layout.table.refs; |
| | | // 滚动 |
| | | const scrollTable = () => { |
| | | clearScroll(); |
| | | tableNode.value = scrollTableOne.value.$refs.bodyWrapper.getElementsByClassName( |
| | | "el-scrollbar__wrap" |
| | | )[0]; |
| | | scrollHeight.value = tableNode.value.scrollHeight; |
| | | scrollTop.value = tableNode.value.scrollTop; |
| | | |
| | | // const tableWrapper = table.bodyWrapper.firstElementChild.firstElementChild; |
| | | // console.log(tableWrapper); |
| | | // timer = setInterval(() => { |
| | | // tableWrapper.scrollTop += 1; |
| | | // if (tableWrapper.clientHeight + tableWrapper.scrollTop >= tableWrapper.scrollHeight) { |
| | | // tableWrapper.scrollTop = 0; |
| | | // } |
| | | // }, 100); |
| | | // } |
| | | // watch(tableState, (newValue) => { |
| | | // console.log(newValue); |
| | | // if (newValue) { |
| | | // nextTick(() => { |
| | | // setTimeout(() => { |
| | | // createScroll(); |
| | | // }, 2000); |
| | | // }) |
| | | // } else { |
| | | // clearScroll(); |
| | | // } |
| | | // }) |
| | | scrollTimer = setInterval(() => { |
| | | scrollTableOne.value.setScrollTop(scrollTop.value++); |
| | | |
| | | // onUnmounted(() => { |
| | | // clearScroll(); |
| | | // }); |
| | | |
| | | if (scrollTop.value >= scrollHeight.value - tableNode.value.offsetHeight) { |
| | | scrollTop.value = 0; |
| | | scrollTableOne.value.setScrollTop(0); |
| | | } |
| | | }, 50); |
| | | }; |
| | | |
| | | |
| | | const clearScroll = (() => { |
| | | clearInterval(scrollTimer); |
| | | }); |
| | | |
| | | watch(tableState, (newVal) => { |
| | | if (newVal) { |
| | | nextTick(() => { |
| | | setTimeout(() => { |
| | | scrollTable(); |
| | | }, 500); |
| | | }); |
| | | } else { |
| | | clearScroll(); |
| | | } |
| | | }) |
| | | |
| | | onUnmounted(() => { |
| | | clearScroll(); |
| | | }); |
| | | |
| | | |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | |
| | | .el-table__fixed-right { |
| | | height: 100% !important; |
| | | } |
| | | </style> |
| | | |
| | | .scroll-table { |
| | | position: absolute; |
| | | bottom: 0; |
| | | left: 0; |
| | | width: 100%; |
| | | height: 85%; |
| | | overflow: hidden; |
| | | } |
| | | |
| | | // .head-table { |
| | | // &:deep(.el-table__body-wrapper) { |
| | | // display: none; |
| | | // } |
| | | // } |
| | | |
| | | // .body-table { |
| | | // :deep(.el-table__header-wrapper) { |
| | | // display: none; |
| | | // } |
| | | // }</style> |