From c22b4cf05599fea5daf60343d5e92d8302a0a847 Mon Sep 17 00:00:00 2001 From: liuwei Date: Thu, 23 Apr 2026 14:26:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=93=8D=E5=BA=94=E6=8C=87?= =?UTF-8?q?=E4=BB=A4=E7=AE=A1=E7=90=86=E4=BD=9C=E7=94=A8=E5=9F=9F=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E4=BA=A4=E4=BA=92=EF=BC=8C=E6=94=AF=E6=8C=81=E7=BE=A4?= =?UTF-8?q?/=E7=94=A8=E6=88=B7=E4=B8=8B=E6=8B=89=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 变更项: - 查询区作用域ID改为下拉选择:群聊与私聊均支持按名称搜索 - 新增私聊联系人数据加载逻辑,接入 /contacts/api/personal - 新增作用域切换自动清空ID逻辑,避免群ID/用户ID串用 - 新增加载失败兜底提示,并统一展示 名称(wxid) 便于识别 --- .../templates/fun_command_rules.html | 91 +++++++++++++++++-- 1 file changed, 85 insertions(+), 6 deletions(-) diff --git a/admin/dashboard/templates/fun_command_rules.html b/admin/dashboard/templates/fun_command_rules.html index 9c1a0ef..6ac734d 100644 --- a/admin/dashboard/templates/fun_command_rules.html +++ b/admin/dashboard/templates/fun_command_rules.html @@ -32,7 +32,43 @@ - + + + + + + + + + + 查询 @@ -93,10 +129,24 @@ + - + + + + + + - @@ -251,6 +301,7 @@ new Vue({ loading: false, rows: [], groupOptions: [], + userOptions: [], filters: { scope_type: '', scope_id: '', enabled: '' }, dialogVisible: false, editing: false, @@ -271,8 +322,19 @@ new Vue({ }, mounted() { this.loadGroups() + this.loadUsers() this.loadRows() }, + watch: { + 'filters.scope_type'() { + // 切换筛选作用域后,清空旧ID,避免群ID/用户ID串用导致查询结果异常。 + this.filters.scope_id = '' + }, + 'form.scope_type'() { + // 编辑表单中切换作用域类型时,同步清空scope_id,强制重新选择目标对象。 + this.form.scope_id = '' + } + }, methods: { scopeLabel(scopeType) { const map = { global: '全局', group: '群聊', private: '私聊' } @@ -446,9 +508,26 @@ new Vue({ } }, async loadGroups() { - const resp = await axios.get('/contacts/api/groups') - const groups = (resp.data && resp.data.data && resp.data.data.groups) || {} - this.groupOptions = Object.entries(groups).map(([wxid, name]) => ({ wxid, name: String(name || wxid) })) + // 群聊数据用于“作用域”下拉选择,统一做名称兜底,确保没有昵称时仍可选。 + try { + const resp = await axios.get('/contacts/api/groups') + const groups = (resp.data && resp.data.data && resp.data.data.groups) || {} + this.groupOptions = Object.entries(groups).map(([wxid, name]) => ({ wxid, name: String(name || wxid) })) + } catch (error) { + this.groupOptions = [] + this.$message.error('加载群列表失败,请稍后重试') + } + }, + async loadUsers() { + // 私聊联系人数据用于“作用域”下拉选择,支持按名称搜索定位目标用户。 + try { + const resp = await axios.get('/contacts/api/personal') + const users = (resp.data && resp.data.data && resp.data.data.personal) || {} + this.userOptions = Object.entries(users).map(([wxid, name]) => ({ wxid, name: String(name || wxid) })) + } catch (error) { + this.userOptions = [] + this.$message.error('加载私聊联系人失败,请稍后重试') + } }, async loadRows() { this.loading = true