mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-18 22:22:59 +08:00
feat: 主机快速命令增加排序 (#3707)
This commit is contained in:
parent
bbe1161dc2
commit
36a253ce03
@ -2,6 +2,8 @@ package dto
|
||||
|
||||
type SearchCommandWithPage struct {
|
||||
SearchWithPage
|
||||
OrderBy string `json:"orderBy"`
|
||||
Order string `json:"order"`
|
||||
GroupID uint `json:"groupID"`
|
||||
Info string `json:"info"`
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ func NewICommandService() ICommandService {
|
||||
}
|
||||
|
||||
func (u *CommandService) List() ([]dto.CommandInfo, error) {
|
||||
commands, err := commandRepo.GetList()
|
||||
commands, err := commandRepo.GetList(commonRepo.WithOrderBy("name"))
|
||||
if err != nil {
|
||||
return nil, constant.ErrRecordNotFound
|
||||
}
|
||||
@ -39,7 +39,7 @@ func (u *CommandService) List() ([]dto.CommandInfo, error) {
|
||||
}
|
||||
|
||||
func (u *CommandService) SearchForTree() ([]dto.CommandTree, error) {
|
||||
cmdList, err := commandRepo.GetList()
|
||||
cmdList, err := commandRepo.GetList(commonRepo.WithOrderBy("name"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -65,11 +65,11 @@ func (u *CommandService) SearchForTree() ([]dto.CommandTree, 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))
|
||||
total, commands, err := commandRepo.Page(search.Page, search.PageSize, commonRepo.WithLikeName(search.Info), commonRepo.WithByGroupID(search.GroupID), commonRepo.WithOrderRuleBy(search.OrderBy, search.Order))
|
||||
if err != nil {
|
||||
return 0, nil, err
|
||||
}
|
||||
groups, _ := groupRepo.GetList(commonRepo.WithByType("command"))
|
||||
groups, _ := groupRepo.GetList(commonRepo.WithByType("command"), commonRepo.WithOrderBy("name"))
|
||||
var dtoCommands []dto.CommandInfo
|
||||
for _, command := range commands {
|
||||
var item dto.CommandInfo
|
||||
|
@ -1,5 +1,3 @@
|
||||
import { ReqPage } from '.';
|
||||
|
||||
export namespace Command {
|
||||
export interface CommandInfo {
|
||||
id: number;
|
||||
@ -13,7 +11,4 @@ export namespace Command {
|
||||
groupID: number;
|
||||
command: string;
|
||||
}
|
||||
export interface CommandSearch extends ReqPage {
|
||||
info: string;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import http from '@/api';
|
||||
import { ResPage } from '../interface';
|
||||
import { ResPage, SearchWithPage } from '../interface';
|
||||
import { Command } from '../interface/command';
|
||||
import { Host } from '../interface/host';
|
||||
import { Base64 } from 'js-base64';
|
||||
@ -56,7 +56,7 @@ export const deleteHost = (params: { ids: number[] }) => {
|
||||
export const getCommandList = () => {
|
||||
return http.get<Array<Command.CommandInfo>>(`/hosts/command`, {});
|
||||
};
|
||||
export const getCommandPage = (params: Command.CommandSearch) => {
|
||||
export const getCommandPage = (params: SearchWithPage) => {
|
||||
return http.post<ResPage<Command.CommandInfo>>(`/hosts/command/search`, params);
|
||||
};
|
||||
export const getCommandTree = () => {
|
||||
|
@ -29,6 +29,7 @@
|
||||
:pagination-config="paginationConfig"
|
||||
v-model:selects="selects"
|
||||
:data="data"
|
||||
@sort-change="search"
|
||||
@search="search"
|
||||
>
|
||||
<el-table-column type="selection" fix />
|
||||
@ -38,12 +39,14 @@
|
||||
min-width="100"
|
||||
prop="name"
|
||||
fix
|
||||
sortable
|
||||
/>
|
||||
<el-table-column
|
||||
:label="$t('terminal.command')"
|
||||
min-width="300"
|
||||
show-overflow-tooltip
|
||||
prop="command"
|
||||
sortable
|
||||
/>
|
||||
<el-table-column
|
||||
:label="$t('commons.table.group')"
|
||||
@ -128,6 +131,8 @@ const paginationConfig = reactive({
|
||||
currentPage: 1,
|
||||
pageSize: 10,
|
||||
total: 0,
|
||||
orderBy: 'name',
|
||||
order: 'ascending',
|
||||
});
|
||||
const info = ref();
|
||||
const group = ref<string>('');
|
||||
@ -260,12 +265,16 @@ const buttons = [
|
||||
},
|
||||
];
|
||||
|
||||
const search = async () => {
|
||||
const search = async (column?: any) => {
|
||||
paginationConfig.orderBy = column?.order ? column.prop : paginationConfig.orderBy;
|
||||
paginationConfig.order = column?.order ? column.order : paginationConfig.order;
|
||||
let params = {
|
||||
page: paginationConfig.currentPage,
|
||||
pageSize: paginationConfig.pageSize,
|
||||
groupID: Number(group.value),
|
||||
info: info.value,
|
||||
orderBy: paginationConfig.orderBy,
|
||||
order: paginationConfig.order,
|
||||
};
|
||||
loading.value = true;
|
||||
await getCommandPage(params)
|
||||
|
Loading…
Reference in New Issue
Block a user