109 行
3.7 KiB
HTML
可执行文件
109 行
3.7 KiB
HTML
可执行文件
<!--[1.6.54]-->
|
|
<style>
|
|
table {
|
|
border: 1px solid #f1f1f1;
|
|
margin-top: 40px;
|
|
}
|
|
|
|
.layui-btn {
|
|
background-color: white !important;
|
|
color: #999 !important;
|
|
border: 1px solid #CCCCCC !important;
|
|
}
|
|
</style>
|
|
<div class="goodsBox goodsCode-box">
|
|
<form action="#" class="form-inline PromotionForm">
|
|
<div class="form-group">
|
|
<div class="col-md-12 col-sm-12 ">
|
|
<div class="form-group">
|
|
<input class="layui-input" type="text" value="" placeholder="商品条码/名称" id="keyword"
|
|
style="width:250px;display: inline-block">
|
|
<button type="button" class="layui-btn layui-btn-primary" id="Preservation">查询</button>
|
|
<button type="button" class="layui-btn layui-btn-primary" id="export">导出</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</form>
|
|
<table class="layui-hide" id="test" lay-filter="demo"></table>
|
|
</div>
|
|
<script>
|
|
layui.use(['form', 'layedit', 'laydate', 'table'], function () {
|
|
// 日期
|
|
var table = layui.table;
|
|
let url = location.href.split('://');
|
|
let new_url = url[0] + '://' + url[1].split('/')[0] + '/Public/images/empty-image-1.png';
|
|
//展示已知数据
|
|
table.render({
|
|
elem: '#test',
|
|
url: "{:U('Retail/GoodsCode/goodsCodelist')}",
|
|
method: 'post',
|
|
cols: [
|
|
[ //标题栏
|
|
{
|
|
field: 'id',
|
|
title: '序号',
|
|
width: 160
|
|
},
|
|
{
|
|
field: 'code',
|
|
title: '商品条码',
|
|
align: 'center',
|
|
}, {
|
|
field: 'name',
|
|
title: '菜单名称',
|
|
align: 'center',
|
|
}, {
|
|
field: 'specification',
|
|
title: '商品规格',
|
|
align: 'center',
|
|
}, {
|
|
field: 'unit',
|
|
title: '商品单位',
|
|
align: 'center',
|
|
}, {
|
|
field: 'origin',
|
|
title: '产地',
|
|
align: 'center',
|
|
}, {
|
|
field: 'image',
|
|
title: '商品图片',
|
|
style: 'height:100%;',
|
|
align: 'center',
|
|
templet: `<div><img class="goods-image" src="{{ d.image}}" onerror="this.error=null;this.src='${new_url}'" style="height: 30px;width: 30px;"></div>`
|
|
}
|
|
]
|
|
],
|
|
page: {
|
|
layout: ['count', 'prev', 'page', 'next', 'skip'] //自定义分页布局
|
|
}, //是否开启分页
|
|
});
|
|
|
|
$("#export").click(function(){
|
|
window.location.href="{:U('export')}";
|
|
})
|
|
//查询
|
|
$('#Preservation').click(function () {
|
|
//执行重载
|
|
table.reload('test', {
|
|
page: {
|
|
curr: 1 //重新从第 1 页开始
|
|
}
|
|
, where: {
|
|
keyword: $('#keyword').val()
|
|
},
|
|
method: "post",
|
|
});
|
|
})
|
|
})
|
|
$(".goodsCode-box").on('click', '.goods-image', function () {
|
|
let image = $(this).attr('src');
|
|
layer.open({
|
|
title: '商品图片',
|
|
type: 1,
|
|
content: `<div><img style="width: 100%;height:auto;display: block;margin: 0 auto;" src="${image}" alt="商品图片"></div>`,
|
|
area: ['500px']
|
|
})
|
|
})
|
|
</script>
|