Insert image for product

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-05-17 13:45:52 +03:30
co-authored by Cursor
parent f994a61567
commit 1c2647d093
11 changed files with 457 additions and 97 deletions
@@ -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({
+1 -1
View File
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { useHead } from '@vueuse/head'
import { useDarkmode } from '/@/core/stores/darkmode'
import { useDarkmode } from '@/core/stores/darkmode'
//import { useUserSession } from '/@src/stores/userSession'
//import { useNotyf } from '/@src/core/composable/useNotyf'
//import sleep from '/@src/utils/sleep'
+10 -3
View File
@@ -14,6 +14,7 @@ import { message } from 'ant-design-vue'
interface Meta {
errorMessage?: 'message' | 'notification' | 'toast'
silent?: boolean
}
interface MyAxiosRequestConfig<D = any> extends AxiosRequestConfig<D> {
@@ -72,11 +73,17 @@ _axios.interceptors.response.use(
// router.push({ name: 'login' })
await router.push({ name: 'login' })
} else if (error.response && error.response.status == 403) {
message.error('شما دسترسی لازم برای انجام این عملیات را ندارید')
if (!error.config?.meta?.silent) {
message.error('شما دسترسی لازم برای انجام این عملیات را ندارید')
}
} else if (error.response && error.response.status == 422) {
message.error(error.response.data?.message)
if (!error.config?.meta?.silent) {
message.error(error.response.data?.message)
}
} else if (error.response) {
message.error('خطا در بارگذاری اطلاعات')
if (!error.config?.meta?.silent) {
message.error('خطا در بارگذاری اطلاعات')
}
}
// Any status codes that falls outside the range of 2xx cause this function to trigger
// Do something with response error