parent
363c1663f4
commit
b926cf61ab
@ -0,0 +1,300 @@ |
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
||||
<html> |
||||
<head> |
||||
<title>商品数据</title> |
||||
<meta http-equiv="pragma" content="no-cache"> |
||||
<meta http-equiv="cache-control" content="no-cache"> |
||||
<meta http-equiv="expires" content="0"> |
||||
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> |
||||
|
||||
<link rel="stylesheet" href="/html/common/layui/css/layui.css"> |
||||
<link rel="stylesheet" href="/html/common/css/style.css"> |
||||
</head> |
||||
<body> |
||||
<div class="layui-fluid"> |
||||
<div class="layui-card" id="cz"> |
||||
<form class="layui-form"> |
||||
<div class="layui-form layui-card-header layuiadmin-card-header-auto" lay-filter="app-forum-list" style="min-height: 40px;height: auto"> |
||||
<div class="layui-row layui-form-item"> |
||||
<div class="layui-block"> |
||||
<label class="layui-form-label">商品名称:</label> |
||||
<div class="layui-input-block"> |
||||
<input type="text" class="layui-input" id="name" > |
||||
</div> |
||||
</div> |
||||
<div class="layui-block"> |
||||
<label class="layui-form-label">开始日期</label> |
||||
<div class="layui-input-block"> |
||||
<input type="text" class="layui-input" id="startDate" placeholder=""> |
||||
</div> |
||||
</div> |
||||
<div class="layui-block"> |
||||
<label class="layui-form-label">结束日期</label> |
||||
<div class="layui-input-block"> |
||||
<input type="text" class="layui-input" id="endDate" placeholder=""> |
||||
</div> |
||||
</div> |
||||
<div class="layui-block"> |
||||
<button class="layui-btn layui-btn-sm layuiadmin-btn-forum-list" id="search" type="button" data-type="reload"> |
||||
<i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>搜索 |
||||
</button> |
||||
<button class="layui-btn layui-btn-sm layuiadmin-btn-forum-list" type="button" id="reset"> |
||||
<i class="layui-icon layui-icon-refresh layuiadmin-button-btn"></i>重置 |
||||
</button> |
||||
|
||||
</div> |
||||
</div> |
||||
</div> |
||||
</form> |
||||
</div> |
||||
<table id="datatable" lay-filter="tablefilter"></table> |
||||
</div> |
||||
</body> |
||||
<script src="/html/common/js/jquery-3.6.0.js"></script> |
||||
<script src="/html/common/layui/layui.all.js"></script> |
||||
<script src="/html/common/js/cjy_common.js"></script> |
||||
<script src="/html/common/js/initParam.js"></script> |
||||
|
||||
<script type="text/html" id="barDemo"> |
||||
<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="speak"><i class="layui-icon layui-icon-edit"></i>详情</a> |
||||
{{# if(d.state== 0){ }} |
||||
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="cancel">取消预约</a> |
||||
{{# } }} |
||||
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除记录</a> |
||||
</script> |
||||
<script> |
||||
//显示下拉列表(必须有) |
||||
layui.config({base: '/html/common/layui/'}).use('global'); |
||||
|
||||
layui.use('table', function() { |
||||
var laydate = layui.laydate; |
||||
// 渲染 |
||||
laydate.render({ |
||||
elem: '#startDate' |
||||
}); |
||||
laydate.render({ |
||||
elem: '#endDate' |
||||
}); |
||||
|
||||
var table = layui.table; |
||||
table.render({ |
||||
elem : '#datatable', |
||||
even: true,//隔行换色 |
||||
url : ctx + 'commodityOpenUrlStatistics/getCommodityOpenUrlStatisticsList',//数据接口 |
||||
method: 'POST', |
||||
contentType: 'application/json', |
||||
cols : [ [ //表头 |
||||
{field: 'guid', type:'checkbox', width:'5%'}, |
||||
{title:'序号', width:'5%', type:'numbers'}, |
||||
{field:'name', title:'商品名称', width:'40%', align:'center'}, |
||||
{field:'price', title:'价格', width:'15%', align:'center'}, |
||||
{field:'count', title:'点击次数', width:'20%', align:'center'}, |
||||
{field:'guid', hide:true, width:0} |
||||
] ], |
||||
id : 'tableId', |
||||
page : true,//开启分页 |
||||
height : tableHight(), |
||||
}); |
||||
|
||||
//搜索 |
||||
var $ = layui.$, active = { |
||||
reload : function() { |
||||
table.reload('tableId', { |
||||
page : {curr : 1}, |
||||
where : { |
||||
name : $('#name').val(), |
||||
startDate:$('#startDate').val(), |
||||
endDate:$('#endDate').val(), |
||||
} |
||||
}); |
||||
} |
||||
}; |
||||
//点击搜索按钮 |
||||
$('#search').on('click', function() { |
||||
var type = $(this).data('type'); |
||||
active[type] ? active[type].call(this) : ''; |
||||
}); |
||||
|
||||
//点击重置按钮 |
||||
$('#reset').on('click', function() { |
||||
var form = layui.form; |
||||
$("#name").val(""); |
||||
$("#startDate").val(""); |
||||
$("#endDate").val(""); |
||||
form.render('select'); |
||||
var type = $(this).data('type'); |
||||
active[type] ? active[type].call(this) : ''; |
||||
table.reload('tableId', { |
||||
page : {curr : 1}, |
||||
where : { |
||||
name : $('#name').val(), |
||||
startDate:$('#startDate').val(), |
||||
endDate:$('#endDate').val(), |
||||
} |
||||
}); |
||||
}); |
||||
|
||||
// $("#download").on("click",function() { |
||||
// table.exportFile('tableData'); |
||||
// }) |
||||
|
||||
//监听行工具事件 |
||||
table.on('tool(tablefilter)', function(obj) { |
||||
var data = obj.data; |
||||
console.log(data['id']) |
||||
switch(obj.event){ |
||||
case 'speak': |
||||
layer.open({ |
||||
type : 2, |
||||
title : '详情', |
||||
area : ['90%','90%'], |
||||
maxmin : true, |
||||
content : '/html/back/yuyueList/reservationRecord_commont.html?guid='+data['id'] , |
||||
/*end: function(){ |
||||
table.reload('tableId',{page:{curr:1}});//刷新 |
||||
}*/ |
||||
}); |
||||
break; |
||||
case 'cancel': |
||||
layer.confirm('确定要取消此条记录吗?', function(index) { |
||||
cancel(data.id) |
||||
layer.close(index); |
||||
}); |
||||
break; |
||||
case 'del': |
||||
layer.confirm('确定要删除此条记录吗?', function(index) { |
||||
delData(data.id) |
||||
layer.close(index); |
||||
}); |
||||
break; |
||||
} |
||||
}); |
||||
|
||||
var laydate = layui.laydate; |
||||
var startDate = laydate.render({ |
||||
elem : '#startDate', |
||||
format: 'yyyy-MM-dd', |
||||
max: new Date().getTime(), |
||||
done : function(value, date) { |
||||
endDate.config.min = { |
||||
year : date.year, |
||||
month : date.month-1, |
||||
date : date.date, |
||||
}; |
||||
} |
||||
}); |
||||
var endDate = laydate.render({ |
||||
elem : '#endDate', |
||||
format: 'yyyy-MM-dd', |
||||
max: new Date().getTime(), |
||||
done : function(value, date) { |
||||
startDate.config.max = { |
||||
year : date.year, |
||||
month : date.month-1, |
||||
date : date.date, |
||||
} |
||||
} |
||||
}); |
||||
|
||||
function cancel(guid,state){ |
||||
$.ajax({ |
||||
url : ctx + "/appointmentRecord/cancelAppointment?id="+guid, |
||||
type : "get", |
||||
xhrFields: { |
||||
withCredentials: true // 这里设置了withCredentials |
||||
}, |
||||
async:true, |
||||
dataType:"json", |
||||
success : function(data) { |
||||
table.reload('tableId', { |
||||
page : {curr : 1}, |
||||
where : { |
||||
name : "", |
||||
startDate:"", |
||||
endDate:"", |
||||
} |
||||
}); |
||||
table.refresh('tableId'); |
||||
}, |
||||
complete:function (){ |
||||
table.reload('tableId', { |
||||
page : {curr : 1}, |
||||
where : { |
||||
name : "", |
||||
startDate:"", |
||||
endDate:"", |
||||
} |
||||
}); |
||||
} |
||||
}); |
||||
} |
||||
}); |
||||
|
||||
function downloadFile(data) { |
||||
// 创建XHR对象 |
||||
var xhr = new XMLHttpRequest(); |
||||
|
||||
// 配置AJAX请求 |
||||
xhr.open("POST", "/appointmentRecord/exportReserveRecord"); |
||||
xhr.setRequestHeader("Content-Type", "application/json"); |
||||
|
||||
// 设置响应类型为blob |
||||
xhr.responseType = "blob"; |
||||
|
||||
// 处理响应 |
||||
xhr.onload = function() { |
||||
if (xhr.status === 200) { |
||||
// 创建一个临时的URL对象,用于下载文件 |
||||
var url = window.URL.createObjectURL(xhr.response); |
||||
|
||||
// 创建一个隐藏的下载链接,并设置下载属性 |
||||
var a = document.createElement("a"); |
||||
a.style.display = "none"; |
||||
a.href = url; |
||||
a.download = "记录.xlsx"; |
||||
|
||||
// 将a元素添加到页面,并模拟点击链接以开始下载 |
||||
document.body.appendChild(a); |
||||
a.click(); |
||||
|
||||
// 移除a元素,并释放临时的URL对象 |
||||
document.body.removeChild(a); |
||||
window.URL.revokeObjectURL(url); |
||||
} |
||||
}; |
||||
|
||||
// 发送POST请求 |
||||
xhr.send(JSON.stringify(data)); |
||||
} |
||||
|
||||
//根据id删除数据 |
||||
function delData(guid) { |
||||
$.ajax({ |
||||
url : ctx + "/appointmentRecord/deleteAppointmentRecord?id="+guid, |
||||
type : "get", |
||||
xhrFields: { |
||||
withCredentials: true // 这里设置了withCredentials |
||||
}, |
||||
async:false, |
||||
dataType:"json", |
||||
success : function(data) { |
||||
if (data.success) { |
||||
$(".layui-laypage-btn")[0].click(); //刷新 |
||||
layer.msg("删除成功"); |
||||
} else { |
||||
$(".layui-laypage-btn")[0].click(); //刷新 |
||||
layer.msg("删除失败"); |
||||
} |
||||
} |
||||
}); |
||||
} |
||||
$("#download").on("click",function(){ |
||||
var temp = { |
||||
name : $('#name').val(), |
||||
startDate:$('#startDate').val(), |
||||
endDate:$('#endDate').val(), |
||||
}; |
||||
downloadFile(temp) |
||||
}); |
||||
</script> |
||||
</html> |
Loading…
Reference in new issue