feat(config): 支持配置名和内容模糊搜索

- 配置列表接口增加 keyword 参数,按 name 或 contents 模糊匹配
- 全局配置、应用配置和回收站页面增加关键字搜索框
This commit is contained in:
2026-09-26 21:07:59 +08:00
parent bb90f9cf79
commit de87d98876
4 changed files with 30 additions and 5 deletions
+6
View File
@@ -29,6 +29,7 @@ type ConfigListRequest struct {
Env string `form:"env"`
AppId *int `form:"appId"`
Deleted bool `form:"deleted"`
Keyword string `form:"keyword"`
}
func (h *ConfigHandler) List(c *gin.Context) {
@@ -59,6 +60,11 @@ func (h *ConfigHandler) List(c *gin.Context) {
conditions = append(conditions, "env = ?")
args = append(args, req.Env)
}
if req.Keyword != "" {
like := "%" + req.Keyword + "%"
conditions = append(conditions, "(name LIKE ? OR contents LIKE ?)")
args = append(args, like, like)
}
if req.AppId != nil {
if *req.AppId <= 0 {
conditions = append(conditions, "(app_id is null OR app_id = 0)")
+8 -2
View File
@@ -2,6 +2,9 @@
<div>
<el-card style="margin-bottom: 16px">
<el-form :inline="true" @submit.native.prevent="handleSearch">
<el-form-item label="关键字">
<el-input v-model="query.keyword" placeholder="配置名或内容" clearable style="width: 200px"></el-input>
</el-form-item>
<el-form-item label="环境">
<el-select v-model="query.env" placeholder="请选择" clearable style="width: 160px">
<el-option v-for="p in profiles" :key="p.value" :label="p.label" :value="p.value"></el-option>
@@ -253,7 +256,7 @@ export default {
list: [],
loading: false,
total: 0,
query: { pageNo: 1, pageSize: 20, env: '', appId: null },
query: { pageNo: 1, pageSize: 20, env: '', appId: null, keyword: '' },
profiles: [],
apps: [],
historyVisible: false,
@@ -280,7 +283,7 @@ export default {
this.loadData()
},
handleReset() {
this.query = { pageNo: 1, pageSize: 20, env: '', appId: null }
this.query = { pageNo: 1, pageSize: 20, env: '', appId: null, keyword: '' }
this.loadData()
},
async loadData() {
@@ -296,6 +299,9 @@ export default {
if (this.query.appId) {
params.appId = this.query.appId
}
if (this.query.keyword) {
params.keyword = this.query.keyword
}
const res = await getConfigList(params)
this.list = res.data || []
this.total = res.total || 0
+8 -1
View File
@@ -2,6 +2,9 @@
<div>
<el-card style="margin-bottom: 16px">
<el-form :inline="true" @submit.native.prevent="handleSearch">
<el-form-item label="关键字">
<el-input v-model="query.keyword" placeholder="配置名或内容" clearable style="width: 200px"></el-input>
</el-form-item>
<el-form-item label="环境">
<el-select v-model="query.env" placeholder="请选择" clearable style="width: 160px">
<el-option v-for="p in profiles" :key="p.value" :label="p.label" :value="p.value"></el-option>
@@ -248,7 +251,7 @@ export default {
list: [],
loading: false,
total: 0,
query: { pageNo: 1, pageSize: 20, env: '' },
query: { pageNo: 1, pageSize: 20, env: '', keyword: '' },
profiles: [],
historyVisible: false,
historyList: [],
@@ -274,6 +277,7 @@ export default {
},
handleReset() {
this.query.env = ''
this.query.keyword = ''
this.query.pageNo = 1
this.loadData()
},
@@ -288,6 +292,9 @@ export default {
if (this.query.env) {
params.env = this.query.env
}
if (this.query.keyword) {
params.keyword = this.query.keyword
}
const res = await getConfigList(params)
this.list = res.data || []
this.total = res.total || 0
+8 -2
View File
@@ -2,6 +2,9 @@
<div>
<el-card style="margin-bottom: 16px">
<el-form :inline="true" @submit.native.prevent="handleSearch">
<el-form-item label="关键字">
<el-input v-model="query.keyword" placeholder="配置名或内容" clearable style="width: 200px"></el-input>
</el-form-item>
<el-form-item label="环境">
<el-select v-model="query.env" placeholder="请选择" clearable style="width: 160px">
<el-option v-for="p in profiles" :key="p.value" :label="p.label" :value="p.value"></el-option>
@@ -61,7 +64,7 @@ export default {
list: [],
loading: false,
total: 0,
query: { pageNo: 1, pageSize: 10, env: '', appId: null },
query: { pageNo: 1, pageSize: 10, env: '', appId: null, keyword: '' },
profiles: [],
apps: []
}
@@ -77,7 +80,7 @@ export default {
this.loadData()
},
handleReset() {
this.query = { pageNo: 1, pageSize: 10, env: '', appId: null }
this.query = { pageNo: 1, pageSize: 10, env: '', appId: null, keyword: '' }
this.loadData()
},
async loadData() {
@@ -94,6 +97,9 @@ export default {
if (this.query.appId) {
params.appId = this.query.appId
}
if (this.query.keyword) {
params.keyword = this.query.keyword
}
const res = await getConfigList(params)
this.list = res.data || []
this.total = res.total || 0