Insert image for product
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -285,7 +285,7 @@ import BaseDatePicker from '@core/components/BaseDatePicker'
|
||||
import { cloneDeep, get, isArray, omit } from 'lodash'
|
||||
import { LoadingOutlined } from '@ant-design/icons-vue'
|
||||
//import { filterOperatorList } from '../hooks/filterOperator'
|
||||
import { ref } from 'vue'
|
||||
import { nextTick, ref } from 'vue'
|
||||
import BaseSwitch from '@core/components/BaseSwitch/src/BaseSwitch.vue'
|
||||
import { mapColumnTypeFilterToFilterType } from '@core/type/baseTable'
|
||||
import {
|
||||
@@ -350,6 +350,8 @@ const orderColumnKey = ref<string | null>(null)
|
||||
const containerRef = ref()
|
||||
//const route = useRoute()
|
||||
const loading = ref<boolean>(false)
|
||||
const tableReady = ref(false)
|
||||
let callApiPromise: Promise<void> | null = null
|
||||
const _props = computed(() => {
|
||||
return omit(props, ['columns', 'pagination', 'dataSource'])
|
||||
})
|
||||
@@ -594,9 +596,9 @@ function handleResizeColumn(w: number, col: any) {
|
||||
}
|
||||
|
||||
async function handleChangePageSize(value: number, option: any) {
|
||||
if (tableInput.value) {
|
||||
tableInput.value.limit = value
|
||||
}
|
||||
if (!tableReady.value || tableInput.value.limit === value) return
|
||||
tableInput.value.limit = value
|
||||
pageReset()
|
||||
await reload()
|
||||
}
|
||||
|
||||
@@ -605,6 +607,7 @@ function pageReset() {
|
||||
}
|
||||
|
||||
async function handleChangePage(page: number, pageSize: number) {
|
||||
if (!tableReady.value || tableInput.value.page === page) return
|
||||
tableInput.value.page = page
|
||||
await callApi()
|
||||
}
|
||||
@@ -615,7 +618,11 @@ async function reload() {
|
||||
|
||||
async function callApi() {
|
||||
const api = get(_props.value, 'api', null)
|
||||
if (api != null) {
|
||||
if (api == null) return
|
||||
|
||||
if (callApiPromise) return callApiPromise
|
||||
|
||||
callApiPromise = (async () => {
|
||||
try {
|
||||
loading.value = true
|
||||
if (orderColumnKey.value != null) {
|
||||
@@ -633,7 +640,6 @@ async function callApi() {
|
||||
tableInput.value = data.query
|
||||
tableOutput.value = data
|
||||
searchText.value = data.query.search ?? ''
|
||||
//console.log('11110', get(data.query.filters ?? [], 'filters', []))
|
||||
filters.value = cloneDeep(data.query.filters ?? []).filter((item) => {
|
||||
return Object.hasOwn(item, 'hidden') && item.hidden == false
|
||||
})
|
||||
@@ -653,14 +659,19 @@ async function callApi() {
|
||||
console.log(e)
|
||||
} finally {
|
||||
loading.value = false
|
||||
callApiPromise = null
|
||||
}
|
||||
}
|
||||
})()
|
||||
|
||||
return callApiPromise
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
tableReady.value = false
|
||||
await callApi()
|
||||
emit('register', { reload })
|
||||
//console.log('router', route.query)
|
||||
await nextTick()
|
||||
tableReady.value = true
|
||||
})
|
||||
|
||||
defineExpose({
|
||||
|
||||
Reference in New Issue
Block a user