mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-31 22:18:07 +08:00
parent
92f019cf7c
commit
42dffe8078
@ -6,6 +6,7 @@ type SearchCommandWithPage struct {
|
|||||||
Order string `json:"order"`
|
Order string `json:"order"`
|
||||||
GroupID uint `json:"groupID"`
|
GroupID uint `json:"groupID"`
|
||||||
Info string `json:"info"`
|
Info string `json:"info"`
|
||||||
|
Name string `json:"name"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type CommandOperate struct {
|
type CommandOperate struct {
|
||||||
|
@ -16,6 +16,7 @@ type ICommandRepo interface {
|
|||||||
Update(id uint, vars map[string]interface{}) error
|
Update(id uint, vars map[string]interface{}) error
|
||||||
Delete(opts ...DBOption) error
|
Delete(opts ...DBOption) error
|
||||||
Get(opts ...DBOption) (model.Command, error)
|
Get(opts ...DBOption) (model.Command, error)
|
||||||
|
WithLikeName(name string) DBOption
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewICommandRepo() ICommandRepo {
|
func NewICommandRepo() ICommandRepo {
|
||||||
@ -79,3 +80,12 @@ func (u *CommandRepo) Delete(opts ...DBOption) error {
|
|||||||
}
|
}
|
||||||
return db.Delete(&model.Command{}).Error
|
return db.Delete(&model.Command{}).Error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a CommandRepo) WithLikeName(name string) DBOption {
|
||||||
|
return func(g *gorm.DB) *gorm.DB {
|
||||||
|
if len(name) == 0 {
|
||||||
|
return g
|
||||||
|
}
|
||||||
|
return g.Where("name like ? or command like ?", "%"+name+"%", "%"+name+"%")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -65,7 +65,7 @@ func (u *CommandService) SearchForTree() ([]dto.CommandTree, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (u *CommandService) SearchWithPage(search dto.SearchCommandWithPage) (int64, interface{}, error) {
|
func (u *CommandService) SearchWithPage(search dto.SearchCommandWithPage) (int64, interface{}, error) {
|
||||||
total, commands, err := commandRepo.Page(search.Page, search.PageSize, commonRepo.WithLikeName(search.Info), commonRepo.WithByGroupID(search.GroupID), commonRepo.WithOrderRuleBy(search.OrderBy, search.Order))
|
total, commands, err := commandRepo.Page(search.Page, search.PageSize, commandRepo.WithLikeName(search.Name), commonRepo.WithLikeName(search.Info), commonRepo.WithByGroupID(search.GroupID), commonRepo.WithOrderRuleBy(search.OrderBy, search.Order))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, nil, err
|
return 0, nil, err
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ export interface SearchWithPage {
|
|||||||
pageSize: number;
|
pageSize: number;
|
||||||
orderBy?: string;
|
orderBy?: string;
|
||||||
order?: string;
|
order?: string;
|
||||||
|
name?: string;
|
||||||
}
|
}
|
||||||
export interface CommonModel {
|
export interface CommonModel {
|
||||||
id: number;
|
id: number;
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
</el-button>
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
<template #search>
|
<template #search>
|
||||||
|
<el-row :gutter="5">
|
||||||
|
<el-col :xs="24" :sm="20" :md="20" :lg="20" :xl="20">
|
||||||
<el-select v-model="group" @change="search()" clearable class="p-w-200">
|
<el-select v-model="group" @change="search()" clearable class="p-w-200">
|
||||||
<template #prefix>{{ $t('terminal.group') }}</template>
|
<template #prefix>{{ $t('terminal.group') }}</template>
|
||||||
<el-option :label="$t('commons.table.all')" value=""></el-option>
|
<el-option :label="$t('commons.table.all')" value=""></el-option>
|
||||||
@ -23,6 +25,11 @@
|
|||||||
<el-option :value="item.id" :label="item.name" />
|
<el-option :value="item.id" :label="item.name" />
|
||||||
</div>
|
</div>
|
||||||
</el-select>
|
</el-select>
|
||||||
|
</el-col>
|
||||||
|
<el-col :xs="24" :sm="4" :md="4" :lg="4" :xl="4">
|
||||||
|
<TableSearch @search="search()" v-model:searchName="commandReq.name" />
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
</template>
|
</template>
|
||||||
<template #main>
|
<template #main>
|
||||||
<ComplexTable
|
<ComplexTable
|
||||||
@ -160,6 +167,10 @@ let commandInfo = reactive<Command.CommandOperate>({
|
|||||||
command: '',
|
command: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const commandReq = reactive({
|
||||||
|
name: '',
|
||||||
|
});
|
||||||
|
|
||||||
const cmdVisible = ref<boolean>(false);
|
const cmdVisible = ref<boolean>(false);
|
||||||
|
|
||||||
const loadGroups = async () => {
|
const loadGroups = async () => {
|
||||||
@ -274,6 +285,7 @@ const search = async (column?: any) => {
|
|||||||
info: info.value,
|
info: info.value,
|
||||||
orderBy: paginationConfig.orderBy,
|
orderBy: paginationConfig.orderBy,
|
||||||
order: paginationConfig.order,
|
order: paginationConfig.order,
|
||||||
|
name: commandReq.name,
|
||||||
};
|
};
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
await getCommandPage(params)
|
await getCommandPage(params)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user