lists.html
5.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
{include file="common/head"/}
<div class="admin-main layui-anim layui-anim-upbit">
<fieldset class="layui-elem-field layui-field-title">
<legend>{:$title}</legend>
</fieldset>
<div class="demoTable">
商家名称:<div class="layui-inline">
<input class="layui-input" name="key" id="key" placeholder="{:lang('pleaseEnter')}店铺名称" autocomplete="off">
</div>
商家来源:
<div class="layui-input-inline layui-form">
<div class="layui-input-8">
<select name="class" id="channel" lay-filter="myselect">
<option value="4">全部</option>
<option value="1" selected>合作</option>
<option value="2">推广</option>
<option value="3">测试</option>
</select>
</div>
</div>
<button class="layui-btn" id="search" data-type="reload">搜索</button> <button class="layui-btn" style="float:right;" id="addfoodsed">新建套餐</button>
</div>
<table class="layui-table" id="list" lay-filter="list"></table>
</div>
<script type="text/html" id="switchTpl">
<input type="checkbox" name="status" value="{{d.id}}" lay-skin="switch" lay-text="上架|下架" lay-filter="switchTpl" {{ d.status == 1 ? 'checked' : '' }}>
</script>
{include file="common/foot"/}
<script>
layui.use(['table','form'], function() {
var table = layui.table,laydate = layui.laydate,form = layui.form,$ = layui.jquery,layer = layui.layer;
var tableIn = table.render({
elem: '#list',
url: '{:url("lists")}',
method: 'post',
title: '卡券列表',
toolbar: '#toolbarDemo',
cols: [[
{field: 'id', title: '商家卡券编号',hide:true, fixed: true},
{field: 'sid', title: '商家编号', fixed: true},
{field: 'sellername', title: '商家名称'},
{field: 'name', title: '卡券名称'},
{field: 'market_price', align: 'center',title: '金额'},
{field: 'cdate', align: 'center', title: '创建日期'},
{field: 'founder', align: 'center', title: '创建人'},
{field: 'status', align: 'center', templet: '#switchTpl',title: '状态'}
]]
,id: 'cardReload'
,page: true
});
//监听单元格,上架/下架
form.on('switch(switchTpl)', function(obj){
loading =layer.load(1, {shade: [0.1,'#fff']});
var id = this.value;
var status = obj.elem.checked===true?1:0;
$.post('{:url("foodState")}',{'id':id,'status':status},function (res) {
layer.close(loading);
if (res.code==1) {
tableIn.reload();
}else{
layer.msg(res.msg,{time:1000,icon:2});
return false;
}
})
});
//监听行双击事件
table.on('rowDouble(list)', function(obj){
//table.on('row(list)', function(obj){ 双击事件
//console.log(obj.tr) //得到当前行元素对象
console.log(obj.data) //得到当前行数据
layer.open({
type: 2,
title: obj.data.sellername,
shadeClose: true,
shade: 0.8,
area: ['90%', '90%'],
content: '{:url("footsetdetail")}?id='+obj.data.id //iframe的url
/*success:function(dom){
let $iframeDom=$(dom[0]).find("iframe").eq(0).contents();
$iframeDom.find("#test").html("我是从父级传来的值哟……")
}*/
});
});
//搜索
$('#search').on('click', function() {
//关键字
var key = $('#key').val();
var channel = $('#channel').val();
//传参
tableIn.reload({ page: {page: 1},where: {key: key,channel: channel}});
});
var $ = layui.$, active = {
reload: function(){
var channel = $('#channel');
var key = $('#key');
//执行重载
table.reload('cardReload', {
page: {
curr: 1 //重新从第 1 页开始
}
,where: {
key: {
id: key.val(),
channel: channel.val()
}
}
});
}
};
//新建卡券
$('#addfoodsed').on('click', function() {
layer.open({
type: 2,
title: '创建套餐',
shadeClose: true,
shade: 0.8,
area: ['90%', '90%'],
content: '{:url("selectseller")}' //iframe的url
/*success:function(dom){
let $iframeDom=$(dom[0]).find("iframe").eq(0).contents();
$iframeDom.find("#test").html("我是从父级传来的值哟……")
}*/
});
});
})
</script>