作者 潘浩文
1 个管道 的构建 通过 耗费 1 秒

后台报警与信息模块开发

  1 +<?php
  2 +// +----------------------------------------------------------------------
  3 +// | bronet [ 以客户为中心 以奋斗者为本 ]
  4 +// +----------------------------------------------------------------------
  5 +// | Copyright (c) 2013-2017 http://www.bronet.cn All rights reserved.
  6 +// +----------------------------------------------------------------------
  7 +// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8 +// +----------------------------------------------------------------------
  9 +// | Author:kane < chengjin005@163.com>
  10 +// +----------------------------------------------------------------------
  11 +namespace app\portal\controller;
  12 +
  13 +use cmf\controller\AdminBaseController;
  14 +use think\Db;
  15 +
  16 +/**
  17 + * Class AdminMessageController
  18 + * @package app\portal\controller
  19 + * @adminMenuRoot(
  20 + * 'name' =>'系统消息',
  21 + * 'action' =>'default',
  22 + * 'parent' =>'',
  23 + * 'display'=> true,
  24 + * 'order' => 30,
  25 + * 'icon' =>'th',
  26 + * 'remark' =>'系统消息'
  27 + * )
  28 + */
  29 +class AdminMessageController extends AdminBaseController
  30 +{
  31 + /**
  32 + * 系统消息
  33 + * @adminMenu(
  34 + * 'name' => '系统消息',
  35 + * 'parent' => 'portal/AdminMessage/default',
  36 + * 'display'=> true,
  37 + * 'hasView'=> true,
  38 + * 'order' => 10000,
  39 + * 'icon' => '',
  40 + * 'remark' => '系统消息',
  41 + * 'param' => ''
  42 + * )
  43 + */
  44 + public function index()
  45 + {
  46 + //数据提取
  47 + $data=Db::name('warning')
  48 + ->alias('w')
  49 + ->join('light l','w.light_id=l.id')
  50 + ->join('temple t','l.temple_id=t.id')
  51 + ->join('temple_area ta','l.area_id=ta.id')
  52 + ->field('w.*,l.row,l.column,l.address,l.temple_id,l.number,t.name as tname ,ta.name as taname,w.status as wstatus')
  53 + ->order('w.create_time','desc')
  54 + ->paginate(10);
  55 + //向地址传参
  56 + $this->assign('page',$data->render());
  57 + $this->assign('list', $data);
  58 + return $this->fetch();
  59 + }
  60 +
  61 +
  62 + public function index2()
  63 + {
  64 + $data=Db::name('message_category')->select();
  65 + $this->assign('list',$data);
  66 + return $this->fetch();
  67 + }
  68 +
  69 +
  70 + /**
  71 + * 删除系统消息
  72 + * @adminMenu(
  73 + * 'name' => '删除系统消息',
  74 + * 'parent' => 'index',
  75 + * 'display'=> false,
  76 + * 'hasView'=> false,
  77 + * 'order' => 10000,
  78 + * 'icon' => '',
  79 + * 'remark' => '删除系统消息',
  80 + * 'param' => ''
  81 + * )
  82 + */
  83 + public function delete()
  84 + {
  85 + $param=$this->request->param();
  86 + if (!empty($param['ids'])){
  87 + Db::name('message')->where(['id' => ['in', $param['ids']]])->delete();
  88 + $this->success('删除成功');
  89 + }
  90 + Db::name('message')->where('id', $param['id'])->delete();
  91 + $this->success('删除成功');
  92 + }
  93 +
  94 +}
@@ -50,6 +50,7 @@ class AdminWarningController extends AdminBaseController @@ -50,6 +50,7 @@ class AdminWarningController extends AdminBaseController
50 ->join('temple t','l.temple_id=t.id') 50 ->join('temple t','l.temple_id=t.id')
51 ->join('temple_area ta','l.area_id=ta.id') 51 ->join('temple_area ta','l.area_id=ta.id')
52 ->field('w.*,l.row,l.column,l.address,l.temple_id,l.number,t.name as tname ,ta.name as taname,w.status as wstatus') 52 ->field('w.*,l.row,l.column,l.address,l.temple_id,l.number,t.name as tname ,ta.name as taname,w.status as wstatus')
  53 + ->order('w.create_time','desc')
53 ->paginate(10); 54 ->paginate(10);
54 //向地址传参 55 //向地址传参
55 $this->assign('page',$data->render()); 56 $this->assign('page',$data->render());
  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="javascript:;">系统消息</a></li>
  7 + <li class="active"> <a href="javascript:parent.openIframeLayer('{:url('AdminMessage/index2',array('id'=>$vo['id']))}','创建消息');">创建消息</a></li>
  8 + </ul>
  9 + <form method="post" class="js-ajax-form margin-top-20">
  10 + <div class="table-actions">
  11 + <!--
  12 + <notempty name="category">
  13 + <button class="btn btn-primary btn-sm js-articles-move" type="button">批量移动</button>
  14 + </notempty>
  15 + <button class="btn btn-primary btn-sm js-articles-copy" type="button">批量复制</button>
  16 + -->
  17 + <button class="btn btn-danger btn-sm js-ajax-submit" type="submit"
  18 + data-action="{:url('AdminWarning/delete')}" data-subcheck="true" data-msg="您确定删除吗?">
  19 + {:lang('DELETE')}
  20 + </button>
  21 + </div>
  22 + <table class="table table-hover table-bordered table-list">
  23 + <thead>
  24 + <tr>
  25 + <th width="15">
  26 + <label>
  27 + <input type="checkbox" class="js-check-all" data-direction="x" data-checklist="js-check-x">
  28 + </label>
  29 + </th>
  30 +
  31 + <th width="50">ID</th>
  32 + <th>消息类型</th>
  33 + <th>消息标题</th>
  34 + <th>消息内容</th>
  35 + <th>操作</th>
  36 + </tr>
  37 + </thead>
  38 + <tbody>
  39 + <foreach name="list" item="vo">
  40 + <tr>
  41 + <td>
  42 + <input type="checkbox" class="js-check" data-yid="js-check-y" data-xid="js-check-x" name="ids[]"
  43 + value="{$vo.id}" title="ID:{$vo.id}">
  44 + </td>
  45 + <td>{$vo.id}</td>
  46 + <td>{$vo.category}</td>
  47 + <td>{$vo.title}</td>
  48 + <td>{$vo.content}</td>
  49 + <td>
  50 + <a href="{:url('AdminWarning/delete',array('id'=>$vo['id']))}">
  51 + {:lang('DELETE')}
  52 + </a>
  53 + </td>
  54 + </tr>
  55 + </foreach>
  56 + </tbody>
  57 + <tfoot>
  58 + <tr>
  59 + <th width="15"><label><input type="checkbox" class="js-check-all" data-direction="x"
  60 + data-checklist="js-check-x"></label></th>
  61 + <th width="50">ID</th>
  62 + <th>消息类型</th>
  63 + <th>消息标题</th>
  64 + <th>消息内容</th>
  65 + <th>操作</th>
  66 + </tr>
  67 + </tfoot>
  68 + </table>
  69 + <div class="table-actions">
  70 + <!--<button type="submit" class="btn btn-primary btn-sm js-ajax-submit">{:lang('SORT')}</button>-->
  71 + <button class="btn btn-danger btn-sm js-ajax-submit" type="submit"
  72 + data-action="{:url('AdminWarning/delete')}" data-subcheck="true" data-msg="您确定删除吗?">
  73 + {:lang('DELETE')}
  74 + </button>
  75 + </div>
  76 + </form>
  77 + <ul class="pagination">{$page|default=''}</ul>
  78 +</div>
  79 +<script src="__STATIC__/js/admin.js">
  80 + $(function () {
  81 + setCookie("refersh_time", 0);
  82 + Wind.use('ajaxForm', 'artDialog', 'iframeTools', function () {
  83 + //批量复制
  84 + $('.js-articles-copy').click(function (e) {
  85 + var ids = [];
  86 + $("input[name='ids[]']").each(function () {
  87 + if ($(this).is(':checked')) {
  88 + ids.push($(this).val());
  89 + }
  90 + });
  91 +
  92 + if (ids.length == 0) {
  93 + art.dialog.through({
  94 + id: 'error',
  95 + icon: 'error',
  96 + content: '您没有勾选信息,无法进行操作!',
  97 + cancelVal: '关闭',
  98 + cancel: true
  99 + });
  100 + return false;
  101 + }
  102 +
  103 + ids = ids.join(',');
  104 + art.dialog.open("__ROOT__/index.php?g=portal&m=AdminArticle&a=copy&ids=" + ids, {
  105 + title: "批量复制",
  106 + width: "300px"
  107 + });
  108 + });
  109 + //批量移动
  110 + $('.js-articles-move').click(function (e) {
  111 + var ids = [];
  112 + $("input[name='ids[]']").each(function () {
  113 + if ($(this).is(':checked')) {
  114 + ids.push($(this).val());
  115 + }
  116 + });
  117 +
  118 + if (ids.length == 0) {
  119 + art.dialog.through({
  120 + id: 'error',
  121 + icon: 'error',
  122 + content: '您没有勾选信息,无法进行操作!',
  123 + cancelVal: '关闭',
  124 + cancel: true
  125 + });
  126 + return false;
  127 + }
  128 +
  129 + ids = ids.join(',');
  130 + art.dialog.open("__ROOT__/index.php?g=portal&m=AdminArticle&a=move&old_term_id={$term.term_id|default=0}&ids=" + ids, {
  131 + title: "批量移动",
  132 + width: "300px"
  133 + });
  134 + });
  135 + });
  136 + });
  137 +</script>
  138 +</body>
  139 +</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="javascript:;">创建消息</a></li>
  7 + </ul>
  8 + <form method="post" class="js-ajax-form margin-top-20">
  9 + <table class="table table-hover table-bordered table-list">
  10 + <thead>
  11 + <tr>
  12 + <th width="50">ID</th>
  13 + <th>消息类型</th>
  14 + <th>消息标题</th>
  15 + <th>消息内容</th>
  16 + <th>操作</th>
  17 + </tr>
  18 + </thead>
  19 + <tbody>
  20 + <foreach name="list" item="vo">
  21 + <tr>
  22 + <td>{$vo.id}</td>
  23 + <td>
  24 + <switch name="vo.category_id">
  25 + <case value="1">订单消息</case>
  26 + <case value="2">续费消息</case>
  27 + <case value="3">到期消息</case>
  28 + </switch>
  29 + </td>
  30 + <td>{$vo.title}</td>
  31 + <td>{$vo.content}</td>
  32 + <td>{$vo.tname}</td>
  33 + <td>
  34 + <a href="{:url('AdminMesaage/edit',array('id'=>$vo['id']))}">
  35 + 编辑
  36 + </a>
  37 + </td>
  38 + </tr>
  39 + </foreach>
  40 + </tbody>
  41 + <tfoot>
  42 + <th width="50">ID</th>
  43 + <th>消息类型</th>
  44 + <th>消息标题</th>
  45 + <th>消息内容</th>
  46 + <th>操作</th>
  47 + </tfoot>
  48 + </table>
  49 + <div class="table-actions">
  50 + <!--<button type="submit" class="btn btn-primary btn-sm js-ajax-submit">{:lang('SORT')}</button>-->
  51 + <button class="btn btn-danger btn-sm js-ajax-submit" type="submit"
  52 + data-action="{:url('AdminWarning/delete')}" data-subcheck="true" data-msg="您确定删除吗?">
  53 + {:lang('DELETE')}
  54 + </button>
  55 + </div>
  56 + </form>
  57 + <ul class="pagination">{$page|default=''}</ul>
  58 +</div>
  59 +<script src="__STATIC__/js/admin.js">
  60 + $(function () {
  61 + setCookie("refersh_time", 0);
  62 + Wind.use('ajaxForm', 'artDialog', 'iframeTools', function () {
  63 + //批量复制
  64 + $('.js-articles-copy').click(function (e) {
  65 + var ids = [];
  66 + $("input[name='ids[]']").each(function () {
  67 + if ($(this).is(':checked')) {
  68 + ids.push($(this).val());
  69 + }
  70 + });
  71 +
  72 + if (ids.length == 0) {
  73 + art.dialog.through({
  74 + id: 'error',
  75 + icon: 'error',
  76 + content: '您没有勾选信息,无法进行操作!',
  77 + cancelVal: '关闭',
  78 + cancel: true
  79 + });
  80 + return false;
  81 + }
  82 +
  83 + ids = ids.join(',');
  84 + art.dialog.open("__ROOT__/index.php?g=portal&m=AdminArticle&a=copy&ids=" + ids, {
  85 + title: "批量复制",
  86 + width: "300px"
  87 + });
  88 + });
  89 + //批量移动
  90 + $('.js-articles-move').click(function (e) {
  91 + var ids = [];
  92 + $("input[name='ids[]']").each(function () {
  93 + if ($(this).is(':checked')) {
  94 + ids.push($(this).val());
  95 + }
  96 + });
  97 +
  98 + if (ids.length == 0) {
  99 + art.dialog.through({
  100 + id: 'error',
  101 + icon: 'error',
  102 + content: '您没有勾选信息,无法进行操作!',
  103 + cancelVal: '关闭',
  104 + cancel: true
  105 + });
  106 + return false;
  107 + }
  108 +
  109 + ids = ids.join(',');
  110 + art.dialog.open("__ROOT__/index.php?g=portal&m=AdminArticle&a=move&old_term_id={$term.term_id|default=0}&ids=" + ids, {
  111 + title: "批量移动",
  112 + width: "300px"
  113 + });
  114 + });
  115 + });
  116 + });
  117 +</script>
  118 +</body>
  119 +</html>