1.添加手动添加群组的能力

2.添加异步入库的能力
This commit is contained in:
liuwei
2025-03-26 13:04:09 +08:00
parent 5c4a76f76b
commit a2a6503e6c
4 changed files with 161 additions and 7 deletions

View File

@@ -10,6 +10,13 @@
<el-card shadow="hover">
<div slot="header" class="clearfix">
<span>群机器人管理</span>
<el-button
type="primary"
size="small"
style="float: right; margin-left: 10px;"
@click="showAddGroupDialog">
添加群组
</el-button>
<el-input
placeholder="搜索群组..."
v-model="searchQuery"
@@ -107,6 +114,22 @@
<el-button @click="permissionDialogVisible = false">关闭</el-button>
</div>
</el-dialog>
<!-- 添加群组对话框 -->
<el-dialog
title="添加群组"
:visible.sync="addGroupDialogVisible"
width="30%">
<el-form :model="addGroupForm" :rules="addGroupRules" ref="addGroupForm">
<el-form-item label="群组ID" prop="groupId">
<el-input v-model="addGroupForm.groupId" placeholder="请输入群组ID"></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="addGroupDialogVisible = false">取消</el-button>
<el-button type="primary" @click="submitAddGroup">确定</el-button>
</span>
</el-dialog>
</div>
{% endblock %}
@@ -123,7 +146,18 @@
currentGroupName: '',
searchQuery: '',
selectedGroups: [],
permissionDialogVisible: false
permissionDialogVisible: false,
// 添加群组相关数据
addGroupDialogVisible: false,
addGroupForm: {
groupId: ''
},
addGroupRules: {
groupId: [
{ required: true, message: '请输入群组ID', trigger: 'blur' },
{ pattern: /^\S+$/, message: '群组ID不能包含空格', trigger: 'blur' }
]
}
}
},
computed: {
@@ -237,6 +271,38 @@
this.$message.error('更新权限失败: ' + error.message);
});
},
// 显示添加群组对话框
showAddGroupDialog() {
this.addGroupForm.groupId = '';
this.addGroupDialogVisible = true;
},
// 提交添加群组
submitAddGroup() {
this.$refs.addGroupForm.validate((valid) => {
if (valid) {
axios.post('/api/robot/add_group', {
group_id: this.addGroupForm.groupId
})
.then(response => {
if (response.data.success) {
this.$message.success(response.data.message);
// 添加新群组到列表
if (response.data.group) {
this.groups.push(response.data.group);
}
this.addGroupDialogVisible = false;
} else {
this.$message.error(response.data.error || '添加失败');
}
})
.catch(error => {
console.error('添加群组失败:', error);
this.$message.error('添加群组失败: ' + (error.response?.data?.error || error.message));
});
}
});
},
enableAllPermissions() {
this.$confirm('确定要启用所有功能吗?', '提示', {
confirmButtonText: '确定',
@@ -419,4 +485,4 @@
}
});
</script>
{% endblock %}
{% endblock %}