123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242 |
- {php}
- $name_label = $json_config['config_option']['name']['label']??'';
- $value_label = $json_config['config_option']['value']['label']??'';
- $desc_label = $json_config['config_option']['description']['label']??'';
- $image_label = $json_config['config_option']['image']['label']??'';
- $image_show = $json_config['config_option']['image']['show']??'';
- {/php}
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>layui</title>
- <meta name="renderer" content="webkit">
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
- <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
- <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css" media="all">
- <link rel="stylesheet" href="__PUBLIC__/font-awesome/css/font-awesome.min.css" media="all"/>
- <link rel="stylesheet" href="__CSS__/admin.css" media="all">
- <style type="text/css">
- /* tooltip */
- #tooltip {
- position: absolute;
- border: 1px solid #ccc;
- background: #333;
- padding: 2px;
- display: none;
- color: #fff;
- }
- </style>
- </head>
- <body style="padding:10px;">
- <div class="tplay-body-div">
- <div class="layui-tab">
- <ul class="layui-tab-title">
- <li class="layui-this">配置项</li>
- <li><a href="{:url('publish',['pid'=>$Request.param.pid])}" class="a_menu">新增</a>
- </ul>
- </div>
- <form class="layui-form serch" action="{:url('index')}" method="post">
- <div class="layui-form-item" style="float: left;">
- <div class="layui-input-inline">
- <input type="text" name="keywords" lay-verify="title" autocomplete="off" placeholder="请输入名称"
- class="layui-input layui-btn-sm">
- </div>
- <button class="layui-btn layui-btn-sm" lay-submit="" lay-filter="serch">立即提交</button>
- </div>
- </form>
- <script type="text/html" id="toolbarDemo">
- <div class="layui-btn-container">
- <button class="layui-btn layui-btn-sm" lay-submit lay-filter="admin">排序</button>
- <button class="layui-btn layui-btn-danger layui-btn-sm" lay-event="deletes">批量删除</button>
- </div>
- </script>
- <script type="text/html" id="barDemo">
- <div class="layui-btn-group">
- <a class="layui-btn layui-btn-xs" lay-event="edit"><i class="layui-icon"
- style="margin-right: 0;"></i></a>
- <a class="layui-btn layui-btn-xs delete" lay-event="del"><i class="layui-icon"
- style="margin-right: 0;"></i></a>
- </div>
- </script>
- <table class="layui-table" id="table" lay-filter="table"></table>
- {include file="public/foot"}
- <script type="text/javascript">
- layui.use(['table', 'layer', 'form'], function () {
- var table = layui.table,
- form = layui.form,
- layer = layui.layer;
- //第一个实例
- table.render({
- id: 'table'
- , elem: '#table'
- , size: 'sm' //小尺寸的表格
- , toolbar: '#toolbarDemo'
- , defaultToolbar: []
- , limit: 15
- , limits: [15, 20, 30, 40, 50, 100]
- , url: "{:url('index',['pid'=>$Request.param.pid])}" //数据接口
- , page: true //开启分页
- , cols: [[ //表头
- {
- key: 'sort', title: '排序', align: 'center', width: 60, templet: function (row) {
- return '<input type="text" name="sorts[]" value="' + row.sort + '" style="width: 20px;" class="sort"><input type="hidden" name="ids[]" value="' + row.id + '">';
- }
- },
- {type: 'checkbox'},
- {field: 'id', title: 'ID', width: 60, align: 'center'},
- {field: 'name', title: '{if condition="!empty($name_label)"}{$name_label}{else/}名称{/if}', minWidth: 150},
- {field: 'value', title: '{if condition="!empty($value_label)"}{$value_label}{else/}配置值{/if}', align: 'center',minWidth:150},
- {field: 'description', title: '{if condition="!empty($desc_label)"}{$desc_label}{else/}备注{/if}', minWidth:150},
- //{if condition="$image_show==true"}
- {
- field: 'image', title: '{if condition="!empty($image_label)"}{$image_label}{else/}配图{/if}', minWidth: 80, align: 'center', templet: function (row) {
- return (row.thumb_url == '') ? '' : '<a href="' + row.thumb_url + '" class="tooltip" target="_blank"><img src="' + row.thumb_url + '" width="20" height="20"></a>';
- }
- },
- //{/if}
- {
- field: 'status', title: '状态', align: 'center', width: 100, templet: function (row) {
- if (row.group_type == 2) {
- return '<a style="font-size:18px;color: #009688" lay-event="single_status">' + (row.single_status == 1 ? '<i class="layui-icon layui-icon-radio"></i>' : '<i class="layui-icon layui-icon-circle"></i>') + '</a>';
- }
- return '<a href="javascript:;" style="font-size:18px;" class="status" data-id="' + row.id + '" data-val="' + row.status + '">' + (row.status == 1 ? '<i class="fa fa-toggle-on"></i>' : '<i class="fa fa-toggle-off"></i>') + '</a>';
- }
- },
- {field: 'action', title: '操作', toolbar: '#barDemo', align: 'center',fixed: 'right',minWidth:80}
- ]],
- done: function () {
- showThumb();
- switchStatus('.status', "{:url('status')}");
- }
- });
- form.on('submit(serch)', function (data) {
- table.reload('table', {
- where: data.field
- , page: {
- curr: 1 //重新从第 1 页开始
- }
- });
- return false;
- });
- table.on('tool(table)', function (obj) {
- if (obj.event == 'edit') {
- location.href = "{:url('publish',['pid'=>$Request.param.pid])}?id=" + obj.data.id;
- }
- else if (obj.event == 'del') {
- layer.confirm('确定要删除?', function (index) {
- $.ajax({
- url: "{:url('delete')}",
- dataType: 'json',
- data: {id: obj.data.id},
- success: function (res) {
- layer.msg(res.msg);
- if (res.code == 1) {
- table.reload('table');
- }
- }
- })
- })
- }
- else if (obj.event == 'single_status') {
- var status = obj.data.single_status == 1 ? 0 : 1;
- $.ajax({
- type: "post",
- url: '{:url("single_status")}',
- data: {status: status, id: obj.data.id , pid:'{$Request.param.pid}'},
- dataType: 'json',
- success: function (res) {
- if (res.code == 1) {
- table.reload('table');
- } else {
- layer.msg(res.msg);
- }
- }
- })
- }
- });
- //监听事件
- table.on('toolbar(table)', function (obj) {
- if (obj.event == 'deletes') {
- var checkStatus = table.checkStatus(obj.config.id);//获取选中的数据
- var data = checkStatus.data;
- if (data.length > 0) {
- var ids = [];//数组
- data.forEach(function (item, key) {
- ids[key] = item.id;
- })
- layer.confirm('是否删除?', function (index, layero) {
- $.ajax({
- url: "{:url('deletes')}",
- dataType: 'json',
- data: {"ids": ids},
- type: 'post',
- success: function (res) {
- layer.msg(res.msg);
- if (res.code == 1) {
- table.reload('table');
- }
- }
- })
- layer.close(index)
- });
- } else {
- layer.msg('请先勾选需要操作的记录');
- }
- }
- });
- });
- </script>
- <script>
- // 排序
- layui.use(['layer', 'form'], function () {
- var layer = layui.layer,
- $ = layui.jquery,
- form = layui.form;
- $(window).on('load', function () {
- form.on('submit(admin)', function (data) {
- $sort_eles = $('.sort');
- $data = {};
- if ($sort_eles.length > 0) {
- for (var i = 0; i < $sort_eles.length; i++) {
- $data['sorts[' + i + ']'] = $sort_eles[i].value;
- $data['ids[' + i + ']'] = $sort_eles[i].nextSibling.value;
- }
- }
- console.log($data)
- $.ajax({
- url: "{:url('sort')}",
- data: $data,
- type: 'post',
- async: false,
- success: function (res) {
- if (res.code == 1) {
- layer.alert(res.msg, function (index) {
- location.reload();
- })
- } else {
- layer.msg(res.msg);
- }
- }
- })
- return false;
- });
- });
- });
- </script>
- </div>
- </body>
- </html>
|