Browse Source

fix(表格-现金收款): 表格数据刷新后自动滚动到顶部

在四个收款明细页面中,为表格添加 ref 引用,并在获取数据后调用 setScrollTop 方法将表格滚动到顶部,避免用户手动滚动查看新数据
milestone-20260212-日常优化2.0
zhangrenyuan 3 weeks ago
parent
commit
791abd2819
  1. 10
      src/views/moneyManage/receiveDetail/receiveFinance.vue
  2. 10
      src/views/moneyManage/receiveDetail/receiveHead.vue
  3. 10
      src/views/moneyManage/receiveDetail/receiveManage.vue
  4. 10
      src/views/moneyManage/receiveDetail/receiveService.vue

10
src/views/moneyManage/receiveDetail/receiveFinance.vue

@ -112,7 +112,7 @@
</div> </div>
<div class="table"> <div class="table">
<el-table :data="tableData" style="width: 80vw;height:64vh;" @sort-change="handleSortChange"
<el-table ref="tableRef" :data="tableData" style="width: 80vw;height:64vh;" @sort-change="handleSortChange"
:row-style="{ height: '60px' }" :header-cell-style="{ textAlign: 'center' }" :row-style="{ height: '60px' }" :header-cell-style="{ textAlign: 'center' }"
:cell-style="{ textAlign: 'center' }"> :cell-style="{ textAlign: 'center' }">
<el-table-column type="index" :label="t('common_list.id')" width="100px" fixed="left"> <el-table-column type="index" :label="t('common_list.id')" width="100px" fixed="left">
@ -640,7 +640,7 @@
<script setup> <script setup>
// //
import { ref, watch, onMounted } from 'vue';
import { ref, watch, onMounted, nextTick } from 'vue';
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
import { ElMessage, ElMessageBox } from 'element-plus'; import { ElMessage, ElMessageBox } from 'element-plus';
import API from '@/util/http.js'; import API from '@/util/http.js';
@ -679,6 +679,10 @@ const superAdmin = ref(false);
const tableData = ref([]); const tableData = ref([]);
const total = ref(0); const total = ref(0);
const pageInfo = ref({ pageSize: 10, pageNum: 1 }); const pageInfo = ref({ pageSize: 10, pageNum: 1 });
const tableRef = ref(null)
const scrollTableTop = () => {
tableRef.value?.setScrollTop?.(0)
}
// //
const market = ref([]) const market = ref([])
@ -1000,6 +1004,8 @@ const getlist = async () => {
if (result.code === 200) { if (result.code === 200) {
tableData.value = result.data.list; tableData.value = result.data.list;
await nextTick()
scrollTableTop()
total.value = result.data.total; total.value = result.data.total;
} else { } else {
ElMessage.error(t('elmessage.orderDataLoadFailed')); ElMessage.error(t('elmessage.orderDataLoadFailed'));

10
src/views/moneyManage/receiveDetail/receiveHead.vue

@ -102,7 +102,7 @@
</div> </div>
<div class="table"> <div class="table">
<el-table :data="tableData" style="width: 80vw;height:64vh;" @sort-change="handleSortChange"
<el-table ref="tableRef" :data="tableData" style="width: 80vw;height:64vh;" @sort-change="handleSortChange"
:row-style="{ height: '60px' }" :header-cell-style="{ textAlign: 'center' }" :row-style="{ height: '60px' }" :header-cell-style="{ textAlign: 'center' }"
:cell-style="{ textAlign: 'center' }"> :cell-style="{ textAlign: 'center' }">
<el-table-column type="index" :label="t('common_list.id')" width="100px" fixed="left"> <el-table-column type="index" :label="t('common_list.id')" width="100px" fixed="left">
@ -521,7 +521,7 @@
<script setup> <script setup>
// //
import { ref, watch, onMounted } from 'vue';
import { ref, watch, onMounted, nextTick } from 'vue';
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
import { ElMessage, ElMessageBox } from 'element-plus'; import { ElMessage, ElMessageBox } from 'element-plus';
import API from '@/util/http.js'; import API from '@/util/http.js';
@ -557,6 +557,10 @@ const { menuTree } = storeToRefs(adminStore);
const tableData = ref([]); const tableData = ref([]);
const total = ref(0); const total = ref(0);
const pageInfo = ref({ pageSize: 10, pageNum: 1 }); const pageInfo = ref({ pageSize: 10, pageNum: 1 });
const tableRef = ref(null)
const scrollTableTop = () => {
tableRef.value?.setScrollTop?.(0)
}
// //
const searchData = ref({}); const searchData = ref({});
@ -861,6 +865,8 @@ const getlist = async () => {
if (result.code === 200) { if (result.code === 200) {
tableData.value = result.data.list; tableData.value = result.data.list;
await nextTick()
scrollTableTop()
total.value = result.data.total; total.value = result.data.total;
} else { } else {
ElMessage.error(t('elmessage.orderDataLoadFailed')); ElMessage.error(t('elmessage.orderDataLoadFailed'));

10
src/views/moneyManage/receiveDetail/receiveManage.vue

@ -112,7 +112,7 @@
</div> </div>
<div class="table"> <div class="table">
<el-table :data="tableData" style="width: 80vw;height:64vh;" @sort-change="handleSortChange"
<el-table ref="tableRef" :data="tableData" style="width: 80vw;height:64vh;" @sort-change="handleSortChange"
:row-style="{ height: '60px' }" :header-cell-style="{ textAlign: 'center' }" :row-style="{ height: '60px' }" :header-cell-style="{ textAlign: 'center' }"
:cell-style="{ textAlign: 'center' }"> :cell-style="{ textAlign: 'center' }">
<el-table-column type="index" :label="t('common_list.id')" width="100px" fixed="left"> <el-table-column type="index" :label="t('common_list.id')" width="100px" fixed="left">
@ -640,7 +640,7 @@
<script setup> <script setup>
// //
import { ref, watch, onMounted } from 'vue';
import { ref, watch, onMounted, nextTick } from 'vue';
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
import { ElMessage, ElMessageBox } from 'element-plus'; import { ElMessage, ElMessageBox } from 'element-plus';
import API from '@/util/http.js'; import API from '@/util/http.js';
@ -679,6 +679,10 @@ const superAdmin = ref(false);
const tableData = ref([]); const tableData = ref([]);
const total = ref(0); const total = ref(0);
const pageInfo = ref({ pageSize: 10, pageNum: 1 }); const pageInfo = ref({ pageSize: 10, pageNum: 1 });
const tableRef = ref(null)
const scrollTableTop = () => {
tableRef.value?.setScrollTop?.(0)
}
// //
const market = ref([]) const market = ref([])
@ -1000,6 +1004,8 @@ const getlist = async () => {
if (result.code === 200) { if (result.code === 200) {
tableData.value = result.data.list; tableData.value = result.data.list;
await nextTick()
scrollTableTop()
total.value = result.data.total; total.value = result.data.total;
} else { } else {
ElMessage.error(t('elmessage.orderDataLoadFailed')); ElMessage.error(t('elmessage.orderDataLoadFailed'));

10
src/views/moneyManage/receiveDetail/receiveService.vue

@ -80,7 +80,7 @@
</div> </div>
<div class="table"> <div class="table">
<el-table :data="tableData" style="width: 80vw;height:64vh;" @sort-change="handleSortChange"
<el-table ref="tableRef" :data="tableData" style="width: 80vw;height:64vh;" @sort-change="handleSortChange"
:row-style="{ height: '60px' }" :header-cell-style="{ textAlign: 'center' }" :row-style="{ height: '60px' }" :header-cell-style="{ textAlign: 'center' }"
:cell-style="{ textAlign: 'center' }"> :cell-style="{ textAlign: 'center' }">
<el-table-column type="index" :label="t('common_list.id')" width="100px" fixed="left"> <el-table-column type="index" :label="t('common_list.id')" width="100px" fixed="left">
@ -430,7 +430,7 @@
</template> </template>
<script setup> <script setup>
import { ref, watch, onMounted, computed } from 'vue';
import { ref, watch, onMounted, computed, nextTick } from 'vue';
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
import { ElMessage, ElMessageBox } from 'element-plus' import { ElMessage, ElMessageBox } from 'element-plus'
import API from '@/util/http.js' import API from '@/util/http.js'
@ -457,6 +457,10 @@ const adminStore = useAdminStore();
const { menuTree } = storeToRefs(adminStore); const { menuTree } = storeToRefs(adminStore);
const adminData = ref({}) // const adminData = ref({}) //
const tableData = ref([]) // const tableData = ref([]) //
const tableRef = ref(null)
const scrollTableTop = () => {
tableRef.value?.setScrollTop?.(0)
}
const total = ref(0) // const total = ref(0) //
const pageInfo = ref({ pageSize: 10, pageNum: 1 }) // const pageInfo = ref({ pageSize: 10, pageNum: 1 }) //
const numUnitList = ref([t('cash.year'), t('cash.month')]) const numUnitList = ref([t('cash.year'), t('cash.month')])
@ -579,6 +583,8 @@ const getlist = async () => {
}) })
if (result.code == 200) { if (result.code == 200) {
tableData.value = result.data.list tableData.value = result.data.list
await nextTick()
scrollTableTop()
total.value = result.data.total total.value = result.data.total
} else { } else {
ElMessage.error(t('elmessage.dataException')) ElMessage.error(t('elmessage.dataException'))

Loading…
Cancel
Save