切换导航条
此项目
正在载入...
登录
王智
/
baoxiu
·
提交
转到一个项目
GitLab
转到仪表盘
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
王智
4 years ago
提交
4e66db705114f45fadc8d1ac3e9b3511f24a3dde
1 个父辈
50fa0807
baoxiu22
隐藏空白字符变更
内嵌
并排对比
正在显示
2 个修改的文件
包含
60 行增加
和
88 行删除
application/admin/controller/Dashboard.php
application/admin/view/dashboard/index.html
application/admin/controller/Dashboard.php
查看文件 @
4e66db7
...
...
@@ -107,99 +107,66 @@ class Dashboard extends Backend
}
//自定义导出
public
function
exportDayInner
(){
$ZhanDianArr
=
Db
::
name
(
'zhandian'
)
->
select
();
foreach
(
$ZhanDianArr
as
$k
=>
$v
)
{
$data
[
$k
][
'id'
]
=
$v
[
'id'
];
$data
[
$k
][
'zhandian_name'
]
=
$v
[
'zhandian'
];
$BaoXiuZhandian
=
Db
::
name
(
'baoxiudan'
)
->
where
(
'zhandian_id'
,
$v
[
'id'
])
->
where
(
$map
)
->
select
();
$BaoxiuWancheng
=
Db
::
name
(
'baoxiudan'
)
->
where
(
'zhandian_id'
,
$v
[
'id'
])
->
where
(
$map
)
->
where
(
'type'
,
2
)
->
select
();
$BaoxiuWeiWancheng
=
Db
::
name
(
'baoxiudan'
)
->
where
(
'zhandian_id'
,
$v
[
'id'
])
->
where
(
$map
)
->
where
(
'type'
,
1
)
->
select
();
if
(
empty
(
$BaoXiuZhandian
))
{
$data
[
$k
][
'baoxiu_num'
]
=
0
;
$data
[
$k
][
'BaoXiuStr'
]
=
''
;
$data
[
$k
][
'Round'
]
=
'无记录'
;
$data
[
$k
][
'WRound'
]
=
'无记录'
;
public
function
out
(){
$result
=
Db
::
name
(
'applet_user'
)
->
field
(
'id,name,mobile,colleges'
)
->
order
(
'id desc'
)
->
select
();
$filename
=
"用户测评数据"
;
vendor
(
'PHPExcel.PHPExcel'
);
$objPHPExcel
=
new
\PHPExcel
();
//设置保存版本格式
$objWriter
=
new
\PHPExcel_Writer_Excel5
(
$objPHPExcel
);
//设置表头
$objPHPExcel
->
getActiveSheet
()
->
setCellValue
(
'A1'
,
'id'
);
$objPHPExcel
->
getActiveSheet
()
->
setCellValue
(
'B1'
,
'姓名'
);
$objPHPExcel
->
getActiveSheet
()
->
setCellValue
(
'C1'
,
'手机'
);
$objPHPExcel
->
getActiveSheet
()
->
setCellValue
(
'D1'
,
'意向院校'
);
$objPHPExcel
->
getActiveSheet
()
->
setCellValue
(
'E1'
,
'测评分值'
);
$objPHPExcel
->
getActiveSheet
()
->
setCellValue
(
'F1'
,
'学历背景得分'
);
$objPHPExcel
->
getActiveSheet
()
->
setCellValue
(
'G1'
,
'企业背景得分'
);
$objPHPExcel
->
getActiveSheet
()
->
setCellValue
(
'H1'
,
'收入水平得分'
);
$objPHPExcel
->
getActiveSheet
()
->
setCellValue
(
'I1'
,
'发展潜力得分'
);
$objPHPExcel
->
getActiveSheet
()
->
setCellValue
(
'J1'
,
'管理经验得分'
);
$objPHPExcel
->
getActiveSheet
()
->
setCellValue
(
'K1'
,
'英语水平得分'
);
$objPHPExcel
->
getActiveSheet
()
->
setCellValue
(
'L1'
,
'背景优势'
);
$objPHPExcel
->
getActiveSheet
()
->
setCellValue
(
'M1'
,
'背景劣势'
);
$objPHPExcel
->
getActiveSheet
()
->
setCellValue
(
'N1'
,
'匹配院校'
);
//改变此处设置的长度数值
$objPHPExcel
->
getActiveSheet
()
->
getColumnDimension
(
'A'
)
->
setWidth
(
10
);
$objPHPExcel
->
getActiveSheet
()
->
getColumnDimension
(
'B'
)
->
setWidth
(
12
);
//输出表格
$str
=
'用户未进行测评'
;
foreach
(
$result
as
$key
=>
&
$val
)
{
$count
=
Db
::
name
(
'applet_answer'
)
->
where
([
'uid'
=>
$val
[
'id'
],
'isdelete'
=>
0
])
->
count
();
$i
=
$key
+
2
;
//表格是从2开始的
if
(
$count
>=
1
){
$row
=
SubjectService
::
getResult
(
$val
[
'id'
],
''
);
//score--1学历背景 2企业背景 3收入水平 4发展潜力 5管理经验 6英语水平
//优势
$advan
=
$row
[
'advan'
]
?
implode
(
'、'
,
$row
[
'advan'
])
:
'暂无优势'
;
$inferi
=
$row
[
'inferi'
]
?
implode
(
'、'
,
$row
[
'inferi'
])
:
'暂无劣势'
;
$colllist
=
$row
[
'colllist'
]
?
implode
(
'、'
,
array_column
(
$row
[
'colllist'
],
'title'
))
:
'无匹配院校'
;
//$score = Db::name('applet_answer')->where(['uid'=>$val['id'],'isdelete'=>0])->sum('score');
//dump($row);exit();
$objPHPExcel
->
getActiveSheet
()
->
setCellValue
(
'A'
.
$i
,
$val
[
'id'
]);
$objPHPExcel
->
getActiveSheet
()
->
setCellValue
(
'B'
.
$i
,
$val
[
'name'
]);
$objPHPExcel
->
getActiveSheet
()
->
setCellValue
(
'C'
.
$i
,
$val
[
'mobile'
]);
$objPHPExcel
->
getActiveSheet
()
->
setCellValue
(
'D'
.
$i
,
$val
[
'colleges'
]);
$objPHPExcel
->
getActiveSheet
()
->
setCellValue
(
'E'
.
$i
,
$row
[
'totalscore'
]);
$objPHPExcel
->
getActiveSheet
()
->
setCellValue
(
'F'
.
$i
,
$row
[
'score'
][
0
]);
$objPHPExcel
->
getActiveSheet
()
->
setCellValue
(
'G'
.
$i
,
$row
[
'score'
][
1
]);
$objPHPExcel
->
getActiveSheet
()
->
setCellValue
(
'H'
.
$i
,
$row
[
'score'
][
2
]);
$objPHPExcel
->
getActiveSheet
()
->
setCellValue
(
'I'
.
$i
,
$row
[
'score'
][
3
]);
$objPHPExcel
->
getActiveSheet
()
->
setCellValue
(
'J'
.
$i
,
$row
[
'score'
][
4
]);
$objPHPExcel
->
getActiveSheet
()
->
setCellValue
(
'K'
.
$i
,
$row
[
'score'
][
5
]);
$objPHPExcel
->
getActiveSheet
()
->
setCellValue
(
'L'
.
$i
,
$advan
);
$objPHPExcel
->
getActiveSheet
()
->
setCellValue
(
'M'
.
$i
,
$inferi
);
$objPHPExcel
->
getActiveSheet
()
->
setCellValue
(
'N'
.
$i
,
$colllist
);
}
else
{
$objPHPExcel
->
getActiveSheet
()
->
setCellValue
(
'A'
.
$i
,
$val
[
'id'
]);
$objPHPExcel
->
getActiveSheet
()
->
setCellValue
(
'B'
.
$i
,
$val
[
'name'
]);
$objPHPExcel
->
getActiveSheet
()
->
setCellValue
(
'C'
.
$i
,
$val
[
'mobile'
]);
$objPHPExcel
->
getActiveSheet
()
->
setCellValue
(
'D'
.
$i
,
$val
[
'colleges'
]);
$objPHPExcel
->
getActiveSheet
()
->
setCellValue
(
'E'
.
$i
,
$str
);
$objPHPExcel
->
getActiveSheet
()
->
setCellValue
(
'F'
.
$i
,
$str
);
$objPHPExcel
->
getActiveSheet
()
->
setCellValue
(
'G'
.
$i
,
$str
);
$objPHPExcel
->
getActiveSheet
()
->
setCellValue
(
'H'
.
$i
,
$str
);
$objPHPExcel
->
getActiveSheet
()
->
setCellValue
(
'I'
.
$i
,
$str
);
$objPHPExcel
->
getActiveSheet
()
->
setCellValue
(
'J'
.
$i
,
$str
);
$objPHPExcel
->
getActiveSheet
()
->
setCellValue
(
'K'
.
$i
,
$str
);
$objPHPExcel
->
getActiveSheet
()
->
setCellValue
(
'L'
.
$i
,
$str
);
$objPHPExcel
->
getActiveSheet
()
->
setCellValue
(
'M'
.
$i
,
$str
);
$objPHPExcel
->
getActiveSheet
()
->
setCellValue
(
'N'
.
$i
,
$str
);
}
else
{
$data
[
$k
][
'baoxiu_num'
]
=
count
(
$BaoXiuZhandian
);
foreach
(
$BaoXiuZhandian
as
$k1
=>
$v1
)
{
$StrArr
[
$k1
]
=
$v1
[
'colum'
];
}
$Round
=
round
(
count
(
$BaoxiuWancheng
)
/
count
(
$BaoXiuZhandian
)
*
100
,
2
);
$WRound
=
round
(
count
(
$BaoxiuWeiWancheng
)
/
count
(
$BaoXiuZhandian
)
*
100
,
2
);
$data
[
$k
][
'BaoXiuStr'
]
=
implode
(
$StrArr
,
','
);
$data
[
$k
][
'Round'
]
=
$Round
.
'%'
;
$data
[
$k
][
'WRound'
]
=
$WRound
.
'%'
;
}
}
$table
=
''
;
$table
.=
"<table>
<thead>
<tr>
<th class='name'>站点</th>
<th class='name'>报修单数量</th>
<th class='name'>报修完成率</th>
<th class='name'>报修未完成率</th>
<th class='name'>故障设备名称</th>
</tr>
</thead>
<tbody>"
;
foreach
(
$data
as
$v
)
{
$table
.=
"<tr>
<td class='name'>
{
$v
[
'zhandian_name'
]}
</
td
>
<
td
class
='
name
'>{$v['
baoxiu_num
']}</td>
<td class='
name
'>{$v['
Round
']}</td>
<td class='
name
'>{$v['
WRound
']}</td>
<td class='
name
'>{$v['
BaoXiuStr
']}</td>
</tr>";
}
$table .= "</tbody>
</table>";
//通过header头控制输出excel表格
header("Pragma: public");
header("Expires: 0");
header("Cache-Control:must-revalidate, post-check=0, pre-check=0");
header("Content-Type:application/force-download");
header("Content-Type:application/vnd.ms-execl");
header("Content-Type:application/octet-stream");
header
(
"Content-Type:application/download"
);
header
(
'Content-Disposition:attachment;filename='
.
$filename
.
'.xls'
);
header("Content-Type:application/download");;
header('
Content
-
Disposition
:
attachment
;
filename
=
"入库明细表.xls"
'
);
header
(
"Content-Transfer-Encoding:binary"
);
$objWriter
->
save
(
'php://output'
)
;
echo
$table
;
}
}
...
...
application/admin/view/dashboard/index.html
查看文件 @
4e66db7
...
...
@@ -156,11 +156,8 @@
<ul
class=
"nav nav-tabs"
>
<li
class=
"active"
><a
href=
"#one"
data-toggle=
"tab"
>
{:__('Dashboard')}
</a></li>
<!--<li><a href="#two" data-toggle="tab">详细1报表</a></li>-->
<a
href=
"dashboard/out"
class=
"btn btn-danger btn-import spec_add_btn"
data-title=
"导出测评数据"
data-multiple=
"false"
initialized=
"true"
style=
"position: relative; z-index: 1;"
>
<i
class=
"fa fa-download"
></i>
导出数据
</a>
</ul>
<button
id=
"btn"
onclick=
"threeFn()"
>
导出
</button>
</div>
<div
class=
"panel-body"
>
<div
id=
"myTabContent"
class=
"tab-content"
>
...
...
@@ -353,3 +350,11 @@
<!--}-->
<!--;-->
<!--</script>-->
<script>
var
btn
=
document
.
getElementById
(
"btn"
);
// 第一种 通过点击事件
btn
.
onclick
=
function
()
{
Fast
.
api
.
ajax
(
'dashboard/exportDayInner'
);
}
</script>
...
...
请
注册
或
登录
后发表评论