|
@@ -2,6 +2,7 @@
|
|
|
<div class="p-small radius-base fill-blank statistics-personnel">
|
|
|
<base-table
|
|
|
ref="tableRef"
|
|
|
+ :key="tableKey"
|
|
|
border
|
|
|
stripe
|
|
|
size="small"
|
|
@@ -10,6 +11,7 @@
|
|
|
:height="tableHeight"
|
|
|
:row-class-name="rowClassName"
|
|
|
highlight-current-row
|
|
|
+ :default-sort="defaultSort"
|
|
|
@current-change="onCurrentChange"
|
|
|
@row-dblclick="myDbClick"
|
|
|
@row-contextmenu="rowContextmenu"
|
|
@@ -84,7 +86,7 @@
|
|
|
<script setup lang="tsx" name="StatisticsPersonnel">
|
|
|
/** 人员数据统计-按人员展开 */
|
|
|
import { ref, inject, computed, watch, nextTick, unref } from 'vue'
|
|
|
-import { useRouter } from 'vue-router'
|
|
|
+import { useRouter, useRoute } from 'vue-router'
|
|
|
import { ElButton, ElPopover, ElMenu, ElMenuItem } from 'element-plus'
|
|
|
import VueECharts from 'vue-echarts'
|
|
|
import BaseTable from '@/components/element/BaseTable.vue'
|
|
@@ -98,7 +100,9 @@ import type { EChartsOption } from 'echarts'
|
|
|
import type { ExtractApiResponse, ExtractApiParams } from '@/api/api'
|
|
|
import type { EpTableColumn } from 'global-type'
|
|
|
import type { PopoverInstance } from 'element-plus'
|
|
|
+const tableKey = ref(Date.now() + '')
|
|
|
const mainStore = useMainStore()
|
|
|
+const firstSorted = ref(false)
|
|
|
const isChief = computed(() => {
|
|
|
const arr = ['CHIEF', 'SECTION_LEADER', 'EXPERT']
|
|
|
return arr.indexOf(mainStore.myUserInfo?.role || '') > -1
|
|
@@ -125,7 +129,8 @@ const setMessageVisible = inject<(visible: boolean) => void>('setMessageVisible'
|
|
|
const setReplyUserId = inject<(id: number) => void>('setReplyUserId')
|
|
|
|
|
|
const { push } = useRouter()
|
|
|
-
|
|
|
+const route = useRoute()
|
|
|
+const defaultSort: any = ref(route.query?.sortKey ? { prop: route.query?.sortKey, order: 'descending' } : undefined)
|
|
|
const columns = computed(() => {
|
|
|
return [
|
|
|
{
|
|
@@ -321,6 +326,7 @@ const myDbClick = (row: any) => {
|
|
|
const sortTableData = ref<any[]>([])
|
|
|
const originalTableData = ref<any[]>([])
|
|
|
const sortChange = (params: any) => {
|
|
|
+ console.log('params:', params)
|
|
|
const { column, prop, order } = params
|
|
|
if (order === 'ascending') {
|
|
|
sortTableData.value.sort((a: any, b: any) => {
|
|
@@ -358,7 +364,7 @@ const sortChange = (params: any) => {
|
|
|
sortTableData.value = JSON.parse(JSON.stringify(originalTableData.value))
|
|
|
}
|
|
|
}
|
|
|
-function initSortTableData() {
|
|
|
+function initSortTableData(sortKey?: any) {
|
|
|
if (tableData.value) {
|
|
|
let data: any[] = JSON.parse(JSON.stringify(tableData.value)) || []
|
|
|
if (data.length && data[data.length - 1].markingGroupNumber === 0) {
|
|
@@ -366,13 +372,27 @@ function initSortTableData() {
|
|
|
data.unshift(last)
|
|
|
}
|
|
|
sortTableData.value = JSON.parse(JSON.stringify(data))
|
|
|
+ if (sortKey) {
|
|
|
+ sortTableData.value.sort((a: any, b: any) => {
|
|
|
+ return b[sortKey] - a[sortKey]
|
|
|
+ })
|
|
|
+ }
|
|
|
originalTableData.value = JSON.parse(JSON.stringify(data))
|
|
|
}
|
|
|
}
|
|
|
initSortTableData()
|
|
|
-watch(tableData, () => {
|
|
|
+watch(tableData, (val) => {
|
|
|
popovers.value = {}
|
|
|
- initSortTableData()
|
|
|
+ if (!firstSorted.value && route.query?.sortKey && val?.length) {
|
|
|
+ initSortTableData(route.query?.sortKey || '')
|
|
|
+ firstSorted.value = true
|
|
|
+ } else {
|
|
|
+ initSortTableData()
|
|
|
+ if (firstSorted.value) {
|
|
|
+ defaultSort.value = undefined
|
|
|
+ tableKey.value = Date.now() + ''
|
|
|
+ }
|
|
|
+ }
|
|
|
})
|
|
|
|
|
|
// watch(currentView, () => {
|