点击表格的订单数跳转链接,参数:表格的时间段,页面上的一个值
第一种.参数:想要参数的接口里都有
//表格
<table class="layui-inline" lay-filter="table" id="cardList"></table>
//跳转
<script type="text/html" id="usernameTpl">
<a href="/order/index?shopname={{d.id}}" class="layui-table-link" target="_blank">{{ d.username }}</a>
</script>
第二种:.参数不止表格的接口获取的数据(表格的值需要用jquery获取,页面上的值通过id的val()获取)
//行工具 跳转
<script type="text/html" id="usernameTpl">
<a href="" class="layui-table-link" target="_self">{{ d.order_count }}</a>
</script>
<script>
table.render({
elem: '#cardList',
url: '/Sales/List',
cols: [
[
{
field: 'order_time',
width: 150,
title: '时间段',
sort: true,
templet: function (d) { return layui.laytpl.toDateString(d.order_time); }
},
{
field: 'order_count',
width: 150,
title: '订单数',
sort: true,
templet: '#usernameTpl'
}
]
],
done: function (res) {
$(".layui-table-link").each(function () {
$(this).attr("href", "/order/index?order_data_after=" + $(this).parent().parent().siblings().attr("data-content")+ "&shopname=" + $("#ShopId").val());
})
}
})
</script>
如有错误或不恰当之处,望大佬们给予批评指正。如有帮助,点个赞再走呗!