在OA系统中经常会用到汇总的数据,以下的代码可以方便调用中的汇总功能
在index方法或者_before_index方法里加入如下
$this->_count['field']['id']='count';// 统计个数据
$this->_count['field']['money']='sum';//合计数
$this->_count['group']['cat_id']='desc';//按照分类来统计 }
前台页面调用_count_list_这个变量进行循环,如果没有设置$this->_count['group']数组的话,就不不用循环输出
<foreach name="_count_list_" item="info">
<tr>
<td>{$file_category[$info[cat_id]]}</td>
<td>{$info[count_id]}</td>
</tr>
</foreach>
注意: $this->_count['field'][id]在变量中会作为count_id,他是根据其值是coun还是sum来决定。
本文介绍了一种在OA系统中实现数据汇总的方法。通过在index或_before_index方法中使用特定代码,可以轻松地实现数据计数和求和等操作,并按分类进行统计。文章还提供了如何在前端页面上展示这些汇总数据的具体实例。
757

被折叠的 条评论
为什么被折叠?



