新增字段
ALTER TABLE `wa_rules`
ADD COLUMN `is_hide` tinyint(1) DEFAULT 0 COMMENT '1:隐藏,0:显示';
plugin/admin/app/controller/RuleController.php
第68行get方法改为
$items = Rule::where('is_hide',0)->orderBy('weight', 'desc')->get()->toArray();
plugin/admin/app/view/rule/index.html
{
title: "显示状态",
field: "is_hide",
templet: function (d) {
let checked = d.is_hide == 0 ? "checked" : "";
return `
<input type="checkbox" lay-skin="switch" lay-text="显示|隐藏"
lay-filter="switchHide" data-id="${d.id}" ${checked} />
`;
},
width: 100
}
form.on('switch(switchHide)', function(obj) {
let id = $(this).data('id');
let is_hide = obj.elem.checked ? 0 : 1;
$.post('/app/admin/rule/update', {
id: id,
is_hide: is_hide
}, function(res) {
if (res.code !== 0) {
layui.popup.failure(res.msg || '更新失败');
} else {
layui.popup.success('更新成功');
}
}, 'json');
});
实现效果
没必要这样啊 类型设置为权限就隐藏了
原来如此,感谢