更新
This commit is contained in:
parent
e52e1fa1c3
commit
7b593aea1f
121
app/admin/controller/nk/Community.php
Normal file
121
app/admin/controller/nk/Community.php
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\admin\controller\nk;
|
||||||
|
|
||||||
|
use app\admin\BaseController;
|
||||||
|
use think\facade\Db;
|
||||||
|
use think\facade\View;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文章投诉
|
||||||
|
*
|
||||||
|
* @icon fa fa-circle-o
|
||||||
|
*/
|
||||||
|
class Community extends BaseController
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构造函数
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->adminInfo = get_login_admin();
|
||||||
|
$this->url=[
|
||||||
|
'/admin/nk.community/index',
|
||||||
|
'/admin/nk.community/add',
|
||||||
|
'/admin/nk.community/edit',
|
||||||
|
'/admin/nk.community/del',
|
||||||
|
'/admin/nk.community/read',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 数据列表
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
if (request()->isAjax()) {
|
||||||
|
$params= get_params();
|
||||||
|
$where['status']=1;
|
||||||
|
$where = [];
|
||||||
|
if (isset($params['keywords'])){
|
||||||
|
// $where[]=['title','like','%'.$params['keywords'].'%'];
|
||||||
|
}
|
||||||
|
if($this->adminInfo['position_id'] != 1){ //不是超级管理员
|
||||||
|
$www['admin_id'] = $this->adminInfo['id'];
|
||||||
|
$user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find();
|
||||||
|
if ($user_address){
|
||||||
|
if ($user_address['auth_range'] == 2){
|
||||||
|
$where['street_id'] = $user_address['street_id'];
|
||||||
|
}elseif ($user_address['auth_range'] == 3){
|
||||||
|
$where['area_id'] = $user_address['area_id'];
|
||||||
|
}else{
|
||||||
|
$where['village_id'] = $user_address['village_id'];
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$where['village_id'] = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$total = Db::connect('shop')->name('community_address')
|
||||||
|
->where($where)
|
||||||
|
->count();
|
||||||
|
if ($total!=0){
|
||||||
|
$list = Db::connect('shop')->name('community_address')
|
||||||
|
->where($where)
|
||||||
|
->page($params['page'])
|
||||||
|
->limit($params['limit'])
|
||||||
|
->select();
|
||||||
|
$arr=[];
|
||||||
|
foreach ($list as $k=>$v){
|
||||||
|
$arr[]=$v['community_id'];
|
||||||
|
}
|
||||||
|
$list2=Db::connect('shop')->name('community')->where('community_id','in',$arr)->select();
|
||||||
|
}else{
|
||||||
|
$list2=[];
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = ['total' => $total, 'data' => $list2];
|
||||||
|
return table_assign(0, '', $result);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return view('nk/community/index',['url'=>$this->url]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查看信息
|
||||||
|
*/
|
||||||
|
public function read()
|
||||||
|
{
|
||||||
|
$param= get_params();
|
||||||
|
$id = isset($param['id']) ? $param['id'] : 0;
|
||||||
|
$detail = Db::connect('shop')->name('community')->where('community_id',$id)->find();
|
||||||
|
if (!empty($detail)) {
|
||||||
|
View::assign('detail', $detail);
|
||||||
|
return view();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
throw new \think\exception\HttpException(404, '找不到页面');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 删除
|
||||||
|
*/
|
||||||
|
public function del()
|
||||||
|
{
|
||||||
|
$param= get_params();
|
||||||
|
$id = isset($param['id']) ? $param['id'] : 0;
|
||||||
|
$res = Db::connect('shop')->name('community')->where('community_id',$id)->delete();
|
||||||
|
Db::connect('shop')->name('community_address')->where('community_id',$id)->delete();
|
||||||
|
if ($res){
|
||||||
|
return to_assign();
|
||||||
|
}else{
|
||||||
|
return to_assign(1, '操作失败,原因:'.$res);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
83
app/admin/controller/nk/RuralWelfare.php
Normal file
83
app/admin/controller/nk/RuralWelfare.php
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\admin\controller\nk;
|
||||||
|
|
||||||
|
use app\admin\BaseController;
|
||||||
|
use think\facade\View;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文章
|
||||||
|
*
|
||||||
|
* @icon fa fa-circle-o
|
||||||
|
*/
|
||||||
|
class RuralWelfare extends BaseController
|
||||||
|
{
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->adminInfo = get_login_admin();
|
||||||
|
$this->category_id=352;
|
||||||
|
$this->url=[
|
||||||
|
'/admin/nk.ruralwelfare/index?category_id='.$this->category_id,
|
||||||
|
'/admin/nk.ruralwelfare/add',
|
||||||
|
'/admin/nk.ruralwelfare/edit',
|
||||||
|
'/admin/nk.ruralwelfare/del',
|
||||||
|
'/admin/nk.ruralwelfare/read',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 查看
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
if (request()->isAjax()) {
|
||||||
|
$params= get_params();
|
||||||
|
$params['category_id']=$this->category_id;
|
||||||
|
(new Article())->index($params);
|
||||||
|
}
|
||||||
|
return view('nk/article/index',['url'=>$this->url]);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 添加
|
||||||
|
*/
|
||||||
|
public function add()
|
||||||
|
{
|
||||||
|
if (request()->isAjax()) {
|
||||||
|
$params= get_params();
|
||||||
|
$params['category_id']=$this->category_id;
|
||||||
|
(new Article())->add($params);
|
||||||
|
}else{
|
||||||
|
View::assign('editor', get_system_config('other','editor'));
|
||||||
|
View::assign('url', $this->url);
|
||||||
|
return view('nk/article/add');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 修改
|
||||||
|
*/
|
||||||
|
public function edit()
|
||||||
|
{
|
||||||
|
$params= get_params();
|
||||||
|
(new Article())->edit($params);
|
||||||
|
return view('nk/article/edit',['url'=>$this->url]);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 查看信息
|
||||||
|
*/
|
||||||
|
public function read()
|
||||||
|
{
|
||||||
|
$params = get_params();
|
||||||
|
(new Article())->read($params);
|
||||||
|
|
||||||
|
return view('nk/article/read',['url'=>$this->url]);
|
||||||
|
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 修改
|
||||||
|
*/
|
||||||
|
public function del()
|
||||||
|
{
|
||||||
|
$params= get_params();
|
||||||
|
(new Article())->del($params);
|
||||||
|
}
|
||||||
|
}
|
122
app/admin/view/nk/community/index.html
Normal file
122
app/admin/view/nk/community/index.html
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
{extend name="common/base"/}
|
||||||
|
<!-- 主体 -->
|
||||||
|
{block name="body"}
|
||||||
|
|
||||||
|
<div class="p-3">
|
||||||
|
<form class="layui-form gg-form-bar border-t border-x">
|
||||||
|
<div class="layui-input-inline" style="width:300px;">
|
||||||
|
<input type="text" name="keywords" placeholder="请输入标题" class="layui-input" autocomplete="off" />
|
||||||
|
</div>
|
||||||
|
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="searchform">提交搜索</button>
|
||||||
|
</form>
|
||||||
|
<table class="layui-hide" id="article" lay-filter="article"></table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script type="text/html" id="status">
|
||||||
|
<i class="layui-icon {{# if(d.status == 1){ }}layui-icon-ok{{# } else { }}layui-icon-close{{# } }}"></i>
|
||||||
|
</script>
|
||||||
|
<script type="text/html" id="is_home">
|
||||||
|
<i class="layui-icon {{# if(d.is_home == 1){ }}layui-icon-ok{{# } else { }}layui-icon-close{{# } }}"></i>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script type="text/html" id="toolbarDemo">
|
||||||
|
<div class="layui-btn-container">
|
||||||
|
<span class="layui-btn layui-btn-sm" lay-event="add" data-title="添加内容">+ 添加内容</span>
|
||||||
|
</div>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script type="text/html" id="barDemo">
|
||||||
|
<div class="layui-btn-group"><a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="read">查看</a><a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a></div>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{/block}
|
||||||
|
<!-- /主体 -->
|
||||||
|
|
||||||
|
<!-- 脚本 -->
|
||||||
|
{block name="script"}
|
||||||
|
<script>
|
||||||
|
const moduleInit = ['tool'];
|
||||||
|
function gouguInit() {
|
||||||
|
var table = layui.table,tool = layui.tool, form = layui.form;
|
||||||
|
layui.pageTable = table.render({
|
||||||
|
elem: '#article',
|
||||||
|
title: '文章表列表',
|
||||||
|
toolbar: '#toolbarDemo',
|
||||||
|
url: '{$url[0]}',
|
||||||
|
page: true,
|
||||||
|
limit: 20,
|
||||||
|
cellMinWidth: 300,
|
||||||
|
cols: [
|
||||||
|
[
|
||||||
|
{
|
||||||
|
fixed: 'left',
|
||||||
|
field: 'community_id',
|
||||||
|
title: '编号',
|
||||||
|
align: 'center',
|
||||||
|
width:120,
|
||||||
|
},{
|
||||||
|
field: 'title',
|
||||||
|
title: '标题',
|
||||||
|
},{
|
||||||
|
fixed: 'right',
|
||||||
|
field: 'right',
|
||||||
|
title: '操作',
|
||||||
|
toolbar: '#barDemo',
|
||||||
|
align: 'center'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
//监听表头工具栏事件
|
||||||
|
table.on('toolbar(article)', function(obj){
|
||||||
|
if (obj.event === 'add') {
|
||||||
|
tool.side('{$url[1]}');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//监听表格行工具事件
|
||||||
|
table.on('tool(article)', function(obj) {
|
||||||
|
var data = obj.data;
|
||||||
|
if (obj.event === 'read') {
|
||||||
|
tool.side('{$url[4]}?id='+obj.data.community_id);
|
||||||
|
}
|
||||||
|
else if (obj.event === 'edit') {
|
||||||
|
tool.side('{$url[2]}?id='+obj.data.community_id);
|
||||||
|
}
|
||||||
|
else if (obj.event === 'del') {
|
||||||
|
layer.confirm('确定要删除该记录吗?', {
|
||||||
|
icon: 3,
|
||||||
|
title: '提示'
|
||||||
|
}, function(index) {
|
||||||
|
let callback = function (e) {
|
||||||
|
layer.msg(e.msg);
|
||||||
|
if (e.code == 0) {
|
||||||
|
obj.del();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tool.delete('{$url[3]}', { id: data.community_id }, callback);
|
||||||
|
layer.close(index);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
//监听搜索提交
|
||||||
|
form.on('submit(searchform)', function(data) {
|
||||||
|
layui.pageTable.reload({
|
||||||
|
where: {
|
||||||
|
keywords: data.field.keywords,
|
||||||
|
cate_id: data.field.cate_id
|
||||||
|
},
|
||||||
|
page: {
|
||||||
|
curr: 1
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
{/block}
|
||||||
|
<!-- /脚本 -->
|
29
app/admin/view/nk/community/read.html
Normal file
29
app/admin/view/nk/community/read.html
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
{extend name="common/base"/}
|
||||||
|
{block name="style"}
|
||||||
|
<style>
|
||||||
|
.content-article img{max-width:88%!important; height:auto!important; margin:6px 0!important; border-radius:4px;}
|
||||||
|
</style>
|
||||||
|
{/block}
|
||||||
|
<!-- 主体 -->
|
||||||
|
{block name="body"}
|
||||||
|
<div class="layui-form p-4">
|
||||||
|
<h3 class="pb-3">文章详情</h3>
|
||||||
|
<table class="layui-table layui-table-form">
|
||||||
|
<tr>
|
||||||
|
<td class="layui-td-gray">标题<font>*</font></td>
|
||||||
|
<td colspan="7">{$detail.title}</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td colspan="6" class="layui-td-gray" style="text-align:left">内容</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="6">
|
||||||
|
{$detail.content|raw}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
{/block}
|
||||||
|
<!-- /主体 -->
|
Loading…
x
Reference in New Issue
Block a user