代码生成新增自定义排序
This commit is contained in:
parent
61ab6961e5
commit
fbdb95fcdd
@ -28,7 +28,7 @@ $end
|
|||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
<!-- 数据区域 -->
|
<!-- 数据区域 -->
|
||||||
<el-table :data="dataList" v-loading="loading" ref="table" border highlight-current-row @selection-change="handleSelectionChange">
|
<el-table :data="dataList" v-loading="loading" ref="table" border highlight-current-row @sort-change="sortChange" @selection-change="handleSelectionChange">
|
||||||
<el-table-column type="selection" width="50" align="center"/>
|
<el-table-column type="selection" width="50" align="center"/>
|
||||||
${VueViewListContent}
|
${VueViewListContent}
|
||||||
<el-table-column label="操作" align="center" width="140">
|
<el-table-column label="操作" align="center" width="140">
|
||||||
@ -92,6 +92,8 @@ export default {
|
|||||||
queryParams: {
|
queryParams: {
|
||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
pageSize: 20,
|
pageSize: 20,
|
||||||
|
sort: undefined,
|
||||||
|
sortType: undefined,
|
||||||
$foreach(item in genTable.Columns)
|
$foreach(item in genTable.Columns)
|
||||||
$if(item.IsQuery == true)
|
$if(item.IsQuery == true)
|
||||||
${item.CsharpFieldFl}: undefined,
|
${item.CsharpFieldFl}: undefined,
|
||||||
@ -199,7 +201,7 @@ $end
|
|||||||
};
|
};
|
||||||
this.resetForm("form");
|
this.resetForm("form");
|
||||||
},
|
},
|
||||||
/** 重置查询操作 */
|
// 重置查询操作
|
||||||
resetQuery() {
|
resetQuery() {
|
||||||
this.timeRange = [];
|
this.timeRange = [];
|
||||||
$foreach(item in genTable.Columns)
|
$foreach(item in genTable.Columns)
|
||||||
@ -216,6 +218,18 @@ $end
|
|||||||
this.ids = selection.map((item) => item.${replaceDto.FistLowerPk});
|
this.ids = selection.map((item) => item.${replaceDto.FistLowerPk});
|
||||||
this.single = selection.length != 1
|
this.single = selection.length != 1
|
||||||
this.multiple = !selection.length;
|
this.multiple = !selection.length;
|
||||||
|
},
|
||||||
|
// 自定义排序
|
||||||
|
sortChange(column) {
|
||||||
|
if (column.prop == null || column.order == null) {
|
||||||
|
this.queryParams.sort = undefined;
|
||||||
|
this.queryParams.sortType = undefined;
|
||||||
|
} else {
|
||||||
|
this.queryParams.sort = column.prop;
|
||||||
|
this.queryParams.sortType = column.order;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.handleQuery();
|
||||||
},
|
},
|
||||||
/** 搜索按钮操作 */
|
/** 搜索按钮操作 */
|
||||||
handleQuery() {
|
handleQuery() {
|
||||||
|
|||||||
@ -18,14 +18,6 @@ namespace ZR.Model
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public int PageIndex { get; set; } = 1;
|
public int PageIndex { get; set; } = 1;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 排序列
|
|
||||||
/// </summary>
|
|
||||||
public string Sort { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 排序类型
|
|
||||||
/// </summary>
|
|
||||||
public string SortType { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 总记录数
|
/// 总记录数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int TotalNum { get; set; }
|
public int TotalNum { get; set; }
|
||||||
@ -50,7 +42,7 @@ namespace ZR.Model
|
|||||||
public List<T> Result { get; set; }
|
public List<T> Result { get; set; }
|
||||||
|
|
||||||
public PagedInfo()
|
public PagedInfo()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,7 @@ namespace ZR.Model
|
|||||||
/// 当前页码
|
/// 当前页码
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int PageNum { get; set; }
|
public int PageNum { get; set; }
|
||||||
private int pageSize;
|
public int PageSize { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 总记录数
|
/// 总记录数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -27,11 +27,16 @@ namespace ZR.Model
|
|||||||
{
|
{
|
||||||
return TotalNum > 0 ? TotalNum % PageSize == 0 ? TotalNum / PageSize : TotalNum / PageSize + 1 : 0;
|
return TotalNum > 0 ? TotalNum % PageSize == 0 ? TotalNum / PageSize : TotalNum / PageSize + 1 : 0;
|
||||||
}
|
}
|
||||||
set { }
|
|
||||||
}
|
}
|
||||||
public int PageSize { get => pageSize; set => pageSize = value; }
|
|
||||||
public string Sort { get; set; }
|
/// <summary>
|
||||||
public string OrderBy { get; set; }
|
/// 排序字段
|
||||||
|
/// </summary>
|
||||||
|
public string Sort { get; set; } = string.Empty;
|
||||||
|
/// <summary>
|
||||||
|
/// 排序类型,前端传入的是"ascending","descending"
|
||||||
|
/// </summary>
|
||||||
|
public string SortType { get; set; } = string.Empty;
|
||||||
public PagerInfo()
|
public PagerInfo()
|
||||||
{
|
{
|
||||||
PageNum = 1;
|
PageNum = 1;
|
||||||
|
|||||||
@ -418,7 +418,7 @@ namespace ZR.Repository
|
|||||||
page.PageSize = parm.PageSize;
|
page.PageSize = parm.PageSize;
|
||||||
page.PageIndex = parm.PageNum;
|
page.PageIndex = parm.PageNum;
|
||||||
|
|
||||||
page.Result = source.OrderByIF(!string.IsNullOrEmpty(parm.Sort), $"{parm.OrderBy} {(parm.Sort == "desc" ? "desc" : "asc")}")
|
page.Result = source.OrderByIF(!string.IsNullOrEmpty(parm.Sort), $"{parm.Sort} {(parm.SortType.Contains("desc") ? "desc" : "asc")}")
|
||||||
.ToPageList(parm.PageNum, parm.PageSize, ref total);
|
.ToPageList(parm.PageNum, parm.PageSize, ref total);
|
||||||
page.TotalNum = total;
|
page.TotalNum = total;
|
||||||
return page;
|
return page;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user