提交一些代码

This commit is contained in:
rm 2024-01-19 18:18:48 +08:00
parent 7cb6c175d8
commit c756eb4211
2 changed files with 206 additions and 76 deletions

View File

@ -2,91 +2,92 @@
<?php include_once('left.php'); ?>
<div class="layui-body">
<!-- 内容主体区域 -->
<div class="layui-row content-body place-holder">
<!-- 说明提示框 -->
<div class="layui-col-lg12">
<div class="setting-msg">
<p>1. 注意:当分类下存在链接时,此分类不允许删除,如果需要删除分类请先前往【<a href = "/index.php?c=admin&page=link_list">我的链接</a>】删除此分类下的所有链接后再操作!</p>
</div>
</div>
<!-- 说明提示框END -->
<div class="layui-col-lg12">
<table id="category_list" lay-filter="mycategory"></table>
</div>
<script type="text/html" id="nav_operate">
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del" onclick = "">删除</a>
</script>
<!-- 内容主体区域 -->
<div class="layui-row content-body place-holder">
<!-- 说明提示框 -->
<div class="layui-col-lg12">
<div class="setting-msg">
<p>1. 注意:当分类下存在链接时,此分类不允许删除,如果需要删除分类请先前往【<a
href="/index.php?c=admin&page=link_list">我的链接</a>】删除此分类下的所有链接后再操作!</p>
</div>
</div>
<!-- 说明提示框END -->
<div class="layui-col-lg12">
<table id="category_list" lay-filter="mycategory"></table>
</div>
<script type="text/html" id="nav_operate">
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del" onclick = "">删除</a>
</script>
<!-- 表头工具栏 -->
<script type="text/html" id="catToolbar">
<div class="layui-btn-container">
<button class="layui-btn layui-btn-sm" lay-event="setPrivate">设为私有</button>
<button class="layui-btn layui-btn-sm" lay-event="setPublic">设为公开</button>
<!-- 表头工具栏 -->
<script type="text/html" id="catToolbar">
<div class="layui-btn-container">
<button class="layui-btn layui-btn-sm" lay-event="setPrivate">设为私有</button>
<button class="layui-btn layui-btn-sm" lay-event="setPublic">设为公开</button>
</div>
</script>
<!-- 表头工具栏END -->
</div>
</script>
<!-- 表头工具栏END -->
</div>
<!-- 内容主题区域END -->
<!-- 内容主题区域END -->
</div>
<?php include_once('footer.php'); ?>
<script>
layui.use(['table','layer','form'], function(){
var table = layui.table;
var form = layui.form;
layer = layui.layer;
layui.use(['table', 'layer', 'form'], function () {
var table = layui.table;
var form = layui.form;
layer = layui.layer;
// 表头工具栏事件
table.on('toolbar(mycategory)', function(obj){
var id = obj.config.id;
var checkStatus = table.checkStatus(id);
var othis = lay(this);
var data = checkStatus.data;
var ids = [];
data.map(function(value,index){
ids.push(value.id);
});
switch(obj.event){
case 'setPrivate':
// 设为私有,1
set_cat_batch(ids,1);
break;
case 'setPublic':
// 设为公开0
set_cat_batch(ids,0);
break;
};
});
});
//设置分类属性,
function set_cat_batch(ids,property) {
if( ids.length === 0 ) {
layer.msg("请先选择分类!",{icon:5});
}
else{
$.post("/index.php?c=api&method=set_cat_batch",{ids:ids,property:property},function(data,status){
if( data.code == 200 ){
layui.use(function(){
var table = layui.table;
table.reloadData('category_list', {
where: {
abc: '123456',
},
scrollPos: 'fixed', // 保持滚动条位置不变 - v2.7.3 新增
});
// 表头工具栏事件
table.on('toolbar(mycategory)', function (obj) {
var id = obj.config.id;
var checkStatus = table.checkStatus(id);
var othis = lay(this);
var data = checkStatus.data;
var ids = [];
data.map(function (value, index) {
ids.push(value.id);
});
layer.msg("设置已更新!",{icon:1});
switch (obj.event) {
case 'setPrivate':
// 设为私有,1
set_cat_batch(ids, 1);
break;
case 'setPublic':
// 设为公开0
set_cat_batch(ids, 0);
break;
};
});
});
//设置分类属性,
function set_cat_batch(ids, property) {
if (ids.length === 0) {
layer.msg("请先选择分类!", { icon: 5 });
}
else{
layer.msg("设置失败!",{icon:5});
else {
$.post("/index.php?c=api&method=set_cat_batch", { ids: ids, property: property }, function (data, status) {
if (data.code == 200) {
layui.use(function () {
var table = layui.table;
table.reloadData('category_list', {
where: {
abc: '123456',
},
scrollPos: 'fixed', // 保持滚动条位置不变 - v2.7.3 新增
});
});
layer.msg("设置已更新!", { icon: 1 });
}
else {
layer.msg("设置失败!", { icon: 5 });
}
});
}
});
}
}
</script>

129
templates/junit/demo1.html Normal file
View File

@ -0,0 +1,129 @@
<!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="../../static/layui-2.6.8/css/layui.css" media="all">
<!-- 注意如果你直接复制所有代码到本地上述css路径需要改成你本地的 -->
</head>
<body>
<div class="layui-body">
<!-- 说明提示框 -->
<div class="layui-col-lg12">
<div class="setting-msg">
<p>1. 注意:当分类下存在链接时,此分类不允许删除,如果需要删除分类请先前往【<a
href="/index.php?c=admin&page=link_list">我的链接</a>】删除此分类下的所有链接后再操作!</p>
</div>
</div>
<!-- 说明提示框END -->
<div class="layui-col-lg12">
<div class="layui-row">
<div class="layui-col-lg2">
<div id="test1" class="demo-tree demo-tree-box"></div>
</div>
<div class="layui-col-lg10">
<table id="category_list" lay-filter="mycategory"></table>
</div>
</div>
</div>
<script type="text/html" id="nav_operate">
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del" onclick = "">删除</a>
</script>
<!-- 表头工具栏 -->
<script type="text/html" id="catToolbar">
<div class="layui-btn-container">
<button class="layui-btn layui-btn-sm" lay-event="setPrivate">设为私有</button>
<button class="layui-btn layui-btn-sm" lay-event="setPublic">设为公开</button>
</div>
</script>
<!-- 表头工具栏END -->
</div>
<script src="../../static/layui-2.6.8/layui.js" charset="utf-8"></script>
<!-- 注意:如果你直接复制所有代码到本地,上述 JS 路径需要改成你本地的 -->
<script>
layui.use('table', function () {
var table = layui.table;
table.render({
elem: '#category_list'
, toolbar: '#catToolbar' //开启头部工具栏,并为其绑定左侧模板
, url: 'http://layui.apixx.net/demo/table/user/data.js'
, cols: [[
{ field: 'id', width: 80, title: 'ID', sort: true }
, { field: 'username', width: 80, title: '用户名' }
, { field: 'sex', width: 80, title: '性别', sort: true }
, { field: 'city', width: 80, title: '城市' }
, { field: 'sign', title: '签名', minWidth: 150 }
, { field: 'experience', width: 80, title: '积分', sort: true }
, { field: 'score', width: 80, title: '评分', sort: true }
, { field: 'classify', width: 80, title: '职业' }
, { field: 'wealth', width: 135, title: '财富', sort: true }
, { fixed: 'right', width: 178, align: 'center', toolbar: '#nav_operate' }
]]
, page: true
});
});
layui.use(['tree', 'util'], function () {
var tree = layui.tree
, layer = layui.layer
, util = layui.util
, data1 = [{
title: '江西'
, id: 1
, children: [{
title: '南昌'
, id: 1000
, children: [{
title: '青山湖区'
, id: 10001
}, {
title: '高新区'
, id: 10002
}]
}, {
title: '九江'
, id: 1001
}, {
title: '赣州'
, id: 1002
}]
}, {
title: '广西'
, id: 2
, children: [{
title: '南宁'
, id: 2000
}, {
title: '桂林'
, id: 2001
}]
}, {
title: '陕西'
, id: 3
, children: [{
title: '西安'
, id: 3000
}, {
title: '延安'
, id: 3001
}]
}];
//常规用法
tree.render({
elem: '#test1' //默认是点击节点可进行收缩
, data: data1
, onlyIconControl: true
, isJump: true
});
});
</script>
</body>