Merge branch 'master' of https://gitee.com/luzhou-lihai-agriculture/nk-lihaink-cn
This commit is contained in:
commit
843fd6f9da
160
app/admin/controller/nk/Article.php
Normal file
160
app/admin/controller/nk/Article.php
Normal file
@ -0,0 +1,160 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\admin\controller\nk;
|
||||||
|
|
||||||
|
use app\admin\BaseController;
|
||||||
|
use think\exception\ValidateException;
|
||||||
|
use think\facade\Db;
|
||||||
|
use think\facade\View;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文章
|
||||||
|
*
|
||||||
|
* @icon fa fa-circle-o
|
||||||
|
*/
|
||||||
|
class Article extends BaseController
|
||||||
|
{
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->adminInfo = get_login_admin();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function index($params)
|
||||||
|
{
|
||||||
|
$where=[
|
||||||
|
'status'=>1
|
||||||
|
];
|
||||||
|
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'] == 1){
|
||||||
|
$where['village'] = $user_address['village_id'];
|
||||||
|
}elseif ($user_address['auth_range'] == 2){
|
||||||
|
$where['township'] = $user_address['street_id'];
|
||||||
|
}elseif ($user_address['auth_range'] == 3){
|
||||||
|
$where['county'] = $user_address['area_id'];
|
||||||
|
}else{
|
||||||
|
$where['village'] = $user_address['village_id'];
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$where['village'] = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$category_id =$params['category_id'];
|
||||||
|
|
||||||
|
if($category_id){
|
||||||
|
$map[] = ['category_id','in',$category_id];
|
||||||
|
}else{
|
||||||
|
$map = [];
|
||||||
|
}
|
||||||
|
$total = Db::table('fa_article')
|
||||||
|
->where($where)
|
||||||
|
->where($map)
|
||||||
|
->count();
|
||||||
|
|
||||||
|
$list = Db::table('fa_article')
|
||||||
|
->withAttr('nickname',function ($value,$data){
|
||||||
|
return Db::table('fa_szxc_information_usermsg')->where('user_id',$data['user_id'])->value('name');
|
||||||
|
})
|
||||||
|
->withAttr('area',function ($value,$data){
|
||||||
|
return Db::table('fa_geo_area')->where('area_code',$data['county'])->value('area_name');
|
||||||
|
})
|
||||||
|
->withAttr('street',function ($value,$data){
|
||||||
|
return Db::table('fa_geo_street')->where('street_code',$data['township'])->value('street_name');
|
||||||
|
})
|
||||||
|
->withAttr('village',function ($value,$data){
|
||||||
|
return Db::table('fa_geo_village')->where('village_id',$data['village'])->value('village_name');
|
||||||
|
})
|
||||||
|
->where($where)
|
||||||
|
->where($map)
|
||||||
|
->page($params['page'])
|
||||||
|
->limit($params['limit'])
|
||||||
|
->field('id,title,user_id,county,township,village,image,view_time')
|
||||||
|
|
||||||
|
->select();
|
||||||
|
$result = ['total' => $total, 'data' => $list];
|
||||||
|
return table_assign(0, '', $result);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function add($param){
|
||||||
|
// 检验完整性
|
||||||
|
try {
|
||||||
|
validate(\app\admin\validate\party\Article::class)->check($param);
|
||||||
|
} catch (ValidateException $e) {
|
||||||
|
// 验证失败 输出错误信息
|
||||||
|
return to_assign(1, $e->getError());
|
||||||
|
}
|
||||||
|
$adds=Db::table('fa_szxc_information_useraddress')->where('admin_id',$this->adminInfo['id'])->find();
|
||||||
|
$param['view_time']=date('Y-m-d H:i:s');
|
||||||
|
$param['county']=$adds['area_id'];
|
||||||
|
$param['township']=$adds['street_id'];
|
||||||
|
$param['village']=$adds['village_id'];
|
||||||
|
$param['user_id']=$adds['user_id'];
|
||||||
|
$res=Db::table('fa_article')->strict(false)->field(true)->insertGetId($param);
|
||||||
|
if ($res){
|
||||||
|
return to_assign(0,'操作成功',['aid'=>$res]);
|
||||||
|
}
|
||||||
|
return to_assign(1, '操作失败,原因:'.$res);
|
||||||
|
}
|
||||||
|
public function edit($param){
|
||||||
|
if (request()->isAjax()) {
|
||||||
|
try {
|
||||||
|
validate(\app\admin\validate\party\Article::class)->check($param);
|
||||||
|
} catch (ValidateException $e) {
|
||||||
|
// 验证失败 输出错误信息
|
||||||
|
return to_assign(1, $e->getError());
|
||||||
|
}
|
||||||
|
$res=Db::table('fa_article')->where('id',$param['id'])->strict(false)->field(true)->update($param);
|
||||||
|
if ($res){
|
||||||
|
return to_assign();
|
||||||
|
}else{
|
||||||
|
return to_assign(1, '操作失败,原因:'.$res);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$id = isset($param['id']) ? $param['id'] : 0;
|
||||||
|
$detail = Db::table('fa_article')->where('id',$id)->find();
|
||||||
|
View::assign('editor', get_system_config('other','editor'));
|
||||||
|
if (!empty($detail)) {
|
||||||
|
View::assign('detail', $detail);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
throw new \think\exception\HttpException(404, '找不到页面');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 查看信息
|
||||||
|
*/
|
||||||
|
public function read($param)
|
||||||
|
{
|
||||||
|
$id = isset($param['id']) ? $param['id'] : 0;
|
||||||
|
$detail = Db::table('fa_article')->where('id',$id)->find();
|
||||||
|
if (!empty($detail)) {
|
||||||
|
View::assign('detail', $detail);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
throw new \think\exception\HttpException(404, '找不到页面');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 删除
|
||||||
|
*/
|
||||||
|
public function del($param)
|
||||||
|
{
|
||||||
|
$id = isset($param['id']) ? $param['id'] : 0;
|
||||||
|
$type = isset($param['type']) ? $param['type'] : 0;
|
||||||
|
$res = Db::table('fa_article')->where('id',$id)->update(['status'=>$type]);
|
||||||
|
if ($res){
|
||||||
|
return to_assign();
|
||||||
|
}else{
|
||||||
|
return to_assign(1, '操作失败,原因:'.$res);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
86
app/admin/controller/nk/Townnews.php
Normal file
86
app/admin/controller/nk/Townnews.php
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\admin\controller\nk;
|
||||||
|
|
||||||
|
use app\admin\BaseController;
|
||||||
|
use think\exception\ValidateException;
|
||||||
|
use think\facade\Db;
|
||||||
|
use app\admin\controller\nk\Article;
|
||||||
|
use think\facade\View;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文章
|
||||||
|
*
|
||||||
|
* @icon fa fa-circle-o
|
||||||
|
*/
|
||||||
|
class Townnews extends BaseController
|
||||||
|
{
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->adminInfo = get_login_admin();
|
||||||
|
$this->category_id=304;
|
||||||
|
$this->url=[
|
||||||
|
'/admin/nk.townnews/index?category_id='.$this->category_id,
|
||||||
|
'/admin/nk.townnews/add',
|
||||||
|
'/admin/nk.townnews/edit',
|
||||||
|
'/admin/nk.townnews/del',
|
||||||
|
'/admin/nk.townnews/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);
|
||||||
|
}
|
||||||
|
}
|
83
app/admin/controller/nk/Treasure.php
Normal file
83
app/admin/controller/nk/Treasure.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 Treasure extends BaseController
|
||||||
|
{
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->adminInfo = get_login_admin();
|
||||||
|
$this->category_id=305;
|
||||||
|
$this->url=[
|
||||||
|
'/admin/nk.treasure/index?category_id='.$this->category_id,
|
||||||
|
'/admin/nk.treasure/add',
|
||||||
|
'/admin/nk.treasure/edit',
|
||||||
|
'/admin/nk.treasure/del',
|
||||||
|
'/admin/nk.treasure/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);
|
||||||
|
}
|
||||||
|
}
|
@ -19,7 +19,8 @@ class Auth
|
|||||||
{
|
{
|
||||||
//获取模块名称
|
//获取模块名称
|
||||||
$controller = app('http')->getName();
|
$controller = app('http')->getName();
|
||||||
$pathInfo = str_replace('.' . $request->ext(), '', $request->pathInfo());
|
// $pathInfo = str_replace('.' . $request->ext(), '', $request->pathInfo());
|
||||||
|
$pathInfo = str_replace('.html', '', $request->pathInfo());
|
||||||
$action = explode('/', $pathInfo)[0];
|
$action = explode('/', $pathInfo)[0];
|
||||||
//var_dump($pathInfo);exit;
|
//var_dump($pathInfo);exit;
|
||||||
if ($pathInfo == '' || $action == '') {
|
if ($pathInfo == '' || $action == '') {
|
||||||
@ -41,6 +42,8 @@ class Auth
|
|||||||
// 验证用户访问权限
|
// 验证用户访问权限
|
||||||
if ($action !== 'index' && $action !== 'api') {
|
if ($action !== 'index' && $action !== 'api') {
|
||||||
if (!$this->checkAuth($controller, $pathInfo, $action, $uid)) {
|
if (!$this->checkAuth($controller, $pathInfo, $action, $uid)) {
|
||||||
|
// $pathUrl = $controller . '/' . $pathInfo;
|
||||||
|
// halt($pathUrl,Cache::get('RulesSrc' . $uid));
|
||||||
if ($request->isAjax()) {
|
if ($request->isAjax()) {
|
||||||
return to_assign(202, '你没有权限,请联系超级管理员!');
|
return to_assign(202, '你没有权限,请联系超级管理员!');
|
||||||
} else {
|
} else {
|
||||||
@ -99,7 +102,6 @@ class Auth
|
|||||||
$auth_list_all = Cache::get('RulesSrc0');
|
$auth_list_all = Cache::get('RulesSrc0');
|
||||||
$auth_list = Cache::get('RulesSrc' . $uid);
|
$auth_list = Cache::get('RulesSrc' . $uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
$pathUrl = $controller . '/' . $pathInfo;
|
$pathUrl = $controller . '/' . $pathInfo;
|
||||||
if (!in_array($pathUrl, $auth_list)) {
|
if (!in_array($pathUrl, $auth_list)) {
|
||||||
return false;
|
return false;
|
||||||
|
102
app/admin/view/nk/article/add.html
Normal file
102
app/admin/view/nk/article/add.html
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
{extend name="common/base"/}
|
||||||
|
{block name="style"}
|
||||||
|
<style type="text/css">
|
||||||
|
.editormd-code-toolbar select {display: inline-block}
|
||||||
|
.editormd li {list-style: inherit;}
|
||||||
|
</style>
|
||||||
|
{/block}
|
||||||
|
<!-- 主体 -->
|
||||||
|
{block name="body"}
|
||||||
|
<form 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"><input type="text" name="title" lay-verify="required" lay-reqText="请输入文章标题"
|
||||||
|
autocomplete="off" placeholder="请输入文章标题" class="layui-input"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="layui-td-gray" style="vertical-align:top;">文章摘要</td>
|
||||||
|
<td colspan="3">
|
||||||
|
<textarea name="describe" placeholder="请输入摘要,不能超过200个字" class="layui-textarea"></textarea>
|
||||||
|
</td>
|
||||||
|
<td class="layui-td-gray" style="vertical-align:top;">缩略图</td>
|
||||||
|
<td>
|
||||||
|
<div class="layui-upload">
|
||||||
|
<button type="button" class="layui-btn layui-btn-sm" id="upload_btn_thumb">上传缩略图(尺寸:640x360)</button>
|
||||||
|
<div class="layui-upload-list" id="upload_box_thumb" style="width: 120px; height:66px; overflow: hidden;">
|
||||||
|
<img src="" onerror="javascript:this.src='{__GOUGU__}/gougu/images/nonepic600x360.jpg';this.onerror=null;" width="100" style="max-width: 100%; height:66px;"/>
|
||||||
|
<input type="hidden" name="image" value="">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="6" class="layui-td-gray" style="text-align:left">文章内容</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="6">
|
||||||
|
<textarea class="layui-textarea" id="container_content"></textarea>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
</table>
|
||||||
|
<div class="pt-3">
|
||||||
|
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">立即提交</button>
|
||||||
|
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
{/block}
|
||||||
|
<!-- /主体 -->
|
||||||
|
|
||||||
|
<!-- 脚本 -->
|
||||||
|
{block name="script"}
|
||||||
|
<script>
|
||||||
|
const editorType = '{$editor}';
|
||||||
|
var moduleInit = ['tool', 'tagpicker', 'tinymce'];
|
||||||
|
|
||||||
|
function gouguInit() {
|
||||||
|
var form = layui.form, tool = layui.tool,tagspicker = layui.tagpicker;
|
||||||
|
|
||||||
|
//上传缩略图
|
||||||
|
var upload_thumb = layui.upload.render({
|
||||||
|
elem: '#upload_btn_thumb',
|
||||||
|
url: '/admin/api/upload',
|
||||||
|
done: function (res) {
|
||||||
|
//如果上传失败
|
||||||
|
if (res.code == 1) {
|
||||||
|
return layer.msg('上传失败');
|
||||||
|
}
|
||||||
|
//上传成功
|
||||||
|
$('#upload_box_thumb input').attr('value', res.data.filepath);
|
||||||
|
$('#upload_box_thumb img').attr('src', res.data.filepath);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var editor = layui.tinymce;
|
||||||
|
var edit = editor.render({
|
||||||
|
selector: "#container_content",
|
||||||
|
height: 500
|
||||||
|
});
|
||||||
|
//监听提交
|
||||||
|
form.on('submit(webform)', function (data) {
|
||||||
|
data.field.content = tinyMCE.editors['container_content'].getContent();
|
||||||
|
if (data.field.content == '') {
|
||||||
|
layer.msg('请先完善文章内容');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
let callback = function (e) {
|
||||||
|
layer.msg(e.msg);
|
||||||
|
if (e.code == 0) {
|
||||||
|
tool.tabRefresh(71);
|
||||||
|
tool.sideClose(1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tool.post('{$url[1]}', data.field, callback);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
{/block}
|
||||||
|
<!-- /脚本 -->
|
119
app/admin/view/nk/article/edit.html
Normal file
119
app/admin/view/nk/article/edit.html
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
{extend name="common/base"/}
|
||||||
|
{block name="style"}
|
||||||
|
<style type="text/css">
|
||||||
|
.editormd-code-toolbar select {
|
||||||
|
display: inline-block
|
||||||
|
}
|
||||||
|
|
||||||
|
.editormd li {
|
||||||
|
list-style: inherit;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
{/block}
|
||||||
|
<!-- 主体 -->
|
||||||
|
{block name="body"}
|
||||||
|
<form 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"><input type="text" name="title" lay-verify="required" lay-reqText="请输入文章标题"
|
||||||
|
autocomplete="off" placeholder="请输入文章标题" class="layui-input"
|
||||||
|
value="{$detail.title}"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="layui-td-gray" style="vertical-align:top;">摘要</td>
|
||||||
|
<td colspan="3">
|
||||||
|
<textarea name="describe" placeholder="请输入摘要,不能超过200个字"
|
||||||
|
class="layui-textarea">{$detail.describe}</textarea>
|
||||||
|
</td>
|
||||||
|
<td class="layui-td-gray" style="vertical-align:top;">缩略图</td>
|
||||||
|
<td>
|
||||||
|
<div class="layui-upload">
|
||||||
|
<button type="button" class="layui-btn layui-btn-sm" id="upload_btn_thumb">
|
||||||
|
上传缩略图(尺寸:640x360)
|
||||||
|
</button>
|
||||||
|
<div class="layui-upload-list" id="upload_box_thumb"
|
||||||
|
style="width: 120px; height:66px; overflow: hidden;">
|
||||||
|
<img src="{$detail.image}"
|
||||||
|
onerror="javascript:this.src='{__GOUGU__}/gougu/images/nonepic600x360.jpg';this.onerror=null;"
|
||||||
|
style="max-width: 100%; height:66px;"/>
|
||||||
|
<input type="hidden" name="image" value="{$detail.image}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="6" class="layui-td-gray" style="text-align:left">文章内容</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="6">
|
||||||
|
<textarea placeholder="请输入内容" class="layui-textarea"
|
||||||
|
id="container_content">{$detail.content}</textarea>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<div class="pt-3">
|
||||||
|
<input type="hidden" name="id" value="{$detail.id}"/>
|
||||||
|
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">立即提交</button>
|
||||||
|
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
{/block}
|
||||||
|
<!-- /主体 -->
|
||||||
|
|
||||||
|
<!-- 脚本 -->
|
||||||
|
{block name="script"}
|
||||||
|
<script>
|
||||||
|
const editorType = '{$editor}';
|
||||||
|
var moduleInit;
|
||||||
|
if (editorType == 1) {
|
||||||
|
moduleInit = ['tool', 'tagpicker', 'tinymce'];
|
||||||
|
} else {
|
||||||
|
moduleInit = ['tool', 'tagpicker', 'editormd'];
|
||||||
|
}
|
||||||
|
|
||||||
|
function gouguInit() {
|
||||||
|
var form = layui.form, tool = layui.tool, tagpicker = layui.tagpicker;
|
||||||
|
|
||||||
|
//上传缩略图
|
||||||
|
var upload_thumb = layui.upload.render({
|
||||||
|
elem: '#upload_btn_thumb',
|
||||||
|
url: '/admin/api/upload',
|
||||||
|
done: function (res) {
|
||||||
|
//如果上传失败
|
||||||
|
if (res.code == 1) {
|
||||||
|
layer.msg('上传失败');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
//上传成功
|
||||||
|
$('#upload_box_thumb input').attr('value', res.data.filepath);
|
||||||
|
$('#upload_box_thumb img').attr('src', res.data.filepath);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
var editor = layui.tinymce;
|
||||||
|
var edit = editor.render({
|
||||||
|
selector: "#container_content",
|
||||||
|
height: 500
|
||||||
|
});
|
||||||
|
//监听提交
|
||||||
|
form.on('submit(webform)', function (data) {
|
||||||
|
data.field.content = tinyMCE.editors['container_content'].getContent();
|
||||||
|
if (data.field.content == '') {
|
||||||
|
layer.msg('请先完善文章内容');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
let callback = function (e) {
|
||||||
|
layer.msg(e.msg);
|
||||||
|
if (e.code == 0) {
|
||||||
|
tool.sideClose(1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tool.post("{$url[2]}", data.field, callback);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
{/block}
|
||||||
|
<!-- /脚本 -->
|
148
app/admin/view/nk/article/index.html
Normal file
148
app/admin/view/nk/article/index.html
Normal file
@ -0,0 +1,148 @@
|
|||||||
|
{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-xs" lay-event="edit">编辑</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: 'id',
|
||||||
|
title: '编号',
|
||||||
|
align: 'center',
|
||||||
|
width: 80
|
||||||
|
},{
|
||||||
|
field: 'title',
|
||||||
|
title: '文章标题',
|
||||||
|
},{
|
||||||
|
field: 'nickname',
|
||||||
|
title: '用户',
|
||||||
|
align: 'center',
|
||||||
|
width: 90
|
||||||
|
},{
|
||||||
|
field: 'area',
|
||||||
|
title: '区县',
|
||||||
|
align: 'center',
|
||||||
|
width: 90
|
||||||
|
},{
|
||||||
|
field: 'street',
|
||||||
|
title: '乡镇',
|
||||||
|
align: 'center',
|
||||||
|
width: 90
|
||||||
|
},{
|
||||||
|
field: 'village',
|
||||||
|
title: '街道/村',
|
||||||
|
align: 'center',
|
||||||
|
width: 90
|
||||||
|
},{
|
||||||
|
field: 'view_time',
|
||||||
|
title: '发布时间',
|
||||||
|
align: 'center',
|
||||||
|
width: 160
|
||||||
|
},{
|
||||||
|
fixed: 'right',
|
||||||
|
field: 'right',
|
||||||
|
title: '操作',
|
||||||
|
toolbar: '#barDemo',
|
||||||
|
width: 136,
|
||||||
|
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.id);
|
||||||
|
}
|
||||||
|
else if (obj.event === 'edit') {
|
||||||
|
tool.side('{$url[2]}?id='+obj.data.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.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}
|
||||||
|
<!-- /脚本 -->
|
39
app/admin/view/nk/article/read.html
Normal file
39
app/admin/view/nk/article/read.html
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
{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">文章标题</td>
|
||||||
|
<td colspan="3">{$detail.title}</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td class="layui-td-gray">创建时间</td>
|
||||||
|
<td>{$detail.view_time}</td>
|
||||||
|
<td class="layui-td-gray">状态</td>
|
||||||
|
<td>
|
||||||
|
{eq name="$detail.status" value="1"}正常{/eq}
|
||||||
|
{eq name="$detail.status" value="0"}下架{/eq}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="layui-td-gray">文章摘要</td>
|
||||||
|
<td colspan="3">{$detail.describe}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="layui-td-gray">文章内容</td>
|
||||||
|
<td colspan="5" class="content-article">
|
||||||
|
{$detail.content|raw}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
{/block}
|
||||||
|
<!-- /主体 -->
|
102
app/admin/view/party/article/add.html
Normal file
102
app/admin/view/party/article/add.html
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
{extend name="common/base"/}
|
||||||
|
{block name="style"}
|
||||||
|
<style type="text/css">
|
||||||
|
.editormd-code-toolbar select {display: inline-block}
|
||||||
|
.editormd li {list-style: inherit;}
|
||||||
|
</style>
|
||||||
|
{/block}
|
||||||
|
<!-- 主体 -->
|
||||||
|
{block name="body"}
|
||||||
|
<form 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"><input type="text" name="title" lay-verify="required" lay-reqText="请输入文章标题"
|
||||||
|
autocomplete="off" placeholder="请输入文章标题" class="layui-input"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="layui-td-gray" style="vertical-align:top;">文章摘要</td>
|
||||||
|
<td colspan="3">
|
||||||
|
<textarea name="describe" placeholder="请输入摘要,不能超过200个字" class="layui-textarea"></textarea>
|
||||||
|
</td>
|
||||||
|
<td class="layui-td-gray" style="vertical-align:top;">缩略图</td>
|
||||||
|
<td>
|
||||||
|
<div class="layui-upload">
|
||||||
|
<button type="button" class="layui-btn layui-btn-sm" id="upload_btn_thumb">上传缩略图(尺寸:640x360)</button>
|
||||||
|
<div class="layui-upload-list" id="upload_box_thumb" style="width: 120px; height:66px; overflow: hidden;">
|
||||||
|
<img src="" onerror="javascript:this.src='{__GOUGU__}/gougu/images/nonepic600x360.jpg';this.onerror=null;" width="100" style="max-width: 100%; height:66px;"/>
|
||||||
|
<input type="hidden" name="image" value="">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="6" class="layui-td-gray" style="text-align:left">文章内容</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="6">
|
||||||
|
<textarea class="layui-textarea" id="container_content"></textarea>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
</table>
|
||||||
|
<div class="pt-3">
|
||||||
|
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">立即提交</button>
|
||||||
|
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
{/block}
|
||||||
|
<!-- /主体 -->
|
||||||
|
|
||||||
|
<!-- 脚本 -->
|
||||||
|
{block name="script"}
|
||||||
|
<script>
|
||||||
|
const editorType = '{$editor}';
|
||||||
|
var moduleInit = ['tool', 'tagpicker', 'tinymce'];
|
||||||
|
|
||||||
|
function gouguInit() {
|
||||||
|
var form = layui.form, tool = layui.tool,tagspicker = layui.tagpicker;
|
||||||
|
|
||||||
|
//上传缩略图
|
||||||
|
var upload_thumb = layui.upload.render({
|
||||||
|
elem: '#upload_btn_thumb',
|
||||||
|
url: '/admin/api/upload',
|
||||||
|
done: function (res) {
|
||||||
|
//如果上传失败
|
||||||
|
if (res.code == 1) {
|
||||||
|
return layer.msg('上传失败');
|
||||||
|
}
|
||||||
|
//上传成功
|
||||||
|
$('#upload_box_thumb input').attr('value', res.data.filepath);
|
||||||
|
$('#upload_box_thumb img').attr('src', res.data.filepath);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var editor = layui.tinymce;
|
||||||
|
var edit = editor.render({
|
||||||
|
selector: "#container_content",
|
||||||
|
height: 500
|
||||||
|
});
|
||||||
|
//监听提交
|
||||||
|
form.on('submit(webform)', function (data) {
|
||||||
|
data.field.content = tinyMCE.editors['container_content'].getContent();
|
||||||
|
if (data.field.content == '') {
|
||||||
|
layer.msg('请先完善文章内容');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
let callback = function (e) {
|
||||||
|
layer.msg(e.msg);
|
||||||
|
if (e.code == 0) {
|
||||||
|
tool.tabRefresh(71);
|
||||||
|
tool.sideClose(1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tool.post("/admin/party.article/add", data.field, callback);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
{/block}
|
||||||
|
<!-- /脚本 -->
|
119
app/admin/view/party/article/edit.html
Normal file
119
app/admin/view/party/article/edit.html
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
{extend name="common/base"/}
|
||||||
|
{block name="style"}
|
||||||
|
<style type="text/css">
|
||||||
|
.editormd-code-toolbar select {
|
||||||
|
display: inline-block
|
||||||
|
}
|
||||||
|
|
||||||
|
.editormd li {
|
||||||
|
list-style: inherit;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
{/block}
|
||||||
|
<!-- 主体 -->
|
||||||
|
{block name="body"}
|
||||||
|
<form 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"><input type="text" name="title" lay-verify="required" lay-reqText="请输入文章标题"
|
||||||
|
autocomplete="off" placeholder="请输入文章标题" class="layui-input"
|
||||||
|
value="{$detail.title}"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="layui-td-gray" style="vertical-align:top;">摘要</td>
|
||||||
|
<td colspan="3">
|
||||||
|
<textarea name="describe" placeholder="请输入摘要,不能超过200个字"
|
||||||
|
class="layui-textarea">{$detail.describe}</textarea>
|
||||||
|
</td>
|
||||||
|
<td class="layui-td-gray" style="vertical-align:top;">缩略图</td>
|
||||||
|
<td>
|
||||||
|
<div class="layui-upload">
|
||||||
|
<button type="button" class="layui-btn layui-btn-sm" id="upload_btn_thumb">
|
||||||
|
上传缩略图(尺寸:640x360)
|
||||||
|
</button>
|
||||||
|
<div class="layui-upload-list" id="upload_box_thumb"
|
||||||
|
style="width: 120px; height:66px; overflow: hidden;">
|
||||||
|
<img src="{:get_file($detail.image)}"
|
||||||
|
onerror="javascript:this.src='{__GOUGU__}/gougu/images/nonepic600x360.jpg';this.onerror=null;"
|
||||||
|
style="max-width: 100%; height:66px;"/>
|
||||||
|
<input type="hidden" name="image" value="{$detail.image}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="6" class="layui-td-gray" style="text-align:left">文章内容</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="6">
|
||||||
|
<textarea placeholder="请输入内容" class="layui-textarea"
|
||||||
|
id="container_content">{$detail.content}</textarea>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<div class="pt-3">
|
||||||
|
<input type="hidden" name="id" value="{$detail.id}"/>
|
||||||
|
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">立即提交</button>
|
||||||
|
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
{/block}
|
||||||
|
<!-- /主体 -->
|
||||||
|
|
||||||
|
<!-- 脚本 -->
|
||||||
|
{block name="script"}
|
||||||
|
<script>
|
||||||
|
const editorType = '{$editor}';
|
||||||
|
var moduleInit;
|
||||||
|
if (editorType == 1) {
|
||||||
|
moduleInit = ['tool', 'tagpicker', 'tinymce'];
|
||||||
|
} else {
|
||||||
|
moduleInit = ['tool', 'tagpicker', 'editormd'];
|
||||||
|
}
|
||||||
|
|
||||||
|
function gouguInit() {
|
||||||
|
var form = layui.form, tool = layui.tool, tagpicker = layui.tagpicker;
|
||||||
|
|
||||||
|
//上传缩略图
|
||||||
|
var upload_thumb = layui.upload.render({
|
||||||
|
elem: '#upload_btn_thumb',
|
||||||
|
url: '/admin/api/upload',
|
||||||
|
done: function (res) {
|
||||||
|
//如果上传失败
|
||||||
|
if (res.code == 1) {
|
||||||
|
layer.msg('上传失败');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
//上传成功
|
||||||
|
$('#upload_box_thumb input').attr('value', res.data.filepath);
|
||||||
|
$('#upload_box_thumb img').attr('src', res.data.filepath);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
var editor = layui.tinymce;
|
||||||
|
var edit = editor.render({
|
||||||
|
selector: "#container_content",
|
||||||
|
height: 500
|
||||||
|
});
|
||||||
|
//监听提交
|
||||||
|
form.on('submit(webform)', function (data) {
|
||||||
|
data.field.content = tinyMCE.editors['container_content'].getContent();
|
||||||
|
if (data.field.content == '') {
|
||||||
|
layer.msg('请先完善文章内容');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
let callback = function (e) {
|
||||||
|
layer.msg(e.msg);
|
||||||
|
if (e.code == 0) {
|
||||||
|
tool.sideClose(1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tool.post("/admin/party.article/edit", data.field, callback);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
{/block}
|
||||||
|
<!-- /脚本 -->
|
148
app/admin/view/party/article/index.html
Normal file
148
app/admin/view/party/article/index.html
Normal file
@ -0,0 +1,148 @@
|
|||||||
|
{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-xs" lay-event="edit">编辑</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: '/admin/party.article/index',
|
||||||
|
page: true,
|
||||||
|
limit: 20,
|
||||||
|
cellMinWidth: 300,
|
||||||
|
cols: [
|
||||||
|
[
|
||||||
|
{
|
||||||
|
fixed: 'left',
|
||||||
|
field: 'id',
|
||||||
|
title: '编号',
|
||||||
|
align: 'center',
|
||||||
|
width: 80
|
||||||
|
},{
|
||||||
|
field: 'title',
|
||||||
|
title: '文章标题',
|
||||||
|
},{
|
||||||
|
field: 'nickname',
|
||||||
|
title: '用户',
|
||||||
|
align: 'center',
|
||||||
|
width: 90
|
||||||
|
},{
|
||||||
|
field: 'area',
|
||||||
|
title: '区县',
|
||||||
|
align: 'center',
|
||||||
|
width: 90
|
||||||
|
},{
|
||||||
|
field: 'street',
|
||||||
|
title: '乡镇',
|
||||||
|
align: 'center',
|
||||||
|
width: 90
|
||||||
|
},{
|
||||||
|
field: 'village',
|
||||||
|
title: '街道/村',
|
||||||
|
align: 'center',
|
||||||
|
width: 90
|
||||||
|
},{
|
||||||
|
field: 'add_time',
|
||||||
|
title: '发布时间',
|
||||||
|
align: 'center',
|
||||||
|
width: 160
|
||||||
|
},{
|
||||||
|
fixed: 'right',
|
||||||
|
field: 'right',
|
||||||
|
title: '操作',
|
||||||
|
toolbar: '#barDemo',
|
||||||
|
width: 136,
|
||||||
|
align: 'center'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
//监听表头工具栏事件
|
||||||
|
table.on('toolbar(article)', function(obj){
|
||||||
|
if (obj.event === 'add') {
|
||||||
|
tool.side("/admin/party.article/add");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//监听表格行工具事件
|
||||||
|
table.on('tool(article)', function(obj) {
|
||||||
|
var data = obj.data;
|
||||||
|
if (obj.event === 'read') {
|
||||||
|
tool.side('/admin/party.article/read?id='+obj.data.id);
|
||||||
|
}
|
||||||
|
else if (obj.event === 'edit') {
|
||||||
|
tool.side('/admin/party.article/edit?id='+obj.data.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("/admin/party.article/del", { id: data.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}
|
||||||
|
<!-- /脚本 -->
|
39
app/admin/view/party/article/read.html
Normal file
39
app/admin/view/party/article/read.html
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
{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">文章标题</td>
|
||||||
|
<td colspan="3">{$detail.title}</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td class="layui-td-gray">创建时间</td>
|
||||||
|
<td>{$detail.add_time}</td>
|
||||||
|
<td class="layui-td-gray">状态</td>
|
||||||
|
<td>
|
||||||
|
{eq name="$detail.status" value="1"}正常{/eq}
|
||||||
|
{eq name="$detail.status" value="0"}下架{/eq}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="layui-td-gray">文章摘要</td>
|
||||||
|
<td colspan="3">{$detail.describe}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="layui-td-gray">文章内容</td>
|
||||||
|
<td colspan="5" class="content-article">
|
||||||
|
{$detail.content|raw}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
{/block}
|
||||||
|
<!-- /主体 -->
|
Loading…
x
Reference in New Issue
Block a user