# table 显示合计
# 前端合计处理
onInited() {
//设置主表合计
this.summary = true;
//如果有明细表,设置明细表合计
this.detailOptions.summary = true;
//设置主表求字段,后台需要实现SummaryExpress方法
this.columns.forEach(x => {
if (x.field == '字段') {
x.summary = true;
//计算平均值
//x.summary = 'avg';//2023.05.03更新voltable文件后才能使用
//设置小数显示位数(默认2位)
// x.numberLength = 4;
}
})
//明细表合计同上
//this.detailOptions.columns.forEach
//一对多明细表
// this.details.forEach(x=>{
// if(x.table=='明细表'){
// x.columns.forEach(col=>{
// //操作同上
// })
// }
// })
// //一对多三级明细表
// this.subDetails.forEach(x=>{
// if(x.table=='明细表'){
// x.columns.forEach(col=>{
// //操作同上
// })
// }
// })
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# 后台合计处理
在后台Partial文件夹下找到当前[表名Service.cs]类,实现下面的GetPageData方法
/// <summary>
/// 主表设置合计
/// </summary>
/// <param name="options"></param>
/// <returns></returns>
public override PageGridData<Demo_Product> GetPageData(PageDataOptions options)
{
//查询table界面显示求和
SummaryExpress = (IQueryable<Demo_Product> queryable) =>
{
return queryable.GroupBy(x => 1).Select(x => new
{
//注意大小写和数据库字段大小写一样
Price = x.Sum(o => o.Price)
})
.FirstOrDefault();
};
return base.GetPageData(options);
}
// /// <summary>
// /// 设置弹出框明细表的合计信息(没有明细表的不用设置)
// /// </summary>
// /// <typeparam name="detail"></typeparam>
// /// <param name="queryeable"></param>
// /// <returns></returns>
// protected override object GetDetailSummary<detail>(IQueryable<detail> queryeable)
// {
// //判断是哪个明细表
// if (typeof(detail)==typeof(Demo_ProductColor))
// {
// //转换为明细表
// return (queryeable as IQueryable<Demo_ProductColor>).GroupBy(x => 1).Select(x => new
// {
// //Qty注意大小写和数据库字段大小写一样
// // Qty = x.Average(o => o.Qty),
// }).FirstOrDefault();
// }
// return null;
// }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
← table多级表头 table动态隐藏列 →