作者 王晓刚
1 个管道 的构建 通过 耗费 2 秒

后台问卷调查

<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2019/3/4
* Time: 10:13
*/
namespace app\admin\controller;
use cmf\controller\AdminBaseController;
use think\Db;
class QuestionController extends AdminBaseController
{
public function index(){
$where=[];
$param = $this->request->param();
$startTime = empty($param['start_time']) ? 0 : strtotime($param['start_time']);
$endTime = empty($param['end_time']) ? 0 : strtotime($param['end_time']);
if (!empty($startTime) && !empty($endTime)) {
$where['q.create_time'] = [['>= time', $startTime], ['<= time', $endTime]];
} else {
if (!empty($startTime)) {
$where['q.create_time'] = ['>= time', $startTime];
}
if (!empty($endTime)) {
$where['q.create_time'] = ['<= time', $endTime];
}
}
$keyword = empty($param['keyword']) ? '' : $param['keyword'];
if (!empty($keyword)) {
$where['u.nickname'] = ['like', "%$keyword%"];
}
$status = empty($param['status']) ? '' : $param['status'];
if (!empty($status)) {
$where['q.status'] = ['eq', "$status"];
}
$data=Db::name('question')
->alias('q')
->field('q.*,u.user_nickname')
->join('cmf_user u','u.id = q.user_id')
->where('q.delete_time',0)
->where($where)
->order('q.create_time desc')
->paginate(10);
$data->appends($param);
$list=$data->items();
$this->assign([
'data'=>$list,
'page'=>$data->render(),
'start_time'=>isset($param['start_time']) ? $param['start_time'] : '',
'end_time'=>isset($param['end_time']) ? $param['end_time'] : '',
'keyword'=>isset($param['keyword']) ? $param['keyword'] : '',
]);
return $this->fetch();
}
}
\ No newline at end of file
... ...
<include file="public@header"/>
</head>
<body>
<!--<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>-->
<div class="wrap js-check-wrap">
<ul class="nav nav-tabs">
<li><a href="{:url('news/index')}">动态列表</a></li>
<li class="active"><a href="{:url('news/add')}">添加动态</a></li>
</ul>
<form action="{:url('news/add')}" 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="100">标题<span class="form-required">*</span></th>
<td>
<input class="form-control" type="text" name="title"
id="title" value="" placeholder="请输入标题"/>
</td>
</tr>
<tr>
<th width="100">摘要<span class="form-required">*</span></th>
<td>
<textarea class="form-control" name="abstract"
id="abstract" placeholder="请输入摘要"></textarea>
</td>
</tr>
<tr>
<th width="100">内容<span class="form-required">*</span></th>
<td>
<script type="text/plain" id="content" name="content"></script>
</td>
</tr>
<!--<tr>-->
<!--<th>相册</th>-->
<!--<td>-->
<!--<ul id="photos" class="pic-list list-unstyled form-inline">-->
<!--</ul>-->
<!--<a href="javascript:uploadMultiImage('图片上传','#photos','photos-item-tpl');"-->
<!--class="btn btn-sm btn-default">选择图片</a>-->
<!--</td>-->
<!--</tr>-->
</table>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-primary js-ajax-submit">{:lang('ADD')}</button>
<a class="btn btn-default" href="javascript:history.back(-1);">{:lang('BACK')}</a>
</div>
</div>
</div>
<div class="col-md-3">
<table class="table table-bordered">
<tr>
<th>缩略图<span class="form-required">(推荐尺寸:240×240px)</span></th>
</tr>
<tr>
<td>
<div style="text-align: center;">
<input type="hidden" name="thumbnail" id="thumbnail"
value="{$data.thumbnail|default=''}">
<a href="javascript:uploadOneImage('image upload','#thumbnail');">
<img src="__TMPL__/public/assets/images/default-thumbnail.png"
id="thumbnail-preview"
width="135" style="cursor: pointer"/>
</a>
<input type="button" class="btn btn-sm btn-cancel-thumbnail"
value="取消图片">
</div>
</td>
</tr>
<tr>
<th><b>发布时间</b></th>
</tr>
<tr>
<td>
<input class="form-control js-bootstrap-date" type="text" name="up_time"
value="{:date('Y-m-d',time())}">
</td>
</tr>
<tr>
<th>状态</th>
</tr>
<tr>
<td>
<div class="checkbox">
<label><input type="checkbox" name="is_up" value="1" checked>发布</label>
</div>
</td>
</tr>
</table>
</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) {
}
$('.btn-cancel-thumbnail').click(function () {
$('#thumbnail-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
$('#thumbnail').val('');
});
});
</script>
</body>
</html>
... ...
<include file="public@header"/>
</head>
<body>
<!--<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>-->
<div class="wrap js-check-wrap">
<ul class="nav nav-tabs">
<li><a href="{:url('Question/index')}">问卷调查</a></li>
<li class="active"><a href="#">审核</a></li>
</ul>
<form action="{:url('Question/edit')}" 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="100">用户昵称</th>
<td>
<input class="form-control" type="text" name=""
id="user_nickname" value="{$data.user_nickname}" placeholder="请输入用户昵称" readonly/>
<input type="hidden" name="id" value="{$data.id}">
</td>
</tr>
<tr>
<th width="100">姓名</th>
<td>
<input class="form-control" type="text" name=""
id="name" value="{$data.name}" placeholder="请输入姓名"/>
</td>
</tr>
<tr>
<th width="100">性别</th>
<td>
<label><input class="form-control" type="radio" name="sex" value="1" <eq name="$data.sex" value="1">checked</eq> />男</label>
<label><input class="form-control" type="radio" name="sex" value="2" <eq name="$data.sex" value="2">checked</eq> />女</label>
</td>
</tr>
<tr>
<th width="100">年龄</th>
<td>
<input class="form-control" type="text" name="birthday"
id="birthday" value="{$data.birthday}" placeholder="请输入年龄"/>
</td>
</tr>
<tr>
<th width="100">所在地</th>
<td>
<input class="form-control" type="text" name="area"
id="area" value="{$data.area}" placeholder="请输入所在地"/>
</td>
</tr>
<tr>
<th width="100">家庭结构</th>
<td>
<input class="form-control" type="text" name="family_num"
id="family_num" value="{$data.family_num}" placeholder="请输入家庭结构"/>
</td>
</tr>
<tr>
<th width="100">职业</th>
<td>
<input class="form-control" type="text" name="occupation"
id="occupation" value="{$data.occupation}" placeholder="请输入职业"/>
</td>
</tr>
<tr>
<th width="100">有无吸烟酗酒史</th>
<td>
<input class="form-control" type="text" name="smoke_drink"
id="smoke_drink" value="{$data.smoke_drink}" placeholder="请输入有误吸烟酗酒史"/>
</td>
</tr>
<tr>
<th width="100">出行方式</th>
<td>
<input class="form-control" type="text" name="going"
id="going" value="{$data.going}" placeholder="请输入出行方式"/>
</td>
</tr>
<tr>
<th width="100">有无社保</th>
<td>
<input class="form-control" type="text" name="social"
id="social" value="{$data.social}" placeholder="请输入有无社保"/>
</td>
</tr>
<tr>
<th width="100">家庭年收入</th>
<td>
<input class="form-control" type="text" name="year_income"
id="year_income" value="{$data.year_income}" placeholder="请输入家庭年收入"/>
</td>
</tr>
<tr>
<th width="100">个人年收入</th>
<td>
<input class="form-control" type="text" name="personage_year_income"
id="personage_year_income" value="{$data.personage_year_income}" placeholder="请输入个人年收入"/>
</td>
</tr>
<tr>
<th width="100">有无负债</th>
<td>
<input class="form-control" type="text" name="liabilities"
id="liabilities" value="{$data.liabilities}" placeholder="请输入有无负债"/>
</td>
</tr>
<tr>
<th width="100">大约未还负债</th>
<td>
<input class="form-control" type="text" name="not_return"
id="not_return" value="{$data.not_return}" placeholder="请输入大约未还负债"/>
</td>
</tr>
<tr>
<th width="100">有无家族病史</th>
<td>
<input class="form-control" type="text" name="family_disease"
id="family_disease" value="{$data.family_disease}" placeholder="请输入有无家族病史"/>
</td>
</tr>
<tr>
<th width="100">你更关心您家人哪方面保障</th>
<td>
<input class="form-control" type="text" name="safeguard"
id="safeguard" value="{$data.safeguard}" placeholder="请输入保障"/>
</td>
</tr>
<tr>
<th width="100">手机号</th>
<td>
<input class="form-control" type="text" name=""
id="phone" value="{$data.phone}" placeholder="请输入手机号"/>
</td>
</tr>
</table>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-primary js-ajax-submit">{:lang('SAVE')}</button>
<a class="btn btn-default" href="javascript:history.back(-1);">{:lang('BACK')}</a>
</div>
</div>
</div>
<div class="col-md-3">
<table class="table table-bordered">
<tr>
<th>状态</th>
</tr>
<tr>
<td>
<div class="radio">
<label><input type="radio" name="status" value="2" <eq name="$data.status" value="2">checked</eq> >审核通过</label>
</div>
</td>
</tr>
<tr>
<td>
<div class="radio">
<label><input type="radio" name="status" value="3" <eq name="$data.status" value="3">checked</eq> >审核未通过</label>
</div>
</td>
</tr>
</table>
</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) {
}
$('.btn-cancel-thumbnail').click(function () {
$('#thumbnail-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
$('#thumbnail').val('');
});
$('.btn-cancel-thumbnail1').click(function () {
$('#thumbnail-preview1').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
$('#thumbnail1').val('');
});
});
</script>
</body>
</html>
... ...
<include file="public@header" />
</head>
<body>
<div class="wrap js-check-wrap">
<ul class="nav nav-tabs">
<li class="active"><a href="{:url('Question/index')}">问卷调查</a></li>
</ul>
<form class="well form-inline margin-top-20" method="post" action="{:url('Question/index')}">
时间:
<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; &nbsp;
关键字:
<input type="text" class="form-control" name="keyword" style="width: 150px;" value="{$keyword|default=''}" placeholder="请输入关键字...">
<input type="submit" class="btn btn-primary" value="搜索" />
<a class="btn btn-danger" href="{:url('Question/index')}">清空</a>
</form>
<form class="js-ajax-form" action="" method="post">
<table class="table table-hover table-bordered">
<div class="table-actions">
<button class="btn btn-danger btn-sm js-ajax-submit"
data-action="{:url('Question/delete')}" data-subcheck="true" data-msg="你确定删除吗?">
{:lang('DELETE')}
</button>
</div>
<thead>
<tr>
<th>
<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>
<th>电话</th>
<th>提交时间</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<foreach name="data" 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}" title="ID:{$vo.id}">
</td>
<td>{$vo.id}</td>
<td>{$vo.user_nickname}</td>
<td>{$vo.name}</td>
<td>
<eq name="$vo.sex" value="1"></eq>
<eq name="$vo.sex" value="2"></eq>
</td>
<td>{$vo.area}</td>
<td>{$vo.phone}</td>
<td>{:date('Y-m-d H:i:s',$vo['create_time'])}</td>
<td>
<a href='{:url("Question/edit",array("id"=>$vo["id"]))}'>更多</a>|
<a class="js-ajax-delete" href="{:url('Question/delete',array('id'=>$vo['id']))}">{:lang('DELETE')}</a>
</td>
</tr>
</foreach>
</tbody>
<thead>
<tr>
<th>
<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>
<th>电话</th>
<th>提交时间</th>
<th>操作</th>
</tr>
</thead>
</table>
<div class="table-actions">
<button class="btn btn-danger btn-sm js-ajax-submit"
data-action="{:url('Question/delete')}" data-subcheck="true" data-msg="你确定删除吗?">
{:lang('DELETE')}
</button>
</div>
<div class="pagination">{$page}</div>
</form>
</div>
<script src="__STATIC__/js/admin.js"></script>
</body>
</html>
\ No newline at end of file
... ...