You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
235 lines
10 KiB
235 lines
10 KiB
{layout name="layout1" /}
|
|
|
|
<div class="wrapper">
|
|
<div class="layui-card">
|
|
<!-- 操作提示 -->
|
|
<div class="layui-card-body">
|
|
<div class="layui-collapse" style="border:1px dashed #c4c4c4">
|
|
<div class="layui-colla-item">
|
|
<h2 class="layui-colla-title like-layui-colla-title">操作提示</h2>
|
|
<div class="layui-colla-content layui-show">
|
|
<p>*平台的资料中心。用户可在商城的下载查看。</p>
|
|
<p>*排序值越小越前,排序值相同时新增在前。</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 搜索区域 -->
|
|
<div class="layui-card-body layui-form">
|
|
<div class="layui-form-item">
|
|
<div class="layui-inline">
|
|
<label for="title" class="layui-form-label">资料标题:</label>
|
|
<div class="layui-input-inline">
|
|
<input type="text" id="title" name="title" autocomplete="off" class="layui-input">
|
|
</div>
|
|
</div>
|
|
<div class="layui-inline">
|
|
<label for="cid" class="layui-form-label">资料分类:</label>
|
|
<div class="layui-input-inline">
|
|
<select name="cid" id="cid">
|
|
<option value="">全部</option>
|
|
{volist name="category" id="vo"}
|
|
<option value="{$vo.id}">{$vo.name}</option>
|
|
{/volist}
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="layui-inline">
|
|
<a class="layui-btn layui-btn-sm layui-btn-normal" lay-submit lay-filter="search">搜索</a>
|
|
<a class="layui-btn layui-btn-sm layui-btn-primary" lay-submit lay-filter="clear-search">重置</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 主体区域 -->
|
|
<div class="layui-card-body">
|
|
<button type="button" class="layui-btn layui-btn-normal layui-btn-sm layEvent" lay-event="add">新增资料</button>
|
|
|
|
<table id="like-table-lists" lay-filter="like-table-lists"></table>
|
|
<script type="text/html" id="table-image">
|
|
{{# if(d.image){ }}
|
|
<img src="{{d.image}}" alt="图" style="width:28px;height:28px;">
|
|
{{# } }}
|
|
</script>
|
|
<script type="text/html" id="table-file">
|
|
{{# if(d.path){ }}
|
|
<a href="{{d.path}}" download="{{d.path_name}}">点击下载</a>
|
|
{{# }else { }}
|
|
--
|
|
{{# } }}
|
|
</script>
|
|
<script type="text/html" id="table-type">
|
|
{{# if(d.type == 0){ }}
|
|
免费
|
|
{{# } }}
|
|
{{# if(d.type == 1){ }}
|
|
VIP用户免费
|
|
{{# } }}
|
|
{{# if(d.type == 2){ }}
|
|
付费{{d.price}}元下载
|
|
{{# } }}
|
|
</script>
|
|
<script type="text/html" id="table-operation">
|
|
<a class="layui-btn layui-btn-normal layui-btn-sm" lay-event="edit">编辑</a>
|
|
{{# if(d.is_show == '显示'){ }}<a class="layui-btn layui-btn-normal layui-btn-sm layui-btn-warm" lay-event="hide">隐藏</a>{{# } }}
|
|
{{# if(d.is_show == '隐藏'){ }}<a class="layui-btn layui-btn-normal layui-btn-sm" lay-event="hide">显示</a>{{# } }}
|
|
<a class="layui-btn layui-btn-danger layui-btn-sm" lay-event="del">删除</a>
|
|
</script>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
layui.use(["table", "form"], function(){
|
|
var table = layui.table;
|
|
var form = layui.form;
|
|
|
|
|
|
like.tableLists("#like-table-lists", "{:url()}", [
|
|
{field:"id", width:60, title:"ID"}
|
|
,{field:"title", width:200, align:"center", title:"资料标题"}
|
|
,{field:"image", width:100, align:"center", title:"封面图", templet:"#table-image"}
|
|
,{field:"category", width:150, align:"center", title:"资料分类"}
|
|
,{field:"category2", width:150, align:"center", title:"子分类"}
|
|
,{field:"address", width:180, align:"center", title:"资料区域"}
|
|
,{field:"type", width:150, align:"center", title:"付费类型", templet:"#table-type"}
|
|
,{field:"type", width:100, align:"center", title:"文件", templet:"#table-file"}
|
|
,{field:"is_show", width:100, align:"center", title:"资料状态"}
|
|
,{field:"visit", width:100, align:"center", title:"浏览量"}
|
|
,{field:"download", width:100, align:"center", title:"下载量"}
|
|
,{field:"sort", width:100, align:"center", title:"排序"}
|
|
,{field:"create_time", width:180, align:"center", title:"创建时间"}
|
|
,{title:"操作", width:200, align:"center", fixed:"right", toolbar:"#table-operation"}
|
|
]);
|
|
|
|
|
|
var active = {
|
|
add: function() {
|
|
layer.open({
|
|
type: 2
|
|
,title: "新增资料"
|
|
,content: "{:url('content.Resource/add')}"
|
|
,area: ["90%", "90%"]
|
|
,btn: ["确定", "取消"]
|
|
,yes: function(index, layero){
|
|
var iframeWindow = window["layui-layer-iframe" + index];
|
|
var submit = layero.find("iframe").contents().find("#addSubmit");
|
|
iframeWindow.layui.form.on("submit(addSubmit)", function(data){
|
|
like.ajax({
|
|
url: "{:url('content.Resource/add')}",
|
|
data: data.field,
|
|
type: "POST",
|
|
success:function(res) {
|
|
if(res.code === 1) {
|
|
layui.layer.msg(res.msg);
|
|
layer.close(index);
|
|
table.reload("like-table-lists", {
|
|
where: {},
|
|
page: { cur: 1 }
|
|
});
|
|
}
|
|
}
|
|
});
|
|
});
|
|
submit.trigger("click");
|
|
}
|
|
});
|
|
},
|
|
edit: function(obj) {
|
|
layer.open({
|
|
type: 2
|
|
,title: "编辑资料"
|
|
,content: "{:url('content.Resource/edit')}?id=" + obj.data.id
|
|
,area: ["90%", "90%"]
|
|
,btn: ["确定", "取消"]
|
|
,yes: function(index, layero){
|
|
var iframeWindow = window["layui-layer-iframe" + index];
|
|
var submit = layero.find("iframe").contents().find("#addSubmit");
|
|
iframeWindow.layui.form.on("submit(addSubmit)", function(data){
|
|
data.field['id'] = obj.data.id;
|
|
like.ajax({
|
|
url: "{:url('content.Resource/edit')}",
|
|
data: data.field,
|
|
type: "POST",
|
|
success:function(res) {
|
|
if(res.code === 1) {
|
|
layui.layer.msg(res.msg);
|
|
layer.close(index);
|
|
table.reload("like-table-lists", {
|
|
where: {},
|
|
page: { cur: 1 }
|
|
});
|
|
}
|
|
}
|
|
});
|
|
});
|
|
submit.trigger("click");
|
|
}
|
|
});
|
|
},
|
|
del: function(obj) {
|
|
layer.confirm("确定删除资料:"+obj.data.title, function(index) {
|
|
like.ajax({
|
|
url: "{:url('content.Resource/del')}",
|
|
data: {id: obj.data.id},
|
|
type: "POST",
|
|
success: function (res) {
|
|
if (res.code === 1) {
|
|
layui.layer.msg(res.msg);
|
|
layer.close(index);
|
|
obj.del();
|
|
}
|
|
}
|
|
});
|
|
layer.close(index);
|
|
})
|
|
},
|
|
hide: function(obj) {
|
|
var text = obj.data.is_show === '显示' ? '确定隐藏:' : '确定显示:';
|
|
layer.confirm(text+obj.data.title, function(index) {
|
|
like.ajax({
|
|
url: "{:url('content.Resource/hide')}",
|
|
data: {id: obj.data.id},
|
|
type: "POST",
|
|
success: function (res) {
|
|
if (res.code === 1) {
|
|
layui.layer.msg(res.msg);
|
|
layer.close(index);
|
|
table.reload("like-table-lists", {
|
|
where: {},
|
|
page: { cur: 1 }
|
|
});
|
|
}
|
|
}
|
|
});
|
|
layer.close(index);
|
|
})
|
|
}
|
|
};
|
|
like.eventClick(active);
|
|
|
|
form.on("submit(search)", function(data){
|
|
table.reload("like-table-lists", {
|
|
where: data.field,
|
|
page: {
|
|
curr: 1
|
|
}
|
|
});
|
|
});
|
|
|
|
form.on("submit(clear-search)", function(){
|
|
$("#title").val("");
|
|
form.render("select");
|
|
table.reload("like-table-lists", {
|
|
where: {},
|
|
page: {
|
|
curr: 1
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
})
|
|
</script>
|