287 行
11 KiB
HTML
可执行文件
287 行
11 KiB
HTML
可执行文件
<!doctype html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport"
|
||
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||
<title>促销单据</title>
|
||
<link rel="stylesheet" href="__PUBLIC__/bootstrap/css/bootstrap.css">
|
||
<link rel="stylesheet" type="text/css" href="__PUBLIC__/layui/css/layui.css" />
|
||
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Retail/css/goodsList.css" />
|
||
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Retail/css/myscroll.css"/>
|
||
<style>
|
||
* {
|
||
margin: 0;
|
||
padding: 0;
|
||
}
|
||
|
||
body {
|
||
padding: 10px 15px;
|
||
}
|
||
|
||
.Promotion, blockquote {
|
||
box-sizing: border-box;
|
||
/*margin: 0;*/
|
||
padding: 0;
|
||
padding-left: 15px;
|
||
border-left: 2px solid #3D4357;
|
||
font-size: 14px;
|
||
}
|
||
table {
|
||
border: 1px solid #f1f1f1;
|
||
margin-top: 40px;
|
||
}
|
||
|
||
.Preservation {
|
||
background: #3E4C72;
|
||
color: #fff;
|
||
}
|
||
.del{
|
||
color: #E44849;
|
||
}
|
||
.see{
|
||
color:#5A76C9;
|
||
}
|
||
.form-group{
|
||
margin-top: 10px;
|
||
}
|
||
#closeall:hover{
|
||
background-color: white;
|
||
color:black;
|
||
}
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<div class="goodsBox">
|
||
<div class="goods_title">
|
||
<div class="goods_title_inner">
|
||
促销单据<span style="color:orangered">(注意:促销商品不参加会员的打折)</span>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<form action="#" class="form-inline PromotionForm">
|
||
<div class="form-group" >
|
||
<div class="col-md-12 col-sm-12 ">
|
||
<div class="form-group">
|
||
<label for="">促销模式:</label>
|
||
<select name="type" id="discountType" class="form-control" style="width: 165px;">
|
||
<option value="-1">选择模式</option>
|
||
<option value="1">直接特价</option>
|
||
<option value="0">直接折扣</option>
|
||
</select>
|
||
<span></span>
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="">促销名称:</label>
|
||
<input type="text" class="form-control " placeholder="" name="dis_name" id="dis_name">
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="form-group" >
|
||
<div class="form-group">
|
||
<button type="button" class="btn btn-default Preservation">查询</button>
|
||
<button type="button" class="btn btn-default" id="closeall" style="background: #3E4C72;color:white;">关闭所有促销活动</button>
|
||
</div>
|
||
</div>
|
||
</form>
|
||
<table class="layui-hide" id="test" lay-filter="demo"></table>
|
||
<script type="text/html" id="barDemo">
|
||
<button class="layui-btn layui-btn-xs" lay-event="detail">查看</button>
|
||
<!--<button class="layui-btn layui-btn-xs" lay-event="edit">开启</button>-->
|
||
<button class="layui-btn layui-btn-xs layui-btn-danger" lay-event="del">删除</button>
|
||
</script>
|
||
<script type="text/html" id="switchTpl">
|
||
<input type="checkbox" name="状态" value="{{d.status}}" data-id="{{d.id}}" lay-skin="switch" lay-text="开启|关闭" lay-filter="statusDemo" {{ d.status == 1? 'checked' : '' }}>
|
||
</script>
|
||
</body>
|
||
<script src="__PUBLIC__/jquery/js/jquery.min.js"></script>
|
||
<script type="text/javascript" src="__PUBLIC__/layui/layui.js"></script>
|
||
<script>
|
||
layui.use(['form', 'layedit', 'laydate', 'table'], function() {
|
||
// 日期
|
||
var laydate = layui.laydate;
|
||
var table = layui.table;
|
||
// 日期
|
||
lay('.test-item').each(function () {
|
||
laydate.render({
|
||
elem: this,
|
||
trigger: 'click'
|
||
});
|
||
});
|
||
// 删除
|
||
$(".tableBox").on("click", '.del', function () {
|
||
$(this).parents('tr').remove();
|
||
})
|
||
//查询
|
||
$('.Preservation').click(function () {
|
||
// console.log(111);
|
||
//执行重载
|
||
table.reload('test', {
|
||
page: {
|
||
curr: 1 //重新从第 1 页开始
|
||
}
|
||
,where: {
|
||
// type:$('#discountType option:selected').val(),
|
||
dis_name:$('#dis_name').val()
|
||
}
|
||
});
|
||
})
|
||
//查询
|
||
$('#discountType').on('change',function () {
|
||
table.reload('test', {
|
||
page: {
|
||
curr: 1 //重新从第 1 页开始
|
||
}
|
||
,where: {
|
||
type:$('#discountType option:selected').val(),
|
||
// dis_name:$('#dis_name').val()
|
||
}
|
||
});
|
||
}),
|
||
table.on('tool(demo)', function(obj){ //注:tool是工具条事件名,test是table原始容器的属性 lay-filter="对应的值"
|
||
var data = obj.data; //获得当前行数据
|
||
var layEvent = obj.event; //获得 lay-event 对应的值(也可以是表头的 event 参数对应的值)
|
||
var tr = obj.tr; //获得当前行 tr 的DOM对象
|
||
if(layEvent === 'detail'){ //查看
|
||
//do somehing
|
||
window.location.href="{:U('discountdetail')}?id="+data.id;
|
||
} else if(layEvent === 'del'){ //删除
|
||
layer.confirm('确定删除这条数据吗?', function(index){
|
||
layer.close(index);
|
||
//向服务端发送删除指令
|
||
$.ajax({
|
||
url:"{:U(deldiscount)}",
|
||
data:{id:data.id},
|
||
type:'post',
|
||
success:function (res) {
|
||
// console.log(res)
|
||
if(res.status==1){
|
||
obj.del(); //删除对应行(tr)的DOM结构,并更新缓存
|
||
}else{
|
||
top.layer.msg('删除失败',{icon:4,time:1000})
|
||
}
|
||
}
|
||
})
|
||
});
|
||
} else if(layEvent === 'edit'){ //编辑
|
||
top.layer.confirm('确定开启该促销活动<br>将关闭其他已开启促销活动',function () {
|
||
top.layer.alert('开启促销单据请注意更新收银前台数据',function () {
|
||
$.ajax({
|
||
url:"{:U(opendiscount)}",
|
||
data:{id:data.id},
|
||
type:'post',
|
||
success:function (res) {
|
||
// console.log(res)
|
||
if(res.status==1){
|
||
//执行重载
|
||
top.layer.msg('促销活动已开启',{icon:1,time:1000});
|
||
table.reload('test', {
|
||
});
|
||
}else{
|
||
top.layer.msg('开启失败',{icon:4,time:1000})
|
||
}
|
||
}
|
||
})
|
||
})
|
||
})
|
||
}
|
||
});
|
||
$('#closeall').click(function () {
|
||
top.layer.confirm('确定关闭所有促销活动',function () {
|
||
top.layer.alert('关闭促销单据请注意更新收银前台数据',function () {
|
||
$.ajax({
|
||
url: "{:U(opendiscount)}",
|
||
data: {},
|
||
type: 'post',
|
||
success: function (res) {
|
||
// console.log(res)
|
||
if (res.status == 1) {
|
||
//执行重载
|
||
top.layer.msg('所有促销活动均已关闭', {icon: 1, time: 2000});
|
||
table.reload('test', {});
|
||
} else {
|
||
top.layer.msg('关闭失败', {icon: 4, time: 2000})
|
||
}
|
||
}
|
||
})
|
||
})
|
||
})
|
||
})
|
||
//展示已知数据
|
||
table.render({
|
||
elem: '#test',
|
||
url: "{:U('Discount/billmsg')}",
|
||
cols: [
|
||
[ //标题栏
|
||
{
|
||
field: 'index',
|
||
title: '序号',
|
||
width:60
|
||
},
|
||
{
|
||
field: 'dis_name',
|
||
title: '促销名称',
|
||
}, {
|
||
field: 'type',
|
||
title: '促销模式'
|
||
}, {
|
||
field: 'status',
|
||
title: '状态',
|
||
templet: '#switchTpl', unresize: true
|
||
}, {
|
||
field: 'starttime',
|
||
title: '开始时间'
|
||
}, {
|
||
field: 'endtime',
|
||
title: '结束时间'
|
||
}, {
|
||
field: 'adminid',
|
||
title: '制单人姓名'
|
||
}, {
|
||
field: 'addtime',
|
||
title: '制单时间'
|
||
},{field: 'right',
|
||
title:'操作',
|
||
align:'center',
|
||
toolbar: '#barDemo',
|
||
width:180
|
||
}]
|
||
],
|
||
page: {
|
||
layout: [ 'count', 'prev', 'page', 'next', 'skip'] //自定义分页布局
|
||
}, //是否开启分页
|
||
});
|
||
//监听switch操作
|
||
var form = layui.form;
|
||
form.on('switch(statusDemo)', function(obj){
|
||
this.value = this.value==1?0:1;
|
||
var status = this.value;
|
||
var id = $(obj.elem).attr('data-id');
|
||
var str = '开启该促销将关闭其他促销?';
|
||
if(status==0){
|
||
str = '确定关闭吗?'
|
||
}
|
||
console.log(status);
|
||
top.layer.confirm(str,function () {
|
||
$.ajax({
|
||
url:"{:U('changestatus')}",
|
||
type:'POST',
|
||
data:{
|
||
status:status,
|
||
id:id
|
||
},
|
||
success:function (res) {
|
||
if(res.status==1){
|
||
table.reload('test',{});
|
||
top.layer.msg('修改成功',{icon:1,time:500})
|
||
}else{
|
||
top.layer.msg('修改失败',{icon:4,time:500})
|
||
}
|
||
}
|
||
})
|
||
})
|
||
});
|
||
})
|
||
</script>
|
||
</html> |