feat: add tenant list id sorting
This commit is contained in:
@@ -92,9 +92,20 @@ func (s *sSysImTenant) List(ctx context.Context, in *sysin.ImTenantListInp) (lis
|
|||||||
mod = mod.WhereBetween(dao.ImTenant.Columns().CreatedAt, in.CreatedAt[0], in.CreatedAt[1])
|
mod = mod.WhereBetween(dao.ImTenant.Columns().CreatedAt, in.CreatedAt[0], in.CreatedAt[1])
|
||||||
}
|
}
|
||||||
|
|
||||||
mod = mod.Page(in.Page, in.PerPage).
|
orderDesc := false
|
||||||
OrderDesc(dao.ImTenant.Columns().Id).
|
for _, sorter := range in.GetSorters() {
|
||||||
Hook(hook.MemberSummary)
|
if sorter != nil && sorter.ColumnKey == "id" {
|
||||||
|
orderDesc = sorter.Order == "descend"
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mod = mod.Page(in.Page, in.PerPage)
|
||||||
|
if orderDesc {
|
||||||
|
mod = mod.OrderDesc(dao.ImTenant.Columns().Id)
|
||||||
|
} else {
|
||||||
|
mod = mod.OrderAsc(dao.ImTenant.Columns().Id)
|
||||||
|
}
|
||||||
|
mod = mod.Hook(hook.MemberSummary)
|
||||||
|
|
||||||
if err = mod.ScanAndCount(&list, &totalCount, false); err != nil {
|
if err = mod.ScanAndCount(&list, &totalCount, false); err != nil {
|
||||||
err = gerror.Wrap(err, "获取IM租户列表失败,请稍后重试!")
|
err = gerror.Wrap(err, "获取IM租户列表失败,请稍后重试!")
|
||||||
|
|||||||
@@ -100,6 +100,7 @@ type ImTenantViewModel struct {
|
|||||||
// ImTenantListInp 获取IM租户列表
|
// ImTenantListInp 获取IM租户列表
|
||||||
type ImTenantListInp struct {
|
type ImTenantListInp struct {
|
||||||
form.PageReq
|
form.PageReq
|
||||||
|
form.Sorters
|
||||||
Id int64 `json:"id" dc:"ID"`
|
Id int64 `json:"id" dc:"ID"`
|
||||||
Code string `json:"code" dc:"租户编码"`
|
Code string `json:"code" dc:"租户编码"`
|
||||||
Name string `json:"name" dc:"租户名称"`
|
Name string `json:"name" dc:"租户名称"`
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
:actionColumn="actionColumn"
|
:actionColumn="actionColumn"
|
||||||
:scroll-x="scrollX"
|
:scroll-x="scrollX"
|
||||||
:resizeHeightOffset="-10000"
|
:resizeHeightOffset="-10000"
|
||||||
|
@update:sorter="handleUpdateSorter"
|
||||||
>
|
>
|
||||||
<template #tableTitle>
|
<template #tableTitle>
|
||||||
<n-button
|
<n-button
|
||||||
@@ -49,6 +50,7 @@
|
|||||||
import { BasicTable, TableAction } from '@/components/Table';
|
import { BasicTable, TableAction } from '@/components/Table';
|
||||||
import { BasicForm, useForm } from '@/components/Form/index';
|
import { BasicForm, useForm } from '@/components/Form/index';
|
||||||
import { usePermission } from '@/hooks/web/usePermission';
|
import { usePermission } from '@/hooks/web/usePermission';
|
||||||
|
import useSorter from '@/hooks/common/useSorter';
|
||||||
import { useDictStore } from '@/store/modules/dict';
|
import { useDictStore } from '@/store/modules/dict';
|
||||||
import { List, Restore, Status } from '@/api/imTenant';
|
import { List, Restore, Status } from '@/api/imTenant';
|
||||||
import { PlusOutlined } from '@vicons/antd';
|
import { PlusOutlined } from '@vicons/antd';
|
||||||
@@ -66,6 +68,7 @@
|
|||||||
const editRef = ref();
|
const editRef = ref();
|
||||||
const usageRef = ref();
|
const usageRef = ref();
|
||||||
const deletionCheckRef = ref();
|
const deletionCheckRef = ref();
|
||||||
|
const { updateSorter: handleUpdateSorter, sortStatesRef } = useSorter(reloadTable);
|
||||||
|
|
||||||
const actionColumn = reactive({
|
const actionColumn = reactive({
|
||||||
width: 320,
|
width: 320,
|
||||||
@@ -130,7 +133,11 @@
|
|||||||
|
|
||||||
// 加载表格数据
|
// 加载表格数据
|
||||||
const loadDataTable = async (res) => {
|
const loadDataTable = async (res) => {
|
||||||
return await List({ ...searchFormRef.value?.formModel, ...res });
|
return await List({
|
||||||
|
...searchFormRef.value?.formModel,
|
||||||
|
sorters: sortStatesRef.value,
|
||||||
|
...res,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// 重新加载表格数据
|
// 重新加载表格数据
|
||||||
|
|||||||
@@ -145,6 +145,8 @@ const baseColumns = [
|
|||||||
key: 'id',
|
key: 'id',
|
||||||
align: 'left',
|
align: 'left',
|
||||||
width: 70,
|
width: 70,
|
||||||
|
sorter: true,
|
||||||
|
defaultSortOrder: 'ascend',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '商户编码',
|
title: '商户编码',
|
||||||
|
|||||||
Reference in New Issue
Block a user