|
@@ -4,6 +4,7 @@ namespace app\company\controller;
|
|
|
|
|
|
use app\common\controller\Apic;
|
|
|
use think\Db;
|
|
|
+use app\common\library\ExcelCsv;
|
|
|
/**
|
|
|
* 月检进度表
|
|
|
*/
|
|
@@ -165,6 +166,8 @@ class Yuejian extends Apic
|
|
|
'month_12' => $month_data['month_12']['total'],
|
|
|
];
|
|
|
|
|
|
+ $bottom_list_export = $bottom_list;
|
|
|
+
|
|
|
//重整结果集,替换,对号,错号,空白
|
|
|
foreach($bottom_list as $bk => $bottom){
|
|
|
foreach($bottom as $key => $val){
|
|
@@ -183,6 +186,24 @@ class Yuejian extends Apic
|
|
|
$bottom_list[$bk] = $bottom;
|
|
|
}
|
|
|
|
|
|
+ //重整结果集,替换,对号,错号,空白
|
|
|
+ foreach($bottom_list_export as $bk => $bottom){
|
|
|
+ foreach($bottom as $key => $val){
|
|
|
+
|
|
|
+ if(strpos($key,'month_') !== false){
|
|
|
+ //这里严格用===是因为,php7.4里: '一切字符串'==0 为true
|
|
|
+ if($val === 'moren'){$val = '';}
|
|
|
+ elseif($val === 1){$val = 'V';}
|
|
|
+ elseif($val === 0){$val = 'X';}
|
|
|
+ }
|
|
|
+
|
|
|
+ $bottom[$key] = $val;
|
|
|
+ }
|
|
|
+
|
|
|
+ $bottom['endtime'] = date('Y-m-d',$bottom['endtime']);
|
|
|
+ $bottom_list_export[$bk] = $bottom;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
//组合结果
|
|
|
$result[] = $top1;
|
|
@@ -190,7 +211,49 @@ class Yuejian extends Apic
|
|
|
$result[] = $top3;
|
|
|
$result = array_merge($result,$bottom_list);
|
|
|
|
|
|
- $this->success(1,$result);
|
|
|
+
|
|
|
+ //导出excel
|
|
|
+ $action = input('action','');
|
|
|
+ if($action == 'export'){
|
|
|
+
|
|
|
+ //表头
|
|
|
+ $excel_header = [
|
|
|
+ 'num' => '序号',
|
|
|
+ 'companyname' => '合同单位',
|
|
|
+ 'projectname' => '项目名称',
|
|
|
+ 'endtime' => '终止日期',
|
|
|
+ 'month_01' => '1月',
|
|
|
+ 'month_02' => '2月',
|
|
|
+ 'month_03' => '3月',
|
|
|
+ 'month_04' => '4月',
|
|
|
+ 'month_05' => '5月',
|
|
|
+ 'month_06' => '6月',
|
|
|
+ 'month_07' => '7月',
|
|
|
+ 'month_08' => '8月',
|
|
|
+ 'month_09' => '9月',
|
|
|
+ 'month_10' => '10月',
|
|
|
+ 'month_11' => '11月',
|
|
|
+ 'month_12' => '12月',
|
|
|
+ ];
|
|
|
+
|
|
|
+ //内容
|
|
|
+ $excel_result[] = $top1;
|
|
|
+ $excel_result[] = $top2;
|
|
|
+ $excel_result[] = $top3;
|
|
|
+ $excel_result = array_merge($excel_result,$bottom_list_export);
|
|
|
+
|
|
|
+ //文件输出
|
|
|
+ $worker_info = Db::name('worker')->where('id',$worker_id)->value('truename');
|
|
|
+
|
|
|
+ $fileName = $year.'年'.$worker_info.'月检-' . date('Y-m-d-H-i-s');
|
|
|
+ $ExcelCsv = new ExcelCsv($excel_header, $excel_result);
|
|
|
+ $data = $ExcelCsv->collection();
|
|
|
+ $ExcelCsv->download($fileName, $excel_header, $data);
|
|
|
+
|
|
|
+ }else{
|
|
|
+ $this->success(1,$result);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|
|
|
|