diff --git a/src/api/customerService/account/index.ts b/src/api/customerService/account/index.ts index 95d7fae..052bd45 100644 --- a/src/api/customerService/account/index.ts +++ b/src/api/customerService/account/index.ts @@ -1,36 +1,70 @@ import request from '/@/utils/request'; -//获取账号列表 -export function getaccountList(data: object) { +export interface AccountParams { + datasetIds: number[]; + documentIds: number[]; + accountCode: string; + accountName?: string; + status?: number; + greeting?: string; + keywordOption?: string[]; + selfIdentity?: string; + platform: string; +} + +export interface AccountListParams { + pageNum?: number; + pageSize?: number; + accountCode?: string; + accountName?: string; + status?: number; + platform?: string; +} + +export interface AccountDetailParams { + id: number; +} + +//获取客服账号列表 +export function getAccountList(data: AccountListParams) { return request({ - url: '/customer-server/customer/service/account/list', + url: '/customer-server/account/list', method: 'get', params: data, }); } +//获取客服账号详情 +export function getAccountOne(params: AccountDetailParams) { + return request({ + url: '/customer-server/account/getOne', + method: 'get', + params: params, + }); +} + //添加客服账号 -export function addAccount(data: object) { +export function addAccount(data: AccountParams) { return request({ - url: '/customer-server/customer/service/account/add', + url: '/customer-server/account/add', method: 'post', data: data, }); } -//禁用账号 -export function updatestate(data: object) { +//更新客服账号 +export function updateAccount(data: AccountParams & { id: number }) { return request({ - url: '/customer-server/customer/service/account/toggleStatus', + url: '/customer-server/account/update', method: 'post', data: data, }); } -//更新账号 -export function updateAccount(data: object) { +//删除客服账号 +export function deleteAccount(data: { id: number }) { return request({ - url: '/customer-server/customer/service/account/update', + url: '/customer-server/account/delete', method: 'post', data: data, }); diff --git a/src/api/knowledge/document/index.ts b/src/api/knowledge/document/index.ts index 88debd6..0f83686 100644 --- a/src/api/knowledge/document/index.ts +++ b/src/api/knowledge/document/index.ts @@ -236,3 +236,20 @@ export function updateDocumentVector(data: any) { data, }); } + +// 获取任务列表 +export function listTasks() { + return request({ + url: '/rag/task/get', + method: 'get', + }); +} + +// 重新执行任务 +export function reexecuteTask(id: string) { + return request({ + url: '/rag/task/reexecute', + method: 'post', + data: { id }, + }); +} diff --git a/src/api/trade/operation/setting/anchor/index.ts b/src/api/trade/operation/setting/anchor/index.ts new file mode 100644 index 0000000..3f58794 --- /dev/null +++ b/src/api/trade/operation/setting/anchor/index.ts @@ -0,0 +1,69 @@ +import request from '/@/utils/request'; + +// 主播管理API接口 + +export interface AnchorListParams { + pageNum: number; + pageSize: number; + name?: string; + phone?: string; + code?: string; + status?: number; +} + +export interface AnchorParams { + id?: string; + name: string; + phone: string; + code: string; + status?: number; + remark?: string; +} + +export function getAnchorList(data: AnchorListParams) { + return request({ + url: '/erp/anchor/controller/listAnchors', + method: 'get', + params: data, + }); +} + +export function getAnchorOne(data: { id: string }) { + return request({ + url: '/erp/anchor/controller/getAnchor', + method: 'get', + params: data, + }); +} + +export function addAnchor(data: AnchorParams) { + return request({ + url: '/erp/anchor/controller/createAnchor', + method: 'post', + data: data, + }); +} + +export function updateAnchor(data: AnchorParams) { + return request({ + url: '/erp/anchor/controller/updateAnchor', + method: 'post', + data: data, + }); +} + +export function deleteAnchor(data: { id: string }) { + return request({ + url: '/erp/anchor/controller/deleteAnchor', + method: 'post', + data: data, + }); +} + +export function updateAnchorStatus(data: { id: string; status: number }) { + return request({ + url: '/erp/anchor/controller/updateAnchorStatus', + method: 'post', + data: data, + }); +} diff --git a/src/directives/debounce.ts b/src/directives/debounce.ts new file mode 100644 index 0000000..fb7fdd9 --- /dev/null +++ b/src/directives/debounce.ts @@ -0,0 +1,49 @@ +import type { Directive, DirectiveBinding } from 'vue'; + +interface DebounceBinding extends DirectiveBinding { + value: () => void; + arg?: string; + modifiers?: { + [key: string]: boolean; + }; +} + +const debounceTimers = new Map(); + +const debounce = (fn: () => void, key: string, delay = 300) => { + if (debounceTimers.has(key)) { + clearTimeout(debounceTimers.get(key) as number); + } + + const timer = setTimeout(() => { + fn(); + debounceTimers.delete(key); + }, delay) as unknown as number; + + debounceTimers.set(key, timer); +}; + +export const debounceDirective: Directive = { + mounted(el: HTMLElement, binding: DebounceBinding) { + const fn = binding.value; + const key = binding.arg || `debounce_${Date.now()}_${Math.random()}`; + const delay = binding.modifiers?.fast ? 200 : binding.modifiers?.slow ? 500 : 300; + + el.addEventListener('click', (event: Event) => { + event.preventDefault(); + event.stopPropagation(); + debounce(fn, key, delay); + }); + + el.dataset.debounceKey = key; + }, + unmounted(el: HTMLElement) { + const key = el.dataset.debounceKey; + if (key && debounceTimers.has(key)) { + clearTimeout(debounceTimers.get(key) as number); + debounceTimers.delete(key); + } + }, +}; + +export default debounceDirective; diff --git a/src/router/backEnd.ts b/src/router/backEnd.ts index 1b53750..c561557 100644 --- a/src/router/backEnd.ts +++ b/src/router/backEnd.ts @@ -141,17 +141,51 @@ export function setBackEndControlRefreshRoutes() { export function backEndComponent(routes: any) { if (!routes) return []; return routes.map((item: any) => { + // 递归处理子路由 if (item.children && item.children.length > 0) { - item.children.some((ci: any) => { - if (!ci.meta.isHide) { - item.redirect = ci; - return true; + item.children = backEndComponent(item.children); + // 找到第一个非隐藏的子路由作为重定向 + const firstVisibleChild = item.children.find((ci: any) => !ci.meta?.isHide); + if (firstVisibleChild) { + item.redirect = firstVisibleChild.path; + } + // 确保父级路由有component + if (!item.component || item.component === false) { + item.component = dynamicViewsModules['../layout/routerView/parent.vue']; + } + } else { + // 确保叶子路由有component + let componentFound = false; + if (item.component && item.component !== false) { + const comp = dynamicImport(dynamicViewsModules, item.component as string); + if (comp) { + item.component = comp; + componentFound = true; } - return false; - }); + } + if (!componentFound) { + // 尝试根据path生成component路径 + const path = item.path.replace(/^\//, ''); + let comp = dynamicImport(dynamicViewsModules, path); + if (!comp) { + comp = dynamicImport(dynamicViewsModules, path + '/index'); + } + if (!comp) { + // 尝试直接拼接views路径 + const viewsPath = 'views/' + path + '/index.vue'; + const directKey = Object.keys(dynamicViewsModules).find((key) => key.includes(viewsPath)); + if (directKey) { + comp = dynamicViewsModules[directKey]; + } + } + if (comp) { + item.component = comp; + } else { + // 如果还是找不到,使用一个默认组件 + item.component = dynamicViewsModules['../layout/routerView/parent.vue']; + } + } } - if (item.component) item.component = dynamicImport(dynamicViewsModules, item.component as string); - item.children && backEndComponent(item.children); return item; }); } @@ -164,10 +198,35 @@ export function backEndComponent(routes: any) { */ export function dynamicImport(dynamicViewsModules: Record, component: string) { const keys = Object.keys(dynamicViewsModules); - const matchKeys = keys.filter((key) => { + + // 尝试多种匹配方式 + let matchKeys = keys.filter((key) => { const k = key.replace(/..\/views|../, ''); return k.startsWith(`${component}`) || k.startsWith(`/${component}`); }); + + // 如果没有匹配到,尝试带index的路径 + if (matchKeys?.length === 0) { + matchKeys = keys.filter((key) => { + const k = key.replace(/..\/views|../, ''); + return k.startsWith(`${component}/index`) || k.startsWith(`/${component}/index`); + }); + } + + // 尝试直接匹配完整路径 + if (matchKeys?.length === 0) { + matchKeys = keys.filter((key) => { + return key.includes(component); + }); + } + + // 尝试更宽松的匹配方式 + if (matchKeys?.length === 0) { + matchKeys = keys.filter((key) => { + return key.replace(/..\/views\//, '').includes(component.replace(/\//g, '')); + }); + } + if (matchKeys?.length === 1) { const matchKey = matchKeys[0]; return dynamicViewsModules[matchKey]; @@ -175,4 +234,6 @@ export function dynamicImport(dynamicViewsModules: Record, com if (matchKeys?.length > 1) { return false; } + + return false; } diff --git a/src/utils/debounce.ts b/src/utils/debounce.ts new file mode 100644 index 0000000..a801627 --- /dev/null +++ b/src/utils/debounce.ts @@ -0,0 +1,53 @@ +import { onUnmounted } from 'vue'; + +interface DebounceOptions { + delay?: number; + immediate?: boolean; +} + +export function useDebounce() { + const timers = new Map(); + + const debounce = (key: string, fn: () => void, options: DebounceOptions = {}) => { + const { delay = 300 } = options; + + if (timers.has(key)) { + clearTimeout(timers.get(key) as number); + } + + const timer = setTimeout(() => { + fn(); + timers.delete(key); + }, delay) as unknown as number; + + timers.set(key, timer); + }; + + const clear = () => { + timers.forEach((timer) => clearTimeout(timer)); + timers.clear(); + }; + + onUnmounted(() => { + clear(); + }); + + return { debounce, clear }; +} + +export function createDebouncedFn(key: string, fn: () => void, delay = 300) { + const timers = new Map(); + + return () => { + if (timers.has(key)) { + clearTimeout(timers.get(key) as number); + } + + const timer = setTimeout(() => { + fn(); + timers.delete(key); + }, delay) as unknown as number; + + timers.set(key, timer); + }; +} diff --git a/src/utils/directive.ts b/src/utils/directive.ts index a75b187..03cb959 100644 --- a/src/utils/directive.ts +++ b/src/utils/directive.ts @@ -1,12 +1,14 @@ import type { App } from 'vue'; import { authDirective } from '/@/utils/authDirective'; import { wavesDirective, dragDirective } from '/@/utils/customDirective'; +import { debounceDirective } from '/@/directives/debounce'; /** * 导出指令方法:v-xxx * @methods authDirective 用户权限指令,用法:v-auth * @methods wavesDirective 按钮波浪指令,用法:v-waves * @methods dragDirective 自定义拖动指令,用法:v-drag + * @methods debounceDirective 防抖指令,用法:v-debounce */ export function directive(app: App) { // 用户权限指令 @@ -15,4 +17,6 @@ export function directive(app: App) { wavesDirective(app); // 自定义拖动指令 dragDirective(app); + // 防抖指令 + app.directive('debounce', debounceDirective); } diff --git a/src/views/ads/summary/monitor/index.vue b/src/views/ads/summary/monitor/index.vue index 94f6572..5559f8f 100644 --- a/src/views/ads/summary/monitor/index.vue +++ b/src/views/ads/summary/monitor/index.vue @@ -4,7 +4,7 @@