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

增加后台年检管理模块

... ... @@ -548,11 +548,32 @@ return array (
'remark.require' => '检测备注不能为空',
]
],
'add_status' => [
'rule' => [
'spot_id' => 'require|number',
'project_id' => 'require|number',
'test_id' => 'require|number',
'status' => 'require|number',
'images' => 'require|array',
],
'msg' => [
'spot_id.require' => '检测点id不能为空',
'spot_id.number' => '检测点id必须为数字',
'project_id.require' => '项目id不能为空',
'project_id.number' => '项目id必须为数字',
'test_id.require' => '检测id不能为空',
'test_id.number' => '检测id必须为数字',
'status.require' => '检测状态不能为空',
'status.number' => '检测状态必须为数字',
'images.require' => '检测图片不能为空',
'images.array' => '检测图片必须为数组',
]
],
'test_status' => [
'rule' => [
'spot_id' => 'require|number',
'status' => 'require|number',
// 'images' => 'require|array',
'images' => 'require|array',
],
'msg' => [
'spot_id.require' => '检测点id不能为空',
... ...
... ... @@ -746,13 +746,12 @@ class CommonController extends RestBaseController
->field('id,user_login')
->select()
->toArray();
if(!empty($flag)){
$users = trim(implode(array_column($user_login,'user_login'),'、'),'、');
}else{
if(empty($flag)){
$users = trim(implode(array_column($user_login,'user_login'),'/'),'/');
}
return $users;
}
return $user_login;
}
//根据项目id获取甲方项目组人员
public function getUserByProject($project_id,$field){
... ... @@ -1083,6 +1082,63 @@ class CommonController extends RestBaseController
return ceil($count/$limit);
}
//获取乙方领导年检检测列表
public function getTestReportList($table,$pids,$data){
$res = Db::name($table)
->alias('t')
->join('project p','t.project_id = p.id','LEFT')
->whereIn('t.project_id',$pids)
->where(function ($query) use ($data) {
//项目id
$project_id = !empty($data['project_id'])&&isset($data['project_id'])?$data['project_id']:'';
if (!empty($project_id)) {
$query->where('t.project_id', $project_id);
}
//日期范围查询
$startTime = isset($data['start_time'])&&!empty($data['start_time'])?$data['start_time']:'';
$endTime = isset($data['end_time'])&&!empty($data['end_time'])?$data['end_time']:'';
if (!empty($startTime)) {
$query->where('t.test_time', '>=', $startTime);
}
if (!empty($endTime)) {
$query->where('t.test_time', '<=', $endTime);
}
})
->field('t.id,t.test_time,t.project_id,p.name project_name')
->select()
->toArray();
return $res;
}
//获取乙方年检检测列表总页数
public function getTestReportCount($table,$pids,$data){
$count = Db::name($table)
->alias('t')
->join('project p','t.project_id = p.id','LEFT')
->whereIn('t.project_id',$pids)
->where(function ($query) use ($data) {
//项目id
$project_id = !empty($data['project_id'])&&isset($data['project_id'])?$data['project_id']:'';
if (!empty($project_id)) {
$query->where('t.project_id', $project_id);
}
//日期范围查询
$startTime = isset($data['start_time'])&&!empty($data['start_time'])?$data['start_time']:'';
$endTime = isset($data['end_time'])&&!empty($data['end_time'])?$data['end_time']:'';
if (!empty($startTime)) {
$query->where('t.test_time', '>=', $startTime);
}
if (!empty($endTime)) {
$query->where('t.test_time', '<=', $endTime);
}
})
->count();
$limit = config('site.limit');
return ceil($count/$limit);
}
//获取项目状态
public function getProjectStatus(){
$status = [
... ... @@ -1953,20 +2009,30 @@ class CommonController extends RestBaseController
$where = ['party'=>$res['party'],'project_id'=>$res['project_id']];
$field = 'id,status,uid,point_id,images,create_time';
$arr['inspect'] = $this->getInspectList($where,$field,$res['project_id'],'inspect');
//日检时间
$arr['inspect_time'] = $res['create_time'];
}else{
//年检
$where = ['party'=>$res['party'],'project_id'=>$res['project_id']];
//年检检测
$where = ['project_id'=>$res['project_id'],'test_id'=>$res['id']];
$field = 'id,status,uid,spot_id,images,create_time';
$arr['years'] = $this->getInspectList($where,$field,$res['project_id'],'years');
}
//检测时间
$arr['test_time'] = $res['test_time'];
}
if($flag == 'inspect'){
//月检人员(乙方项目组)
if($res['party'] == 0){
//甲方
$arr['inspect_name'] = $this->getUserByProject($res['project_id'],'id,a_sid');
}else{
$arr['years_name'] = $this->getUserByProjectId($res['project_id'],'id,b_sid',1);
$arr['inspect_name'] = $this->getUserByProjectId($res['project_id'],'id,b_sid',1);
}
}else{
//乙方项目组
$arr['inspect_name'] = $this->getUserByProjectId($res['project_id'],'id,b_sid',1);
}
//评价内容
... ... @@ -2020,7 +2086,7 @@ class CommonController extends RestBaseController
$point_list = $this->getPoint(['p_id'=>$project_id],'id,point_name');
}else{
//年检
$point_list = $this->getSpot(['p_id'=>$project_id],'id,spot_name');
$point_list = $this->getSpot(['project_id'=>$project_id],'id,spot_name');
}
... ...
... ... @@ -108,7 +108,7 @@ class ReportController extends RestBaseController
* @param name:end_time type:inter require:0 default: other desc:开始日期(检索结束日期)
*
* @return data:列表@
* @data id:列表id project_id:项目id project_name:项目名称 create_time:年检时间 user_group:项目组人员
* @data id:列表id project_id:项目id project_name:项目名称 test_time:检测时间 user_group:项目组人员
* @return page:当前页数
* @return total_page:总页数
*/
... ... @@ -127,19 +127,13 @@ class ReportController extends RestBaseController
//根据企业id查询项目id
$pIds = $common->getCheckStatus($user,$company_id);
$result = $common->getInspectReportList('years',$user['party'],$pIds,$data);
//查找项目组人员名称
$result = $common->getTestReportList('test',$pIds,$data);
//查找项目组乙方人员名称
foreach($result as &$value){
if($user['party'] == 0){
//甲方项目组
$user_group = $common->getUserByProject($value['project_id'],'id,a_sid');
$value['user_group'] = trim(implode(array_column($user_group,'user_login'),'/'),'/');
}else{
//乙方项目组
$value['user_group'] = $common->getUserByProjectId($value['project_id'],'id,b_sid');
}
}
$total_page = $common->getInspectReportCount('years',$user['party'],$pIds,$data);
$total_page = $common->getTestReportCount('test',$pIds,$data);
$res['data'] = $result;
$res['page'] = intval($data['page']);
$res['total_page'] = $total_page;
... ... @@ -268,6 +262,8 @@ class ReportController extends RestBaseController
* @return title:报表名称
* @return inspect_name:项目组(甲方或者乙方)
*
* @return inspect_time:日检巡检时间
*
* @return inspect:日检@
* @inspect day:日检日期 point:日检点列表@
* @point point_id:日检点id status:日检点状态(0:正常,1:故障,2:未检查) user_login:检查人姓名 point_name:日检点名称 images:日检图片@
... ... @@ -384,6 +380,8 @@ class ReportController extends RestBaseController
* @return title:报表名称
* @return inspect_name:项目组(甲方或者乙方)
*
* @return test_time:检测时间
*
* @return years:年检@
* @years day:年检日期 point:年检点列表@
* @point spot_id:年检点id status:日检点状态(0:正常,1:故障,2:未检查) user_login:检查人姓名 spot_name:年检点名称 images:年检图片@
... ... @@ -403,7 +401,7 @@ class ReportController extends RestBaseController
$this->error($validate->getError());
}
$arr = [];
$res = Db::name('years')
$res = Db::name('test')
->where(['id'=>$data['id']])
->find();
... ...
... ... @@ -50,6 +50,7 @@ class YearsController extends RestBaseController
$data['project_id'] = $user['project_id'];
$data['create_time'] = time();
$data['uid'] = $this->userId;
$test = new TestModel();
$res = $test->create($data);
if($res){
... ... @@ -237,7 +238,9 @@ class YearsController extends RestBaseController
*
* @return id:检测点id
* @return spot_name:检测点名称
* @return test_id:检测id
* @return status:检测点状态(0:正常,1:故障,2:未检测)
* @return project_id:项目id
* @return images:检测点图片@
* @images image_url:图片路径 file_time:图片时间
*/
... ... @@ -252,24 +255,21 @@ class YearsController extends RestBaseController
//查询年检名称,状态
$res = Db::name('spot')
->where(['id'=>$id])
->field('id,test_id,spot_name')
->field('id,test_id,spot_name,project_id')
->find();
$arr = [];
if($res){
$arr['id'] = $res['id'];
$arr['spot_name'] = $res['spot_name'];
$arr['status'] = 2;
$arr['images'] = [];
$res['status'] = 2;
$res['images'] = [];
//查询检测时间
$common = new CommonController();
//根据检测时间查看是否检测巡检点
$years = $common->getYearsList($id,'status,images');
if($years){
$arr['status'] = $years['status'];
$arr['images'] = $common->absolutionUrl($years['images']);
$res['status'] = $years['status'];
$res['images'] = $common->absolutionUrl($years['images']);
}
}
$this->success('成功',$arr);
$this->success('成功',$res);
}else{
$this->error('请求方式错误!');
}
... ... @@ -285,6 +285,8 @@ class YearsController extends RestBaseController
* @header name:token require:1 default: desc:header
*
* @param name:spot_id type:inter require:1 default: other desc:检测点id
* @param name:project_id type:inter require:1 default: other desc:项目id
* @param name:test_id type:inter require:1 default: other desc:检测id
* @param name:status type:inter require:1 default: other desc:检测点状态(0:正常,1:故障)
* @param name:images type:array require:1 default: other desc:检测点图片(二维数组形式)
*/
... ... @@ -298,7 +300,7 @@ class YearsController extends RestBaseController
if($user['party'] == 0){
$this->error('无权操作');
}
$rule = config('site.test_status');
$rule = config('site.add_status');
$validate = new Validate($rule['rule'],$rule['msg']);
if (!$validate->check($data)) {
$this->error($validate->getError());
... ...
... ... @@ -718,6 +718,68 @@ class AdminCommonController extends AdminBaseController
return $arr;
}
//获取导出检测列表
public function testList($table,$param,$field){
$res_ins = Db::name($table)
->alias('t')
->join('project p','t.project_id = p.id','LEFT')
->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('t.test_time', '>=', $startTime);
}
if (!empty($endTime)) {
$query->where('t.test_time', '<=', $endTime);
}
})
->field($field)
->select()->toArray();
return $res_ins;
}
//获取年检点相关的信息
public function getSpot($where){
$spot = Db::name('spot')
->alias('s')
->join('years y','s.id = y.spot_id','LEFT')
->where($where)
->field('s.spot_name,y.images')
->select()
->toArray();
$inspect_a = new AdminInspectAController();
foreach($spot as &$value){
$value['images'] = $inspect_a->absolutionUrl($value['images']);
}
return $spot;
}
//获取年检报表详情
public function yearsExportData($res){
$arr = [];
$company = $this->getCompanyName($res['project_id'],'年检');
if($company){
$arr['a_company'] = $company['a_company'];
$arr['b_company'] = $company['b_company'];
$arr['title'] = $company['title'];
}
//年检检测
$where = ['s.project_id'=>$res['project_id'],'s.test_id'=>$res['id']];
$arr['years'] = $this->getSpot($where);
//检测时间
$arr['test_time'] = date('Y/m/d',$res['test_time']);
$arr['time'] = date('Y-m-d',$res['test_time']);
//乙方项目组
$arr['group_name'] = $this->getBUserByProject($res['project_id'],'id,b_sid',1);
return $arr;
}
//导出培训演习报表详情
public function trainExportData($res,$table){
$arr = [];
... ...
... ... @@ -529,6 +529,183 @@ class AdminExcelDataController extends AdminBaseController
return $url;
}
//年检渲染数据到表格上
public function testExcelData($arr){
$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');
$sheet->mergeCells('B3:B4');
$sheet->mergeCells('B6:D6');
$sheet->mergeCells('B7:D7');
$sheet->mergeCells('C3:D3');
$sheet->mergeCells('C4:D4');
$sheet->mergeCells('F3:F4');
$sheet->mergeCells('G3:I3');
$sheet->mergeCells('G4:I4');
$spreadsheet->getDefaultStyle()->getFont()->setName('微软雅黑');//字体
//设置默认宽
$sheet->getDefaultColumnDimension()->setWidth(8);
//设置高度
$sheet->getRowDimension(1)->setRowHeight(45);
//***********************背景填充颜色*****************************
$sheet->getStyle( 'A1:M8')->getFill()->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID);
$sheet->getStyle( 'A1:M8')->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:G7')->getFont()->setSize(8);//字体大小
$sheet->getStyle('C3:G3')->getFont()->getColor()->setRGB('949494');//设置颜色为灰色
$sheet->getStyle('B6:G6')->getFont()->getColor()->setRGB('949494');//设置颜色为灰色
$sheet->getStyle('C4:G4')->getFont()->getColor()->setRGB('FFFFFF');//设置颜色为白色
$sheet->getStyle('B7:G7')->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']);
//项目组
$sheet->setCellValue('B6', '项目组');
//项目组名称
$sheet->setCellValue('B7', $arr['group_name']);
//巡检日期
$sheet->setCellValue('E6', '年检日期');
//巡检日期名称
$sheet->setCellValue('E7', $arr['test_time']);
//循环开始
$cols = 10;
$cells = ['C','E','G','I','K'];
foreach($arr['years'] as $value){
$cols += 0;
//巡检点名称
$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['spot_name']);
$sheet->getStyle('A'.$cols)->getAlignment()->applyFromArray($array);//垂直水平居中
//获取图片个数
$length = count($value['images']);
$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($value['images'] 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( 'A9:M'.$cols)->getFill()->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID);
$sheet->getStyle( 'A9: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;
}
//培训演习渲染数据到表格上
public function trainExcelData($arr,$table){
$spreadsheet = new Spreadsheet();
... ...
<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2019 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: Powerless < wzxaini9@gmail.com>
// +----------------------------------------------------------------------
namespace app\portal\controller;
use api\home\controller\CommonController;
use cmf\controller\AdminBaseController;
use app\portal\model\InspectModel;
use think\Db;
use think\db\Query;
//乙方年检列表
class AdminTestController extends AdminBaseController
{
//月检列表(项目名称,月检时间,月检发起人)
public function index(){
$param = $this->request->param();
$res = Db::name('test')
->alias('t')
->join('user u','t.uid = u.id','LEFT')
->join('project p','t.project_id = p.id','LEFT')
->where(function (Query $query) {
$param = $this->request->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('t.test_time', '>=', $startTime);
}
if (!empty($endTime)) {
$query->where('t.test_time', '<=', $endTime);
}
})
->field('t.id,p.name project_name,t.test_time,t.address,u.user_login')
->order('t.id desc')
->paginate(10,false,['query'=>request()->param()]);
$data = $res->toArray();
$data = $data['data'];
$page = $res->render();
//渲染
$this->assign('start_time', isset($param['start_time']) ? $param['start_time'] : '');
$this->assign('end_time', isset($param['end_time']) ? $param['end_time'] : '');
$this->assign('list',$data);
$this->assign('page',$page);
return $this->fetch();
}
//编辑页面
public function edit(){
$id = $this->request->param('id');
$res = Db::name('test')
->alias('t')
->join('user u','t.uid = u.id','LEFT')
->join('project p','t.project_id = p.id','LEFT')
->where(['t.id'=>$id])
->field('t.id,p.name project_name,t.test_time,t.address,u.user_login,t.remark')
->find();
$spot = Db::name('spot')
->alias('s')
->join('years y','s.id = y.spot_id','LEFT')
->where(['s.test_id'=>$id])
->field('s.id,y.uid,s.spot_name,y.create_time,y.images')
->select()
->toArray();
$inspect_a = new AdminInspectAController();
foreach($spot as &$value){
$test_user = $this->getUserBid($value['uid']);
$value['create_time'] = !empty($value['create_time'])&&isset($value['create_time'])?date('Y-m-d',$value['create_time']):'';
$value['test_user'] = !empty($test_user)?$test_user['user_login']:'';
$value['images'] = $inspect_a->absolutionUrl($value['images']);
}
$res['spot'] = $spot;
$this->assign('post',$res);
return $this->fetch();
}
//获取用户名
public function getUserBid($uid){
$res = Db::name('user')
->where(['id'=>$uid,'user_status'=>1])
->field('id,user_login')
->find();
return $res;
}
//导出数据
public function exportData(){
$param = $this->request->param();
$adminCommon = new AdminCommonController();
$adminExcel = new AdminExcelDataController();
$res_ins = $adminCommon->testList('test',$param,'t.id,t.project_id,t.test_time,p.name project_name');
$arr_url = [];
$arr_time = [];
foreach($res_ins as $key=>$value){
$arr = $adminCommon->yearsExportData($value);
//获取文件路径
$url = $adminExcel->testExcelData($arr);
//按日导出
$arr_url[$key] = $url;
$arr_time[$key] = $value['project_name'].'('.$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->exportCheckList('check',$param,'t.id');
if($res_ins){
$adminCommon->apiResponse(1);
}else{
$adminCommon->apiResponse(0,'暂无数据');
}
}
}
... ...
... ... @@ -188,6 +188,8 @@ return array (
'PORTAL_ADMINTAG_DELETE' => '删除文章标签',
'PORTAL_ADMINTAG_INDEX' => '文章标签',
'PORTAL_ADMINTAG_UPSTATUS' => '更新标签状态',
'PORTAL_ADMINTEST_INDEX' => '年检列表',
'PORTAL_ADMINTESTDEFAULT_DEFAULT' => '年检管理',
'PORTAL_ADMINTRAIN_INDEX' => '培训列表',
'PORTAL_ADMINTRAINDEFAULT_DEFAULT' => '培训管理',
'PORTAL_ADMINTRAINSTATISTICAL_INDEX' => '培训统计',
... ...
<include file="public@header"/>
<style type="text/css">
.pic-list li {
margin-bottom: 5px;
}
</style>
<script type="text/html" id="photos-item-tpl">
<li id="saved-image{id}">
<input id="photo-{id}" type="hidden" name="photo_urls[]" value="{filepath}">
<input class="form-control" id="photo-{id}-name" type="text" name="photo_names[]" value="{name}"
style="width: 200px;" title="图片名称">
<img id="photo-{id}-preview" src="{url}" style="height:36px;width: 36px;"
onclick="imagePreviewDialog(this.src);">
<a href="javascript:uploadOneImage('图片上传','#photo-{id}');">替换</a>
<a href="javascript:(function(){$('#saved-image{id}').remove();})();">移除</a>
</li>
</script>
<script type="text/html" id="files-item-tpl">
<li id="saved-file{id}">
<input id="file-{id}" type="hidden" name="file_urls[]" value="{filepath}">
<input class="form-control" id="file-{id}-name" type="text" name="file_names[]" value="{name}"
style="width: 200px;" title="文件名称">
<a id="file-{id}-preview" href="{preview_url}" target="_blank">下载</a>
<a href="javascript:uploadOne('文件上传','#file-{id}','file');">替换</a>
<a href="javascript:(function(){$('#saved-file{id}').remove();})();">移除</a>
</li>
</script>
</head>
<body>
<div class="wrap js-check-wrap">
<ul class="nav nav-tabs">
<li><a href="{:url('AdminTest/index')}">年检列表</a></li>
<li class="active"><a href="{:url('AdminTest/edit')}">年检详情</a></li>
</ul>
<form action="{:url('AdminTest/editPost')}" method="post" class="form-horizontal js-ajax-form margin-top-20">
<div class="row">
<div class="col-md-9">
<table class="table table-bordered">
<tr>
<th width="150">项目名称</th>
<td>
<input class="form-control" type="text" value="{$post.project_name}"/>
</td>
</tr>
<tr>
<th>年检发起人</th>
<td>
<input class="form-control" type="text" value="{$post.user_login}"/>
</td>
</tr>
<tr>
<th>年检时间</th>
<td>
<input class="form-control" type="text" value="{$post.test_time|date='Y-m-d',###}"/>
</td>
</tr>
<tr>
<th>年检地点</th>
<td>
<input class="form-control" type="text" value="{$post.address}"/>
</td>
</tr>
<tr>
<th>年检备注</th>
<td>
<input class="form-control" type="text" value="{$post.remark}"/>
</td>
</tr>
<tr>
<th style="border:2px solid lightgrey;"></th>
<td style="border:2px solid lightgrey;"></td>
</tr>
<volist name="post.spot" id="vo">
<!--循环-->
<tr>
<th>年检点名称</th>
<td>
<input class="form-control" type="text" value="{$vo.spot_name}"/>
</td>
</tr>
<tr>
<th>年检人员</th>
<td>
<input class="form-control" type="text" value="{$vo.test_user}"/>
</td>
</tr>
<tr>
<th>年检时间</th>
<td>
<input class="form-control" type="text" value="{$vo.create_time}"/>
</td>
</tr>
<tr>
<th>年检图片</th>
<td>
<volist name="vo.images" id="voo">
<img src="{$voo.image_url}" width="250"/>
</volist>
</td>
</tr>
<tr>
<th style="border:2px solid lightgrey;"></th>
<td style="border:2px solid lightgrey;"></td>
</tr>
</volist>
</table>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<a class="btn btn-default" href="{:url('AdminTest/index')}">{:lang('BACK')}</a>
</div>
</div>
</div>
</div>
</form>
</div>
<script type="text/javascript" src="__STATIC__/js/admin.js"></script>
<script type="text/javascript">
//编辑器路径定义
var editorURL = GV.WEB_ROOT;
</script>
<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript">
$(function () {
editorcontent = new baidu.editor.ui.Editor();
editorcontent.render('content');
try {
editorcontent.sync();
} catch (err) {
}
});
</script>
</body>
</html>
... ...
<include file="public@header"/>
</head>
<body>
<div class="wrap">
<ul class="nav nav-tabs">
<li class="active"><a>年检列表</a></li>
</ul>
<form class="well form-inline margin-top-20" method="post" action="{:url('AdminTest/index')}">
项目名称:
<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" 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('AdminTest/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>
<tr>
<th width="16">
<label>
<input type="checkbox" class="js-check-all" data-direction="x" data-checklist="js-check-x">
</label>
</th>
<th>ID</th>
<th>项目名称</th>
<th>检测发起人</th>
<th>检测时间</th>
<th>检测地点</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<foreach name="list" item="vo">
<tr>
<td>
<input type="checkbox" class="js-check" data-yid="js-check-y" data-xid="js-check-x" name="ids[]"
value="{$vo.id}">
</td>
<td>{$vo.id}</td>
<td>{$vo.project_name}</td>
<td>{$vo.user_login}</td>
<td>{$vo.test_time|date="Y-m-d",###}</td>
<td>{$vo.address}</td>
<td width="150">
<a class="btn btn-xs btn-primary" href="{:url('AdminTest/edit',array('id'=>$vo['id']))}">详情</a>
</td>
</tr>
</foreach>
</tbody>
</table>
<div class="pagination">{$page}</div>
</form>
</div>
<script src="__STATIC__/js/admin.js"></script>
</body>
</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
... ...