diff --git a/im-admin-ui/src/api/im/agent/index.ts b/im-admin-ui/src/api/im/agent/index.ts index 760b499..0f401df 100644 --- a/im-admin-ui/src/api/im/agent/index.ts +++ b/im-admin-ui/src/api/im/agent/index.ts @@ -48,6 +48,6 @@ export function saveDefaultCustomer(kefuId: number | null): AxiosPromise { return request({ url: '/im/agent/saveDefaultCustomer', method: 'post', - data: { defaultCustomerId: kefuId } + data: { defaultKefuId: kefuId } }); } diff --git a/im-admin-ui/src/views/im/code/index.vue b/im-admin-ui/src/views/im/code/index.vue index 1de1b11..b89be24 100644 --- a/im-admin-ui/src/views/im/code/index.vue +++ b/im-admin-ui/src/views/im/code/index.vue @@ -5,41 +5,47 @@
指定客服: - - -
+ + +
{{ item.nickName }}
+ + 清除 +
+ - - + - + @@ -52,6 +58,8 @@ import { ref, computed, onMounted, getCurrentInstance } from 'vue'; // import { useStore } from 'vuex'; // import { adminAppCustomer, appReset } from '@/api/kefu'; import alink from './components/alink.vue'; +import { ElMessage } from 'element-plus'; + import wangye from './components/wangye.vue'; import FloatBallSetting from './components/FloatBallSetting.vue'; import { listUser, listAllCustomer } from '@/api/im/user/customer'; @@ -74,7 +82,7 @@ const { proxy } = getCurrentInstance() as any; // 👇 定义悬浮球配置(默认空) const floatBallConfig = ref({ pcImage: '', - mobileImage: '', + mobileImage: '' }); const token = ref(''); const canfrime = ref(false); @@ -85,7 +93,7 @@ const canCustomerServer = ref(''); const selectedKefuId = ref(''); const kefuList = ref([]); - +const kefuSaving = ref(false); const linkUrl = computed(() => `${location.origin}/chat/index?token=${token.value?.token_md5}&noCanClose=1`); onMounted(() => { // 页面加载就获取当前代理的 uniqueToken ✅ @@ -132,7 +140,6 @@ async function loadKefuList() { } } - // 加载已保存的默认客服ID async function loadDefaultKefu() { try { @@ -145,13 +152,30 @@ async function loadDefaultKefu() { } } - async function onKefuChange(val: number | '') { + if (kefuSaving.value) return; + kefuSaving.value = true; try { await saveDefaultCustomer(val || null); - proxy?.$Message?.success('已保存'); + ElMessage.success('已保存'); } catch (e) { console.error('保存默认客服失败', e); + } finally { + kefuSaving.value = false; + } +} + +async function onClearKefu() { + if (kefuSaving.value) return; + selectedKefuId.value = ''; + kefuSaving.value = true; + try { + await saveDefaultCustomer(null); + ElMessage.success('已清除'); + } catch (e) { + console.error('清除默认客服失败', e); + } finally { + kefuSaving.value = false; } } @@ -167,7 +191,7 @@ function handleFloatBallConfigSaved(config: FloatBallConfig) { floatBallConfig.value = config; // 可以在这里执行额外的保存逻辑,比如同步到服务器 console.log('悬浮球配置已保存:', config); - + // 如果需要保存到服务器,可以在这里调用API // saveFloatBallConfigToServer(config); } @@ -364,4 +388,4 @@ function copyToClipboard(elem: HTMLElement) { height: 40px !important; margin-right: 30px; } - \ No newline at end of file + diff --git a/im-admin/ruoyi-im/src/main/java/org/dromara/im/controller/ImAgentController.java b/im-admin/ruoyi-im/src/main/java/org/dromara/im/controller/ImAgentController.java index b6f629f..fa6a9c7 100644 --- a/im-admin/ruoyi-im/src/main/java/org/dromara/im/controller/ImAgentController.java +++ b/im-admin/ruoyi-im/src/main/java/org/dromara/im/controller/ImAgentController.java @@ -151,7 +151,6 @@ public class ImAgentController extends BaseController { /** * 保存默认客服ID */ - @RepeatSubmit() @PostMapping("/saveDefaultCustomer") public R saveDefaultCustomer(@RequestBody ImAgentBo bo) { imAgentService.saveDefaultCustomerId(bo.getDefaultKefuId()); diff --git a/im-admin/ruoyi-im/src/main/java/org/dromara/im/service/impl/ImAgentServiceImpl.java b/im-admin/ruoyi-im/src/main/java/org/dromara/im/service/impl/ImAgentServiceImpl.java index 48d71e1..0bcca00 100644 --- a/im-admin/ruoyi-im/src/main/java/org/dromara/im/service/impl/ImAgentServiceImpl.java +++ b/im-admin/ruoyi-im/src/main/java/org/dromara/im/service/impl/ImAgentServiceImpl.java @@ -283,11 +283,11 @@ public class ImAgentServiceImpl implements IImAgentService { if (agent == null) { throw new RuntimeException("代理不存在"); } - LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper<>(); - wrapper.eq(ImAgent::getId, agent.getId()); - wrapper.set(ImAgent::getDefaultKefuId, customerId); - baseMapper.update(null, wrapper); + + agent.setDefaultKefuId(customerId); + baseMapper.updateById(agent); } + }