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

后台问卷调查

  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: Administrator
  5 + * Date: 2019/3/4
  6 + * Time: 10:13
  7 + */
  8 +
  9 +namespace app\admin\controller;
  10 +
  11 +
  12 +use cmf\controller\AdminBaseController;
  13 +use think\Db;
  14 +
  15 +class QuestionController extends AdminBaseController
  16 +{
  17 + public function index(){
  18 + $where=[];
  19 + $param = $this->request->param();
  20 + $startTime = empty($param['start_time']) ? 0 : strtotime($param['start_time']);
  21 + $endTime = empty($param['end_time']) ? 0 : strtotime($param['end_time']);
  22 + if (!empty($startTime) && !empty($endTime)) {
  23 + $where['q.create_time'] = [['>= time', $startTime], ['<= time', $endTime]];
  24 + } else {
  25 + if (!empty($startTime)) {
  26 + $where['q.create_time'] = ['>= time', $startTime];
  27 + }
  28 + if (!empty($endTime)) {
  29 + $where['q.create_time'] = ['<= time', $endTime];
  30 + }
  31 + }
  32 + $keyword = empty($param['keyword']) ? '' : $param['keyword'];
  33 + if (!empty($keyword)) {
  34 + $where['u.nickname'] = ['like', "%$keyword%"];
  35 + }
  36 + $status = empty($param['status']) ? '' : $param['status'];
  37 + if (!empty($status)) {
  38 + $where['q.status'] = ['eq', "$status"];
  39 + }
  40 + $data=Db::name('question')
  41 + ->alias('q')
  42 + ->field('q.*,u.user_nickname')
  43 + ->join('cmf_user u','u.id = q.user_id')
  44 + ->where('q.delete_time',0)
  45 + ->where($where)
  46 + ->order('q.create_time desc')
  47 + ->paginate(10);
  48 + $data->appends($param);
  49 + $list=$data->items();
  50 + $this->assign([
  51 + 'data'=>$list,
  52 + 'page'=>$data->render(),
  53 + 'start_time'=>isset($param['start_time']) ? $param['start_time'] : '',
  54 + 'end_time'=>isset($param['end_time']) ? $param['end_time'] : '',
  55 + 'keyword'=>isset($param['keyword']) ? $param['keyword'] : '',
  56 + ]);
  57 + return $this->fetch();
  58 + }
  59 +}
  1 +<include file="public@header"/>
  2 +</head>
  3 +<body>
  4 +<!--<script type="text/html" id="photos-item-tpl">-->
  5 + <!--<li id="saved-image{id}">-->
  6 + <!--<input id="photo-{id}" type="hidden" name="photo_urls[]" value="{filepath}">-->
  7 + <!--<input class="form-control" id="photo-{id}-name" type="text" name="photo_names[]" value="{name}"-->
  8 + <!--style="width: 200px;" title="图片名称">-->
  9 + <!--<img id="photo-{id}-preview" src="{url}" style="height:36px;width: 36px;"-->
  10 + <!--onclick="imagePreviewDialog(this.src);">-->
  11 + <!--<a href="javascript:uploadOneImage('图片上传','#photo-{id}');">替换</a>-->
  12 + <!--<a href="javascript:(function(){$('#saved-image{id}').remove();})();">移除</a>-->
  13 + <!--</li>-->
  14 +<!--</script>-->
  15 +<div class="wrap js-check-wrap">
  16 + <ul class="nav nav-tabs">
  17 + <li><a href="{:url('news/index')}">动态列表</a></li>
  18 + <li class="active"><a href="{:url('news/add')}">添加动态</a></li>
  19 + </ul>
  20 + <form action="{:url('news/add')}" method="post" class="form-horizontal js-ajax-form margin-top-20">
  21 + <div class="row">
  22 + <div class="col-md-9">
  23 + <table class="table table-bordered">
  24 + <tr>
  25 + <th width="100">标题<span class="form-required">*</span></th>
  26 + <td>
  27 + <input class="form-control" type="text" name="title"
  28 + id="title" value="" placeholder="请输入标题"/>
  29 + </td>
  30 + </tr>
  31 + <tr>
  32 + <th width="100">摘要<span class="form-required">*</span></th>
  33 + <td>
  34 + <textarea class="form-control" name="abstract"
  35 + id="abstract" placeholder="请输入摘要"></textarea>
  36 + </td>
  37 + </tr>
  38 + <tr>
  39 + <th width="100">内容<span class="form-required">*</span></th>
  40 + <td>
  41 + <script type="text/plain" id="content" name="content"></script>
  42 + </td>
  43 + </tr>
  44 + <!--<tr>-->
  45 + <!--<th>相册</th>-->
  46 + <!--<td>-->
  47 + <!--<ul id="photos" class="pic-list list-unstyled form-inline">-->
  48 + <!--</ul>-->
  49 + <!--<a href="javascript:uploadMultiImage('图片上传','#photos','photos-item-tpl');"-->
  50 + <!--class="btn btn-sm btn-default">选择图片</a>-->
  51 + <!--</td>-->
  52 + <!--</tr>-->
  53 + </table>
  54 + <div class="form-group">
  55 + <div class="col-sm-offset-2 col-sm-10">
  56 + <button type="submit" class="btn btn-primary js-ajax-submit">{:lang('ADD')}</button>
  57 + <a class="btn btn-default" href="javascript:history.back(-1);">{:lang('BACK')}</a>
  58 + </div>
  59 + </div>
  60 + </div>
  61 + <div class="col-md-3">
  62 + <table class="table table-bordered">
  63 + <tr>
  64 + <th>缩略图<span class="form-required">(推荐尺寸:240×240px)</span></th>
  65 + </tr>
  66 + <tr>
  67 + <td>
  68 + <div style="text-align: center;">
  69 + <input type="hidden" name="thumbnail" id="thumbnail"
  70 + value="{$data.thumbnail|default=''}">
  71 + <a href="javascript:uploadOneImage('image upload','#thumbnail');">
  72 + <img src="__TMPL__/public/assets/images/default-thumbnail.png"
  73 + id="thumbnail-preview"
  74 + width="135" style="cursor: pointer"/>
  75 + </a>
  76 + <input type="button" class="btn btn-sm btn-cancel-thumbnail"
  77 + value="取消图片">
  78 + </div>
  79 + </td>
  80 + </tr>
  81 + <tr>
  82 + <th><b>发布时间</b></th>
  83 + </tr>
  84 + <tr>
  85 + <td>
  86 + <input class="form-control js-bootstrap-date" type="text" name="up_time"
  87 + value="{:date('Y-m-d',time())}">
  88 + </td>
  89 + </tr>
  90 + <tr>
  91 + <th>状态</th>
  92 + </tr>
  93 + <tr>
  94 + <td>
  95 + <div class="checkbox">
  96 + <label><input type="checkbox" name="is_up" value="1" checked>发布</label>
  97 + </div>
  98 + </td>
  99 + </tr>
  100 + </table>
  101 + </div>
  102 + </div>
  103 + </form>
  104 +</div>
  105 +<script type="text/javascript" src="__STATIC__/js/admin.js"></script>
  106 +<script type="text/javascript">
  107 + //编辑器路径定义
  108 + var editorURL = GV.WEB_ROOT;
  109 +</script>
  110 +<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.config.js"></script>
  111 +<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.all.min.js"></script>
  112 +<script type="text/javascript">
  113 + $(function () {
  114 +
  115 + editorcontent = new baidu.editor.ui.Editor();
  116 + editorcontent.render('content');
  117 + try {
  118 + editorcontent.sync();
  119 + } catch (err) {
  120 + }
  121 +
  122 + $('.btn-cancel-thumbnail').click(function () {
  123 + $('#thumbnail-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
  124 + $('#thumbnail').val('');
  125 + });
  126 +
  127 + });
  128 +</script>
  129 +</body>
  130 +</html>
  1 +<include file="public@header"/>
  2 +</head>
  3 +<body>
  4 +<!--<script type="text/html" id="photos-item-tpl">-->
  5 +<!--<li id="saved-image{id}">-->
  6 +<!--<input id="photo-{id}" type="hidden" name="photo_urls[]" value="{filepath}">-->
  7 +<!--<input class="form-control" id="photo-{id}-name" type="text" name="photo_names[]" value="{name}"-->
  8 +<!--style="width: 200px;" title="图片名称">-->
  9 +<!--<img id="photo-{id}-preview" src="{url}" style="height:36px;width: 36px;"-->
  10 +<!--onclick="imagePreviewDialog(this.src);">-->
  11 +<!--<a href="javascript:uploadOneImage('图片上传','#photo-{id}');">替换</a>-->
  12 +<!--<a href="javascript:(function(){$('#saved-image{id}').remove();})();">移除</a>-->
  13 +<!--</li>-->
  14 +<!--</script>-->
  15 +<div class="wrap js-check-wrap">
  16 + <ul class="nav nav-tabs">
  17 + <li><a href="{:url('Question/index')}">问卷调查</a></li>
  18 + <li class="active"><a href="#">审核</a></li>
  19 + </ul>
  20 + <form action="{:url('Question/edit')}" method="post" class="form-horizontal js-ajax-form margin-top-20">
  21 + <div class="row">
  22 + <div class="col-md-9">
  23 + <table class="table table-bordered">
  24 + <tr>
  25 + <th width="100">用户昵称</th>
  26 + <td>
  27 + <input class="form-control" type="text" name=""
  28 + id="user_nickname" value="{$data.user_nickname}" placeholder="请输入用户昵称" readonly/>
  29 + <input type="hidden" name="id" value="{$data.id}">
  30 + </td>
  31 + </tr>
  32 + <tr>
  33 + <th width="100">姓名</th>
  34 + <td>
  35 + <input class="form-control" type="text" name=""
  36 + id="name" value="{$data.name}" placeholder="请输入姓名"/>
  37 + </td>
  38 + </tr>
  39 + <tr>
  40 + <th width="100">性别</th>
  41 + <td>
  42 + <label><input class="form-control" type="radio" name="sex" value="1" <eq name="$data.sex" value="1">checked</eq> />男</label>
  43 + <label><input class="form-control" type="radio" name="sex" value="2" <eq name="$data.sex" value="2">checked</eq> />女</label>
  44 + </td>
  45 + </tr>
  46 + <tr>
  47 + <th width="100">年龄</th>
  48 + <td>
  49 + <input class="form-control" type="text" name="birthday"
  50 + id="birthday" value="{$data.birthday}" placeholder="请输入年龄"/>
  51 + </td>
  52 + </tr>
  53 + <tr>
  54 + <th width="100">所在地</th>
  55 + <td>
  56 + <input class="form-control" type="text" name="area"
  57 + id="area" value="{$data.area}" placeholder="请输入所在地"/>
  58 + </td>
  59 + </tr>
  60 + <tr>
  61 + <th width="100">家庭结构</th>
  62 + <td>
  63 + <input class="form-control" type="text" name="family_num"
  64 + id="family_num" value="{$data.family_num}" placeholder="请输入家庭结构"/>
  65 + </td>
  66 + </tr>
  67 + <tr>
  68 + <th width="100">职业</th>
  69 + <td>
  70 + <input class="form-control" type="text" name="occupation"
  71 + id="occupation" value="{$data.occupation}" placeholder="请输入职业"/>
  72 + </td>
  73 + </tr>
  74 + <tr>
  75 + <th width="100">有无吸烟酗酒史</th>
  76 + <td>
  77 + <input class="form-control" type="text" name="smoke_drink"
  78 + id="smoke_drink" value="{$data.smoke_drink}" placeholder="请输入有误吸烟酗酒史"/>
  79 + </td>
  80 + </tr>
  81 + <tr>
  82 + <th width="100">出行方式</th>
  83 + <td>
  84 + <input class="form-control" type="text" name="going"
  85 + id="going" value="{$data.going}" placeholder="请输入出行方式"/>
  86 + </td>
  87 + </tr>
  88 + <tr>
  89 + <th width="100">有无社保</th>
  90 + <td>
  91 + <input class="form-control" type="text" name="social"
  92 + id="social" value="{$data.social}" placeholder="请输入有无社保"/>
  93 + </td>
  94 + </tr>
  95 + <tr>
  96 + <th width="100">家庭年收入</th>
  97 + <td>
  98 + <input class="form-control" type="text" name="year_income"
  99 + id="year_income" value="{$data.year_income}" placeholder="请输入家庭年收入"/>
  100 + </td>
  101 + </tr>
  102 + <tr>
  103 + <th width="100">个人年收入</th>
  104 + <td>
  105 + <input class="form-control" type="text" name="personage_year_income"
  106 + id="personage_year_income" value="{$data.personage_year_income}" placeholder="请输入个人年收入"/>
  107 + </td>
  108 + </tr>
  109 + <tr>
  110 + <th width="100">有无负债</th>
  111 + <td>
  112 + <input class="form-control" type="text" name="liabilities"
  113 + id="liabilities" value="{$data.liabilities}" placeholder="请输入有无负债"/>
  114 + </td>
  115 + </tr>
  116 + <tr>
  117 + <th width="100">大约未还负债</th>
  118 + <td>
  119 + <input class="form-control" type="text" name="not_return"
  120 + id="not_return" value="{$data.not_return}" placeholder="请输入大约未还负债"/>
  121 + </td>
  122 + </tr>
  123 + <tr>
  124 + <th width="100">有无家族病史</th>
  125 + <td>
  126 + <input class="form-control" type="text" name="family_disease"
  127 + id="family_disease" value="{$data.family_disease}" placeholder="请输入有无家族病史"/>
  128 + </td>
  129 + </tr>
  130 + <tr>
  131 + <th width="100">你更关心您家人哪方面保障</th>
  132 + <td>
  133 + <input class="form-control" type="text" name="safeguard"
  134 + id="safeguard" value="{$data.safeguard}" placeholder="请输入保障"/>
  135 + </td>
  136 + </tr>
  137 + <tr>
  138 + <th width="100">手机号</th>
  139 + <td>
  140 + <input class="form-control" type="text" name=""
  141 + id="phone" value="{$data.phone}" placeholder="请输入手机号"/>
  142 + </td>
  143 + </tr>
  144 + </table>
  145 + <div class="form-group">
  146 + <div class="col-sm-offset-2 col-sm-10">
  147 + <button type="submit" class="btn btn-primary js-ajax-submit">{:lang('SAVE')}</button>
  148 + <a class="btn btn-default" href="javascript:history.back(-1);">{:lang('BACK')}</a>
  149 + </div>
  150 + </div>
  151 + </div>
  152 + <div class="col-md-3">
  153 + <table class="table table-bordered">
  154 + <tr>
  155 + <th>状态</th>
  156 + </tr>
  157 + <tr>
  158 + <td>
  159 + <div class="radio">
  160 + <label><input type="radio" name="status" value="2" <eq name="$data.status" value="2">checked</eq> >审核通过</label>
  161 + </div>
  162 + </td>
  163 + </tr>
  164 + <tr>
  165 + <td>
  166 + <div class="radio">
  167 + <label><input type="radio" name="status" value="3" <eq name="$data.status" value="3">checked</eq> >审核未通过</label>
  168 + </div>
  169 + </td>
  170 + </tr>
  171 + </table>
  172 + </div>
  173 + </div>
  174 + </form>
  175 +</div>
  176 +<script type="text/javascript" src="__STATIC__/js/admin.js"></script>
  177 +<script type="text/javascript">
  178 + //编辑器路径定义
  179 + var editorURL = GV.WEB_ROOT;
  180 +</script>
  181 +<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.config.js"></script>
  182 +<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.all.min.js"></script>
  183 +<script type="text/javascript">
  184 + $(function () {
  185 +
  186 + editorcontent = new baidu.editor.ui.Editor();
  187 + editorcontent.render('content');
  188 + try {
  189 + editorcontent.sync();
  190 + } catch (err) {
  191 + }
  192 +
  193 + $('.btn-cancel-thumbnail').click(function () {
  194 + $('#thumbnail-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
  195 + $('#thumbnail').val('');
  196 + });
  197 +
  198 + $('.btn-cancel-thumbnail1').click(function () {
  199 + $('#thumbnail-preview1').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
  200 + $('#thumbnail1').val('');
  201 + });
  202 +
  203 +
  204 + });
  205 +</script>
  206 +</body>
  207 +</html>
  1 +<include file="public@header" />
  2 +</head>
  3 +<body>
  4 +<div class="wrap js-check-wrap">
  5 + <ul class="nav nav-tabs">
  6 + <li class="active"><a href="{:url('Question/index')}">问卷调查</a></li>
  7 + </ul>
  8 + <form class="well form-inline margin-top-20" method="post" action="{:url('Question/index')}">
  9 + 时间:
  10 + <input type="text" class="form-control js-bootstrap-datetime" name="start_time"
  11 + value="{$start_time|default=''}"
  12 + style="width: 140px;" autocomplete="off">-
  13 + <input type="text" class="form-control js-bootstrap-datetime" name="end_time"
  14 + value="{$end_time|default=''}"
  15 + style="width: 140px;" autocomplete="off"> &nbsp; &nbsp;
  16 + 关键字:
  17 + <input type="text" class="form-control" name="keyword" style="width: 150px;" value="{$keyword|default=''}" placeholder="请输入关键字...">
  18 + <input type="submit" class="btn btn-primary" value="搜索" />
  19 + <a class="btn btn-danger" href="{:url('Question/index')}">清空</a>
  20 + </form>
  21 + <form class="js-ajax-form" action="" method="post">
  22 + <table class="table table-hover table-bordered">
  23 + <div class="table-actions">
  24 + <button class="btn btn-danger btn-sm js-ajax-submit"
  25 + data-action="{:url('Question/delete')}" data-subcheck="true" data-msg="你确定删除吗?">
  26 + {:lang('DELETE')}
  27 + </button>
  28 + </div>
  29 + <thead>
  30 + <tr>
  31 + <th>
  32 + <label>
  33 + <input type="checkbox" class="js-check-all" data-direction="x" data-checklist="js-check-x">
  34 + </label>
  35 + </th>
  36 + <th>ID</th>
  37 + <th>用户昵称</th>
  38 + <th>姓名</th>
  39 + <th>性别</th>
  40 + <th>年龄</th>
  41 + <th>所在地</th>
  42 + <th>电话</th>
  43 + <th>提交时间</th>
  44 + <th>操作</th>
  45 + </tr>
  46 + </thead>
  47 + <tbody>
  48 + <foreach name="data" item="vo">
  49 + <tr>
  50 + <td>
  51 + <input type="checkbox" class="js-check" data-yid="js-check-y" data-xid="js-check-x" name="ids[]"
  52 + value="{$vo.id}" title="ID:{$vo.id}">
  53 + </td>
  54 + <td>{$vo.id}</td>
  55 + <td>{$vo.user_nickname}</td>
  56 + <td>{$vo.name}</td>
  57 + <td>
  58 + <eq name="$vo.sex" value="1"></eq>
  59 + <eq name="$vo.sex" value="2"></eq>
  60 + </td>
  61 + <td>{$vo.area}</td>
  62 + <td>{$vo.phone}</td>
  63 + <td>{:date('Y-m-d H:i:s',$vo['create_time'])}</td>
  64 + <td>
  65 + <a href='{:url("Question/edit",array("id"=>$vo["id"]))}'>更多</a>|
  66 + <a class="js-ajax-delete" href="{:url('Question/delete',array('id'=>$vo['id']))}">{:lang('DELETE')}</a>
  67 + </td>
  68 + </tr>
  69 + </foreach>
  70 + </tbody>
  71 + <thead>
  72 + <tr>
  73 + <th>
  74 + <label>
  75 + <input type="checkbox" class="js-check-all" data-direction="x" data-checklist="js-check-x">
  76 + </label>
  77 + </th>
  78 + <th>ID</th>
  79 + <th>用户昵称</th>
  80 + <th>姓名</th>
  81 + <th>性别</th>
  82 + <th>年龄</th>
  83 + <th>所在地</th>
  84 + <th>电话</th>
  85 + <th>提交时间</th>
  86 + <th>操作</th>
  87 + </tr>
  88 + </thead>
  89 + </table>
  90 + <div class="table-actions">
  91 + <button class="btn btn-danger btn-sm js-ajax-submit"
  92 + data-action="{:url('Question/delete')}" data-subcheck="true" data-msg="你确定删除吗?">
  93 + {:lang('DELETE')}
  94 + </button>
  95 + </div>
  96 + <div class="pagination">{$page}</div>
  97 + </form>
  98 +</div>
  99 +<script src="__STATIC__/js/admin.js"></script>
  100 +</body>
  101 +</html>