文件

112 行
3.6 KiB
HTML
可执行文件

<!--[1.6.54]-->
<style>
* {
margin: 0;
padding: 0;
}
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="goodsCode-box">
<input type="text" id="keyword" placeholder="商品条码/名称" class="layui-input" style="width:200px;display: inline-block">
<button class="layui-btn" type="button" id="Preservation">查询</button>
<if condition="$authArr['export_goods']">
<button class="layui-btn" type="button" id="exportGoods">导入</button>
</if>
<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';
console.log(new_url);
//展示已知数据
table.render({
elem: '#test',
url: "{:U('Super/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'] //自定义分页布局
}, //是否开启分页
});
//查询
$('#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']
})
})
$('#exportGoods').click(() => {
MenuApp.pathData.push({
name: '导入商品',
path: '/index.php/Super/GoodsCode/export_goods',
})
})
</script>