452 lines
18 KiB
PHP
452 lines
18 KiB
PHP
<?php
|
||
|
||
/**
|
||
* @author Any
|
||
* @description KISS
|
||
* @date 2021年10月5日
|
||
* @version 1.0.0
|
||
*
|
||
* _____LOG_____
|
||
*
|
||
*/
|
||
use yii\widgets\LinkPager;
|
||
use app\models\Cat;
|
||
|
||
$this->title = '冠军性别';
|
||
$this->params['breadcrumbs'][] = $this->title;
|
||
|
||
?>
|
||
<div class="layui-fluid">
|
||
<div class="layui-card">
|
||
<div class="layui-card-header">
|
||
<?= $this->title ?>
|
||
</div>
|
||
<div class="layui-card-header layuiadmin-card-header-auto">
|
||
<div class="layui-form-item">
|
||
<div class="layui-inline">
|
||
<a class=" layui-btn" href="<?=\Yii::$app->urlManager->createUrl(["admin/mall/goods/cat3-edit"])?>">添加冠军性别</a>
|
||
</div>
|
||
<div class="layui-inline layui-float-right layui-form">
|
||
|
||
|
||
<div class="layui-inline layui-form-item">
|
||
<label class="layui-form-label">关键词</label>
|
||
<div class="layui-input-block">
|
||
<input type="text" name="keywords" placeholder="搜索名称" autocomplete="off" class="layui-input" value="<?=\Yii::$app->request->get("keywords")?>">
|
||
</div>
|
||
</div>
|
||
<div class="layui-inline">
|
||
<button class="layui-btn layuiadmin-btn-useradmin" lay-submit lay-filter="dtable-search">
|
||
<i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
|
||
</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="layui-card-body">
|
||
<table id="dtable" lay-filter="dtable"></table>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!--工具栏模板-->
|
||
<script type="text/html" id="toolBarTpl">
|
||
<div class="layui-btn-container">
|
||
<!--<button class="layui-btn layui-btn-sm" lay-event="add">添加</button>-->
|
||
<button class="layui-btn layui-btn-sm" lay-event="batch_open">批量开启</button>
|
||
<button class="layui-btn layui-btn-sm layui-btn-warm" lay-event="batch_close">批量关闭</button>
|
||
<button class="layui-btn layui-btn-sm" lay-event="batch_show">批量显示</button>
|
||
<button class="layui-btn layui-btn-sm layui-btn-warm" lay-event="batch_hide">批量隐藏</button>
|
||
<button class="layui-btn layui-btn-sm layui-btn-danger" lay-event="batch_delete">批量删除</button>
|
||
</div>
|
||
</script>
|
||
<!--行操作列模板-->
|
||
<script type="text/html" id="rowBarTpl">
|
||
<button class="layui-btn layui-btn-xs" lay-event="edit">编辑</button>
|
||
{{# if(d.status == 0){ }}
|
||
<button class="layui-btn layui-btn-xs layui-btn-danger" lay-event="delete">删除</button>
|
||
{{# } }}
|
||
</script>
|
||
|
||
<script type="text/html" id="imgUrlTpl">
|
||
<img src="{{d.img_url}}" style="width:30px;height: 30px"/>
|
||
</script>
|
||
|
||
<script type="text/html" id="statusTpl">
|
||
<input type="checkbox" name="status" value="{{ d.id }}" {{ d.status == 1 ? 'checked' : '' }} lay-skin="switch" lay-text="开启|关闭" lay-filter="switch_status">
|
||
</script>
|
||
|
||
<script type="text/html" id="hideTpl">
|
||
<input type="checkbox" name="is_hide" value="{{ d.id }}" {{ d.is_hide == 0 ? 'checked' : '' }} lay-skin="switch" lay-text="显示|隐藏" lay-filter="switch_hide">
|
||
</script>
|
||
|
||
<script>
|
||
<?php $this->beginBlock('js_script_wrap') ?>
|
||
layui.config({
|
||
base: '/statics/layuiadmin/' //静态资源所在路径
|
||
}).extend({
|
||
index: 'lib/index' //主入口模块
|
||
}).use(['index', 'user', 'table'], function () {
|
||
var $ = layui.$
|
||
, form = layui.form
|
||
, table = layui.table
|
||
, admin = layui.admin;
|
||
form.render();
|
||
|
||
//search
|
||
form.on('submit(dtable-search)', function (obj) {
|
||
var field = obj.field;
|
||
reload_table_data(field);
|
||
});
|
||
|
||
form.on('select(batch-action)', function (obj) {
|
||
var lay_event = obj.value;
|
||
var check_status = table.checkStatus('dtable');
|
||
var id = [];
|
||
$(check_status.data).each(function(index){
|
||
id.push(check_status.data[index]['id']);
|
||
});
|
||
|
||
var confirm_url = null;
|
||
var confirm_tip = null;
|
||
|
||
if(confirm_url != null){
|
||
layer.confirm(confirm_tip, {
|
||
btn: ['确定','取消']
|
||
}, function(){
|
||
$.ajax(confirm_url,{
|
||
type:"POST",
|
||
dataType:"json",
|
||
data:{
|
||
cat_id:id,
|
||
_csrf:_csrf
|
||
},
|
||
success:function(res){
|
||
if(res.code == 0){
|
||
layer.msg(res.msg, {
|
||
offset: '15px'
|
||
,icon: 1
|
||
,time: 1000
|
||
}, function(){
|
||
location.reload();
|
||
});
|
||
} else {
|
||
layer.msg(res.msg, {
|
||
offset: '15px'
|
||
,icon: 2
|
||
,time: 1000
|
||
}, function(){
|
||
});
|
||
}
|
||
},
|
||
error:function(xhr,type,err){
|
||
layer.msg(xhr.responseText, {
|
||
offset: '15px'
|
||
,icon: 2
|
||
,time: 1000
|
||
}, function(){
|
||
});
|
||
}
|
||
})
|
||
}, function(){
|
||
});
|
||
}
|
||
});
|
||
|
||
//重新加载表格数据
|
||
function reload_table_data(conf){
|
||
table.reload('dtable', {
|
||
url:'<?=\Yii::$app->urlManager->createUrl(['admin/mall/goods/cat3'])?>'
|
||
,page: true
|
||
,where: conf
|
||
});
|
||
};
|
||
|
||
//执行渲染
|
||
table.render({
|
||
//指定原始表格元素选择器(推荐id选择器)
|
||
elem: '#dtable'
|
||
//容器高度
|
||
//,height: 315
|
||
//容器宽度
|
||
//,width: 720
|
||
//设置表头
|
||
,cols: [[
|
||
{checkbox: true}
|
||
, {field: 'id', title: 'ID', width: 80}
|
||
, {field: 'name', title: '名称', width: 120}
|
||
, {field: 'img_url', title: '图标',templet:'#imgUrlTpl'}
|
||
, {field: 'status', title: '开启状态', templet:'#statusTpl'}
|
||
, {field: 'is_hide', title: '隐藏状态', templet:'#hideTpl'}
|
||
, {field: 'sort', title: '排序'}
|
||
, {field: 'created_at_cn', title: '添加时间'}
|
||
, {title: '操作',fixed: 'right', toolbar: '#rowBarTpl', width:200}
|
||
]
|
||
]
|
||
, url:'<?=\Yii::$app->urlManager->createUrl(['admin/mall/goods/cat3'])?>'
|
||
, page:true
|
||
//指向自定义工具栏模板选择器
|
||
, toolbar:'#toolBarTpl'
|
||
//头部工具栏右侧的图标按钮
|
||
, defaultToolbar:['filter', 'print', 'exports']
|
||
, limit: 20
|
||
, limits:[10,20,30,40,50,60,70,80,90,100]
|
||
, title:'<?=$this->title?>'
|
||
, data:[]
|
||
});
|
||
//监听工具栏
|
||
table.on('toolbar(dtable)', function(obj){
|
||
var lay_event = obj.event;
|
||
var check_status = table.checkStatus('dtable');
|
||
var id = [];
|
||
$(check_status.data).each(function(index){
|
||
id.push(check_status.data[index]['id']);
|
||
});
|
||
if(id.length == 0){
|
||
return layer.msg("请选择需要操作项");
|
||
}
|
||
|
||
var confirm_url = null;
|
||
var confirm_tip = null;
|
||
if(lay_event == 'batch_open'){
|
||
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['admin/mall/goods/cat3-open'])?>";
|
||
confirm_tip = "确定开启选中分类吗";
|
||
}
|
||
if(lay_event == 'batch_close'){
|
||
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['admin/mall/goods/cat3-close'])?>";
|
||
confirm_tip = "确定关闭选中分类吗";
|
||
}
|
||
if(lay_event == 'batch_show'){
|
||
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['admin/mall/goods/cat3-show'])?>";
|
||
confirm_tip = "确定显示选中分类吗";
|
||
}
|
||
if(lay_event == 'batch_hide'){
|
||
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['admin/mall/goods/cat3-hide'])?>";
|
||
confirm_tip = "确定隐藏选中分类吗";
|
||
}
|
||
if(lay_event == 'batch_delete'){
|
||
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['admin/mall/goods/cat3-delete'])?>";
|
||
confirm_tip = "确定删除选中分类吗";
|
||
}
|
||
|
||
if(confirm_url != null){
|
||
layer.confirm(confirm_tip, {
|
||
btn: ['确定','取消']
|
||
}, function(){
|
||
$.ajax(confirm_url,{
|
||
type:"POST",
|
||
dataType:"json",
|
||
data:{
|
||
cat_id:id,
|
||
_csrf:_csrf
|
||
},
|
||
success:function(res){
|
||
if(res.code == 0){
|
||
layer.msg(res.msg, {
|
||
offset: '15px'
|
||
,icon: 1
|
||
,time: 1000
|
||
}, function(){
|
||
location.reload();
|
||
});
|
||
} else {
|
||
layer.msg(res.msg, {
|
||
offset: '15px'
|
||
,icon: 2
|
||
,time: 1000
|
||
}, function(){
|
||
});
|
||
}
|
||
},
|
||
error:function(xhr,type,err){
|
||
layer.msg(xhr.responseText, {
|
||
offset: '15px'
|
||
,icon: 2
|
||
,time: 1000
|
||
}, function(){
|
||
});
|
||
}
|
||
})
|
||
}, function(){
|
||
});
|
||
}
|
||
});
|
||
|
||
//监听工具条
|
||
table.on('tool(dtable)', function(obj){
|
||
var row_data = obj.data;
|
||
var lay_event = obj.event;
|
||
var id = row_data.id;
|
||
|
||
if(lay_event == 'edit'){
|
||
var url = "<?=\Yii::$app->urlManager->createUrl(['admin/mall/goods/cat3-edit'])?>" + "?id=" + id;
|
||
location.href= url;
|
||
return;
|
||
}
|
||
|
||
var confirm_url = null;
|
||
var confirm_tip = null;
|
||
if(lay_event == "delete"){
|
||
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['admin/mall/goods/cat3-delete'])?>";
|
||
confirm_tip = "确定删除此分类吗";
|
||
}
|
||
|
||
if(confirm_url != null){
|
||
layer.confirm(confirm_tip, {
|
||
btn: ['确定','取消']
|
||
}, function(){
|
||
$.ajax(confirm_url,{
|
||
type:"POST",
|
||
dataType:"json",
|
||
data:{
|
||
cat_id:id,
|
||
_csrf:_csrf
|
||
},
|
||
success:function(res){
|
||
if(res.code == 0){
|
||
layer.msg(res.msg, {
|
||
offset: '15px'
|
||
,icon: 1
|
||
,time: 1000
|
||
}, function(){
|
||
location.reload();
|
||
});
|
||
} else {
|
||
layer.msg(res.msg, {
|
||
offset: '15px'
|
||
,icon: 2
|
||
,time: 1000
|
||
}, function(){
|
||
});
|
||
}
|
||
},
|
||
error:function(xhr,type,err){
|
||
layer.msg(xhr.responseText, {
|
||
offset: '15px'
|
||
,icon: 2
|
||
,time: 1000
|
||
}, function(){
|
||
});
|
||
}
|
||
})
|
||
}, function(){
|
||
});
|
||
}
|
||
});
|
||
form.on('switch(switch_status)', function(obj){
|
||
var lay_event = obj.elem.checked ? 'open' : 'close';
|
||
var id = this.value;
|
||
|
||
var confirm_url = null;
|
||
var confirm_tip = null;
|
||
|
||
if(lay_event == "close"){
|
||
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['admin/mall/goods/cat3-close'])?>";
|
||
confirm_tip = "确定关闭此分类吗";
|
||
}
|
||
if(lay_event == "open"){
|
||
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['admin/mall/goods/cat3-open'])?>";
|
||
confirm_tip = "确定开启此分类吗";
|
||
}
|
||
if(confirm_url == null){
|
||
return;
|
||
}
|
||
|
||
$.ajax(confirm_url,{
|
||
type:"POST",
|
||
dataType:"json",
|
||
data:{
|
||
cat_id:id,
|
||
_csrf:_csrf
|
||
},
|
||
success:function(res){
|
||
if(res.code == 0){
|
||
layer.msg(res.msg, {
|
||
offset: '15px'
|
||
,icon: 1
|
||
,time: 1000
|
||
}, function(){
|
||
location.reload();
|
||
});
|
||
} else {
|
||
layer.msg(res.msg, {
|
||
offset: '15px'
|
||
,icon: 2
|
||
,time: 1000
|
||
}, function(){
|
||
});
|
||
}
|
||
},
|
||
error:function(xhr,type,err){
|
||
layer.msg(xhr.responseText, {
|
||
offset: '15px'
|
||
,icon: 2
|
||
,time: 1000
|
||
}, function(){
|
||
});
|
||
}
|
||
})
|
||
});
|
||
form.on('switch(switch_hide)', function(obj){
|
||
var lay_event = obj.elem.checked ? 'show' : 'hide';
|
||
var id = this.value;
|
||
|
||
var confirm_url = null;
|
||
var confirm_tip = null;
|
||
|
||
if(lay_event == "hide"){
|
||
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['admin/mall/goods/cat3-hide'])?>";
|
||
confirm_tip = "确定隐藏此分类吗";
|
||
}
|
||
if(lay_event == "show"){
|
||
confirm_url = "<?=\Yii::$app->urlManager->createUrl(['admin/mall/goods/cat3-show'])?>";
|
||
confirm_tip = "确定显示此分类吗";
|
||
}
|
||
if(confirm_url == null){
|
||
return;
|
||
}
|
||
|
||
$.ajax(confirm_url,{
|
||
type:"POST",
|
||
dataType:"json",
|
||
data:{
|
||
cat_id:id,
|
||
_csrf:_csrf
|
||
},
|
||
success:function(res){
|
||
if(res.code == 0){
|
||
layer.msg(res.msg, {
|
||
offset: '15px'
|
||
,icon: 1
|
||
,time: 1000
|
||
}, function(){
|
||
location.reload();
|
||
});
|
||
} else {
|
||
layer.msg(res.msg, {
|
||
offset: '15px'
|
||
,icon: 2
|
||
,time: 1000
|
||
}, function(){
|
||
});
|
||
}
|
||
},
|
||
error:function(xhr,type,err){
|
||
layer.msg(xhr.responseText, {
|
||
offset: '15px'
|
||
,icon: 2
|
||
,time: 1000
|
||
}, function(){
|
||
});
|
||
}
|
||
})
|
||
});
|
||
|
||
});
|
||
<?php $this->endBlock(); ?>
|
||
</script>
|
||
<?php $this->registerJs($this->blocks['js_script_wrap'], \yii\web\View::POS_END); ?>
|
||
|
||
|
||
|