mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-06 03:58:04 +08:00
修改文章标签管理
This commit is contained in:
parent
608421a84a
commit
dcd92ea511
@ -4,6 +4,7 @@ namespace app\data\controller\news;
|
||||
|
||||
use app\data\model\DataNewsMark;
|
||||
use think\admin\Controller;
|
||||
use think\admin\helper\QueryHelper;
|
||||
|
||||
/**
|
||||
* 文章标签管理
|
||||
@ -15,16 +16,31 @@ class Mark extends Controller
|
||||
/**
|
||||
* 文章标签管理
|
||||
* @auth true
|
||||
* @return void
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->title = '文章标签管理';
|
||||
$query = DataNewsMark::mQuery();
|
||||
$query->like('name')->equal('status')->dateBetween('create_at');
|
||||
$query->where(['deleted' => 0])->order('sort desc,id desc')->page();
|
||||
DataNewsMark::mQuery()->layTable(function () {
|
||||
$this->title = '文章标签管理';
|
||||
}, function (QueryHelper $query) {
|
||||
$query->where(['deleted' => 0]);
|
||||
$query->like('name')->equal('status')->dateBetween('create_at');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 文章标签选择
|
||||
* @login true
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function select()
|
||||
{
|
||||
DataNewsMark::mQuery()->order('sort desc,id desc')->page();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -45,16 +61,25 @@ class Mark extends Controller
|
||||
DataNewsMark::mForm('form');
|
||||
}
|
||||
|
||||
/**
|
||||
* 表单结果处理
|
||||
* @param bool $state
|
||||
* @return void
|
||||
*/
|
||||
protected function _form_result(bool $state)
|
||||
{
|
||||
if ($state) {
|
||||
$this->success('修改标签成功', "javascript:$('#TagsData').trigger('reload')");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改文章标签状态
|
||||
* @auth true
|
||||
*/
|
||||
public function state()
|
||||
{
|
||||
DataNewsMark::mSave($this->_vali([
|
||||
'status.in:0,1' => '状态值范围异常!',
|
||||
'status.require' => '状态值不能为空!',
|
||||
]));
|
||||
DataNewsMark::mSave();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -10,7 +10,7 @@
|
||||
<!--{/if}-->
|
||||
|
||||
<!--{if auth("news.mark/index")}-->
|
||||
<button class='layui-btn layui-btn-sm layui-btn-primary' data-iframe='{:url("news.mark/index")}' data-title="标签管理" data-width="900px">标签管理</button>
|
||||
<button class='layui-btn layui-btn-sm layui-btn-primary' data-modal='{:url("news.mark/index")}' data-title="标签管理" data-width="900px">标签管理</button>
|
||||
<!--{/if}-->
|
||||
{/block}
|
||||
|
||||
|
@ -1,19 +1,19 @@
|
||||
<form action="{:sysuri()}" autocomplete="off" class="layui-form layui-card" data-auto="true" method="post">
|
||||
<form action="{:sysuri()}" data-table-id="TagsData" class="layui-form layui-card" data-auto="true" method="post">
|
||||
<div class="layui-card-body padding-left-40">
|
||||
|
||||
<label class="layui-form-item relative block">
|
||||
<span class="color-green font-w7">标签名称</span>
|
||||
<span class="color-desc margin-left-5">Mark Name</span>
|
||||
<span class="help-label"><b>标签名称</b>Mark Name</span>
|
||||
<input class="layui-input" name="name" placeholder="请输入标签名称" required value="{$vo.name|default=''}"/>
|
||||
<span class="help-block"><b>必填,</b>请填写标签名称,建议字符不要太长,一般4-6个汉字</span>
|
||||
<span class="help-block"><b>必填,</b>请填写标签名称,建议字符不要太长</span>
|
||||
</label>
|
||||
|
||||
<div class="layui-form-item relative block">
|
||||
<span class="color-green font-w7">标签描述</span>
|
||||
<span class="color-desc margin-left-5">Mark Remark</span>
|
||||
<div class="layui-form-item relative">
|
||||
<span class="help-label"><b>标签描述</b>Mark Remark</span>
|
||||
<label class="relative block">
|
||||
<textarea class="layui-textarea" name="remark" placeholder="请输入文档描述">{$vo.remark|default=''}</textarea>
|
||||
<textarea class="layui-textarea" name="desc" placeholder="请输入文档描述">{$vo.desc|default=''}</textarea>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="hr-line-dashed"></div>
|
||||
@ -21,6 +21,6 @@
|
||||
|
||||
<div class="layui-form-item text-center">
|
||||
<button class="layui-btn" type='submit'>保存数据</button>
|
||||
<button class="layui-btn layui-btn-danger" data-close data-confirm="确定要取消编辑吗?" type='button'>取消编辑</button>
|
||||
<button class="layui-btn layui-btn-danger" data-close type='button' data-confirm="确定要取消修改吗?">取消编辑</button>
|
||||
</div>
|
||||
</form>
|
@ -1,63 +1,100 @@
|
||||
{extend name="../../admin/view/full"}
|
||||
<div class="think-box-shadow">
|
||||
<fieldset>
|
||||
<legend>条件搜索</legend>
|
||||
<form action="{:sysuri()}" id="TagsDataSearch" autocomplete="off" class="layui-form layui-form-pane nowrap form-search" method="get" onsubmit="return false">
|
||||
<div class="layui-form-item layui-inline">
|
||||
<label class="layui-form-label">标签名称</label>
|
||||
<label class="layui-input-inline">
|
||||
<input class="layui-input" name="name" placeholder="请输入标签名称" value="{$get.name|default=''}">
|
||||
</label>
|
||||
</div>
|
||||
|
||||
{block name='content'}
|
||||
<div class="iframe-pagination">
|
||||
{include file='news/mark/index_search'}
|
||||
<table class="layui-table margin-top-10" lay-skin="line">
|
||||
{notempty name='list'}
|
||||
<thead>
|
||||
<tr>
|
||||
<th class='list-table-check-td think-checkbox'>
|
||||
<label><input data-auto-none data-check-target='.list-check-box' type='checkbox'></label>
|
||||
</th>
|
||||
<th class='list-table-sort-td'>
|
||||
<button class="layui-btn layui-btn-xs" data-reload type="button">刷 新</button>
|
||||
</th>
|
||||
<th class="text-left nowrap">标签名称</th>
|
||||
<th class="text-left nowrap">标签状态</th>
|
||||
<th class="text-left nowrap">创建时间</th>
|
||||
<th class="text-left nowrap"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
{/notempty}
|
||||
<tbody>
|
||||
{foreach $list as $key=>$vo}
|
||||
<tr data-dbclick>
|
||||
<td class='list-table-check-td think-checkbox'>
|
||||
<label><input class="list-check-box" type='checkbox' value='{$vo.id}'></label>
|
||||
</td>
|
||||
<td class='list-table-sort-td'>
|
||||
<label><input class="list-sort-input" data-action-blur="{:sysuri()}" data-loading="false" data-value="id#{$vo.id};action#sort;sort#{value}" value="{$vo.sort}"></label>
|
||||
</td>
|
||||
<td class="text-left nowrap">{$vo.name|default=''}</td>
|
||||
<td>{if $vo.status eq 0}<span class="color-red">已禁用</span>{elseif $vo.status eq 1}<span class="color-green">已激活</span>{/if}</td>
|
||||
<td class="text-left nowrap">{$vo.create_at|format_datetime}</td>
|
||||
<td class='text-left nowrap'>
|
||||
<!--{if auth("edit")}-->
|
||||
<a class="layui-btn layui-btn-sm" data-dbclick data-modal="{:url('edit')}?id={$vo.id}" data-title="编辑标签" data-width="500px">编 辑</a>
|
||||
<!--{/if}-->
|
||||
<div class="layui-form-item layui-inline">
|
||||
<label class="layui-form-label">使用状态</label>
|
||||
<div class="layui-input-inline">
|
||||
<select class="layui-select" name="status">
|
||||
<option value=''>-- 全部 --</option>
|
||||
{foreach ['已禁用的记录','已激活的记录'] as $k=>$v}
|
||||
{if isset($get.status) and $get.status eq $k.''}
|
||||
<option selected value="{$k}">{$v}</option>
|
||||
{else}
|
||||
<option value="{$k}">{$v}</option>
|
||||
{/if}{/foreach}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--{if auth("state") and $vo.status eq 1}-->
|
||||
<a class="layui-btn layui-btn-sm layui-btn-warm" data-action="{:url('state')}" data-value="id#{$vo.id};status#0">禁 用</a>
|
||||
<!--{/if}-->
|
||||
<div class="layui-form-item layui-inline">
|
||||
<label class="layui-form-label">创建时间</label>
|
||||
<label class="layui-input-inline">
|
||||
<input class="layui-input" data-date-range name="create_at" placeholder="请选择创建时间" value="{$get.create_at|default=''}">
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<!--{if auth("state") and $vo.status eq 0}-->
|
||||
<a class="layui-btn layui-btn-sm layui-btn-warm" data-action="{:url('state')}" data-value="id#{$vo.id};status#1">激 活</a>
|
||||
<!--{/if}-->
|
||||
<div class="layui-form-item layui-inline">
|
||||
<button class="layui-btn layui-btn-primary"><i class="layui-icon"></i> 搜 索</button>
|
||||
<!-- {if auth('add')} -->
|
||||
<button class="layui-btn" data-title="添加素材标签" data-modal="{:url('add')}" type="button">
|
||||
<i class="layui-icon"></i> 添 加
|
||||
</button>
|
||||
<!-- {/if} -->
|
||||
</div>
|
||||
|
||||
<!--{if auth("remove")}-->
|
||||
<a class="layui-btn layui-btn-sm layui-btn-danger" data-action="{:url('remove')}" data-confirm="确定要删除该标签吗?" data-value="id#{$vo.id}">删 除</a>
|
||||
<!--{/if}-->
|
||||
</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
</tbody>
|
||||
</table>
|
||||
{empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}
|
||||
<!--{if auth("add")}-->
|
||||
<div class="fixed" style="bottom:5px;right:10px">
|
||||
<button class='layui-btn layui-btn-sm' data-modal='{:url("add")}' data-title="添加标签" data-width="500px" type="button">添加标签</button>
|
||||
</div>
|
||||
<!--{/if}-->
|
||||
</form>
|
||||
</fieldset>
|
||||
<table id="TagsData" data-url="{:sysuri()}" data-target-search="#TagsDataSearch"></table>
|
||||
</div>
|
||||
{/block}
|
||||
|
||||
<script>
|
||||
$(function () {
|
||||
$('#TagsData').layTable({
|
||||
even: true, height: 'full',
|
||||
sort: {field: 'sort desc,id', type: 'desc'},
|
||||
cols: [[
|
||||
{field: 'id', title: 'ID', width: 80, align: 'center', sort: true},
|
||||
{field: 'sort', title: '排序权重', width: 100, align: 'center', sort: true, templet: '#SortInputTagsDataTplModal'},
|
||||
{field: 'name', title: '标签名称', minWidth: 100},
|
||||
{field: 'status', title: '状态', width: 110, align: 'center', templet: '#StatusSwitchTagsDataTpl'},
|
||||
{field: 'create_at', title: '创建时间', minWidth: 170, align: 'center'},
|
||||
{toolbar: '#ToolbarTagsData', title: '操作面板', minWidth: 100, align: 'center', fixed: 'right'},
|
||||
]]
|
||||
});
|
||||
|
||||
// 数据状态切换操作
|
||||
layui.form.on('switch(StatusSwitchTagsData)', function (obj) {
|
||||
var data = {id: obj.value, status: obj.elem.checked > 0 ? 1 : 0};
|
||||
$.form.load("{:url('state')}", data, 'post', function (ret) {
|
||||
if (ret.code < 1) $.msg.error(ret.info, 3, function () {
|
||||
$('#TagsData').trigger('reload');
|
||||
});
|
||||
return false;
|
||||
}, false);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<!-- 数据状态切换模板 -->
|
||||
<script type="text/html" id="StatusSwitchTagsDataTpl">
|
||||
<!--{if auth("state")}-->
|
||||
<input type="checkbox" value="{{d.id}}" lay-skin="switch" lay-text="已激活|已禁用" lay-filter="StatusSwitchTagsData" {{d.status>0?'checked':''}}>
|
||||
<!--{else}-->
|
||||
{{d.status ? '<b class="color-green">已激活</b>' : '<b class="color-red">已禁用</b>'}}
|
||||
<!--{/if}-->
|
||||
</script>
|
||||
|
||||
<!-- 列表排序权重模板 -->
|
||||
<script type="text/html" id="SortInputTagsDataTplModal">
|
||||
<input type="number" min="0" data-blur-number="0" data-action-blur="{:sysuri()}" data-value="id#{{d.id}};action#sort;sort#{value}" data-loading="false" value="{{d.sort}}" class="layui-input text-center">
|
||||
</script>
|
||||
|
||||
<!-- 操控面板的模板 -->
|
||||
<script type="text/html" id="ToolbarTagsData">
|
||||
|
||||
<!--{if auth("edit")}-->
|
||||
<a class="layui-btn layui-btn-sm" data-title="编辑标签数据" data-modal='{:url("edit")}?id={{d.id}}'>编 辑</a>
|
||||
<!--{/if}-->
|
||||
|
||||
<!--{if auth("remove")}-->
|
||||
<a class="layui-btn layui-btn-sm layui-btn-danger" data-confirm="确定要删除此标签吗?" data-action="{:url('remove')}" data-value="id#{{d.id}}">删 除</a>
|
||||
<!--{/if}-->
|
||||
</script>
|
Loading…
x
Reference in New Issue
Block a user