Merge remote-tracking branch 'origin/master'

This commit is contained in:
mkm 2023-02-08 17:30:33 +08:00
commit fbc9c99129
9 changed files with 780 additions and 7 deletions

View File

@ -0,0 +1,163 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use app\admin\controller\nk\Article;
use think\exception\ValidateException;
use think\facade\Db;
use think\facade\View;
/**
* 镇列表
*
* @icon fa fa-circle-o
*/
class Street extends BaseController
{
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->url=[
'/admin/nk.street/index',
'/admin/nk.street/add',
'/admin/nk.street/edit',
'/admin/nk.street/del',
'/admin/nk.street/read',
];
}
/**
* 查看
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$where[]=['status','=',1];
$where[]=['village_id','=',''];
if (isset($params['keywords'])){
$where[]=['title','like','%'.$params['keywords'].'%'];
}
$total = Db::table('fa_szxc_village')
->where($where)->count();
$list = Db::table('fa_szxc_village')
->withAttr('is_hot',function ($value,$data){
return $value==1?'是':'否';
})
->withAttr('is_tourism',function ($value,$data){
return $value==1?'是':'否';
})
->where($where)
->page($params['page'])
->limit($params['limit'])
->order('id desc')
->select();
$result = ['total' => $total, 'data' => $list];
return table_assign(0, '', $result);
}
View::assign('url', $this->url);
return view();
}
/**
* 添加
*/
public function add()
{
if (request()->isAjax()) {
$params= get_params();
if (!empty($params['is_hot'])&&$params['is_hot']=='on'){
$params['is_hot']=1;
}else{
$params['is_hot']=0;
}
if (!empty($params['is_tourism'])&&$params['is_tourism']=='on'){
$params['is_tourism']=1;
}else{
$params['is_tourism']=0;
}
$area_code=Db::table('fa_geo_area')->where('area_code',$params['area_id'])->value('area_name');
$street_code=Db::table('fa_geo_street')->where('street_code',$params['street_id'])->value('street_name');
$village_id=Db::table('fa_geo_village')->where('village_id',$params['village_id'])->value('village_name');
$params['address']='泸州市'.$area_code.$street_code.$village_id;
$params['createtime']=time();
$res=Db::table('fa_szxc_village')->strict(false)->field(true)->insertGetId($params);
if ($res){
return to_assign(0,'操作成功',['aid'=>$res]);
}
return to_assign(1, '操作失败,原因:'.$res);
}
$street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
->field('area_id id,area_code code,area_name name')
->select();
View::assign('street', $street);
View::assign('editor', get_system_config('other','editor'));
View::assign('url', $this->url);
return view();
}
/**
* 修改
*/
public function edit()
{
$params= get_params();
if (request()->isAjax()) {
if (!empty($params['is_hot'])&&$params['is_hot']=='on'){
$params['is_hot']=1;
}else{
$params['is_hot']=0;
}
if (!empty($params['is_tourism'])&&$params['is_tourism']=='on'){
$params['is_tourism']=1;
}else{
$params['is_tourism']=0;
}
$area_code=Db::table('fa_geo_area')->where('area_code',$params['area_id'])->value('area_name');
$street_code=Db::table('fa_geo_street')->where('street_code',$params['street_id'])->value('street_name');
$village_id=Db::table('fa_geo_village')->where('village_id',$params['village_id'])->value('village_name');
$params['address']='泸州市'.$area_code.$street_code.$village_id;
$res=Db::table('fa_szxc_village')->where('id',$params['id'])->strict(false)->field(true)->update($params);
if ($res){
return to_assign();
}else{
return to_assign(1, '操作失败,原因:'.$res);
}
}
$detail = Db::table('fa_szxc_village')->where('id',$params['id'])->find();
$street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
->field('area_id id,area_code code,area_name name')
->select();
View::assign('street', $street);
View::assign('detail', $detail);
View::assign('url', $this->url);
return view();
}
/**
* 查看信息
*/
public function read()
{
$params = get_params();
$detail = Db::table('fa_szxc_village')->where('id',$params['id'])->find();
View::assign('url', $this->url);
View::assign('detail', $detail);
return view();
}
/**
* 修改
*/
public function del()
{
$param= get_params();
$id = isset($param['id']) ? $param['id'] : 0;
$type = isset($param['type']) ? $param['type'] : 0;
$res = Db::table('fa_szxc_village')->where('id',$id)->update(['status'=>$type]);
if ($res){
return to_assign();
}else{
return to_assign(1, '操作失败,原因:'.$res);
}
}
}

View File

@ -35,6 +35,7 @@ class Village extends BaseController
if (request()->isAjax()) {
$params= get_params();
$where[]=['status','=',1];
$where[]=['village_id','<>',''];
if (isset($params['keywords'])){
$where[]=['title','like','%'.$params['keywords'].'%'];
}

View File

@ -0,0 +1,192 @@
{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">人数<font>*</font></td>
<td colspan="3">
<input type="text" name="people_num" lay-verify="required" lay-reqText="请输入人数"
autocomplete="off" placeholder="请输入人数" class="layui-input"></td>
<td class="layui-td-gray">标签(多选)<font>*</font></td>
<td>
<input type="checkbox" name="is_hot" title="热门">
<input type="checkbox" name="is_tourism" title="文旅">
</td>
</tr>
<tr>
<td class="layui-td-gray" style="vertical-align:top;">简介</td>
<td colspan="3">
<textarea name="info" 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="images" value="">
</div>
</div>
</td>
</tr>
{if {:session('gougu_admin')['group_access']==1}
<tr >
<td colspan="3">
<div class="layui-form-item">
<label class="layui-form-label">区县</label>
<div class="layui-input-block">
<select name="area_id" lay-filter="area_id" lay-verify="required">
{volist name='street' id='vo'}
<option value="{$vo.code}">{$vo.name}</option>
{/volist}
</select>
</div>
</div>
</td>
<td colspan="3">
<div class="layui-form-item">
<label class="layui-form-label">街道/镇</label>
<div class="layui-input-block">
<div id="demo1"></div>
</div>
</div>
</td>
</tr>
{/if}
<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 src="/static/assets/js/xm-select.js"></script>
<script>
const editorType = '{$editor}';
var moduleInit = ['tool', 'tagpicker', 'tinymce'];
var group_access = "{:session('gougu_admin')['group_access']}"
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);
}
});
form.on('select(area_id)', function (data) {
street(data.value)
});
function street (id) {
var demo1 = xmSelect.render({
name: 'street_id',
el: '#demo1',
prop: {
name: 'name',
value: 'code',
},
data: [],
radio: true,
disabled: group_access == 2 ? true : false,
on: function (data) {
var arr = data.arr;
village(arr[0]['code'])
},
})
$.get('/api/geo/street?pcode=' + id, function (result) {
demo1.update({
data: result.data
})
});
}
function village (id) {
var demo2 = xmSelect.render({
name: 'village_id',
el: '#demo2',
prop: {
name: 'name',
value: 'id',
},
data: [],
radio: true,
disabled: group_access == 2 ? true : false,
})
$.get('/api/geo/village?pcode=' + id, function (result) {
demo2.update({
data: result.data
})
});
}
var editor = layui.tinymce;
var edit = editor.render({
selector: "#container_content",
height: 500
});
//监听提交
form.on('submit(webform)', function (data) {
data.field.introduce = tinyMCE.editors['container_content'].getContent();
if (data.field.introduce == '') {
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}
<!-- /脚本 -->

View File

@ -0,0 +1,210 @@
{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">人数<font>*</font></td>
<td colspan="3">
<input type="text" name="people_num" lay-verify="required" lay-reqText="请输入人数"
autocomplete="off" placeholder="请输入人数" class="layui-input" value="{$detail.people_num}"></td>
<td class="layui-td-gray">标签(多选)<font>*</font></td>
<td>
<input type="checkbox" name="is_hot" title="热门" {if $detail.is_hot==1} checked {/if}>
<input type="checkbox" name="is_tourism" title="文旅" {if $detail.is_tourism==1} checked {/if}>
</td>
</tr>
<tr>
<td class="layui-td-gray" style="vertical-align:top;">简介</td>
<td colspan="3">
<textarea name="info" placeholder="请输入摘要不能超过200个字" class="layui-textarea">{$detail.info}</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.images}"
onerror="javascript:this.src='{__GOUGU__}/gougu/images/nonepic600x360.jpg';this.onerror=null;"
width="100" style="max-width: 100%; height:66px;"/>
<input type="hidden" name="images" value="{$detail.images}">
</div>
</div>
</td>
</tr>
<tr>
<td colspan="3">
<div class="layui-form-item">
<label class="layui-form-label">区县</label>
<div class="layui-input-block">
{if {:session('gougu_admin')['group_access']==1}
<select name="area_id" lay-filter="area_id" lay-verify="required">
{volist name='street' id='vo'}
<option value="{$vo.code}">{$vo.name}</option>
{/volist}
</select>
{else /}
{volist name='street' id='vo'}
{if $address.area_id==$vo.code}
<input type="text" value="{$vo.name}" autocomplete="off" class="layui-input" disabled>
{/if}
{/volist}
{/if}
</div>
</div>
</td>
<td colspan="3">
<div class="layui-form-item">
<label class="layui-form-label">街道/镇</label>
<div class="layui-input-block">
<div id="demo1"></div>
</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">{$detail.introduce}</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 src="/static/assets/js/xm-select.js"></script>
<script>
var moduleInit = ['tool', 'tagpicker', 'tinymce'];
var area_id = "{$detail.area_id}"
var street_id = "{$detail.street_id}"
var group_access = "{:session('gougu_admin')['group_access']}"
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);
}
});
if (area_id != 0) {
street(area_id)
}
if (street_id != 0) {
village(street_id)
}
form.on('select(area_id)', function (data) {
street(data.value)
});
function street (id) {
var demo1 = xmSelect.render({
name: 'street_id',
el: '#demo1',
initValue: ["{$detail.street_id}"],
prop: {
name: 'name',
value: 'code',
},
data: [],
radio: true,
disabled: group_access == 2 ? true : false,
on: function (data) {
var arr = data.arr;
village(arr[0]['code'])
},
})
$.get('/api/geo/street?pcode=' + id, function (result) {
demo1.update({
data: result.data
})
});
}
function village (id) {
var demo2 = xmSelect.render({
name: 'village_id',
el: '#demo2',
prop: {
name: 'name',
value: 'id',
},
data: [],
initValue: ["{$detail.village_id}"],
radio: true,
disabled: group_access == 2 ? true : false,
})
$.get('/api/geo/village?pcode=' + id, function (result) {
demo2.update({
data: result.data
})
});
}
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}
<!-- /脚本 -->

View File

@ -0,0 +1,152 @@
{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:120,
},{
field: 'title',
title: '标题',
},{
field: 'address',
title: '具体地址',
align: 'center',
},{
field: 'people_num',
title: '人数',
align: 'center',
},{
field: 'images',
title: '图片',
align: 'center',
templet: '<div><img src="{{ d.images }}" style="width:30px; height:30px;"></div>',
},{
field: 'views',
title: '浏览量',
align: 'center',
},{
field: 'likes',
title: '点赞数',
align: 'center',
},{
field: 'is_hot',
title: '是否热门',
align: 'center',
},{
field: 'is_tourism',
title: '是否文旅',
align: 'center',
},{
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.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}
<!-- /脚本 -->

View File

@ -0,0 +1,55 @@
{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 class="layui-td-gray">人数<font>*</font></td>
<td colspan="3">{$detail.people_num}</td>
<td class="layui-td-gray">标签(多选)<font>*</font></td>
<td>
<input type="checkbox" name="is_hot" title="热门" {if $detail.is_hot==1} checked {/if}>
<input type="checkbox" name="is_tourism" title="文旅" {if $detail.is_tourism==1} checked {/if>
</td>
</tr>
<tr>
<td class="layui-td-gray" style="vertical-align:top;">简介</td>
<td colspan="3">
{$detail.info}
</td>
<td class="layui-td-gray" style="vertical-align:top;">缩略图</td>
<td>
<div class="layui-upload">
<div class="layui-upload-list" id="upload_box_thumb"
style="width: 120px; height:66px; overflow: hidden;">
<img src="{$detail.images}"
width="100" style="max-width: 100%; height:66px;"/>
</div>
</div>
</td>
</tr>
<tr>
<td colspan="6" class="layui-td-gray" style="text-align:left">文章内容</td>
</tr>
<tr>
<td colspan="6">
{$detail.introduce|raw}
</td>
</tr>
</table>
</div>
{/block}
<!-- /主体 -->

View File

@ -55,7 +55,7 @@
</tr>
{if {:session('gougu_admin')['group_access']==1}
<tr>
<td style="width: 20%">
<td style="width: 30%">
<div class="layui-form-item">
<label class="layui-form-label">区县</label>
<div class="layui-input-block">
@ -67,7 +67,7 @@
</div>
</div>
</td>
<td >
<td colspan="3">
<div class="layui-form-item">
<label class="layui-form-label">街道/镇</label>
<div class="layui-input-block">
@ -75,7 +75,7 @@
</div>
</div>
</td>
<td >
<td colspan="3">
<div class="layui-form-item">
<label class="layui-form-label">村/社区</label>
<div class="layui-input-block">

View File

@ -54,7 +54,7 @@
</td>
</tr>
<tr>
<td style="width: 20%">
<td style="width: 30%;">
<div class="layui-form-item">
<label class="layui-form-label">区县</label>
<div class="layui-input-block">
@ -74,7 +74,7 @@
</div>
</div>
</td>
<td >
<td colspan="3">
<div class="layui-form-item">
<label class="layui-form-label">街道/镇</label>
<div class="layui-input-block">
@ -82,7 +82,7 @@
</div>
</div>
</td>
<td >
<td colspan="3">
<div class="layui-form-item">
<label class="layui-form-label">村/社区</label>
<div class="layui-input-block">

View File

@ -20,7 +20,7 @@
<td class="layui-td-gray">标签(多选)<font>*</font></td>
<td>
<input type="checkbox" name="is_hot" title="热门" {if $detail.is_hot==1} checked {/if}>
<input type="checkbox" name="is_tourism" title="文旅" {if $detail.is_hot==1} checked {/if>
<input type="checkbox" name="is_tourism" title="文旅" {if $detail.is_tourism==1} checked {/if>
</td>
</tr>
<tr>