|
|
|
|
@ -25,6 +25,8 @@ use Illuminate\Http\Request;
|
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
|
use Kris\LaravelFormBuilder\FormBuilder;
|
|
|
|
|
use Maatwebsite\Excel\Facades\Excel;
|
|
|
|
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
|
|
|
|
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
|
|
|
|
use Spatie\Permission\Models\Role;
|
|
|
|
|
|
|
|
|
|
class ProjectController extends CommonController
|
|
|
|
|
@ -294,6 +296,7 @@ class ProjectController extends CommonController
|
|
|
|
|
*/
|
|
|
|
|
public function askSubmit()
|
|
|
|
|
{
|
|
|
|
|
$is_export = \request('export', 0);
|
|
|
|
|
$userId = auth()->id();
|
|
|
|
|
$project_id = \request('project_id', 0);
|
|
|
|
|
$projects = (new ProjectController())->_checkProjects();
|
|
|
|
|
@ -308,8 +311,48 @@ class ProjectController extends CommonController
|
|
|
|
|
->where(function ($qeury) use ($hushizhang, $userId, $project_id) {
|
|
|
|
|
if ($hushizhang) $qeury->where('admin_id', $userId);
|
|
|
|
|
if ($project_id) $qeury->where('project_id', $project_id);
|
|
|
|
|
})->paginate(10);
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 导出
|
|
|
|
|
if ($is_export) {
|
|
|
|
|
$data = $data->get()->toArray();
|
|
|
|
|
$spreadsheet = new Spreadsheet();
|
|
|
|
|
$sheet = $spreadsheet->getActiveSheet();
|
|
|
|
|
$sheet->setCellValue('A1', '日期');
|
|
|
|
|
$sheet->setCellValue('B1', '名字');
|
|
|
|
|
$sheet->setCellValue('C1', '医院');
|
|
|
|
|
$sheet->setCellValue('D1', '详情');
|
|
|
|
|
$sheet->setCellValue('E1', '建议');
|
|
|
|
|
$sheet->setCellValue('F1', '总分');
|
|
|
|
|
|
|
|
|
|
$sheet->getColumnDimension('A')->setWidth(20);
|
|
|
|
|
$sheet->getColumnDimension('B')->setWidth(20);
|
|
|
|
|
$sheet->getColumnDimension('C')->setWidth(20);
|
|
|
|
|
$sheet->getColumnDimension('D')->setWidth(60);
|
|
|
|
|
$sheet->getColumnDimension('E')->setWidth(20);
|
|
|
|
|
$sheet->getColumnDimension('F')->setWidth(20);
|
|
|
|
|
|
|
|
|
|
$count = count($data); //计算有多少条数据
|
|
|
|
|
for ($i = 2; $i <= $count + 1; $i++) {
|
|
|
|
|
$content = '';
|
|
|
|
|
foreach ($data[$i - 2]['content'] as $item) {
|
|
|
|
|
$content .= $item['ask'] . ':' . $item['score'] . "\n";
|
|
|
|
|
}
|
|
|
|
|
$sheet->setCellValue('A' . $i, $data[$i - 2]['date']);
|
|
|
|
|
$sheet->setCellValue('B' . $i, $data[$i - 2]['admin']['name']);
|
|
|
|
|
$sheet->setCellValue('C' . $i, $data[$i - 2]['project']['name']);
|
|
|
|
|
$sheet->setCellValue('D' . $i, $content);
|
|
|
|
|
$sheet->setCellValue('E' . $i, $data[$i - 2]['tip']);
|
|
|
|
|
$sheet->setCellValue('F' . $i, $data[$i - 2]['score']);
|
|
|
|
|
}
|
|
|
|
|
header('Content-Type: application/vnd.ms-excel');
|
|
|
|
|
header('Content-Disposition: attachment;filename="' . '满意度调查_' . date('YmdHis') . '.xlsx"');
|
|
|
|
|
header('Cache-Control: max-age=0');
|
|
|
|
|
$writer = new Xlsx($spreadsheet);
|
|
|
|
|
$writer->save('php://output');
|
|
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
$data = $data->paginate(10);
|
|
|
|
|
return view($this->bladePath . ".asksubmit_index", compact("data", "projects", "project_id"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|