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