|
@@ -2,7 +2,7 @@
|
|
|
* @Author: fxs bjnsfxs@163.com
|
|
* @Author: fxs bjnsfxs@163.com
|
|
|
* @Date: 2024-08-20 18:16:18
|
|
* @Date: 2024-08-20 18:16:18
|
|
|
* @LastEditors: fxs bjnsfxs@163.com
|
|
* @LastEditors: fxs bjnsfxs@163.com
|
|
|
- * @LastEditTime: 2024-10-14 14:36:44
|
|
|
|
|
|
|
+ * @LastEditTime: 2024-10-15 11:49:12
|
|
|
* @FilePath: \Game-Backstage-Management-System\src\components\Table.vue
|
|
* @FilePath: \Game-Backstage-Management-System\src\components\Table.vue
|
|
|
* @Description:
|
|
* @Description:
|
|
|
*
|
|
*
|
|
@@ -10,22 +10,21 @@
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
|
import type { PropsParams, TablePaginationSetting } from '@/types/table'
|
|
import type { PropsParams, TablePaginationSetting } from '@/types/table'
|
|
|
import type { ReqConfig } from '@/types/dataAnalysis'
|
|
import type { ReqConfig } from '@/types/dataAnalysis'
|
|
|
|
|
+import type { TableFieldInfo } from '@/types/table'
|
|
|
|
|
+import type { FormInstance } from 'element-plus'
|
|
|
|
|
+
|
|
|
import { FilterType, FieldSpecialEffectType } from '@/types/table'
|
|
import { FilterType, FieldSpecialEffectType } from '@/types/table'
|
|
|
import { initLoadResouce } from '@/utils/resource'
|
|
import { initLoadResouce } from '@/utils/resource'
|
|
|
import { fuzzySearch } from '@/utils/common'
|
|
import { fuzzySearch } from '@/utils/common'
|
|
|
-
|
|
|
|
|
|
|
+import { throttleFunc } from '@/utils/common'
|
|
|
import { computed, onMounted, reactive, ref, toRaw, watch } from 'vue'
|
|
import { computed, onMounted, reactive, ref, toRaw, watch } from 'vue'
|
|
|
import { useTable } from '@/hooks/useTable'
|
|
import { useTable } from '@/hooks/useTable'
|
|
|
|
|
+import { useRequest } from '@/hooks/useRequest'
|
|
|
|
|
|
|
|
import FilterPopover from './toolsBtn/FilterPopover.vue'
|
|
import FilterPopover from './toolsBtn/FilterPopover.vue'
|
|
|
import RegreshBtn from './toolsBtn/RegreshBtn.vue'
|
|
import RegreshBtn from './toolsBtn/RegreshBtn.vue'
|
|
|
-import { useRequest } from '@/hooks/useRequest'
|
|
|
|
|
-
|
|
|
|
|
-import type { FormInstance } from 'element-plus'
|
|
|
|
|
import axiosInstance from '@/utils/axios/axiosInstance'
|
|
import axiosInstance from '@/utils/axios/axiosInstance'
|
|
|
|
|
|
|
|
-import { throttleFunc } from '@/utils/common'
|
|
|
|
|
-
|
|
|
|
|
const { analysisResCode } = useRequest()
|
|
const { analysisResCode } = useRequest()
|
|
|
|
|
|
|
|
// 节流的延迟时间
|
|
// 节流的延迟时间
|
|
@@ -140,42 +139,34 @@ const handleSizeChange = (val: number) => {
|
|
|
* @return {*}
|
|
* @return {*}
|
|
|
*/
|
|
*/
|
|
|
const loadTableData = async () => {
|
|
const loadTableData = async () => {
|
|
|
- return new Promise((resolve, reject) => {
|
|
|
|
|
|
|
+ return new Promise(async (resolve, reject) => {
|
|
|
|
|
+ loading.value = true
|
|
|
if (props.dataList) {
|
|
if (props.dataList) {
|
|
|
tableData.splice(0, tableData.length, ...props.dataList)
|
|
tableData.splice(0, tableData.length, ...props.dataList)
|
|
|
|
|
|
|
|
paginationConfig.total = props.paginationConfig.total
|
|
paginationConfig.total = props.paginationConfig.total
|
|
|
loading.value = false
|
|
loading.value = false
|
|
|
- // emits('loadSuccess', tableData)
|
|
|
|
|
|
|
|
|
|
resolve(true)
|
|
resolve(true)
|
|
|
} else {
|
|
} else {
|
|
|
- loading.value = true
|
|
|
|
|
if (props.requestConfig) {
|
|
if (props.requestConfig) {
|
|
|
- if (props.openPageQuery) {
|
|
|
|
|
|
|
+ try {
|
|
|
// 如果开启了分页查询,那么要计算出需要展示的页码位置所对应的偏移量
|
|
// 如果开启了分页查询,那么要计算出需要展示的页码位置所对应的偏移量
|
|
|
// 同时要将查询的条数改为对应的用户选择的展示条数
|
|
// 同时要将查询的条数改为对应的用户选择的展示条数
|
|
|
- reqconfig.otherOptions.offset =
|
|
|
|
|
- (paginationConfig.currentPage - 1) * paginationConfig.limit
|
|
|
|
|
- reqconfig.otherOptions.limit = paginationConfig.limit
|
|
|
|
|
|
|
+ if (props.openPageQuery) {
|
|
|
|
|
+ reqconfig.otherOptions.offset =
|
|
|
|
|
+ (paginationConfig.currentPage - 1) * paginationConfig.limit
|
|
|
|
|
+ reqconfig.otherOptions.limit = paginationConfig.limit
|
|
|
|
|
+ }
|
|
|
|
|
+ await getTableData(reqconfig.url, reqconfig.otherOptions, props.openPageQuery)
|
|
|
|
|
+ backupTableData.splice(0, backupTableData.length, ...tableData)
|
|
|
|
|
+ resolve(true)
|
|
|
|
|
+ } catch (err) {
|
|
|
|
|
+ console.log(err)
|
|
|
|
|
+ reject(err)
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ loading.value = false
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- // 查询时要根据是否开启分页查询传入对应参数
|
|
|
|
|
- getTableData(reqconfig.url, reqconfig.otherOptions, props.openPageQuery)
|
|
|
|
|
- .then(() => {
|
|
|
|
|
- // emits('loadSuccess', tableData)
|
|
|
|
|
- backupTableData.splice(0, backupTableData.length, ...tableData)
|
|
|
|
|
-
|
|
|
|
|
- resolve(true)
|
|
|
|
|
- })
|
|
|
|
|
- .catch((err) => {
|
|
|
|
|
- console.log(err)
|
|
|
|
|
-
|
|
|
|
|
- reject(err)
|
|
|
|
|
- })
|
|
|
|
|
- .finally(() => {
|
|
|
|
|
- loading.value = false
|
|
|
|
|
- })
|
|
|
|
|
} else {
|
|
} else {
|
|
|
loading.value = false
|
|
loading.value = false
|
|
|
|
|
|
|
@@ -184,7 +175,6 @@ const loadTableData = async () => {
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
-import type { TableFieldInfo } from '@/types/table'
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @description: 获取数据,如果没有直接传入数据,则去请求数据,有则直接用
|
|
* @description: 获取数据,如果没有直接传入数据,则去请求数据,有则直接用
|
|
@@ -339,22 +329,23 @@ const tableCellStyle = (info: any) => {
|
|
|
/**
|
|
/**
|
|
|
* @description: 监听litmit,currentpage的变化,改变后去重新请求数据
|
|
* @description: 监听litmit,currentpage的变化,改变后去重新请求数据
|
|
|
* 如果是limit的变化,则需要把当前页置为1
|
|
* 如果是limit的变化,则需要把当前页置为1
|
|
|
- *
|
|
|
|
|
- * 对于Gid需要去监听props的,而不是本地的,因为是外部的改变
|
|
|
|
|
* @return {*}
|
|
* @return {*}
|
|
|
*/
|
|
*/
|
|
|
-const changePageLimit = watch(
|
|
|
|
|
|
|
+watch(
|
|
|
() => [paginationConfig.limit, paginationConfig.currentPage],
|
|
() => [paginationConfig.limit, paginationConfig.currentPage],
|
|
|
- ([newLimit, newCurPage], [oldLimit, oldCruPage]) => {
|
|
|
|
|
|
|
+ ([newLimit], [oldLimit]) => {
|
|
|
|
|
+ console.log(newLimit, oldLimit)
|
|
|
if (newLimit != oldLimit) {
|
|
if (newLimit != oldLimit) {
|
|
|
// 需要给分页按钮加上:current-page.sync="current_page" 配置,不然不生效
|
|
// 需要给分页按钮加上:current-page.sync="current_page" 配置,不然不生效
|
|
|
// 当改变每页大小时把之前的缓存全部清除,重新开始
|
|
// 当改变每页大小时把之前的缓存全部清除,重新开始
|
|
|
paginationConfig.currentPage = 1
|
|
paginationConfig.currentPage = 1
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (newCurPage != oldCruPage) paginationConfig.currentPage = newCurPage
|
|
|
|
|
-
|
|
|
|
|
- if (newLimit != oldLimit || !tableData[paginationConfig.currentPage]) {
|
|
|
|
|
|
|
+ // 开启分页查询的情况下,改变limit或者没有这页的缓存的情况下,重新请求
|
|
|
|
|
+ if (
|
|
|
|
|
+ props.openPageQuery &&
|
|
|
|
|
+ (newLimit !== oldLimit || !tableData[paginationConfig.currentPage])
|
|
|
|
|
+ ) {
|
|
|
getData()
|
|
getData()
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
@@ -430,11 +421,6 @@ if (!props.dataList) {
|
|
|
changeDataList()
|
|
changeDataList()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// 没有开启分页查询就关闭掉这个监听
|
|
|
|
|
-if (!props.openPageQuery) {
|
|
|
|
|
- changePageLimit()
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* @description: 拷贝一份配置文件
|
|
* @description: 拷贝一份配置文件
|
|
|
* @return {*}
|
|
* @return {*}
|