diff --git a/src/App.vue b/src/App.vue index 582bfad..8d74c47 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,8 +1,21 @@ + diff --git a/src/api/index.ts b/src/api/index.ts index cb2c883..858212e 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -1,35 +1,33 @@ import axios from 'axios' import type { AxiosResponse, AxiosError, InternalAxiosRequestConfig } from 'axios' import type { ApiResponse } from '@/api/types' -import { ElLoading, ElNotification } from 'element-plus' +import { ElNotification } from 'element-plus' import { getStorage, setStorage, removeStorage } from '@/utils/storage' import router from '../router' -// 定义loading实例类型,用于控制loading的显示和关闭 -let loadingInstance: ReturnType | null = null -// 记录当前请求数量,防止多个请求重复显示/关闭loading +// 记录当前请求数量,用于控制顶部进度条 let requestCount = 0 -// 显示loading的方法 +// 获取 TopLoading 实例 +const getTopLoading = () => { + // @ts-ignore + return window.__topLoading__ +} + +// 显示顶部进度条 const showLoading = () => { - if (requestCount === 0 && !loadingInstance) { - loadingInstance = ElLoading.service({ - lock: true, // 锁定屏幕滚动 - fullscreen: true, // 全屏显示 - }) + if (requestCount === 0) { + getTopLoading()?.start() } requestCount++ } -// 关闭loading的方法 +// 关闭顶部进度条 const hideLoading = () => { requestCount-- if (requestCount <= 0) { - if (loadingInstance) { - loadingInstance.close() - loadingInstance = null - } - requestCount = 0 // 重置计数,防止负数 + getTopLoading()?.complete() + requestCount = 0 } } @@ -49,10 +47,8 @@ const service = axios.create({ const requestInterceptor = (config: InternalAxiosRequestConfig) => { console.log('请求配置', config) - // 显示loading(可通过config配置项控制是否显示,比如某些请求不需要loading) - if (config.headers?.showLoading !== false) { - showLoading() - } + // 显示顶部进度条 + showLoading() // 添加token到请求头 const token = getStorage('token') if (token) { diff --git a/src/api/modules/agent/customerList.ts b/src/api/modules/agent/customerList.ts index 7c058ac..7e2f6ae 100644 --- a/src/api/modules/agent/customerList.ts +++ b/src/api/modules/agent/customerList.ts @@ -13,4 +13,9 @@ export const getSelfVarietyPointDiffConfigApi = (params: any) => { //编辑代理客户接口 export const editCustomerApi = (params: any) => { return request.post('/agent/editAgent', {...params}) +} + +//编辑代理客户接口 +export const updateToAgent = (params: any) => { + return request.post('/agent/updateToAgent', {...params}) } \ No newline at end of file diff --git a/src/components/common/Dialog.vue b/src/components/common/Dialog.vue index 0abcd92..a76103d 100644 --- a/src/components/common/Dialog.vue +++ b/src/components/common/Dialog.vue @@ -16,7 +16,7 @@ @@ -31,6 +31,7 @@ interface Props { type?: string showFooter?: boolean fullscreen?: boolean + buttonLoading?: boolean } interface Emits { @@ -45,6 +46,7 @@ const props = withDefaults(defineProps(), { destroyOnClose: true, showFooter: true, fullscreen: false, + buttonLoading: false, }) const emit = defineEmits() diff --git a/src/components/common/Search.vue b/src/components/common/Search.vue index f6863ac..6f52b81 100644 --- a/src/components/common/Search.vue +++ b/src/components/common/Search.vue @@ -44,10 +44,10 @@ - + {{ buttonConfig.searchText || '搜索' }} - + {{ buttonConfig.resetText || '重置' }} @@ -99,6 +99,10 @@ const props = defineProps({ type: Object as () => ButtonConfig, default: () => ({}), }, + buttonLoading: { + type: Boolean, + default: false, + }, }) // 暴露事件 diff --git a/src/components/common/Table.vue b/src/components/common/Table.vue index 7d4cb68..0f12c14 100644 --- a/src/components/common/Table.vue +++ b/src/components/common/Table.vue @@ -8,10 +8,16 @@ :tree-props="treeProps" :border="border" :highlight-current-row="highlightCurrentRow" + v-loading="loading" v-bind="$attrs" @row-click="handleRowClick" @row-contextmenu="handleRowContextmenu" + @selection-change="handleSelectionChange" + @current-change="handleCurrentChange" > + + +