feat: 环境管理页面添加环境名称模糊查询,统一双卡片布局

This commit is contained in:
2026-06-02 21:08:32 +08:00
parent d9043c6f78
commit 9d475eacba
2 changed files with 35 additions and 8 deletions
+6 -1
View File
@@ -18,8 +18,13 @@ func NewProfileHandler() *ProfileHandler {
} }
func (h *ProfileHandler) List(c *gin.Context) { func (h *ProfileHandler) List(c *gin.Context) {
alias := c.Query("alias")
query := dao.Engine.Where("1=1")
if alias != "" {
query = query.Where("alias LIKE ?", "%"+alias+"%")
}
var profiles []model.Profile var profiles []model.Profile
dao.Engine.Find(&profiles) query.Find(&profiles)
c.JSON(http.StatusOK, model.WrapperResponse{Code: 0, Data: profiles}) c.JSON(http.StatusOK, model.WrapperResponse{Code: 0, Data: profiles})
} }
+29 -7
View File
@@ -1,10 +1,22 @@
<template> <template>
<el-card> <div>
<div slot="header" style="display: flex; justify-content: space-between; align-items: center"> <el-card style="margin-bottom: 16px">
<span>环境列表</span> <el-form :inline="true" @submit.native.prevent="handleSearch">
<el-button type="primary" @click="showAdd">新建环境</el-button> <el-form-item label="环境名称">
</div> <el-input v-model="queryAlias" placeholder="请输入" clearable style="width: 200px"></el-input>
<el-table :data="list" v-loading="loading" border stripe> </el-form-item>
<el-form-item>
<el-button type="primary" @click="handleSearch">查询</el-button>
<el-button @click="handleReset">重置</el-button>
</el-form-item>
</el-form>
</el-card>
<el-card>
<div slot="header" style="display: flex; justify-content: flex-end">
<el-button type="primary" @click="showAdd">新建环境</el-button>
</div>
<el-table :data="list" v-loading="loading" border stripe>
<el-table-column prop="id" label="ID" width="60"></el-table-column> <el-table-column prop="id" label="ID" width="60"></el-table-column>
<el-table-column prop="name" label="环境标识"></el-table-column> <el-table-column prop="name" label="环境标识"></el-table-column>
<el-table-column prop="alias" label="环境名称"></el-table-column> <el-table-column prop="alias" label="环境名称"></el-table-column>
@@ -52,6 +64,7 @@ export default {
return { return {
list: [], list: [],
loading: false, loading: false,
queryAlias: '',
dialogVisible: false, dialogVisible: false,
dialogTitle: '', dialogTitle: '',
form: {}, form: {},
@@ -64,10 +77,19 @@ export default {
this.loadData() this.loadData()
}, },
methods: { methods: {
handleSearch() {
this.loadData()
},
handleReset() {
this.queryAlias = ''
this.loadData()
},
async loadData() { async loadData() {
this.loading = true this.loading = true
try { try {
const res = await request({ url: '/admin/profile/list', method: 'get' }) const params = {}
if (this.queryAlias) params.alias = this.queryAlias
const res = await request({ url: '/admin/profile/list', method: 'get', params })
this.list = res.data || [] this.list = res.data || []
} finally { } finally {
this.loading = false this.loading = false