作者 景龙
1 个管道 的构建 通过 耗费 1 秒

写后台报修改造导出excel

... ... @@ -609,6 +609,32 @@ class AdminCommonController extends AdminBaseController
return $res_ins;
}
//获取导出(报修改造)列表
public function exportRepairList($table,$param,$party,$field){
$res_ins = Db::name($table)
->alias('r')
->join('project p','r.project_id = p.id','LEFT')
->where(['r.party'=>$party])
->where(function (Query $query) use ($param){
if (!empty($param['name'])) {
$keyword = $param['name'];
$query->where('p.name', 'like', "%$keyword%");
}
$startTime = empty($param['start_time']) ? 0 : strtotime($param['start_time']);
$endTime = empty($param['end_time']) ? 0 : strtotime($param['end_time']);
if (!empty($startTime)) {
$query->where('r.create_time', '>=', $startTime);
}
if (!empty($endTime)) {
$query->where('r.create_time', '<=', $endTime);
}
})
->field($field)
->select()->toArray();
return $res_ins;
}
//导出月检报表详情
public function checkExportData($res){
$arr = [];
... ... @@ -785,6 +811,129 @@ class AdminCommonController extends AdminBaseController
return $arr;
}
//导出报修改造报表详情
public function repairExportData($res,$table,$party){
$arr = [];
//甲乙方logo,名称,报表名称
if($table == 'repair'){
if($party == 0){
$company = $this->getCompanyName($res['project_id'],'(甲方)报修');
}else{
$company = $this->getCompanyName($res['project_id'],'(乙方)报修');
}
}else{
if($party == 0){
$company = $this->getCompanyName($res['project_id'],'(甲方)改造');
}else{
$company = $this->getCompanyName($res['project_id'],'(乙方)改造');
}
}
if($company){
$arr['a_company'] = $company['a_company'];
$arr['b_company'] = $company['b_company'];
$arr['title'] = $company['title'];
}
//培训报修改造单号
$arr['number'] = $res['number'];
//报修改造人员(乙方项目组)
$arr['group_name'] = $this->getBUserByProject($res['project_id'],'id,b_sid',1);
//报修改造时间
$arr['create_time'] = date('Y/m/d',$res['create_time']);
$arr['time'] = date('Y-m-d',$res['create_time']);
//报修改造(甲方/乙方发起人)
$user = $this->getUserById(['id'=>$res['uid']]);
if($user){
$arr['user_login'] = $user['user_login'];
}else{
$arr['user_login'] = '';
}
//报修改造确认人(甲方发起,乙方确认,乙方发起,甲方确认)
$h_user = $this->getUserById(['id'=>$res['h_uid']]);
if($h_user){
$arr['h_user'] = $h_user['user_login'];
}else{
$arr['h_user'] = '';
}
//甲方确认完成人
$finish_user = $this->getUserById(['id'=>$res['confirm_uid']]);
if($finish_user){
$arr['confirm_user'] = $finish_user['user_login'];
}else{
$arr['confirm_user'] = '';
}
//报修改造工期及验收完成时间
if($res['finish_time']){
$arr['finish_time'] = date('Y/m/d',$res['finish_time']);
$arr['check_period'] = $this->getPeriod($res['finish_time'],$res['create_time']);
}else{
//验收完成时间
$arr['finish_time'] = '';
//工期
$arr['check_period'] = '';
}
//甲乙方图片凭证
if($res['images']){
$images = $this->exportUrl($res['images']);
$arr1 = $this->getDayImages($images);
if($party == 0){
$arr['repair'][0]['check_name'] = '甲方发起图片凭证';
}else{
$arr['repair'][0]['check_name'] = '乙方发起图片凭证';
}
$arr['repair'][0]['images'] = $arr1;
}else{
if($party == 0){
$arr['repair'][0]['check_name'] = '甲方发起图片凭证';
}else{
$arr['repair'][0]['check_name'] = '乙方发起图片凭证';
}
$arr['repair'][0]['images'] = [];
}
//甲乙方完善图片
if($table == 'repair'){
if($res['repair_images']){
$images = $this->exportUrl($res['repair_images']);
$arr1 = $this->getDayImages($images);
$arr['repair'][1]['check_name'] = '甲乙方完善图片';
$arr['repair'][1]['images'] = $arr1;
}else{
$arr['repair'][1]['check_name'] = '甲乙方完善图片';
$arr['repair'][1]['images'] = [];
}
}else{
if($res['reform_images']){
$images = $this->exportUrl($res['reform_images']);
$arr1 = $this->getDayImages($images);
$arr['repair'][1]['check_name'] = '甲乙方完善图片';
$arr['repair'][1]['images'] = $arr1;
}else{
$arr['repair'][1]['check_name'] = '甲乙方完善图片';
$arr['repair'][1]['images'] = [];
}
}
//确认图片
if($res['confirm_images']){
$images = $this->exportUrl($res['confirm_images']);
$arr1 = $this->getDayImages($images);
$arr['repair'][2]['check_name'] = '确认完成图片';
$arr['repair'][2]['images'] = $arr1;
}else{
$arr['repair'][2]['check_name'] = '确认完成图片';
$arr['repair'][2]['images'] = [];
}
return $arr;
}
//根据uid查询用户
public function getUserById($where){
$res = Db::name('user')
... ...
... ... @@ -792,4 +792,274 @@ class AdminExcelDataController extends AdminBaseController
return $url;
}
//报修改造渲染数据到表格上
public function repairExcelData($arr,$table,$party){
$spreadsheet = new Spreadsheet();
$adminCommon = new AdminCommonController();
$sheet = $spreadsheet->getActiveSheet();
$xlsName = $arr['time'];
//设置sheet名称
$name = '报表';
$name = $adminCommon->iconv_to_utf8($name);
$sheet->setTitle($xlsName.$name);
//合并单元格
//报表名称
$sheet->mergeCells('B1:J1');
//甲方logo,甲方公司名称
$sheet->mergeCells('B3:B4');
$sheet->mergeCells('C3:D3');
$sheet->mergeCells('C4:D4');
//乙方logo,乙方公司名称
$sheet->mergeCells('F3:F4');
$sheet->mergeCells('G3:I3');
$sheet->mergeCells('G4:I4');
//乙方发起人姓名
$sheet->mergeCells('B6:C6');
$sheet->mergeCells('B7:C7');
//乙方项目组
$sheet->mergeCells('F6:H6');
$sheet->mergeCells('F7:H7');
//培训演习状态
$sheet->mergeCells('I6:J6');
$sheet->mergeCells('I7:J7');
//培训演习单号
$sheet->mergeCells('K6:L6');
$sheet->mergeCells('K7:L7');
//甲方领导确认人
$sheet->mergeCells('B9:C9');
$sheet->mergeCells('B10:C10');
//乙方员工确认人
$sheet->mergeCells('D9:E9');
$sheet->mergeCells('D10:E10');
$spreadsheet->getDefaultStyle()->getFont()->setName('微软雅黑');//字体
//设置默认宽
$sheet->getDefaultColumnDimension()->setWidth(8);
//设置高度
$sheet->getRowDimension(1)->setRowHeight(45);
// $sheet->getRowDimension(2)->setRowHeight(55);
//***********************背景填充颜色*****************************
$sheet->getStyle( 'A1:M11')->getFill()->setFillType(\PHPExcel_Style_Fill::FILL_SOLID);
$sheet->getStyle( 'A1:M11')->getFill()->getStartColor()->setRGB('222B35');//背景颜色
//***********************画出单元格边框结束*****************************
//标题
$sheet->setCellValue('B1', $arr['title']);
$sheet->getStyle('B1')->getFont()->setSize(18);//字体大小
$sheet->getStyle('B1')->getFont()->getColor()->setRGB('FFFFFF');//设置颜色为白色
$sheet->getStyle('B1')->getFont()->setBold(true);//字体加粗
//甲方logo
$imageA = $arr['a_company']['logo'];
if(@fopen($imageA , 'r' ) ) {
//这是一个坑,刚开始我把实例化图片类放在了循环外面,但是失败了,也就是每个图片都要实例化一次
$imageADrawing = new Drawing();
$imageADrawing->setPath($imageA);
// 设置图片的宽度
$imageADrawing->setResizeProportional(false);
$imageADrawing->setWidthAndHeight(40,40);
//图片显示在B3
$imageADrawing->setCoordinates('B3');
$imageADrawing->setWorksheet($sheet);
}
$sheet->getStyle('B3:K10')->getFont()->setSize(8);//字体大小
$sheet->getStyle('C3:G3')->getFont()->getColor()->setRGB('949494');//设置颜色为灰色
$sheet->getStyle('B6:K6')->getFont()->getColor()->setRGB('949494');//设置颜色为灰色
$sheet->getStyle('B9:I9')->getFont()->getColor()->setRGB('949494');//设置颜色为灰色
$sheet->getStyle('C4:G4')->getFont()->getColor()->setRGB('FFFFFF');//设置颜色为白色
$sheet->getStyle('B7:K7')->getFont()->getColor()->setRGB('FFFFFF');//设置颜色为白色
$sheet->getStyle('B10:I10')->getFont()->getColor()->setRGB('FFFFFF');//设置颜色为白色
//甲方公司
$sheet->setCellValue('C3', '甲方公司');
//甲方公司名称
$sheet->setCellValue('C4', $arr['a_company']['company_name']);
//乙方logo
$imageB = $arr['b_company']['logo'];
if(@fopen($imageB , 'r' ) ) {
//这是一个坑,刚开始我把实例化图片类放在了循环外面,但是失败了,也就是每个图片都要实例化一次
$objDrawing = new Drawing();
$objDrawing->setPath($imageB);
// 设置图片的宽度
$objDrawing->setResizeProportional(false);
$objDrawing->setWidthAndHeight(40,40);
//图片显示在F3
$objDrawing->setCoordinates('F3');
$objDrawing->setWorksheet($sheet);
}
//乙方公司
$sheet->setCellValue('G3', '乙方公司');
//乙方公司名称
$sheet->setCellValue('G4', $arr['b_company']['company_name']);
//甲方/乙方发起人姓名
if($party == 0){
$sheet->setCellValue('B6', '甲方发起人');
}else{
$sheet->setCellValue('B6', '乙方发起人');
}
$sheet->setCellValue('B7', $arr['user_login']);
//报修改造时间
if($table == 'repair'){
$sheet->setCellValue('D6', '报修时间');
}else{
$sheet->setCellValue('D6', '改造时间');
}
$sheet->setCellValue('D7', $arr['create_time']);
//乙方项目组
$sheet->setCellValue('F6', '项目组');
$sheet->setCellValue('F7', $arr['group_name']);
//报修改造状态
if($table == 'repair'){
$sheet->setCellValue('I6', '报修状态');
}else{
$sheet->setCellValue('I6', '改造状态');
}
$sheet->setCellValue('I7', $arr['status']);
//报修改造单号
if($table == 'repair'){
$sheet->setCellValue('K6', '报修单号');
}else{
$sheet->setCellValue('K6', '改造单号');
}
$sheet->setCellValue('K7', $arr['number']);
$sheet->getStyle('K7')->getNumberFormat()->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_NUMBER);//解决长数字显示为科学计数法
//报修改造确认人(甲方发起,乙方确认,乙方发起,甲方确认)
if($party == 0){
$sheet->setCellValue('B9', '乙方员工确认人');
}else{
$sheet->setCellValue('B9', '甲方员工确认人');
}
$sheet->setCellValue('B10', $arr['h_user']);
//甲方员工确认完成人
$sheet->setCellValue('D9', '甲方员工确认完成人');
$sheet->setCellValue('D10', $arr['confirm_user']);
//完成时间
$sheet->setCellValue('F9', '完成时间');
$sheet->setCellValue('F10', $arr['finish_time']);
//工期
$sheet->setCellValue('I9', '工期(天)');
$sheet->setCellValue('I10', $arr['check_period']);
$array1 = [
'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_LEFT,
'textRotation' => 0,
'wrapText' => TRUE
];
$sheet->getStyle('K7')->getAlignment()->applyFromArray($array1);//垂直水平居左
$sheet->getStyle('F10')->getAlignment()->applyFromArray($array1);//垂直水平居左
$sheet->getStyle('I10')->getAlignment()->applyFromArray($array1);//垂直水平居左
//循环开始
$cols = 13;
$cells = ['C','E','G','I','K'];
foreach($arr['repair'] as $value){
$cols += 1;
//巡检点名称
$array = [
'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
'vertical' => \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER,
'textRotation' => 0,
'wrapText' => TRUE
];
$sheet->mergeCells('A'.$cols.':B'.$cols);
$sheet->setCellValue('A'.$cols, $value['check_name']);
$sheet->getStyle('A'.$cols)->getAlignment()->applyFromArray($array);//垂直水平居中
//循环第二层
foreach($value['images'] as $image_image){
//渲染图片日期
$col_day = $cols - 1;
$sheet->mergeCells('C'.$col_day.':D'.$col_day);
$sheet->setCellValue('C'.$col_day, $image_image['day']);
//获取图片个数
$length = count($image_image['image']);
$col = ceil($length/5);
for($i=0;$i<$col;$i++) {
$col_i = $cols + $i;
$sheet->getRowDimension($col_i)->setRowHeight(105);
$sheet->mergeCells('C' . $col_i . ':D' . $col_i);
$sheet->mergeCells('E' . $col_i . ':F' . $col_i);
$sheet->mergeCells('G' . $col_i . ':H' . $col_i);
$sheet->mergeCells('I' . $col_i . ':J' . $col_i);
$sheet->mergeCells('K' . $col_i . ':L' . $col_i);
$key = 0;
foreach($image_image['image'] as $k=>$image_value){
$pre = $i+4*$i;
$next = $i+1+4*($i+1);
if($k>=$pre && $k<$next){
//巡检图片
$image = $image_value['image_url'];
if(@fopen($image , 'r' ) ) {
//这是一个坑,刚开始我把实例化图片类放在了循环外面,但是失败了,也就是每个图片都要实例化一次
$obj = new Drawing();
$obj->setPath($image);
// 设置图片的宽度
$obj->setResizeProportional(false);
$obj->setWidthAndHeight(105,130);
//图片显示在F3
$obj->setCoordinates($cells[$key].$col_i);
$obj->setWorksheet($sheet);
}
$key++;
}
}
}
$cols += $col+1;
}
}
$sheet->getStyle( 'A12:M'.$cols)->getFill()->setFillType(\PHPExcel_Style_Fill::FILL_SOLID);
$sheet->getStyle( 'A12:M'.$cols)->getFill()->getStartColor()->setRGB('F3F3F4');//背景颜色浅灰色
$objWrite = IOFactory::createWriter($spreadsheet, 'Xls');
//直接从浏览器中输出star
// header('pragma:public');
// header("Content-Disposition:attachment;filename=出货装箱单.xls");
// $objWrite->save('php://output');
// exit;
//直接从浏览器中输出end
$file_name = $xlsName.'.xls';
$files_url = ROOT_PATH . '/public/upload/export';
if(!is_dir($files_url)){
mkdir($files_url);
}
$file_url = ROOT_PATH . '/public/upload/export/'.$file_name;
$objWrite->save($file_url);
$sys = $adminCommon->getOperateSys();
if($sys == 'Linux'){
chmod($file_url, 0777);//适用于linux
}
//相对路径
$url = 'upload/export/'.$file_name;
return $url;
}
}
... ...
... ... @@ -28,7 +28,7 @@ class AdminReformAController extends AdminBaseController
->alias('r')
->join('user u','r.uid = u.id','LEFT')
->join('project p','r.project_id = p.id','LEFT')
->where(['party'=>0])
->where(['r.party'=>0])
->where(function (Query $query) {
$param = $this->request->param();
if (!empty($param['name'])) {
... ... @@ -122,4 +122,44 @@ class AdminReformAController extends AdminBaseController
->find();
return $res;
}
//导出数据
public function exportData(){
$param = $this->request->param();
$adminCommon = new AdminCommonController();
$adminExcel = new AdminExcelDataController();
$res_ins = $adminCommon->exportRepairList('reform',$param,0,'r.*');
$arr_url = [];
$arr_time = [];
foreach($res_ins as $key=>$value){
$arr = $adminCommon->repairExportData($value,'reform',0);
$arr['status'] = $this->getStatus()[$value['status']];
//获取文件路径
$url = $adminExcel->repairExcelData($arr,'reform',0);
//按日导出
$arr_url[$key] = $url;
$arr_time[$key] = $arr['time'].'报表.xls';
}
$xlsName = '甲方改造报表';
//解决zip中文文件名
$xlsName = $adminCommon->iconv_to_utf8($xlsName);
$filename = ROOT_PATH . 'public/upload/export/' . $xlsName . '.zip';
$adminCommon->zip($arr_url,$filename,$arr_time);
}
//检查是否有数据
public function checkData(){
$param = $this->request->param();
$adminCommon = new AdminCommonController();
$res_ins = $adminCommon->exportRepairList('reform',$param,0,'r.id');
if($res_ins){
$adminCommon->apiResponse(1);
}else{
$adminCommon->apiResponse(0,'暂无数据');
}
}
}
... ...
... ... @@ -28,7 +28,7 @@ class AdminReformBController extends AdminBaseController
->alias('r')
->join('user u','r.uid = u.id','LEFT')
->join('project p','r.project_id = p.id','LEFT')
->where(['party'=>1])
->where(['r.party'=>1])
->where(function (Query $query) {
$param = $this->request->param();
if (!empty($param['name'])) {
... ... @@ -122,4 +122,44 @@ class AdminReformBController extends AdminBaseController
->find();
return $res;
}
//导出数据
public function exportData(){
$param = $this->request->param();
$adminCommon = new AdminCommonController();
$adminExcel = new AdminExcelDataController();
$res_ins = $adminCommon->exportRepairList('reform',$param,1,'r.*');
$arr_url = [];
$arr_time = [];
foreach($res_ins as $key=>$value){
$arr = $adminCommon->repairExportData($value,'reform',1);
$arr['status'] = $this->getStatus()[$value['status']];
//获取文件路径
$url = $adminExcel->repairExcelData($arr,'reform',1);
//按日导出
$arr_url[$key] = $url;
$arr_time[$key] = $arr['time'].'报表.xls';
}
$xlsName = '乙方改造报表';
//解决zip中文文件名
$xlsName = $adminCommon->iconv_to_utf8($xlsName);
$filename = ROOT_PATH . 'public/upload/export/' . $xlsName . '.zip';
$adminCommon->zip($arr_url,$filename,$arr_time);
}
//检查是否有数据
public function checkData(){
$param = $this->request->param();
$adminCommon = new AdminCommonController();
$res_ins = $adminCommon->exportRepairList('reform',$param,1,'r.id');
if($res_ins){
$adminCommon->apiResponse(1);
}else{
$adminCommon->apiResponse(0,'暂无数据');
}
}
}
... ...
... ... @@ -28,7 +28,7 @@ class AdminRepairAController extends AdminBaseController
->alias('r')
->join('user u','r.uid = u.id','LEFT')
->join('project p','r.project_id = p.id','LEFT')
->where(['party'=>0])
->where(['r.party'=>0])
->where(function (Query $query) {
$param = $this->request->param();
if (!empty($param['name'])) {
... ... @@ -122,4 +122,44 @@ class AdminRepairAController extends AdminBaseController
->find();
return $res;
}
//导出数据
public function exportData(){
$param = $this->request->param();
$adminCommon = new AdminCommonController();
$adminExcel = new AdminExcelDataController();
$res_ins = $adminCommon->exportRepairList('repair',$param,0,'r.*');
$arr_url = [];
$arr_time = [];
foreach($res_ins as $key=>$value){
$arr = $adminCommon->repairExportData($value,'repair',0);
$arr['status'] = $this->getStatus()[$value['status']];
//获取文件路径
$url = $adminExcel->repairExcelData($arr,'repair',0);
//按日导出
$arr_url[$key] = $url;
$arr_time[$key] = $arr['time'].'报表.xls';
}
$xlsName = '甲方报修报表';
//解决zip中文文件名
$xlsName = $adminCommon->iconv_to_utf8($xlsName);
$filename = ROOT_PATH . 'public/upload/export/' . $xlsName . '.zip';
$adminCommon->zip($arr_url,$filename,$arr_time);
}
//检查是否有数据
public function checkData(){
$param = $this->request->param();
$adminCommon = new AdminCommonController();
$res_ins = $adminCommon->exportRepairList('repair',$param,0,'r.id');
if($res_ins){
$adminCommon->apiResponse(1);
}else{
$adminCommon->apiResponse(0,'暂无数据');
}
}
}
... ...
... ... @@ -28,7 +28,7 @@ class AdminRepairBController extends AdminBaseController
->alias('r')
->join('user u','r.uid = u.id','LEFT')
->join('project p','r.project_id = p.id','LEFT')
->where(['party'=>1])
->where(['r.party'=>1])
->where(function (Query $query) {
$param = $this->request->param();
if (!empty($param['name'])) {
... ... @@ -122,4 +122,44 @@ class AdminRepairBController extends AdminBaseController
->find();
return $res;
}
//导出数据
public function exportData(){
$param = $this->request->param();
$adminCommon = new AdminCommonController();
$adminExcel = new AdminExcelDataController();
$res_ins = $adminCommon->exportRepairList('repair',$param,1,'r.*');
$arr_url = [];
$arr_time = [];
foreach($res_ins as $key=>$value){
$arr = $adminCommon->repairExportData($value,'repair',1);
$arr['status'] = $this->getStatus()[$value['status']];
//获取文件路径
$url = $adminExcel->repairExcelData($arr,'repair',1);
//按日导出
$arr_url[$key] = $url;
$arr_time[$key] = $arr['time'].'报表.xls';
}
$xlsName = '乙方报修报表';
//解决zip中文文件名
$xlsName = $adminCommon->iconv_to_utf8($xlsName);
$filename = ROOT_PATH . 'public/upload/export/' . $xlsName . '.zip';
$adminCommon->zip($arr_url,$filename,$arr_time);
}
//检查是否有数据
public function checkData(){
$param = $this->request->param();
$adminCommon = new AdminCommonController();
$res_ins = $adminCommon->exportRepairList('repair',$param,1,'r.id');
if($res_ins){
$adminCommon->apiResponse(1);
}else{
$adminCommon->apiResponse(0,'暂无数据');
}
}
}
... ...
... ... @@ -7,19 +7,15 @@
</ul>
<form class="well form-inline margin-top-20" method="post" action="{:url('AdminReformA/index')}">
项目名称:
<input class="form-control" type="text" name="name" style="width: 200px;" value="{:input('request.name')}"
placeholder="请输入项目名称">
<input class="form-control" type="text" name="name" style="width: 200px;" value="{:input('request.name')}" id="project_name" placeholder="请输入项目名称">
改造时间:
<input type="text" class="form-control js-bootstrap-datetime" name="start_time"
value="{$start_time|default=''}"
style="width: 140px;" autocomplete="off">-
<input type="text" class="form-control js-bootstrap-datetime" name="end_time"
value="{$end_time|default=''}"
style="width: 140px;" autocomplete="off"> &nbsp;
<input type="text" class="form-control js-bootstrap-datetime" style="width:160px;" name="start_time" value="{$start_time|default=''}" autocomplete="off" id="start_time" placeholder="请输入开始时间">-
<input type="text" class="form-control js-bootstrap-datetime" style="width:160px;" name="end_time" value="{$end_time|default=''}" autocomplete="off" id="end_time" placeholder="请输入结束时间"> &nbsp;
<input type="submit" class="btn btn-primary" value="搜索"/>
<a class="btn btn-danger" href="{:url('AdminReformA/index')}">清空</a>
</form>
<button class="btn btn-success" id="export_data">导出改造数据</button>
<form method="post" class="js-ajax-form">
<table class="table table-hover table-bordered">
<thead>
... ... @@ -63,4 +59,49 @@
</div>
<script src="__STATIC__/js/admin.js"></script>
</body>
</html>
\ No newline at end of file
</html>
<script>
$(function(){
//导出数据
$('#export_data').click(function(){
var project_name = $('#project_name').val();
var start_time = $('#start_time').val();
var end_time = $('#end_time').val();
var code = checkData(start_time,end_time,project_name);
if(code == 1){
window.location.href = 'exportData?start_time='+start_time+'&end_time='+end_time+'&name='+project_name;
}
});
});
//检查是否有可导出的数据
function checkData(start_time,end_time,project_name){
if(start_time == ''){
alert('请输入改造开始时间');
return false;
}
if(end_time == ''){
alert('请输入改造结束时间');
return false;
}
var code = 1;
$.ajax({
type:'GET',
url:'checkData' ,
data:{
'start_time':start_time,
'end_time':end_time,
'name':project_name
},
dataType:'json',
async:false,//同步
success:function(data){
if (data.code == 0) {
alert(data.msg);
code = 0;
}
}
});
return code;
}
</script>
\ No newline at end of file
... ...
... ... @@ -7,19 +7,15 @@
</ul>
<form class="well form-inline margin-top-20" method="post" action="{:url('AdminReformB/index')}">
项目名称:
<input class="form-control" type="text" name="name" style="width: 200px;" value="{:input('request.name')}"
placeholder="请输入项目名称">
<input class="form-control" type="text" name="name" style="width: 200px;" value="{:input('request.name')}" id="project_name" placeholder="请输入项目名称">
改造时间:
<input type="text" class="form-control js-bootstrap-datetime" name="start_time"
value="{$start_time|default=''}"
style="width: 140px;" autocomplete="off">-
<input type="text" class="form-control js-bootstrap-datetime" name="end_time"
value="{$end_time|default=''}"
style="width: 140px;" autocomplete="off"> &nbsp;
<input type="text" class="form-control js-bootstrap-datetime" style="width:160px;" name="start_time" value="{$start_time|default=''}" autocomplete="off" id="start_time" placeholder="请输入开始时间">-
<input type="text" class="form-control js-bootstrap-datetime" style="width:160px;" name="end_time" value="{$end_time|default=''}" autocomplete="off" id="end_time" placeholder="请输入结束时间"> &nbsp;
<input type="submit" class="btn btn-primary" value="搜索"/>
<a class="btn btn-danger" href="{:url('AdminReformB/index')}">清空</a>
</form>
<button class="btn btn-success" id="export_data">导出改造数据</button>
<form method="post" class="js-ajax-form">
<table class="table table-hover table-bordered">
<thead>
... ... @@ -63,4 +59,49 @@
</div>
<script src="__STATIC__/js/admin.js"></script>
</body>
</html>
\ No newline at end of file
</html>
<script>
$(function(){
//导出数据
$('#export_data').click(function(){
var project_name = $('#project_name').val();
var start_time = $('#start_time').val();
var end_time = $('#end_time').val();
var code = checkData(start_time,end_time,project_name);
if(code == 1){
window.location.href = 'exportData?start_time='+start_time+'&end_time='+end_time+'&name='+project_name;
}
});
});
//检查是否有可导出的数据
function checkData(start_time,end_time,project_name){
if(start_time == ''){
alert('请输入改造开始时间');
return false;
}
if(end_time == ''){
alert('请输入改造结束时间');
return false;
}
var code = 1;
$.ajax({
type:'GET',
url:'checkData' ,
data:{
'start_time':start_time,
'end_time':end_time,
'name':project_name
},
dataType:'json',
async:false,//同步
success:function(data){
if (data.code == 0) {
alert(data.msg);
code = 0;
}
}
});
return code;
}
</script>
\ No newline at end of file
... ...
... ... @@ -7,19 +7,15 @@
</ul>
<form class="well form-inline margin-top-20" method="post" action="{:url('AdminRepairA/index')}">
项目名称:
<input class="form-control" type="text" name="name" style="width: 200px;" value="{:input('request.name')}"
placeholder="请输入项目名称">
<input class="form-control" type="text" name="name" style="width: 200px;" value="{:input('request.name')}" id="project_name" placeholder="请输入项目名称">
报修时间:
<input type="text" class="form-control js-bootstrap-datetime" name="start_time"
value="{$start_time|default=''}"
style="width: 140px;" autocomplete="off">-
<input type="text" class="form-control js-bootstrap-datetime" name="end_time"
value="{$end_time|default=''}"
style="width: 140px;" autocomplete="off"> &nbsp;
<input type="text" class="form-control js-bootstrap-datetime" style="width:160px;" name="start_time" value="{$start_time|default=''}" autocomplete="off" id="start_time" placeholder="请输入开始时间">-
<input type="text" class="form-control js-bootstrap-datetime" style="width:160px;" name="end_time" value="{$end_time|default=''}" autocomplete="off" id="end_time" placeholder="请输入结束时间"> &nbsp;
<input type="submit" class="btn btn-primary" value="搜索"/>
<a class="btn btn-danger" href="{:url('AdminRepairA/index')}">清空</a>
</form>
<button class="btn btn-success" id="export_data">导出报修数据</button>
<form method="post" class="js-ajax-form">
<table class="table table-hover table-bordered">
<thead>
... ... @@ -63,4 +59,49 @@
</div>
<script src="__STATIC__/js/admin.js"></script>
</body>
</html>
\ No newline at end of file
</html>
<script>
$(function(){
//导出数据
$('#export_data').click(function(){
var project_name = $('#project_name').val();
var start_time = $('#start_time').val();
var end_time = $('#end_time').val();
var code = checkData(start_time,end_time,project_name);
if(code == 1){
window.location.href = 'exportData?start_time='+start_time+'&end_time='+end_time+'&name='+project_name;
}
});
});
//检查是否有可导出的数据
function checkData(start_time,end_time,project_name){
if(start_time == ''){
alert('请输入报修开始时间');
return false;
}
if(end_time == ''){
alert('请输入报修结束时间');
return false;
}
var code = 1;
$.ajax({
type:'GET',
url:'checkData' ,
data:{
'start_time':start_time,
'end_time':end_time,
'name':project_name
},
dataType:'json',
async:false,//同步
success:function(data){
if (data.code == 0) {
alert(data.msg);
code = 0;
}
}
});
return code;
}
</script>
\ No newline at end of file
... ...
... ... @@ -7,19 +7,15 @@
</ul>
<form class="well form-inline margin-top-20" method="post" action="{:url('AdminRepairB/index')}">
项目名称:
<input class="form-control" type="text" name="name" style="width: 200px;" value="{:input('request.name')}"
placeholder="请输入项目名称">
<input class="form-control" type="text" name="name" style="width: 200px;" value="{:input('request.name')}" id="project_name" placeholder="请输入项目名称">
报修时间:
<input type="text" class="form-control js-bootstrap-datetime" name="start_time"
value="{$start_time|default=''}"
style="width: 140px;" autocomplete="off">-
<input type="text" class="form-control js-bootstrap-datetime" name="end_time"
value="{$end_time|default=''}"
style="width: 140px;" autocomplete="off"> &nbsp;
<input type="text" class="form-control js-bootstrap-datetime" style="width:160px;" name="start_time" value="{$start_time|default=''}" autocomplete="off" id="start_time" placeholder="请输入开始时间">-
<input type="text" class="form-control js-bootstrap-datetime" style="width:160px;" name="end_time" value="{$end_time|default=''}" autocomplete="off" id="end_time" placeholder="请输入结束时间"> &nbsp;
<input type="submit" class="btn btn-primary" value="搜索"/>
<a class="btn btn-danger" href="{:url('AdminRepairB/index')}">清空</a>
</form>
<button class="btn btn-success" id="export_data">导出报修数据</button>
<form method="post" class="js-ajax-form">
<table class="table table-hover table-bordered">
<thead>
... ... @@ -63,4 +59,49 @@
</div>
<script src="__STATIC__/js/admin.js"></script>
</body>
</html>
\ No newline at end of file
</html>
<script>
$(function(){
//导出数据
$('#export_data').click(function(){
var project_name = $('#project_name').val();
var start_time = $('#start_time').val();
var end_time = $('#end_time').val();
var code = checkData(start_time,end_time,project_name);
if(code == 1){
window.location.href = 'exportData?start_time='+start_time+'&end_time='+end_time+'&name='+project_name;
}
});
});
//检查是否有可导出的数据
function checkData(start_time,end_time,project_name){
if(start_time == ''){
alert('请输入报修开始时间');
return false;
}
if(end_time == ''){
alert('请输入报修结束时间');
return false;
}
var code = 1;
$.ajax({
type:'GET',
url:'checkData' ,
data:{
'start_time':start_time,
'end_time':end_time,
'name':project_name
},
dataType:'json',
async:false,//同步
success:function(data){
if (data.code == 0) {
alert(data.msg);
code = 0;
}
}
});
return code;
}
</script>
\ No newline at end of file
... ...