美化导出表格格式
This commit is contained in:
1 parent
8c4b557cc2
commit
3363b0dcfa
6 files changed
+343
-293
No files matched your search
+211
-242
@@ -11,212 +11,212 @@
|
||||
|
||||
// 应用公共文件
|
||||
|
||||
// 获取类别列表
|
||||
function getCategory($str = 0)
|
||||
{
|
||||
|
||||
$category = new \app\system\model\Category;
|
||||
|
||||
// 如果参数格式不为数字的时候查询$pid
|
||||
if(is_numeric($str) == false)
|
||||
// 获取类别列表
|
||||
function getCategory($str = 0)
|
||||
{
|
||||
// 根据父级id查询类别列表
|
||||
$str = $category
|
||||
->where('title',$str)
|
||||
->value('id');
|
||||
}
|
||||
|
||||
$category = new \app\system\model\Category;
|
||||
|
||||
$str == '' || $str == null ? $str=0 :$str=$str;
|
||||
|
||||
|
||||
// 根据父级id查询类别列表
|
||||
$list = $category
|
||||
->where('pid',$str)
|
||||
->where('status',1)
|
||||
->field('id,title')
|
||||
->select();
|
||||
|
||||
|
||||
// 返回类别列表
|
||||
return $list;
|
||||
}
|
||||
|
||||
|
||||
function nianjiList($riqi=0)
|
||||
{
|
||||
// 定义学年时间节点日期为每年的8月1日
|
||||
// $yd = '8-1';
|
||||
if($riqi == 0)
|
||||
{
|
||||
$jiedian = strtotime(date('Y').'-8-1');
|
||||
$thisday = time();
|
||||
$nian = date('Y');
|
||||
}else{
|
||||
$jiedian = strtotime(date('Y',$riqi).'-8-1');
|
||||
$thisday = $riqi;
|
||||
$nian = date('Y',$riqi);
|
||||
}
|
||||
|
||||
|
||||
if($thisday<=$jiedian)
|
||||
{
|
||||
$str = 1;
|
||||
}else{
|
||||
$str = 0;
|
||||
}
|
||||
|
||||
|
||||
$nian = $nian - $str;
|
||||
|
||||
$njlist = array();
|
||||
|
||||
$njlist[$nian]='一年级';
|
||||
$njlist[$nian-1]='二年级';
|
||||
$njlist[$nian-2]='三年级';
|
||||
$njlist[$nian-3]='四年级';
|
||||
$njlist[$nian-4]='五年级';
|
||||
$njlist[$nian-5]='六年级';
|
||||
|
||||
return $njlist;
|
||||
}
|
||||
|
||||
|
||||
// 班级列表
|
||||
function banjinamelist()
|
||||
{
|
||||
$bjarr = array(
|
||||
'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'=>'二十五班',
|
||||
);
|
||||
|
||||
return $bjarr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* $date是时间戳
|
||||
* $type为1的时候是虚岁,2的时候是周岁
|
||||
*/
|
||||
function getAgeByBirth($date = 0,$type = 1){
|
||||
$nowYear = date("Y",time());
|
||||
$nowMonth = date("m",time());
|
||||
$nowDay = date("d",time());
|
||||
$birthYear = date("Y",$date);
|
||||
$birthMonth = date("m",$date);
|
||||
$birthDay = date("d",$date);
|
||||
if($type == 1){
|
||||
$age = $nowYear - ($birthYear - 1);
|
||||
}elseif($type == 2){
|
||||
if($nowMonth<$birthMonth){
|
||||
$age = $nowYear - $birthYear - 1;
|
||||
}elseif($nowMonth==$birthMonth){
|
||||
if($nowDay<$birthDay){
|
||||
$age = $nowYear - $birthYear - 1;
|
||||
}else{
|
||||
$age = $nowYear - $birthYear;
|
||||
}
|
||||
}else{
|
||||
$age = $nowYear - $birthYear;
|
||||
}
|
||||
}
|
||||
return $age;
|
||||
}
|
||||
|
||||
|
||||
// EXCEL表格列名
|
||||
function excelLieming()
|
||||
{
|
||||
$liemingarr = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','AA','AB','AC','AD','AE','AF','AG','AH','AI','AJ','AK','AL','AM','AN','AO','AP','AQ','AR','AS','AT','AU','AV','AW','AX','AY','AZ','BA','BB','BC','BD','BE','BF','BG','BH','BI','BJ','BK','BL','BM','BN','BO','BP','BQ','BR','BS','BT','BU','BV','BW'];
|
||||
return $liemingarr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 单位列表
|
||||
function schlist($low='班级',$high='其它级',$xueduan=array())
|
||||
{
|
||||
|
||||
// 实例化单位模型
|
||||
$sch = new \app\system\model\School;
|
||||
// 实例化类别数据模型
|
||||
$cat = new \app\system\model\Category;
|
||||
// 获取获取级别列表
|
||||
$catlist = $cat->where('pid',102)
|
||||
->where('status',1)
|
||||
->column('id','title');
|
||||
|
||||
// 获取学段列表
|
||||
if(count($xueduan)>0){
|
||||
$xdlist = $cat->where('pid',103)
|
||||
->where('status',1)
|
||||
->where('title','in',$xueduan)
|
||||
->column('id');
|
||||
}else{
|
||||
$xdlist = $cat->where('pid',103)
|
||||
->where('status',1)
|
||||
->column('id');
|
||||
}
|
||||
|
||||
|
||||
// 查询学校
|
||||
$schlist = $sch->where('jibie','between',[$catlist[$low],$catlist[$high]])
|
||||
->where('status',1)
|
||||
->where('xueduan','in',$xdlist)
|
||||
->order(['paixu'])
|
||||
->field('id,title,jiancheng')
|
||||
->select();
|
||||
|
||||
return $schlist;
|
||||
}
|
||||
|
||||
|
||||
// 整理教师名
|
||||
function teacherNames($list = array())
|
||||
{
|
||||
if(count($list) == 0 )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
$names = '';
|
||||
foreach ($list as $key => $value) {
|
||||
if($key == 0)
|
||||
// 如果参数格式不为数字的时候查询$pid
|
||||
if(is_numeric($str) == false)
|
||||
{
|
||||
$names = $value['teacher']['xingming'];
|
||||
}else{
|
||||
$names = $names . '、'. $value['teacher']['xingming'];
|
||||
// 根据父级id查询类别列表
|
||||
$str = $category
|
||||
->where('title',$str)
|
||||
->value('id');
|
||||
}
|
||||
|
||||
|
||||
$str == '' || $str == null ? $str=0 :$str=$str;
|
||||
|
||||
|
||||
// 根据父级id查询类别列表
|
||||
$list = $category
|
||||
->where('pid',$str)
|
||||
->where('status',1)
|
||||
->field('id,title')
|
||||
->select();
|
||||
|
||||
|
||||
// 返回类别列表
|
||||
return $list;
|
||||
}
|
||||
|
||||
return $names;
|
||||
}
|
||||
|
||||
function nianjiList($riqi=0)
|
||||
{
|
||||
// 定义学年时间节点日期为每年的8月1日
|
||||
// $yd = '8-1';
|
||||
if($riqi == 0)
|
||||
{
|
||||
$jiedian = strtotime(date('Y').'-8-1');
|
||||
$thisday = time();
|
||||
$nian = date('Y');
|
||||
}else{
|
||||
$jiedian = strtotime(date('Y',$riqi).'-8-1');
|
||||
$thisday = $riqi;
|
||||
$nian = date('Y',$riqi);
|
||||
}
|
||||
|
||||
|
||||
if($thisday<=$jiedian)
|
||||
{
|
||||
$str = 1;
|
||||
}else{
|
||||
$str = 0;
|
||||
}
|
||||
|
||||
|
||||
$nian = $nian - $str;
|
||||
|
||||
$njlist = array();
|
||||
|
||||
$njlist[$nian]='一年级';
|
||||
$njlist[$nian-1]='二年级';
|
||||
$njlist[$nian-2]='三年级';
|
||||
$njlist[$nian-3]='四年级';
|
||||
$njlist[$nian-4]='五年级';
|
||||
$njlist[$nian-5]='六年级';
|
||||
|
||||
return $njlist;
|
||||
}
|
||||
|
||||
|
||||
// 班级列表
|
||||
function banjinamelist()
|
||||
{
|
||||
$bjarr = array(
|
||||
'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'=>'二十五班',
|
||||
);
|
||||
|
||||
return $bjarr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* $date是时间戳
|
||||
* $type为1的时候是虚岁,2的时候是周岁
|
||||
*/
|
||||
function getAgeByBirth($date = 0,$type = 1){
|
||||
$nowYear = date("Y",time());
|
||||
$nowMonth = date("m",time());
|
||||
$nowDay = date("d",time());
|
||||
$birthYear = date("Y",$date);
|
||||
$birthMonth = date("m",$date);
|
||||
$birthDay = date("d",$date);
|
||||
if($type == 1){
|
||||
$age = $nowYear - ($birthYear - 1);
|
||||
}elseif($type == 2){
|
||||
if($nowMonth<$birthMonth){
|
||||
$age = $nowYear - $birthYear - 1;
|
||||
}elseif($nowMonth==$birthMonth){
|
||||
if($nowDay<$birthDay){
|
||||
$age = $nowYear - $birthYear - 1;
|
||||
}else{
|
||||
$age = $nowYear - $birthYear;
|
||||
}
|
||||
}else{
|
||||
$age = $nowYear - $birthYear;
|
||||
}
|
||||
}
|
||||
return $age;
|
||||
}
|
||||
|
||||
|
||||
// EXCEL表格列名
|
||||
function excelLieming()
|
||||
{
|
||||
$liemingarr = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','AA','AB','AC','AD','AE','AF','AG','AH','AI','AJ','AK','AL','AM','AN','AO','AP','AQ','AR','AS','AT','AU','AV','AW','AX','AY','AZ','BA','BB','BC','BD','BE','BF','BG','BH','BI','BJ','BK','BL','BM','BN','BO','BP','BQ','BR','BS','BT','BU','BV','BW'];
|
||||
return $liemingarr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 单位列表
|
||||
function schlist($low='班级',$high='其它级',$xueduan=array())
|
||||
{
|
||||
|
||||
// 实例化单位模型
|
||||
$sch = new \app\system\model\School;
|
||||
// 实例化类别数据模型
|
||||
$cat = new \app\system\model\Category;
|
||||
// 获取获取级别列表
|
||||
$catlist = $cat->where('pid',102)
|
||||
->where('status',1)
|
||||
->column('id','title');
|
||||
|
||||
// 获取学段列表
|
||||
if(count($xueduan)>0){
|
||||
$xdlist = $cat->where('pid',103)
|
||||
->where('status',1)
|
||||
->where('title','in',$xueduan)
|
||||
->column('id');
|
||||
}else{
|
||||
$xdlist = $cat->where('pid',103)
|
||||
->where('status',1)
|
||||
->column('id');
|
||||
}
|
||||
|
||||
|
||||
// 查询学校
|
||||
$schlist = $sch->where('jibie','between',[$catlist[$low],$catlist[$high]])
|
||||
->where('status',1)
|
||||
->where('xueduan','in',$xdlist)
|
||||
->order(['paixu'])
|
||||
->field('id,title,jiancheng')
|
||||
->select();
|
||||
|
||||
return $schlist;
|
||||
}
|
||||
|
||||
|
||||
// 整理教师名
|
||||
function teacherNames($list = array())
|
||||
{
|
||||
if(count($list) == 0 )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
$names = '';
|
||||
foreach ($list as $key => $value) {
|
||||
if($key == 0)
|
||||
{
|
||||
$names = $value['teacher']['xingming'];
|
||||
}else{
|
||||
$names = $names . '、'. $value['teacher']['xingming'];
|
||||
}
|
||||
}
|
||||
|
||||
return $names;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -275,37 +275,6 @@ function teacherNames($list = array())
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 数组重新排序
|
||||
* $array 要排序的数组
|
||||
* $field 排序字段
|
||||
* $sort 排序方式 SORT_DESC 降序;SORT_ASC 升序
|
||||
* */
|
||||
// function arraySequence($data, $field = 'id', $sort = 'desc') {
|
||||
|
||||
// // // 获取当前地址
|
||||
// // $mod = strtolower(app('http')->getName());
|
||||
// // $con = strtolower(request()->controller());
|
||||
// // $act = strtolower(request()->action());
|
||||
|
||||
// // $url = $mod.'/'.$con.'/'.$act;
|
||||
|
||||
// // halt($url);
|
||||
// // 排序方式
|
||||
// $sort == 'desc' ? $sort = 'SORT_DESC' : $sort = 'SORT_ASC';
|
||||
// // 获取参考列
|
||||
// $column = array_column($data, $field);
|
||||
// // 排序
|
||||
// array_multisort($column, $sort, $data);
|
||||
|
||||
|
||||
|
||||
// return $data;
|
||||
// }
|
||||
|
||||
function sortArrByManyField(){
|
||||
$args = func_get_args();
|
||||
if(empty($args)){
|
||||
@@ -395,21 +364,21 @@ function subjectList()
|
||||
* @param str或array $str 表单中获取的参数
|
||||
* @return array 返回类型
|
||||
*/
|
||||
function strToarray($str)
|
||||
{
|
||||
// 如果str是字符串,则转换成数组
|
||||
if(is_array($str)==false)
|
||||
function strToarray($str)
|
||||
{
|
||||
$str = explode(',', $str);
|
||||
}
|
||||
// 循环数组,删除空元素
|
||||
foreach ($str as $key => $value) {
|
||||
if($value == "" && $value == null){
|
||||
unset($str[$key]);
|
||||
// 如果str是字符串,则转换成数组
|
||||
if(is_array($str)==false)
|
||||
{
|
||||
$str = explode(',', $str);
|
||||
}
|
||||
// 循环数组,删除空元素
|
||||
foreach ($str as $key => $value) {
|
||||
if($value == "" && $value == null){
|
||||
unset($str[$key]);
|
||||
}
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user