327 行
12 KiB
HTML
可执行文件
327 行
12 KiB
HTML
可执行文件
<!--[1.6.48]-->
|
||
|
||
<style>
|
||
.goods_title {
|
||
font-size: 14px;
|
||
box-sizing: border-box;
|
||
padding: 10px 20px;
|
||
}
|
||
|
||
.goods_title_inner {
|
||
width: 100%;
|
||
height: 100%;
|
||
border-left: 2px solid #232b42;
|
||
box-sizing: border-box;
|
||
padding-left: 10px;
|
||
}
|
||
|
||
.goods_edit {
|
||
box-sizing: border-box;
|
||
padding: 10px 20px 10px 30px;
|
||
display: flex;
|
||
align-items: center;
|
||
}
|
||
|
||
.goods_edit_select {
|
||
width: 230px;
|
||
height: 35px;
|
||
border: 1px solid #ccc;
|
||
border-radius: 4px;
|
||
box-sizing: border-box;
|
||
background: white;
|
||
margin-right: 20px;
|
||
padding-left: 5px;
|
||
}
|
||
|
||
.goods_edit_select > select {
|
||
display: block;
|
||
border: none;
|
||
outline: none;
|
||
width: 100%;
|
||
height: 100%;
|
||
box-sizing: border-box;
|
||
padding: 0 10px;
|
||
border-radius: 4px;
|
||
}
|
||
|
||
.gA_inner {
|
||
box-sizing: border-box;
|
||
padding: 10px 100px;
|
||
display: flex;
|
||
align-items: center;
|
||
width: 580px;
|
||
}
|
||
|
||
.gA_inner_left {
|
||
width: 100px;
|
||
text-align: right;
|
||
}
|
||
|
||
.gA_inner_right {
|
||
width: 300px;
|
||
}
|
||
|
||
.gA_inner_right > input {
|
||
display: block;
|
||
width: 100%;
|
||
height: 40px;
|
||
border: 1px solid #CCCCCC;
|
||
border-radius: 5px;
|
||
box-sizing: border-box;
|
||
padding: 0 5px;
|
||
}
|
||
</style>
|
||
<div class="goodsBox">
|
||
<div class="goods_title">
|
||
<div class="goods_title_inner">
|
||
商品标签 <span style="color:#009688">(标签只能该店使用,用作小程序标签打印)</span>
|
||
</div>
|
||
</div>
|
||
<div class="goods_edit">
|
||
<form id="select_serach">
|
||
<div>
|
||
<input type="text" name="text" id="keyword" class="goods_edit_select" placeholder="请输入要查询的标签名或序号">
|
||
</div>
|
||
</form>
|
||
<div class="layui-btn " id="serach_icon" style="margin-left: -10px;
|
||
" data-type="reload">搜索
|
||
</div>
|
||
<if condition="$authArr['labelSet'] eq true">
|
||
<div class="layui-btn " id="newlyIncreased">新增</div>
|
||
</if>
|
||
<if condition="$authArr['unboundGoods'] eq true">
|
||
<div class="layui-btn " id="bindGoods">未绑定标签商品</div>
|
||
</if>
|
||
</div>
|
||
<div class="goods_table" style="margin-left: 30px">
|
||
<table class="layui-hide" id="test" lay-filter="demo"></table>
|
||
<script type="text/html" id="barDemo">
|
||
<if condition="$authArr['labelSet'] eq true">
|
||
<a class="layui-btn layui-btn-xs" lay-event="change">编辑</a>
|
||
</if>
|
||
<if condition="$authArr['deleteLabel'] eq true">
|
||
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
|
||
</if>
|
||
</script>
|
||
</div>
|
||
<div class="goodsAlert" style="display: none">
|
||
<form id="create_cate">
|
||
<input type="hidden" name="id" id="label_id" value="">
|
||
<div class="gA_inner">
|
||
<div class="gA_inner_left">标签名称:</div>
|
||
<div class="gA_inner_right">
|
||
<input type="text" name="label_name" id="label_name" value="" placeholder="请填写标签名称"/>
|
||
</div>
|
||
</div>
|
||
<div class="gA_inner">
|
||
<div class="gA_inner_left">序号:</div>
|
||
<div class="gA_inner_right">
|
||
<input type="text" name="sort" id="sort" value="" placeholder="列表将按照序号从大到小顺序排列 "/>
|
||
</div>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
|
||
<script type="text/javascript">
|
||
var rest = function () {
|
||
document.getElementById("create_cate").reset();
|
||
}
|
||
layui.use('table', function () {
|
||
var table = layui.table;
|
||
//展示已知数据
|
||
table.render({
|
||
elem: '#test',
|
||
url: "{:U('GoodsLabel/labelList')}",
|
||
method: 'post',
|
||
width: 700,
|
||
cols: [
|
||
[ //标题栏
|
||
{
|
||
field: 'key',
|
||
title: '序号',
|
||
width: 60
|
||
}, {
|
||
field: 'label_name',
|
||
title: '标签名称',
|
||
}, {
|
||
field: 'sort',
|
||
title: '排序',
|
||
sort: true,
|
||
}, {
|
||
field: 'addtime',
|
||
title: '创建时间'
|
||
}, {
|
||
fixed: 'right',
|
||
title: '操作',
|
||
width: 150,
|
||
align: 'center',
|
||
toolbar: '#barDemo'
|
||
}
|
||
]
|
||
],
|
||
id: 'couponReload',
|
||
page: {
|
||
layout: ['count', 'prev', 'page', 'next', 'skip'] //自定义分页布局
|
||
}, //是否开启分页
|
||
});
|
||
|
||
$("#serach_icon").click(function () {
|
||
var keyword = $("#keyword").val();
|
||
table.reload('couponReload', {
|
||
page: {
|
||
curr: 1 //重新从第 1 页开始
|
||
}
|
||
, where: {
|
||
keyword: keyword
|
||
}
|
||
});
|
||
})
|
||
|
||
//监听工具条
|
||
table.on('tool(demo)', function (obj) {
|
||
var data = obj.data;
|
||
var id = data.id;
|
||
if (obj.event === 'change') {
|
||
rest();
|
||
$("#label_id").val(data.id);
|
||
$("#label_name").val(data.label_name);
|
||
$("#sort").val(data.sort);
|
||
layer.open({
|
||
type: 1,
|
||
shade: false,
|
||
content: $('.goodsAlert'),
|
||
title: "修改标签",
|
||
area: '650px',
|
||
btn: ['修改', '取消'],
|
||
btnAlign: 'c',
|
||
yes: function () {
|
||
var label_name = $("#label_name").val();
|
||
var sort = $("#sort").val();
|
||
if (label_name == '') {
|
||
layer.tips("请填写标签名称", "#label_name");
|
||
return false;
|
||
}
|
||
if (sort == '') {
|
||
layer.tips("请填写序号", "#sort");
|
||
return false;
|
||
}
|
||
$.ajax({
|
||
url: "{:U('GoodsLabel/labelSet')}",
|
||
type: "POST",
|
||
data: $("#create_cate").serialize(),
|
||
success: function (data) {
|
||
if (data.status == 1) {
|
||
top.layer.msg(data.msg, {
|
||
icon: 1,
|
||
time: 2000 //2秒关闭(如果不配置,默认是3秒)
|
||
}, function () {
|
||
table.reload('couponReload');
|
||
});
|
||
layer.closeAll();
|
||
|
||
} else if (data.status == 2) {
|
||
layer.tips(data.msg, "#label_name");
|
||
} else if (data.status == 3) {
|
||
layer.tips(data.msg, "#sort");
|
||
} else {
|
||
top.layer.msg("添加失败", {time: 2000})
|
||
}
|
||
}
|
||
})
|
||
}
|
||
})
|
||
|
||
} else if (obj.event === 'del') {
|
||
var id = data.id;
|
||
layer.confirm('确认删除该标签吗?', function (index) {
|
||
$.ajax({
|
||
url: "{:U('GoodsLabel/deleteLabel')}",
|
||
type: "POST",
|
||
data: {id: id},
|
||
success: function (data) {
|
||
if (data.status == 1) {
|
||
top.layer.msg(data.msg, {
|
||
icon: 1,
|
||
time: 1000 //2秒关闭(如果不配置,默认是3秒)
|
||
}, function () {
|
||
obj.del();
|
||
layer.close(index);
|
||
table.reload('couponReload');
|
||
});
|
||
} else {
|
||
top.layer.msg(data.msg, {time: 2000})
|
||
layer.close(index);
|
||
}
|
||
}
|
||
})
|
||
});
|
||
}
|
||
});
|
||
|
||
layui.use('layer', function () {
|
||
var layer = layui.layer;
|
||
$("#newlyIncreased").click(function () {
|
||
rest();
|
||
layer.open({
|
||
type: 1,
|
||
shade: false,
|
||
content: $('.goodsAlert'),
|
||
title: "添加标签",
|
||
area: '650px',
|
||
btn: ['保存', '取消'],
|
||
btnAlign: 'c',
|
||
yes: function () {
|
||
var label_name = $("#label_name").val();
|
||
var sort = $("#sort").val();
|
||
if (label_name == '') {
|
||
layer.tips("请填写标签名称", "#label_name");
|
||
return false;
|
||
}
|
||
if (sort == '') {
|
||
layer.tips("请填写序号", "#sort");
|
||
return false;
|
||
}
|
||
$.ajax({
|
||
url: "{:U('GoodsLabel/labelSet')}",
|
||
type: "POST",
|
||
data: $("#create_cate").serialize(),
|
||
success: function (data) {
|
||
if (data.status == 1) {
|
||
top.layer.msg(data.msg, {
|
||
icon: 1,
|
||
time: 2000 //2秒关闭(如果不配置,默认是3秒)
|
||
}, function () {
|
||
table.reload('couponReload');
|
||
layer.closeAll();
|
||
});
|
||
} else if (data.status == 2) {
|
||
layer.tips(data.msg, "#label_name");
|
||
} else if (data.status == 3) {
|
||
layer.tips(data.msg, "#sort");
|
||
} else {
|
||
top.layer.msg("添加失败", {time: 2000})
|
||
}
|
||
}
|
||
})
|
||
}
|
||
})
|
||
})
|
||
|
||
/**
|
||
* 打开新页面
|
||
*/
|
||
$("#bindGoods").click(function () {
|
||
layer.open({
|
||
type: 2,
|
||
title: "未绑定标签商品<span style='color:#009688;font-weight: bold'>(该部分仅显示未绑定标签的商品)</span>",
|
||
content: "{:U('GoodsLabel/unboundGoods')}",
|
||
area: ['750px', '700px'],
|
||
end: function () {
|
||
table.reload('couponReload');
|
||
}
|
||
})
|
||
})
|
||
});
|
||
})
|
||
</script> |